2 * $Id: zoomtst4.c,v 1.5 2001-11-18 21:14:23 adam Exp $
4 * Asynchronous multi-target going through proxy doing search and retrieve
10 #include <yaz/xmalloc.h>
14 const char *my_callback (void *handle, const char *name)
16 if (!strcmp (name, "async"))
21 int main(int argc, char **argv)
25 ZOOM_connection z[500]; /* allow at most 500 connections */
26 ZOOM_resultset r[500]; /* and result sets .. */
28 ZOOM_options o = ZOOM_options_create ();
32 fprintf (stderr, "usage:\n%s proxy target1 .. targetN query\n",
39 /* function my_callback called when reading options .. */
40 ZOOM_options_set_callback (o, my_callback, 0);
42 /* get 20 (at most) records from offset 5 */
43 ZOOM_options_set (o, "start", "5");
44 ZOOM_options_set (o, "count", "20");
47 ZOOM_options_set (o, "proxy", argv[1]);
50 q = ZOOM_query_create ();
51 if (ZOOM_query_prefix (q, argv[argc-1]))
53 printf ("bad PQF: %s\n", argv[argc-1]);
56 /* connect - and search all */
57 for (i = 0; i<no; i++)
59 z[i] = ZOOM_connection_create (o);
60 ZOOM_connection_connect (z[i], argv[i+2], 0);
61 r[i] = ZOOM_connection_search (z[i], q);
65 while (ZOOM_event (no, z))
69 for (i = 0; i<no; i++)
72 const char *errmsg, *addinfo;
73 if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
74 fprintf (stderr, "%s error: %s (%d) %s\n",
75 ZOOM_connection_option_get(z[i], "host"),
76 errmsg, error, addinfo);
79 /* destroy stuff and exit */
80 ZOOM_query_destroy (q);
81 for (i = 0; i<no; i++)
83 ZOOM_resultset_destroy (r[i]);
84 ZOOM_connection_destroy (z[i]);
86 ZOOM_options_destroy(o);