1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2009 Index Data
3 * See the file LICENSE for details.
10 #include <yaz/xmalloc.h>
13 int main(int argc, char **argv)
17 ZOOM_connection z[500]; /* allow at most 500 connections */
18 ZOOM_scanset s[500]; /* and scan sets .. */
19 ZOOM_options o = ZOOM_options_create ();
23 fprintf (stderr, "usage:\n%s target1 target2 ... targetN scan\n",
31 ZOOM_options_set (o, "async", "1");
34 for (i = 0; i<no; i++)
36 /* create connection - pass options (they are the same for all) */
37 z[i] = ZOOM_connection_create (o);
39 /* connect and init */
40 ZOOM_connection_connect (z[i], argv[1+i], 0);
44 for (i = 0; i<no; i++)
46 /* set number of scan terms to be returned. */
47 ZOOM_connection_option_set (z[i], "number", "7");
48 /* and perform scan */
49 s[i] = ZOOM_connection_scan(z[i], argv[argc-1]);
52 /* network I/O. pass number of connections and array of connections */
53 while (ZOOM_event (no, z))
56 for (i = 0; i<no; i++)
59 const char *errmsg, *addinfo;
60 if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
61 fprintf (stderr, "%s error: %s (%d) %s\n",
62 ZOOM_connection_option_get(z[i], "host"),
63 errmsg, error, addinfo);
67 printf ("%s\n", ZOOM_connection_option_get(z[i], "host"));
68 for (j = 0; j < (int) ZOOM_scanset_size (s[i]); j++)
72 term = ZOOM_scanset_term (s[i], j, &occur, &len);
74 printf ("%d %.*s %d\n", j, len, term, occur);
79 /* destroy and exit */
80 for (i = 0; i<no; i++)
82 ZOOM_scanset_destroy (s[i]);
83 ZOOM_connection_destroy (z[i]);
85 ZOOM_options_destroy(o);
91 * indent-tabs-mode: nil
93 * vim: shiftwidth=4 tabstop=8 expandtab