1 /* $Id: zoomtst4.c,v 1.10 2007-01-03 08:42:17 adam Exp $ */
4 \brief Asynchronous multi-target client with separate present
6 Asynchronous multi-target going through proxy doing search and retrieve
12 #include <yaz/xmalloc.h>
16 const char *my_callback (void *handle, const char *name)
18 if (!strcmp (name, "async"))
23 int main(int argc, char **argv)
27 ZOOM_connection z[500]; /* allow at most 500 connections */
28 ZOOM_resultset r[500]; /* and result sets .. */
30 ZOOM_options o = ZOOM_options_create ();
34 fprintf (stderr, "usage:\n%s proxy target1 .. targetN query\n",
41 /* function my_callback called when reading options .. */
42 ZOOM_options_set_callback (o, my_callback, 0);
44 /* get 20 (at most) records from offset 5 */
45 ZOOM_options_set (o, "start", "5");
46 ZOOM_options_set (o, "count", "20");
47 ZOOM_options_set (o, "schema", "gils-schema");
48 ZOOM_options_set (o, "elementSetName", "F");
51 ZOOM_options_set (o, "proxy", argv[1]);
54 q = ZOOM_query_create ();
55 if (ZOOM_query_prefix (q, argv[argc-1]))
57 printf ("bad PQF: %s\n", argv[argc-1]);
60 /* connect - and search all */
61 for (i = 0; i<no; i++)
63 z[i] = ZOOM_connection_create (o);
64 ZOOM_connection_connect (z[i], argv[i+2], 0);
65 r[i] = ZOOM_connection_search (z[i], q);
69 while (ZOOM_event (no, z))
73 for (i = 0; i<no; i++)
76 const char *errmsg, *addinfo;
77 if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
78 fprintf (stderr, "%s error: %s (%d) %s\n",
79 ZOOM_connection_option_get(z[i], "host"),
80 errmsg, error, addinfo);
82 printf ("%s: %ld hits\n", ZOOM_connection_option_get(z[i], "host"),
83 (long) ZOOM_resultset_size(r[i]));
86 /* destroy stuff and exit */
87 ZOOM_query_destroy (q);
88 for (i = 0; i<no; i++)
90 ZOOM_resultset_destroy (r[i]);
91 ZOOM_connection_destroy (z[i]);
93 ZOOM_options_destroy(o);
99 * indent-tabs-mode: nil
101 * vim: shiftwidth=4 tabstop=8 expandtab