X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=zoom%2Fzoomsh.c;h=c72eaa27df7a33b3cdae0fdd3761fccfa7351f03;hb=ab75b3bd5dffe9425dfcfd36e76a60e8496bdd5d;hp=9115bf3afc6bd9932ec331f85832b22bff9e4f65;hpb=37fbd309fef590f0cc0e3bc955161bcb8e37e99e;p=yaz-moved-to-github.git diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 9115bf3..c72eaa2 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -14,6 +14,7 @@ #include #include #include +#include #if HAVE_READLINE_READLINE_H #include @@ -43,7 +44,8 @@ static void process_events(ZOOM_connection *c) } } -static int next_token(const char **cpp, const char **t_start) +static int next_token_chars(const char **cpp, const char **t_start, + const char *tok_chars) { int len = 0; const char *cp = *cpp; @@ -64,7 +66,7 @@ static int next_token(const char **cpp, const char **t_start) else { *t_start = cp; - while (*cp && *cp != ' ' && *cp != '\r' && *cp != '\n') + while (*cp && !strchr(tok_chars, *cp)) { cp++; len++; @@ -76,6 +78,12 @@ static int next_token(const char **cpp, const char **t_start) return len; /* return -1 if no token was read .. */ } +static int next_token(const char **cpp, const char **t_start) +{ + return next_token_chars(cpp, t_start, "\r\n "); +} + + static WRBUF next_token_new_wrbuf(const char **cpp) { WRBUF w = 0; @@ -103,18 +111,18 @@ static void cmd_set(ZOOM_connection *c, ZOOM_resultset *r, ZOOM_options options, const char **args) { - WRBUF key, val; + WRBUF key; + const char *val_buf; + int val_len; if (!(key = next_token_new_wrbuf(args))) { printf("missing argument for set\n"); return ; } - if ((val = next_token_new_wrbuf(args))) - { - ZOOM_options_set(options, wrbuf_cstr(key), wrbuf_cstr(val)); - wrbuf_destroy(val); - } + val_len = next_token_chars(args, &val_buf, ""); + if (val_len != -1) + ZOOM_options_setl(options, wrbuf_cstr(key), val_buf, val_len); else ZOOM_options_set(options, wrbuf_cstr(key), 0); wrbuf_destroy(key); @@ -717,8 +725,8 @@ void shell(ZOOM_connection *c, ZOOM_resultset *r, static void zoomsh(int argc, char **argv) { - ZOOM_options options = ZOOM_options_create(); - int i, res; + ZOOM_options zoom_options = ZOOM_options_create(); + int i, res = 1; ZOOM_connection z39_con[MAX_CON]; ZOOM_resultset z39_res[MAX_CON]; @@ -727,21 +735,31 @@ static void zoomsh(int argc, char **argv) z39_con[i] = 0; z39_res[i] = 0; } - - for (i = 0; i 2 && !strcmp(argv[1], "-v")) - { - maskstr = argv[2]; - argv += 2; - argc -= 2; - } - else if (argc > 1 && !strncmp(argv[1], "-v", 2)) - { - maskstr = argv[1]+2; - argv++; - argc--; - } - if (maskstr) - { - int mask = yaz_log_mask_str(maskstr); - yaz_log_init_level(mask); - } zoomsh(argc, argv); exit(0); }