Change K&R-style empty function declarations to explicit ANSI-C (void) prototypes
[yaz-moved-to-github.git] / zoom / zoom-ka.c
1 /* $Id: zoom-ka.c,v 1.1 2006-09-19 19:41:32 adam Exp $  */
2
3 /** \file zoom-ka.c
4     \brief Test ZOOM Keepalive / reconnect
5 */
6
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <yaz/wrbuf.h>
12
13 #include <yaz/nmem.h>
14 #include <yaz/xmalloc.h>
15 #include <yaz/zoom.h>
16
17 int main(int argc, char **argv)
18 {
19     ZOOM_connection z;
20     ZOOM_options o = ZOOM_options_create ();
21     const char *errmsg, *addinfo;
22     
23     if (argc != 4)
24     {
25         fprintf (stderr, "usage:\nzoom-ka sleepinterval target query\n");
26         exit(1);
27     }
28     /* async mode */
29     ZOOM_options_set (o, "async", "1");
30
31     z = ZOOM_connection_create(o);
32
33     while(1)
34     {
35         int i, error;
36         ZOOM_resultset rset;
37         ZOOM_connection_connect (z, argv[2], 0);
38         rset = ZOOM_connection_search_pqf(z, argv[3]);
39         
40         while ((i = ZOOM_event(1, &z)))
41         {
42             printf ("no = %d event = %d\n", i-1,
43                     ZOOM_connection_last_event(z));
44         }
45         if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
46         {
47             fprintf(stderr, "%s error: %s (%d) %s\n",
48                     ZOOM_connection_option_get(z, "host"),
49                     errmsg, error, addinfo);
50         }
51         ZOOM_resultset_destroy(rset);
52         sleep(atoi(argv[1]));
53     }
54     ZOOM_connection_destroy (z);
55     ZOOM_options_destroy(o);
56 }
57 /*
58  * Local variables:
59  * c-basic-offset: 4
60  * indent-tabs-mode: nil
61  * End:
62  * vim: shiftwidth=4 tabstop=8 expandtab
63  */
64