document parameter (Doxygen warning)
[yaz-moved-to-github.git] / zoom / zoomtst2.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2013 Index Data
3  * See the file LICENSE for details.
4  */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 #include <yaz/zoom.h>
10
11 int main(int argc, char **argv)
12 {
13     ZOOM_connection z;
14     ZOOM_resultset r;
15     int error;
16     const char *errmsg, *addinfo, *diagset;
17
18     if (argc < 3)
19     {
20         fprintf (stderr, "usage:\n%s target query\n", *argv);
21         fprintf (stderr,
22                  "Verify: asynchronous single-target client\n");
23         exit (1);
24     }
25
26     /* create connection (don't connect yet) */
27     z = ZOOM_connection_create(0);
28
29     /* option: set sru/get operation (only applicable if http: is used) */
30     ZOOM_connection_option_set (z, "sru", "post");
31
32     /* option: set async operation */
33     ZOOM_connection_option_set (z, "async", "1");
34
35     /* connect to target and initialize */
36     ZOOM_connection_connect (z, argv[1], 0);
37
38     /* search using prefix query format */
39     r = ZOOM_connection_search_pqf (z, argv[2]);
40
41     /* block here: only one connection */
42     while (ZOOM_event (1, &z))
43         ;
44
45     /* see if any error occurred */
46     if ((error = ZOOM_connection_error_x(z, &errmsg, &addinfo, &diagset)))
47     {
48         fprintf (stderr, "Error: %s: %s (%d) %s\n", diagset, errmsg, error,
49                          addinfo);
50         exit (2);
51     }
52     else /* OK print hit count */
53         printf ("Result count: %ld\n", (long) ZOOM_resultset_size(r));
54     ZOOM_resultset_destroy (r);
55     ZOOM_connection_destroy (z);
56     exit (0);
57 }
58 /*
59  * Local variables:
60  * c-basic-offset: 4
61  * c-file-style: "Stroustrup"
62  * indent-tabs-mode: nil
63  * End:
64  * vim: shiftwidth=4 tabstop=8 expandtab
65  */
66