X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=zoom%2Fzoomsh.c;h=c6b29ae16237e68906aae0bdceba7d069fad7e98;hb=e1efa4cdf426e7eb952584ed4b9d3b818c8ff070;hp=24746d26a5c033c9f5c7ce5d45ec83897b91ecd3;hpb=13671e7cc0f3dd4e4b02f94d64a50778c5696ba6;p=yaz-moved-to-github.git diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 24746d2..c6b29ae 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -1,5 +1,5 @@ /* - * $Id: zoomsh.c,v 1.7 2001-11-18 21:14:23 adam Exp $ + * $Id: zoomsh.c,v 1.22 2003-07-10 11:50:32 mike Exp $ * * ZOOM-C Shell */ @@ -18,7 +18,10 @@ #include +#include +#include #include +#include #define MAX_CON 100 @@ -28,24 +31,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; @@ -70,18 +90,31 @@ static void cmd_set (ZOOM_connection *c, ZOOM_resultset *r, { 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 = ZOOM_options_get(options, key); - printf ("%s = %s\n", key, val ? val : ""); + printf ("missing argument for get\n"); } else - ZOOM_options_set(options, key, val); + { + const char *val = ZOOM_options_get(options, key); + printf ("%s = %s\n", key, val ? val : ""); + } } static void cmd_close (ZOOM_connection *c, ZOOM_resultset *r, @@ -126,10 +159,13 @@ static void display_records (ZOOM_connection c, /* if rec is non-null, we got a record for display */ if (rec) { - printf ("%d %s %s\n", pos+1, (db ? db : "unknown"), syntax); + 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); - putchar ('\n'); + printf ("\n"); } } } @@ -141,10 +177,10 @@ static void cmd_show (ZOOM_connection *c, ZOOM_resultset *r, int i; char start_str[10], count_str[10]; - if (next_token_copy (args, start_str, sizeof(start_str))) + if (next_token_copy (args, start_str, sizeof(start_str)) >= 0) ZOOM_options_set (options, "start", start_str); - if (next_token_copy (args, count_str, sizeof(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