X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=zoom%2Fzoomsh.c;h=111f629a9d1bdd3a8576ca997af7a4dab07846a6;hp=bf35f6a9bf40de8b3108f3a9c89aa6fde88a8888;hb=1632ffe4788128f6557bbaa9764e92493ae4934c;hpb=4d531a1a9131d69c3b6c27fbac42837e22cff61c diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index bf35f6a..111f629 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -1,14 +1,19 @@ /* - * $Id: zoomsh.c,v 1.12 2003-01-06 08:20:28 adam Exp $ + * Copyright (C) 1995-2005, Index Data ApS + * See the file LICENSE for details. * - * ZOOM-C Shell + * $Id: zoomsh.c,v 1.37 2005-06-25 15:46:08 adam Exp $ */ +/* ZOOM-C Shell */ + #include #include #include #include +#include + #if HAVE_READLINE_READLINE_H #include #endif @@ -18,7 +23,10 @@ #include +#include +#include #include +#include #define MAX_CON 100 @@ -27,28 +35,45 @@ static int next_token (const char **cpp, const char **t_start) int len = 0; const char *cp = *cpp; while (*cp == ' ') - cp++; - *t_start = cp; - while (*cp && *cp != ' ' && *cp != '\r' && *cp != '\n') + cp++; + if (*cp == '"') + { + cp++; + *t_start = cp; + while (*cp && *cp != '"') + { + cp++; + len++; + } + if (*cp) + cp++; + } + else { - cp++; - len++; + *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; + *buf_out = 0; + return len; } if (len >= buf_max) - len = buf_max-1; + len = buf_max-1; memcpy (buf_out, start, len); buf_out[len] = '\0'; return len; @@ -58,37 +83,37 @@ static int is_command (const char *cmd_str, const char *this_str, int this_len) { int cmd_len = strlen(cmd_str); if (cmd_len != this_len) - return 0; + return 0; if (memcmp (cmd_str, this_str, cmd_len)) - return 0; + return 0; return 1; } static void cmd_set (ZOOM_connection *c, ZOOM_resultset *r, - ZOOM_options options, - const char **args) + 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 ; + printf ("missing argument for set\n"); + return ; } - if (!next_token_copy (args, val, sizeof(val))) - ZOOM_options_set(options, key, 0); + if (next_token_copy (args, val, sizeof(val)) < 0) + ZOOM_options_set(options, key, 0); else - ZOOM_options_set(options, key, val); + ZOOM_options_set(options, key, val); } static void cmd_get (ZOOM_connection *c, ZOOM_resultset *r, - ZOOM_options options, - const char **args) + ZOOM_options options, + const char **args) { char key[40]; - if (!next_token_copy (args, key, sizeof(key))) + if (next_token_copy (args, key, sizeof(key)) < 0) { - printf ("missing argument for get\n"); + printf ("missing argument for get\n"); } else { @@ -98,92 +123,101 @@ static void cmd_get (ZOOM_connection *c, ZOOM_resultset *r, } static void cmd_close (ZOOM_connection *c, ZOOM_resultset *r, - ZOOM_options options, - const char **args) + ZOOM_options options, + const char **args) { char host[60]; int i; next_token_copy (args, host, sizeof(host)); for (i = 0; i= 0) + ZOOM_options_set (options, "start", start_str); - if (next_token_copy (args, count_str, sizeof(count_str))) - ZOOM_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 ("ext \n"); printf ("set