2 * $Id: zoomtst4.c,v 1.2 2001-10-24 21:35:46 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 Z3950_connection z[500]; /* allow at most 500 connections */
26 Z3950_resultset r[500]; /* and result sets .. */
28 Z3950_options o = Z3950_options_create ();
32 fprintf (stderr, "usage:\n%s proxy target1 .. targetN query\n",
39 /* function my_callback called when reading options .. */
40 Z3950_options_set_callback (o, my_callback, 0);
42 /* get 20 (at most) records from offset 5 */
43 Z3950_options_set (o, "start", "5");
44 Z3950_options_set (o, "count", "20");
47 Z3950_options_set (o, "proxy", argv[1]);
50 s = Z3950_search_create ();
51 if (Z3950_search_prefix (s, 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] = Z3950_connection_create (o);
60 Z3950_connection_connect (z[i], argv[i+2], 0);
61 r[i] = Z3950_connection_search (z[i], s);
65 while (Z3950_event (no, z))
69 for (i = 0; i<no; i++)
72 const char *errmsg, *addinfo;
73 if ((error = Z3950_connection_error(z[i], &errmsg, &addinfo)))
74 fprintf (stderr, "%s error: %s (%d) %s\n",
75 Z3950_connection_host(z[i]), errmsg, error, addinfo);
78 /* destroy stuff and exit */
79 Z3950_search_destroy (s);
80 for (i = 0; i<no; i++)
82 Z3950_resultset_destroy (r[i]);
83 Z3950_connection_destroy (z[i]);
85 Z3950_options_destroy(o);