X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=zoom%2Fzoomsh.c;h=7276d63fef7bea7a2adb0b4b747e4380424242c0;hb=f517f60a95e2f94edd1efd750024642b5941ef08;hp=f263768ed55b652564e4751290af48246a1c5d1c;hpb=1cd88a77abb7c32e5ff938e2f4b9392d03d45ec5;p=yaz-moved-to-github.git diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index f263768..7276d63 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -1,14 +1,19 @@ /* - * $Id: zoomsh.c,v 1.9 2002-05-18 09:52:37 oleg Exp $ + * Copyright (C) 1995-2005, Index Data ApS + * See the file LICENSE for details. * - * ZOOM-C Shell + * $Id: zoomsh.c,v 1.32 2005-01-15 19:47:15 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 @@ -28,24 +36,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 +95,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, @@ -120,17 +158,24 @@ static void display_records (ZOOM_connection c, int pos = i + start; ZOOM_record rec = ZOOM_resultset_record (r, pos); const char *db = ZOOM_record_get (rec, "database", 0); - int len; + 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) { - 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); printf ("\n"); + if (opac_render) + fwrite (opac_render, 1, opac_len, stdout); } + } } @@ -141,10 +186,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