+static void cmd_rget(ZOOM_connection *c, ZOOM_resultset *r,
+ ZOOM_options options,
+ const char **args)
+{
+ char key[40];
+ if (next_token_copy (args, key, sizeof(key)) < 0)
+ {
+ printf ("missing argument for get\n");
+ }
+ else
+ {
+ int i;
+ for (i = 0; i<MAX_CON; i++)
+ {
+ const char *val;
+ if (!r[i])
+ continue;
+
+ val = ZOOM_resultset_option_get(r[i], key);
+ printf ("%s = %s\n", key, val ? val : "<null>");
+ }
+ }
+}
+
{
char host[60];
int i;
next_token_copy (args, host, sizeof(host));
for (i = 0; i<MAX_CON; i++)
{
{
char host[60];
int i;
next_token_copy (args, host, sizeof(host));
for (i = 0; i<MAX_CON; i++)
{
- {
- ZOOM_connection_destroy (c[i]);
- c[i] = 0;
- }
- else if (*host == '\0')
- {
- ZOOM_connection_destroy (c[i]);
- c[i] = 0;
- }
+ {
+ ZOOM_connection_destroy (c[i]);
+ c[i] = 0;
+ }
+ else if (*host == '\0')
+ {
+ ZOOM_connection_destroy (c[i]);
+ c[i] = 0;
+ }
- const char *db = ZOOM_record_get (rec, "database", 0);
- int len;
- const char *render = ZOOM_record_get (rec, "render", &len);
- const char *syntax = ZOOM_record_get (rec, "syntax", 0);
- /* if rec is non-null, we got a record for display */
- if (rec)
- {
- printf ("%d %s %s\n", pos+1, (db ? db : "unknown"), syntax);
- if (render)
- fwrite (render, 1, len, stdout);
- printf ("\n");
- }
+ const char *db = ZOOM_record_get (rec, "database", 0);
+ int len, opac_len;
+ const char *render = ZOOM_record_get (rec, "render", &len);
+ const char *opac_render = ZOOM_record_get (rec, "opac", &opac_len);
+ const char *syntax = ZOOM_record_get (rec, "syntax", 0);
+ /* if rec is non-null, we got a record for display */
+ if (rec)
+ {
+ char oidbuf[100];
+ (void) oid_name_to_dotstring(CLASS_RECSYN, syntax, oidbuf);
+ printf ("%d %s %s (%s)\n",
+ pos+1, (db ? db : "unknown"), syntax, oidbuf);
+ if (render)
+ fwrite (render, 1, len, stdout);
+ printf ("\n");
+ if (opac_render)
+ fwrite (opac_render, 1, opac_len, stdout);
+ }
+
{
int i;
char start_str[10], count_str[10];
if (next_token_copy (args, start_str, sizeof(start_str)) >= 0)
{
int i;
char start_str[10], count_str[10];
if (next_token_copy (args, start_str, sizeof(start_str)) >= 0)
- ZOOM_resultset_records (r[i], 0, atoi(start_str), atoi(count_str));
+ ZOOM_resultset_records (r[i], 0, atoi(start_str), atoi(count_str));
- 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. Display records... */
- int start = ZOOM_options_get_int (options, "start", 0);
- int count = ZOOM_options_get_int (options, "count", 0);
- display_records (c[i], r[i], start, count);
- }
+ 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. Display records... */
+ int start = ZOOM_options_get_int (options, "start", 0);
+ int count = ZOOM_options_get_int (options, "count", 0);
+ display_records (c[i], r[i], start, count);
+ }
}
ZOOM_options_set (options, "count", "0");
ZOOM_options_set (options, "start", "0");
}
ZOOM_options_set (options, "count", "0");
ZOOM_options_set (options, "start", "0");
- int error;
- const char *errmsg, *addinfo, *dset;
- /* display errors if any */
- if (!p[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 (p[i])
- {
+ int error;
+ const char *errmsg, *addinfo, *dset;
+ /* display errors if any */
+ if (!p[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 (p[i])
+ {
+ const char *v;
+ v = ZOOM_package_option_get (p[i], "targetReference");
+ if (v)
+ printf("targetReference: %s\n", v);
+ v = ZOOM_package_option_get (p[i], "xmlUpdateDoc");
+ if (v)
+ printf("xmlUpdateDoc: %s\n", v);
+ }
- if (c[i])
- {
- ZOOM_resultset_destroy (r[i]);
- r[i] = 0;
- }
- if (c[i])
- r[i] = ZOOM_connection_search (c[i], s);
+ if (c[i])
+ {
+ ZOOM_resultset_destroy (r[i]);
+ r[i] = 0;
+ }
+ if (c[i])
+ r[i] = ZOOM_connection_search (c[i], 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: %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);
- }
+ 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: %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);
+ }
+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))
+ ;
+}
+
printf (" implementationName\n");
printf (" charset\n");
printf (" lang\n");
}
static void cmd_connect (ZOOM_connection *c, ZOOM_resultset *r,
printf (" implementationName\n");
printf (" charset\n");
printf (" lang\n");
}
static void cmd_connect (ZOOM_connection *c, ZOOM_resultset *r,
- const char *h;
- if (c[i] && (h = ZOOM_connection_option_get(c[i], "host")) &&
- !strcmp (h, host))
- {
- ZOOM_connection_destroy (c[i]);
- break;
- }
- else if (c[i] == 0 && j == -1)
- j = i;
+ const char *h;
+ if (c[i] && (h = ZOOM_connection_option_get(c[i], "host")) &&
+ !strcmp (h, host))
+ {
+ ZOOM_connection_destroy (c[i]);
+ break;
+ }
+ else if (c[i] == 0 && j == -1)
+ j = i;
- if (j == -1)
- {
- printf ("no more connection available\n");
- return;
- }
- i = j; /* OK, use this one is available */
+ if (j == -1)
+ {
+ printf ("no more connection available\n");
+ return;
+ }
+ i = j; /* OK, use this one is available */
}
c[i] = ZOOM_connection_create (options);
ZOOM_connection_connect (c[i], host, 0);
}
c[i] = ZOOM_connection_create (options);
ZOOM_connection_connect (c[i], host, 0);
if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
printf ("%s error: %s (%s:%d) %s\n",
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);
+ ZOOM_connection_option_get(c[i], "host"), errmsg,
+ dset, error, addinfo);
- cmd_get (c, r, options, buf);
+ cmd_get (c, r, options, buf);
+ else if (is_command ("rget", cmd_str, cmd_len))
+ cmd_rget (c, r, options, buf);
- cmd_scan(c, r, options, buf);
+ cmd_scan(c, r, options, buf);
+ else if (is_command ("sort", cmd_str, cmd_len))
+ cmd_sort(c, r, options, buf);
- printf ("ZOOM>"); fflush (stdout);
- if (!fgets (buf, 999, stdin))
- break;
+ printf ("ZOOM>"); fflush (stdout);
+ if (!fgets (buf, 999, stdin))
+ break;
- if ((cp = strchr(buf, '\n')))
- *cp = '\0';
- if (!cmd_parse (c, r, options, &bp))
- break;
+ if ((cp = strchr(buf, '\n')))
+ *cp = '\0';
+ if (!cmd_parse (c, r, options, &bp))
+ break;
{
ZOOM_options options = ZOOM_options_create();
int i, res;
ZOOM_connection z39_con[MAX_CON];
ZOOM_resultset z39_res[MAX_CON];
{
ZOOM_options options = ZOOM_options_create();
int i, res;
ZOOM_connection z39_con[MAX_CON];
ZOOM_resultset z39_res[MAX_CON];
- const char *bp = argv[i];
- res = cmd_parse(z39_con, z39_res, options, &bp);
- if (res == 0) /* received quit */
- break;
+ const char *bp = argv[i];
+ res = cmd_parse(z39_con, z39_res, options, &bp);
+ if (res == 0) /* received quit */
+ break;
+}
+
+int main(int argc, char **argv)
+{
+ const char *maskstr = 0;
+ if (argc > 2 && !strcmp(argv[1], "-v"))
+ {
+ maskstr = argv[2];
+ argv += 2;
+ argc -= 2;
+ }
+ else if (argc > 1 && !strncmp(argv[1], "-v", 2))
+ {
+ maskstr = argv[1]+2;
+ argv++;
+ argc--;
+ }
+ if (maskstr)
+ {
+ int mask = yaz_log_mask_str(maskstr);
+ yaz_log_init_level(mask);
+ }
+ nmem_init();
+ zoomsh(argc, argv);