Version 5.11.0
[yaz-moved-to-github.git] / zoom / zoomtst1.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
5
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <yaz/xmalloc.h>
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;
17
18     if (argc != 3)
19     {
20         fprintf (stderr, "usage:\n%s target query\n", *argv);
21         fprintf (stderr, " eg.  bagel.indexdata.dk/gils computer\n");
22         exit (1);
23     }
24     z = ZOOM_connection_new (argv[1], 0);
25
26     if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
27     {
28         fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
29         exit (2);
30     }
31
32     ZOOM_connection_option_set(z, "saveAPDU", "1");
33     r = ZOOM_connection_search_pqf (z, argv[2]);
34     if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
35         fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
36     else
37         printf ("Result count: %ld\n", (long) ZOOM_resultset_size(r));
38     puts("APDUlog");
39     puts(ZOOM_connection_option_get(z, "APDU"));
40     ZOOM_resultset_destroy (r);
41     ZOOM_connection_destroy (z);
42     exit (0);
43 }
44 /*
45  * Local variables:
46  * c-basic-offset: 4
47  * c-file-style: "Stroustrup"
48  * indent-tabs-mode: nil
49  * End:
50  * vim: shiftwidth=4 tabstop=8 expandtab
51  */
52