+
+ while (ZOOM_event (MAX_CON, c))
+ ;
+
+ for (i = 0; i<MAX_CON; i++)
+ {
+ int error;
+ const char *errmsg, *addinfo, *dset;
+ /* display errors if any */
+ if (!c[i])
+ continue;
+ if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
+ printf ("%s error: %s (%s:%d) %s\n",
+ ZOOM_connection_option_get(c[i], "host"), errmsg,
+ dset, error, addinfo);
+ else if (r[i])
+ {
+ /* OK, no major errors. Look at the result count */
+ int start = ZOOM_options_get_int (options, "start", 0);
+ int count = ZOOM_options_get_int (options, "count", 0);
+
+ printf ("%s: %ld hits\n", ZOOM_connection_option_get(c[i], "host"),
+ (long) ZOOM_resultset_size(r[i]));
+ /* and display */
+ display_records (c[i], r[i], start, count);
+ }
+ }
+ ZOOM_query_destroy (s);
+}
+
+static void cmd_scan (ZOOM_connection *c, ZOOM_resultset *r,
+ ZOOM_options options,
+ const char **args)
+{
+ const char *start_term = *args;
+ int i;
+ ZOOM_scanset s[MAX_CON];
+
+ while (*start_term == ' ')
+ start_term++;
+
+ for (i = 0; i<MAX_CON; i++)
+ {
+ if (c[i])
+ s[i] = ZOOM_connection_scan(c[i], start_term);
+ else
+ s[i] = 0;
+ }
+ while (ZOOM_event(MAX_CON, c))
+ ;
+ for (i = 0; i<MAX_CON; i++)
+ {
+ if (s[i]) {
+ size_t p, sz = ZOOM_scanset_size(s[i]);
+ for (p = 0; p < sz; p++)
+ {
+ int occ = 0;
+ int len = 0;
+ const char *term = ZOOM_scanset_display_term(s[i], p,
+ &occ, &len);
+ fwrite(term, 1, len, stdout);
+ printf (" %d\n", occ);
+ }
+ ZOOM_scanset_destroy(s[i]);
+ }
+ }
+}
+
+static void cmd_sort (ZOOM_connection *c, ZOOM_resultset *r,
+ ZOOM_options options,
+ const char **args)
+{
+ const char *sort_spec = *args;
+ int i;
+
+ while (*sort_spec == ' ')
+ sort_spec++;
+
+ for (i = 0; i<MAX_CON; i++)
+ {
+ if (r[i])
+ ZOOM_resultset_sort(r[i], "yaz", sort_spec);
+ }
+ while (ZOOM_event(MAX_CON, c))
+ ;