Add link to our own Libxml2/Libxslt binaries for Windows
[yaz-moved-to-github.git] / zoom / zoomtst10.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     ZOOM_query q = ZOOM_query_create();
16     int error;
17     const char *errmsg, *addinfo;
18     int ccl_error_code, ccl_error_pos;
19     const char *ccl_error_string;
20
21     if (argc != 3)
22     {
23         fprintf (stderr, "usage:\n%s target cclquery\n", *argv);
24         fprintf (stderr, " eg.  bagel.indexdata.dk/gils \"ti=utah\"\n");
25         exit (1);
26     }
27
28     if (ZOOM_query_ccl2rpn(q, argv[2],
29                            "term t=l,r s=al\n" "ti u=4 s=pw\n",
30                            &ccl_error_code, &ccl_error_string, &ccl_error_pos))
31     {
32         printf("CCL Error %d: %s\n", ccl_error_code, ccl_error_string);
33         if (ccl_error_pos >= 0)
34             printf("%s\n%*s^\n", argv[2], ccl_error_pos, "");
35         ZOOM_query_destroy(q);
36     }
37     else
38     {
39         z = ZOOM_connection_new (argv[1], 0);
40
41         if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
42         {
43             fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
44             exit (2);
45         }
46
47         r = ZOOM_connection_search (z, q);
48         ZOOM_query_destroy(q);
49         if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
50             fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
51         else
52             printf ("Result count: %ld\n", (long) ZOOM_resultset_size(r));
53         ZOOM_resultset_destroy (r);
54         ZOOM_connection_destroy (z);
55     }
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