X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=client%2Fclient.c;h=748c1844f25c9d641515cec3096609f93c774b68;hb=ffe5c37f0c9f55a685ac3559f1cad44baae399f4;hp=bf248301458a73b67e8a80356935cd29aa06ab57;hpb=3baa4049b64103161bfc03360cfd61683faacd22;p=yaz-moved-to-github.git diff --git a/client/client.c b/client/client.c index bf24830..748c184 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2002, Index Data * See the file LICENSE for details. * - * $Id: client.c,v 1.146 2002-03-06 01:22:41 adam Exp $ + * $Id: client.c,v 1.151 2002-05-03 13:48:27 adam Exp $ */ #include @@ -89,6 +89,12 @@ static QueryType queryType = QueryType_Prefix; static CCL_bibset bibset; /* CCL bibset handle */ #endif +#if HAVE_READLINE_COMPLETION_OVER + +#else +/* readline doesn't have this var. Define it ourselves. */ +int rl_attempted_completion_over = 0; +#endif /* set this one to 1, to avoid decode of unknown MARCs */ #define AVOID_MARC_DECODE 1 @@ -828,6 +834,59 @@ static int send_searchRequest(char *arg) return 2; } +/* display Query Expression as part of searchResult-1 */ +static void display_queryExpression (Z_QueryExpression *qe) +{ + if (!qe) + return; + if (qe->which == Z_QueryExpression_term) + { + if (qe->u.term->queryTerm) + { + Z_Term *term = qe->u.term->queryTerm; + if (term->which == Z_Term_general) + printf (" %.*s", term->u.general->len, term->u.general->buf); + } + } + +} + +/* see if we can find USR:SearchResult-1 */ +static void display_searchResult (Z_OtherInformation *o) +{ + int i; + if (!o) + return ; + for (i = 0; i < o->num_elements; i++) + { + if (o->list[i]->which == Z_OtherInfo_externallyDefinedInfo) + { + Z_External *ext = o->list[i]->information.externallyDefinedInfo; + + if (ext->which == Z_External_searchResult1) + { + int j; + Z_SearchInfoReport *sr = ext->u.searchResult1; + printf ("SearchResult-1:"); + for (j = 0; j < sr->num; j++) + { + if (!sr->elements[j]->subqueryExpression) + printf (" %d", j); + display_queryExpression ( + sr->elements[j]->subqueryExpression); + display_queryExpression ( + sr->elements[j]->subqueryInterpretation); + display_queryExpression ( + sr->elements[j]->subqueryRecommendation); + if (sr->elements[j]->subqueryCount) + printf ("(%d)", *sr->elements[j]->subqueryCount); + } + printf ("\n"); + } + } + } +} + static int process_searchResponse(Z_SearchResponse *res) { printf ("Received SearchResponse.\n"); @@ -839,7 +898,9 @@ static int process_searchResponse(Z_SearchResponse *res) printf("Number of hits: %d", *res->resultCount); if (setnumber >= 0) printf (", setno %d", setnumber); - printf("\nrecords returned: %d\n", + printf ("\n"); + display_searchResult (res->additionalSearchInfo); + printf("records returned: %d\n", *res->numberOfRecordsReturned); setno += *res->numberOfRecordsReturned; if (res->records) @@ -2546,7 +2607,7 @@ void process_cmd_line(char* line) { printf("Unknown command: %s.\n", word); cmd_help (""); - + res = 1; } if(apdu_file) fflush(apdu_file); @@ -2584,7 +2645,7 @@ char ** readline_completer(char *text, int start, int end) { #if HAVE_READLINE_READLINE_H if(start == 0) { -#ifdef RL_READLINE_VERSION +#if HAVE_READLINE_RL_COMPLETION_MATCHES char** res=rl_completion_matches(text, command_generator); #else @@ -2615,7 +2676,7 @@ char ** readline_completer(char *text, int start, int end) { if(!cmd[i].complete_filenames) rl_attempted_completion_over = 1; if(cmd[i].rl_completerfunction) { -#ifdef RL_READLINE_VERSION +#ifdef HAVE_READLINE_RL_COMPLETION_MATCHES char** res= rl_completion_matches(text, cmd[i].rl_completerfunction);