X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=client%2Fclient.c;h=70455bb51d9bbedc7830f81233a156f99f605504;hp=dafd7ef7ecbaaab4aa70c2443c408695559fffa5;hb=bee632cc3a4d22b61dd7dc1a196253be5782cf0c;hpb=e0bff0e5d91422453fa9779565beeef33c4f2740 diff --git a/client/client.c b/client/client.c index dafd7ef..70455bb 100644 --- a/client/client.c +++ b/client/client.c @@ -4,7 +4,22 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: client.c,v $ - * Revision 1.8 1995-06-05 10:52:22 quinn + * Revision 1.13 1995-06-16 10:29:11 quinn + * *** empty log message *** + * + * Revision 1.12 1995/06/15 07:44:57 quinn + * Moving to v3. + * + * Revision 1.11 1995/06/14 15:26:40 quinn + * *** empty log message *** + * + * Revision 1.10 1995/06/06 14:56:58 quinn + * Better diagnostics. + * + * Revision 1.9 1995/06/06 08:15:19 quinn + * Cosmetic. + * + * Revision 1.8 1995/06/05 10:52:22 quinn * Added SCAN. * * Revision 1.7 1995/06/02 09:50:09 quinn @@ -51,7 +66,6 @@ #endif #include - #include #ifdef RPN_QUERY @@ -62,8 +76,6 @@ #endif #endif -#include "../version.h" - #define C_PROMPT "Z> " static ODR out, in, print; /* encoding and decoding streams */ @@ -78,6 +90,8 @@ static int setno = 1; /* current set offset */ static int protocol = PROTO_Z3950; /* current app protocol */ static ODR_MEM session_mem; /* memory handle for init-response */ static Z_InitResponse *session = 0; /* session parameters */ +static char last_scan[512] = "0"; +static char last_cmd[100] = "?"; #ifdef RPN_QUERY #ifndef PREFIX_QUERY static CCL_bibset bibset; /* CCL bibset handle */ @@ -127,7 +141,7 @@ static void send_initRequest() static int process_initResponse(Z_InitResponse *res) { - /* save parameters for later use */ + /* save session parameters for later use */ session_mem = odr_extract_mem(in); session = res; @@ -259,18 +273,9 @@ void display_record(Z_DatabaseRecord *p) odr_reset(print); } } -#if 1 if (r->which == ODR_EXTERNAL_octet && p->u.octet_aligned->len) { -#if 1 marc_display ((char*)p->u.octet_aligned->buf, stdout); -#else - FILE *ofi = fopen("dump", "a"); - assert(ofi); - fwrite(p->u.octet_aligned->buf, 1, p->u.octet_aligned->len, ofi); - fclose(ofi); - printf("dumped record\n"); -#endif } else { @@ -281,19 +286,32 @@ void display_record(Z_DatabaseRecord *p) odr_reset(print); } } -#endif } static void display_diagrec(Z_DiagRec *p) { oident *ent; +#ifdef Z_95 + Z_DefaultDiagFormat *r; +#else + Z_DiagRec *r = p; +#endif printf("Diagnostic message from database.\n"); - if (!(ent = oid_getentbyoid(p->diagnosticSetId)) || +#ifdef Z_95 + if (p->which != Z_DiagRec_defaultFormat) + { + printf("Diagnostic record not in default format.\n"); + return; + } + else + r = p->u.defaultFormat; +#endif + if (!(ent = oid_getentbyoid(r->diagnosticSetId)) || ent->class != CLASS_DIAGSET || ent->value != VAL_BIB1) printf("Missing or unknown diagset\n"); - printf("Error condition: %d", *p->condition); - printf(" -- %s\n", p->addinfo ? p->addinfo : ""); + printf("Error condition: %d", *r->condition); + printf(" -- %s\n", r->addinfo ? r->addinfo : ""); } static void display_nameplusrecord(Z_NamePlusRecord *p) @@ -409,7 +427,7 @@ static int send_searchRequest(char *arg) static int process_searchResponse(Z_SearchResponse *res) { - if (res->searchStatus) + if (*res->searchStatus) printf("Search was a success.\n"); else printf("Search was a bloomin' failure.\n"); @@ -569,9 +587,6 @@ int send_scanrequest(char *string, int pp, int num) Z_ScanRequest *req = apdu->u.scanRequest; char *db = database; oident attset; - Z_AttributesPlusTerm sp; - Z_Term term; - Odr_oct trm; req->num_databaseNames = 1; req->databaseNames = &db; @@ -579,14 +594,7 @@ int send_scanrequest(char *string, int pp, int num) attset.class = CLASS_ATTSET; attset.value = VAL_BIB1; req->attributeSet = oid_getoidbyent(&attset); - req->termListAndStartPoint = &sp; - sp.num_attributes = 0; - sp.attributeList = ODR_NULLVAL; - sp.term = &term; - term.which = Z_Term_general; - term.u.general = &trm; - trm.buf = (unsigned char*) string; - trm.len = trm.size = strlen(string); + req->termListAndStartPoint = p_query_scan(out, string); req->numberOfTermsRequested = # req->preferredPositionInResponse = &pp; send_apdu(apdu); @@ -596,8 +604,12 @@ int send_scanrequest(char *string, int pp, int num) void display_term(Z_TermInfo *t) { if (t->term->which == Z_Term_general) + { printf("%.*s (%d)\n", t->term->u.general->len, t->term->u.general->buf, t->globalOccurrences ? *t->globalOccurrences : -1); + sprintf(last_scan, "%.*s", t->term->u.general->len, + t->term->u.general->buf); + } else printf("Term type not general.\n"); } @@ -642,7 +654,12 @@ int cmd_scan(char *arg) return 0; } if (*arg) - if (send_scanrequest(arg, 5, 19) < 0) + { + if (send_scanrequest(arg, 5, 20) < 0) + return 0; + } + else + if (send_scanrequest(last_scan, 1, 20) < 0) return 0; return 2; } @@ -728,11 +745,12 @@ static int client(void) break; if ((res = sscanf(line, "%s %[^;]", word, arg)) <= 0) { - printf(C_PROMPT); - continue; + strcpy(word, last_cmd); + *arg = '\0'; } - if (res == 1) + else if (res == 1) *arg = 0; + strcpy(last_cmd, word); for (i = 0; cmd[i].cmd; i++) if (!strncmp(cmd[i].cmd, word, strlen(word))) {