- 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)))
- fprintf (stderr, "%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: %d hits\n", ZOOM_connection_option_get(c[i], "host"),
- ZOOM_resultset_size(r[i]));
- /* and display */
- display_records (c[i], r[i], start, count);
- }
- }
- ZOOM_query_destroy (s);
+ 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: %lld hits\n", ZOOM_connection_option_get(c[i], "host"),
+ (long long int) ZOOM_resultset_size(r[i]));
+ /* and display */
+ display_records(c[i], r[i], start, count, "render");
+ }
+ }
+}
+
+static void cmd_scan(ZOOM_connection *c, ZOOM_resultset *r,
+ ZOOM_options options,
+ const char **args)
+{
+ const char *query_str = *args;
+ ZOOM_query query = ZOOM_query_create();
+ int i;
+ ZOOM_scanset s[MAX_CON];
+
+ while (*query_str == ' ')
+ query_str++;
+
+ if (memcmp(query_str, "cql:", 4) == 0)
+ {
+ ZOOM_query_cql(query, query_str + 4);
+ }
+ else if (ZOOM_query_prefix(query, query_str))
+ {
+ printf("Bad PQF: %s\n", query_str);
+ return;
+ }
+
+ for (i = 0; i<MAX_CON; i++)
+ {
+ if (c[i])
+ s[i] = ZOOM_connection_scan1(c[i], query);
+ else
+ s[i] = 0;
+ }
+ ZOOM_query_destroy(query);
+
+ 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);
+
+ if (s[i]) {
+ size_t p, sz = ZOOM_scanset_size(s[i]);
+ for (p = 0; p < sz; p++)
+ {
+ size_t occ = 0;
+ size_t len = 0;
+ const char *term = ZOOM_scanset_display_term(s[i], p,
+ &occ, &len);
+ printf("%.*s %lld\n", (int) len, term, (long long int) 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))
+ ;