X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=zoom%2Fzoomsh.c;h=37f5452223f3572d20e9da37e3eafdae9ef17493;hp=35b14a00ef07fc7626be4a12b4bbb973d49cb041;hb=d84e4c3cd444d04aee7beeadb5bb0ae061ee24c9;hpb=50fbdc0bbd17afe2fd8f128330dc313700593d78 diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 35b14a0..37f5452 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #if HAVE_READLINE_READLINE_H @@ -493,6 +494,43 @@ static int cmd_debug(struct zoom_sh *sh, const char **args) return 0; } +static void display_search_result(struct zoom_db *db) +{ + const char *v; + int num; + + v = ZOOM_resultset_option_get(db->res, "searchresult.size"); + if (v && (num = atoi(v))) + { + int i; + printf("SearchResult-1:"); + for (i = 0; i < num; i++) + { + const char *v; + char str[60]; + + if (i) + printf(","); + + sprintf(str, "searchresult.%d.id", i); + v = ZOOM_resultset_option_get(db->res, str); + if (v) + printf(" id=%s", v); + + sprintf(str, "searchresult.%d.subquery.term", i); + v = ZOOM_resultset_option_get(db->res, str); + if (v) + printf(" term=%s", v); + + sprintf(str, "searchresult.%d.count", i); + v = ZOOM_resultset_option_get(db->res, str); + if (v) + printf(" cnt=%s", v); + } + printf("\n"); + } +} + static int cmd_search(struct zoom_sh *sh, const char **args) { ZOOM_query s; @@ -586,6 +624,7 @@ static int cmd_search(struct zoom_sh *sh, const char **args) } } } + display_search_result(db); /* and display */ display_records(db->con, db->res, start, count, "render"); } @@ -882,7 +921,10 @@ static int shell(struct zoom_sh *sh, int exit_on_error) #endif if (!line_in) /* no line buffer via readline or not enabled at all */ { - printf("ZOOM>"); fflush(stdout); + if (isatty(0)) + { + printf("ZOOM>"); fflush(stdout); + } if (!fgets(buf, sizeof(buf)-1, stdin)) { res = -1; @@ -916,7 +958,7 @@ static int zoomsh(int argc, char **argv) { int mask; char *arg = 0; - int option_ret = options("ev:", argv, argc, &arg); + int option_ret = options("a:ev:", argv, argc, &arg); const char *bp = arg; switch (option_ret) { @@ -929,6 +971,9 @@ static int zoomsh(int argc, char **argv) case YAZ_OPTIONS_EOF: res = shell(&sh, exit_on_error); break; + case 'a': + ZOOM_options_set(sh.options, "apdufile", arg); + break; case 'e': exit_on_error = 1; break; @@ -937,7 +982,7 @@ static int zoomsh(int argc, char **argv) yaz_log_init_level(mask); break; default: - fprintf(stderr, "zoomsh: [-e] [-v] [commands]\n"); + fprintf(stderr, "zoomsh: [-a apdulog] [-e] [-v level] [commands]\n"); res = 1; } } @@ -960,7 +1005,10 @@ static int zoomsh(int argc, char **argv) int main(int argc, char **argv) { - int ret = zoomsh(argc, argv); + int ret; + + yaz_enable_panic_backtrace(*argv); + ret = zoomsh(argc, argv); exit(ret); } /*