X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=zoom%2Fzoomsh.c;h=2cbd6d4f540821b8f995d057ac4cc4d302d9f738;hp=2d592213684135a926e257f1cc46f0265ad9a60b;hb=4936dff1c451bc76df80ddad8557c2396526f843;hpb=c516122e7966c81722715371eb899655979adc8a diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 2d59221..2cbd6d4 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -1,11 +1,11 @@ -/* - * Copyright (C) 1995-2005, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2008 Index Data * See the file LICENSE for details. - * - * $Id: zoomsh.c,v 1.35 2005-06-06 12:32:03 adam Exp $ */ -/* ZOOM-C Shell */ +/** \file zoomsh.c + \brief ZOOM C command line tool (shell) +*/ #include #include @@ -26,16 +26,15 @@ #include #include #include -#include #define MAX_CON 100 -static int next_token (const char **cpp, const char **t_start) +static int next_token(const char **cpp, const char **t_start) { int len = 0; const char *cp = *cpp; while (*cp == ' ') - cp++; + cp++; if (*cp == '"') { cp++; @@ -63,304 +62,373 @@ static int next_token (const char **cpp, const char **t_start) return len; /* return -1 if no token was read .. */ } -static int next_token_copy (const char **cpp, char *buf_out, int buf_max) +static int next_token_copy(const char **cpp, char *buf_out, int buf_max) { const char *start; - int len = next_token (cpp, &start); + int len = next_token(cpp, &start); if (len < 0) { - *buf_out = 0; - return len; + *buf_out = 0; + return len; } if (len >= buf_max) - len = buf_max-1; - memcpy (buf_out, start, len); + len = buf_max-1; + memcpy(buf_out, start, len); buf_out[len] = '\0'; return len; } -static int is_command (const char *cmd_str, const char *this_str, int this_len) +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; - if (memcmp (cmd_str, this_str, cmd_len)) - return 0; + return 0; + if (memcmp(cmd_str, this_str, cmd_len)) + return 0; return 1; } -static void cmd_set (ZOOM_connection *c, ZOOM_resultset *r, - ZOOM_options options, - const char **args) +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)) < 0) + 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)) < 0) - 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) +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) + if (next_token_copy(args, key, sizeof(key)) < 0) { - printf ("missing argument for get\n"); + printf("missing argument for get\n"); } else { const char *val = ZOOM_options_get(options, key); - printf ("%s = %s\n", key, val ? val : ""); + printf("%s = %s\n", key, val ? val : ""); + } +} + +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"); + } } } -static void cmd_close (ZOOM_connection *c, ZOOM_resultset *r, - ZOOM_options options, - const char **args) +static void cmd_close(ZOOM_connection *c, ZOOM_resultset *r, + ZOOM_options options, + const char **args) { char host[60]; int i; - next_token_copy (args, host, sizeof(host)); + next_token_copy(args, host, sizeof(host)); for (i = 0; i= 0) - ZOOM_options_set (options, "start", 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)) >= 0) - 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 ("set