2 * $Id: zoomtst7.c,v 1.1 2001-10-23 21:00:20 adam Exp $
11 #include <yaz/xmalloc.h>
16 int main(int argc, char **argv)
20 Z3950_resultset r[10]; /* and result sets .. */
25 o = Z3950_options_create ();
27 for (block = 0; block < 3; block++)
32 printf ("blocking - not calling Z3950_events\n");
35 printf ("blocking - calling Z3950_events\n");
38 printf ("non-blocking - calling Z3950_events\n");
42 Z3950_options_set (o, "async", "1");
43 for (i = 0; i<10; i++)
46 printf ("session %2d", i);
47 sprintf (host, "localhost:9999/%d", i);
48 z = Z3950_connection_create (o);
49 Z3950_connection_connect (z, host, 0);
51 for (j = 0; j < 10; j++)
54 size_t recs_count = 2;
56 Z3950_search s = Z3950_search_create ();
58 sprintf (query, "i%dr%d", i, j);
60 if (Z3950_search_prefix (s, query))
62 printf ("bad PQF: %s\n", query);
65 Z3950_options_set (o, "start", "0");
66 Z3950_options_set (o, "count", "0");
68 r[j] = Z3950_connection_search (z, s); /* non-piggy */
70 Z3950_options_set (o, "count", "2");
71 Z3950_resultset_records (r[j], 0, 0); /* first two */
73 Z3950_options_set (o, "start", "1");
74 Z3950_options_set (o, "count", "2");
75 Z3950_resultset_records (r[j], recs, &recs_count); /* third */
76 Z3950_resultset_records (r[j], 0, 0); /* ignored */
78 if (Z3950_resultset_size (r[j]) > 2)
82 fprintf (stderr, "\nrecord missing\n");
86 Z3950_record_destroy (recs[0]);
87 Z3950_record_destroy (recs[1]);
89 Z3950_search_destroy (s);
93 while (Z3950_event (1, &z))
97 Z3950_resultset_destroy (r[j]);
98 Z3950_connection_destroy (z);
100 Z3950_resultset_destroy (r[j]);
101 printf ("10 searches, 20 presents done\n");
104 for (i = 0; i<1; i++)
106 Z3950_search s = Z3950_search_create ();
109 printf ("session %2d", i+10);
110 sprintf (host, "localhost:9999/%d", i);
111 z = Z3950_connection_create (o);
112 Z3950_connection_connect (z, host, 0);
114 for (j = 0; j < 10; j++)
118 sprintf (query, "i%dr%d", i, j);
120 Z3950_options_set (o, "count", "0");
122 r[j] = Z3950_connection_search_pqf (z, query);
126 while (Z3950_event (1, &z))
129 Z3950_connection_destroy (z);
131 Z3950_options_set (o, "count", "1");
132 for (j = 0; j < 10; j++)
134 Z3950_resultset_records (r[j], 0, 0);
136 while (Z3950_event (1, &z))
139 for (j = 0; j < 10; j++)
140 Z3950_resultset_destroy (r[j]);
141 Z3950_search_destroy (s);
142 printf ("10 searches, 10 ignored presents done\n");
145 Z3950_options_destroy (o);