2 * $Id: zoomtst4.c,v 1.1 2001-10-23 21:00:20 adam Exp $
4 * Asynchronous multi-target going through proxy doing search and retrieve
9 #include <yaz/xmalloc.h>
13 const char *my_callback (void *handle, const char *name)
15 if (!strcmp (name, "async"))
20 int main(int argc, char **argv)
24 Z3950_connection z[500]; /* allow at most 500 connections */
25 Z3950_resultset r[500]; /* and result sets .. */
27 Z3950_options o = Z3950_options_create ();
31 fprintf (stderr, "usage:\n%s proxy target1 .. targetN query\n",
38 /* function my_callback called when reading options .. */
39 Z3950_options_set_callback (o, my_callback, 0);
41 /* get 20 (at most) records from offset 5 */
42 Z3950_options_set (o, "start", "5");
43 Z3950_options_set (o, "count", "20");
46 Z3950_options_set (o, "proxy", argv[1]);
49 s = Z3950_search_create ();
50 if (Z3950_search_prefix (s, argv[argc-1]))
52 printf ("bad PQF: %s\n", argv[argc-1]);
55 /* connect - and search all */
56 for (i = 0; i<no; i++)
58 z[i] = Z3950_connection_create (o);
59 Z3950_connection_connect (z[i], argv[i+2], 0);
60 r[i] = Z3950_connection_search (z[i], s);
64 while (Z3950_event (no, z))
68 for (i = 0; i<no; i++)
71 const char *errmsg, *addinfo;
72 if ((error = Z3950_connection_error(z[i], &errmsg, &addinfo)))
73 fprintf (stderr, "%s error: %s (%d) %s\n",
74 Z3950_connection_host(z[i]), errmsg, error, addinfo);
77 /* destroy stuff and exit */
78 Z3950_search_destroy (s);
79 for (i = 0; i<no; i++)
81 Z3950_resultset_destroy (r[i]);
82 Z3950_connection_destroy (z[i]);
84 Z3950_options_destroy(o);