2 * $Id: zoomtst7.c,v 1.9 2002-02-20 14:40:42 adam Exp $
11 #include <yaz/xmalloc.h>
16 int main(int argc, char **argv)
20 ZOOM_resultset r[10]; /* and result sets .. */
24 o = ZOOM_options_create ();
26 z = ZOOM_connection_new ("localhost", 9999);
27 if (ZOOM_connection_error (z, 0, 0))
29 printf ("error - couldn't connect?\n");
33 ZOOM_connection_destroy (z);
35 for (block = 0; block < 3; block++)
40 printf ("blocking - not calling ZOOM_events\n");
43 printf ("blocking - calling ZOOM_events\n");
46 printf ("non-blocking - calling ZOOM_events\n");
50 ZOOM_options_set (o, "async", "1");
51 for (i = 0; i<10; i++)
55 printf ("session %2d", i);
56 sprintf (host, "localhost:9999/%d", i);
57 z = ZOOM_connection_create (o);
58 ZOOM_connection_connect (z, host, 0);
60 for (j = 0; j < 10; j++)
64 ZOOM_query s = ZOOM_query_create ();
66 sprintf (query, "i%dr%d", i, j);
68 if (ZOOM_query_prefix (s, query))
70 printf ("bad PQF: %s\n", query);
73 ZOOM_options_set (o, "start", "0");
74 ZOOM_options_set (o, "count", "0");
76 r[j] = ZOOM_connection_search (z, s); /* non-piggy */
78 ZOOM_resultset_records (r[j], recs, 0, 2); /* first two */
80 ZOOM_resultset_records (r[j], recs, 1, 2); /* third */
82 ZOOM_resultset_records (r[j], recs, 0, 0); /* ignored */
84 if (ZOOM_resultset_size (r[j]) > 2)
88 fprintf (stderr, "\nrecord missing\n");
93 ZOOM_query_destroy (s);
97 while (ZOOM_event (1, &z))
100 for (j = 0; j<i; j++)
101 ZOOM_resultset_destroy (r[j]);
102 ZOOM_connection_destroy (z);
104 ZOOM_resultset_destroy (r[j]);
105 printf ("10 searches, 20 presents done\n");
109 for (i = 0; i<1; i++)
111 ZOOM_query q = ZOOM_query_create ();
114 printf ("session %2d", i+10);
115 sprintf (host, "localhost:9999/%d", i);
116 z = ZOOM_connection_create (o);
117 ZOOM_connection_connect (z, host, 0);
119 for (j = 0; j < 10; j++)
123 sprintf (query, "i%dr%d", i, j);
125 ZOOM_options_set (o, "count", "0");
127 r[j] = ZOOM_connection_search_pqf (z, query);
131 while (ZOOM_event (1, &z))
135 ZOOM_connection_destroy (z);
137 for (j = 0; j < 10; j++)
139 ZOOM_resultset_records (r[j], 0, 0, 1);
141 while (ZOOM_event (1, &z))
144 for (j = 0; j < 10; j++)
145 ZOOM_resultset_destroy (r[j]);
146 ZOOM_query_destroy (q);
147 printf ("10 searches, 10 ignored presents done\n");
151 for (i = 0; i<1; i++)
154 ZOOM_scanset scan = 0;
156 printf ("session %2d", i);
157 sprintf (host, "localhost:9999/%d", i);
158 z = ZOOM_connection_create (o);
159 ZOOM_connection_connect (z, host, 0);
161 scan = ZOOM_connection_scan (z, "@attr 1=4 a");
163 while (ZOOM_event (1, &z))
165 printf (" scan size = %d\n", ZOOM_scanset_size(scan));
166 for (j = 0; j<ZOOM_scanset_size (scan); j++)
170 term = ZOOM_scanset_term (scan, j, &occur, &len);
172 printf ("%d %.*s %d\n", j, len, term, occur);
175 ZOOM_scanset_destroy (scan);
176 ZOOM_connection_destroy (z);
180 ZOOM_options_destroy (o);