2 * $Id: zoomtst7.c,v 1.2 2001-10-24 12:24:43 adam Exp $
11 #include <yaz/xmalloc.h>
16 int main(int argc, char **argv)
20 Z3950_resultset r[10]; /* and result sets .. */
23 o = Z3950_options_create ();
25 for (block = 0; block < 3; block++)
30 printf ("blocking - not calling Z3950_events\n");
33 printf ("blocking - calling Z3950_events\n");
36 printf ("non-blocking - calling Z3950_events\n");
40 Z3950_options_set (o, "async", "1");
41 for (i = 0; i<10; i++)
44 printf ("session %2d", i);
45 sprintf (host, "localhost:9999/%d", i);
46 z = Z3950_connection_create (o);
47 Z3950_connection_connect (z, host, 0);
49 for (j = 0; j < 10; j++)
52 size_t recs_count = 2;
54 Z3950_search s = Z3950_search_create ();
56 sprintf (query, "i%dr%d", i, j);
58 if (Z3950_search_prefix (s, query))
60 printf ("bad PQF: %s\n", query);
63 Z3950_options_set (o, "start", "0");
64 Z3950_options_set (o, "count", "0");
66 r[j] = Z3950_connection_search (z, s); /* non-piggy */
68 Z3950_options_set (o, "count", "2");
69 Z3950_resultset_records (r[j], 0, 0); /* first two */
71 Z3950_options_set (o, "start", "1");
72 Z3950_options_set (o, "count", "2");
73 Z3950_resultset_records (r[j], recs, &recs_count); /* third */
74 Z3950_resultset_records (r[j], 0, 0); /* ignored */
76 if (Z3950_resultset_size (r[j]) > 2)
80 fprintf (stderr, "\nrecord missing\n");
84 Z3950_record_destroy (recs[0]);
85 Z3950_record_destroy (recs[1]);
87 Z3950_search_destroy (s);
91 while (Z3950_event (1, &z))
95 Z3950_resultset_destroy (r[j]);
96 Z3950_connection_destroy (z);
98 Z3950_resultset_destroy (r[j]);
99 printf ("10 searches, 20 presents done\n");
102 for (i = 0; i<1; i++)
104 Z3950_search s = Z3950_search_create ();
107 printf ("session %2d", i+10);
108 sprintf (host, "localhost:9999/%d", i);
109 z = Z3950_connection_create (o);
110 Z3950_connection_connect (z, host, 0);
112 for (j = 0; j < 10; j++)
116 sprintf (query, "i%dr%d", i, j);
118 Z3950_options_set (o, "count", "0");
120 r[j] = Z3950_connection_search_pqf (z, query);
124 while (Z3950_event (1, &z))
127 Z3950_connection_destroy (z);
129 Z3950_options_set (o, "count", "1");
130 for (j = 0; j < 10; j++)
132 Z3950_resultset_records (r[j], 0, 0);
134 while (Z3950_event (1, &z))
137 for (j = 0; j < 10; j++)
138 Z3950_resultset_destroy (r[j]);
139 Z3950_search_destroy (s);
140 printf ("10 searches, 10 ignored presents done\n");
143 Z3950_options_destroy (o);