1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
10 #include <yaz/xmalloc.h>
15 int main(int argc, char **argv)
20 ZOOM_resultset r[10]; /* and result sets .. */
23 o = ZOOM_options_create ();
25 z = ZOOM_connection_new ("localhost", 9999);
26 if (ZOOM_connection_error (z, 0, 0))
28 printf ("error - couldn't connect?\n");
32 ZOOM_connection_destroy (z);
34 for (block = 0; block < 3; block++)
39 printf ("blocking - not calling ZOOM_events\n");
42 printf ("blocking - calling ZOOM_events\n");
45 printf ("non-blocking - calling ZOOM_events\n");
49 ZOOM_options_set (o, "async", "1");
50 for (i = 0; i<10; i++)
54 printf ("session %2d", i);
55 sprintf (host, "localhost:9999/%d", i);
56 z = ZOOM_connection_create (o);
57 ZOOM_connection_connect (z, host, 0);
59 for (j = 0; j < 10; j++)
63 ZOOM_query s = ZOOM_query_create ();
65 sprintf (query, "i%dr%d", i, j);
67 if (ZOOM_query_prefix (s, query))
69 printf ("bad PQF: %s\n", query);
72 ZOOM_options_set (o, "start", "0");
73 ZOOM_options_set (o, "count", "0");
75 r[j] = ZOOM_connection_search (z, s); /* non-piggy */
77 ZOOM_resultset_records (r[j], recs, 0, 2); /* first two */
79 ZOOM_resultset_records (r[j], recs, 1, 2); /* third */
81 ZOOM_resultset_records (r[j], recs, 0, 0); /* ignored */
83 if (ZOOM_resultset_size (r[j]) > 2)
87 fprintf (stderr, "\nrecord missing\n");
92 ZOOM_query_destroy (s);
96 while (ZOOM_event (1, &z))
100 ZOOM_resultset_destroy (r[j]);
101 ZOOM_connection_destroy (z);
103 ZOOM_resultset_destroy (r[j]);
104 printf ("10 searches, 20 presents done\n");
108 for (i = 0; i<1; i++)
110 ZOOM_query q = ZOOM_query_create ();
113 printf ("session %2d", i+10);
114 sprintf (host, "localhost:9999/%d", i);
115 z = ZOOM_connection_create (o);
116 ZOOM_connection_connect (z, host, 0);
118 for (j = 0; j < 10; j++)
122 sprintf (query, "i%dr%d", i, j);
124 ZOOM_options_set (o, "count", "0");
126 r[j] = ZOOM_connection_search_pqf (z, query);
130 while (ZOOM_event (1, &z))
134 ZOOM_connection_destroy (z);
136 for (j = 0; j < 10; j++)
138 ZOOM_resultset_records (r[j], 0, 0, 1);
140 for (j = 0; j < 10; j++)
141 ZOOM_resultset_destroy (r[j]);
142 ZOOM_query_destroy (q);
143 printf ("10 searches, 10 ignored presents done\n");
147 for (i = 0; i<1; i++)
150 ZOOM_scanset scan = 0;
152 printf ("session %2d", i);
153 sprintf (host, "localhost:9999/%d", i);
154 z = ZOOM_connection_create (o);
155 ZOOM_connection_connect (z, host, 0);
157 scan = ZOOM_connection_scan(z, "@attr 1=4 a");
159 while (ZOOM_event (1, &z))
161 printf (" scan size = %ld\n", (long) ZOOM_scanset_size(scan));
162 for (j = 0; j < (int) ZOOM_scanset_size (scan); j++)
167 term = ZOOM_scanset_term (scan, j, &occur, &len);
169 printf ("%d %.*s %d\n", j, (int) len, term, (int) occur);
172 ZOOM_scanset_destroy (scan);
173 ZOOM_connection_destroy (z);
177 ZOOM_options_destroy (o);
184 * c-file-style: "Stroustrup"
185 * indent-tabs-mode: nil
187 * vim: shiftwidth=4 tabstop=8 expandtab