Fixes for gcc warnings - mostly WRT check of returns values
[yaz-moved-to-github.git] / zoom / zoom-ka.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2008 Index Data
3  * See the file LICENSE for details.
4  */
5
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include <yaz/wrbuf.h>
11
12 #include <yaz/nmem.h>
13 #include <yaz/xmalloc.h>
14 #include <yaz/zoom.h>
15
16 int main(int argc, char **argv)
17 {
18     ZOOM_connection z;
19     ZOOM_options o = ZOOM_options_create ();
20     const char *errmsg, *addinfo;
21     
22     if (argc != 4)
23     {
24         fprintf (stderr, "usage:\nzoom-ka sleepinterval target query\n");
25         exit(1);
26     }
27     /* async mode */
28     ZOOM_options_set (o, "async", "1");
29
30     z = ZOOM_connection_create(o);
31
32     while(1)
33     {
34         int i, error;
35         ZOOM_resultset rset;
36         ZOOM_connection_connect (z, argv[2], 0);
37         rset = ZOOM_connection_search_pqf(z, argv[3]);
38         
39         while ((i = ZOOM_event(1, &z)))
40         {
41             printf ("no = %d event = %d\n", i-1,
42                     ZOOM_connection_last_event(z));
43         }
44         if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
45         {
46             fprintf(stderr, "%s error: %s (%d) %s\n",
47                     ZOOM_connection_option_get(z, "host"),
48                     errmsg, error, addinfo);
49         }
50         ZOOM_resultset_destroy(rset);
51         sleep(atoi(argv[1]));
52     }
53     ZOOM_connection_destroy (z);
54     ZOOM_options_destroy(o);
55 }
56 /*
57  * Local variables:
58  * c-basic-offset: 4
59  * indent-tabs-mode: nil
60  * End:
61  * vim: shiftwidth=4 tabstop=8 expandtab
62  */
63