X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=zoom%2Fzoomsh.c;h=ad829489bffcab461aa02459a548879f6064ad22;hp=6d9fce21405433a3704e9f461fd0451cfe78f68c;hb=16ee7ff60aee87829916837bcb2a200ce72870d9;hpb=67002f49611adb64993391b0cbf6c235f18080a4 diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 6d9fce2..ad82948 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -2,10 +2,12 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: zoomsh.c,v 1.36 2005-06-25 15:42:19 adam Exp $ + * $Id: zoomsh.c,v 1.41 2006-04-24 10:30:44 adam Exp $ */ -/* ZOOM-C Shell */ +/** \file zoomsh.c + \brief ZOOM C command line tool (shell) +*/ #include #include @@ -35,7 +37,7 @@ 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++; @@ -69,11 +71,11 @@ static int next_token_copy (const char **cpp, char *buf_out, int buf_max) 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; + len = buf_max-1; memcpy (buf_out, start, len); buf_out[len] = '\0'; return len; @@ -83,37 +85,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)) < 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); + 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)) < 0) { - printf ("missing argument for get\n"); + printf ("missing argument for get\n"); } else { @@ -122,99 +124,123 @@ static void cmd_get (ZOOM_connection *c, ZOOM_resultset *r, } } +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) + 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); + 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); + ZOOM_options_set (options, "count", count_str); for (i = 0; i\n"); printf ("search \n"); @@ -430,8 +456,8 @@ static void cmd_help (ZOOM_connection *c, ZOOM_resultset *r, } static void cmd_connect (ZOOM_connection *c, ZOOM_resultset *r, - ZOOM_options options, - const char **args) + ZOOM_options options, + const char **args) { int error; const char *errmsg, *addinfo, *dset; @@ -439,79 +465,81 @@ static void cmd_connect (ZOOM_connection *c, ZOOM_resultset *r, int j, i; if (next_token_copy (args, host, sizeof(host)) < 0) { - printf ("missing host after connect\n"); - return ; + printf ("missing host after connect\n"); + return ; } for (j = -1, i = 0; i"); - if (!line_in) - break; + char* line_in; + line_in=readline("ZOOM>"); + if (!line_in) + break; #if HAVE_READLINE_HISTORY_H - if (*line_in) - add_history(line_in); + if (*line_in) + add_history(line_in); #endif - if(strlen(line_in) > 999) { - printf("Input line too long\n"); - break; - }; - strcpy(buf,line_in); - free (line_in); + if(strlen(line_in) > 999) { + printf("Input line too long\n"); + break; + }; + strcpy(buf,line_in); + free (line_in); #else - printf ("ZOOM>"); fflush (stdout); - if (!fgets (buf, 999, stdin)) - break; + printf ("ZOOM>"); fflush (stdout); + if (!fgets (buf, 999, stdin)) + break; #endif - if ((cp = strchr(buf, '\n'))) - *cp = '\0'; - if (!cmd_parse (c, r, options, &bp)) - break; + if ((cp = strchr(buf, '\n'))) + *cp = '\0'; + if (!cmd_parse (c, r, options, &bp)) + break; } } @@ -559,29 +587,29 @@ static void zoomsh(int argc, char **argv) for (i = 0; i