X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=zoom%2Fzoomsh.c;h=54ebda231d3e09874af98d8502008af74206eff6;hb=f98330f4a395ec9f830c39b4a4eb4e523bc0c796;hp=9f9d0e4e149c6a7750a2be8bddcf59e47a55358a;hpb=bc66c2a11aa31c16f46c49100e99dc9b7e940faf;p=yaz-moved-to-github.git diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 9f9d0e4..54ebda2 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -1,5 +1,5 @@ /* - * $Id: zoomsh.c,v 1.2 2001-10-24 12:24:43 adam Exp $ + * $Id: zoomsh.c,v 1.19 2003-04-23 20:39:25 adam Exp $ * * ZOOM-C Shell */ @@ -18,6 +18,8 @@ #include +#include +#include #include #define MAX_CON 100 @@ -28,24 +30,41 @@ static int next_token (const char **cpp, const char **t_start) const char *cp = *cpp; while (*cp == ' ') cp++; - *t_start = cp; - while (*cp && *cp != ' ' && *cp != '\r' && *cp != '\n') + if (*cp == '"') { - cp++; - len++; + cp++; + *t_start = cp; + while (*cp && *cp != '"') + { + cp++; + len++; + } + if (*cp) + cp++; + } + else + { + *t_start = cp; + while (*cp && *cp != ' ' && *cp != '\r' && *cp != '\n') + { + cp++; + len++; + } + if (len == 0) + len = -1; } *cpp = cp; - return len; + return len; /* return -1 if no token was read .. */ } static int next_token_copy (const char **cpp, char *buf_out, int buf_max) { const char *start; int len = next_token (cpp, &start); - if (!len) + if (len < 0) { *buf_out = 0; - return 0; + return len; } if (len >= buf_max) len = buf_max-1; @@ -64,28 +83,41 @@ static int is_command (const char *cmd_str, const char *this_str, int this_len) return 1; } -static void cmd_set (Z3950_connection *c, Z3950_resultset *r, - Z3950_options options, +static void cmd_set (ZOOM_connection *c, ZOOM_resultset *r, + ZOOM_options options, const char **args) { char key[40], val[80]; - if (!next_token_copy (args, key, sizeof(key))) + if (next_token_copy (args, key, sizeof(key)) < 0) { printf ("missing argument for set\n"); return ; } - if (!next_token_copy (args, val, sizeof(val))) + if (next_token_copy (args, val, sizeof(val)) < 0) + ZOOM_options_set(options, key, 0); + else + ZOOM_options_set(options, key, val); +} + +static void cmd_get (ZOOM_connection *c, ZOOM_resultset *r, + ZOOM_options options, + const char **args) +{ + char key[40]; + if (next_token_copy (args, key, sizeof(key)) < 0) { - const char *val = Z3950_options_get(options, key); - printf ("%s = %s\n", key, val ? val : ""); + printf ("missing argument for get\n"); } else - Z3950_options_set(options, key, val); + { + const char *val = ZOOM_options_get(options, key); + printf ("%s = %s\n", key, val ? val : ""); + } } -static void cmd_close (Z3950_connection *c, Z3950_resultset *r, - Z3950_options options, +static void cmd_close (ZOOM_connection *c, ZOOM_resultset *r, + ZOOM_options options, const char **args) { char host[60]; @@ -96,144 +128,242 @@ static void cmd_close (Z3950_connection *c, Z3950_resultset *r, const char *h; if (!c[i]) continue; - if ((h = Z3950_connection_host(c[i])) && !strcmp (h, host)) + if ((h = ZOOM_connection_option_get(c[i], "host")) + && !strcmp (h, host)) { - Z3950_connection_destroy (c[i]); + ZOOM_connection_destroy (c[i]); c[i] = 0; } else if (*host == '\0') { - Z3950_connection_destroy (c[i]); + ZOOM_connection_destroy (c[i]); c[i] = 0; } } } -static void display_records (Z3950_connection c, - Z3950_resultset r, +static void display_records (ZOOM_connection c, + ZOOM_resultset r, int start, int count) { int i; for (i = 0; i= 0) + ZOOM_options_set (options, "start", start_str); - if (next_token_copy (args, count_str, sizeof(count_str))) - Z3950_options_set (options, "count", count_str); + if (next_token_copy (args, count_str, sizeof(count_str)) >= 0) + ZOOM_options_set (options, "count", count_str); for (i = 0; i\n"); printf ("search \n"); printf ("show [ []\n"); + printf ("scan \n"); printf ("quit\n"); printf ("close \n"); - printf ("set