X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=client%2Fclient.c;h=f009640ccc7b4a52cc7c30b6c78bf6f20af4aca8;hp=1512e88732c25ecc3bc5b6259318ae1599719d48;hb=975c22d3fb94aaf91399f1967dbb173129205888;hpb=4ddee9959ca6f59d3f8bd4259dfecee04b12c925 diff --git a/client/client.c b/client/client.c index 1512e88..f009640 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: client.c,v 1.225 2004-01-13 11:19:24 adam Exp $ + * $Id: client.c,v 1.231 2004-02-16 21:40:39 adam Exp $ */ #include @@ -104,6 +104,7 @@ static char *refid = NULL; static char *last_open_command = NULL; static int auto_reconnect = 0; static Odr_bitmask z3950_options; +static int z3950_version = 3; static char cur_host[200]; @@ -280,12 +281,13 @@ static void send_initRequest(const char* type_and_host) { Z_APDU *apdu = zget_APDU(out, Z_APDU_initRequest); Z_InitRequest *req = apdu->u.initRequest; + int i; req->options = &z3950_options; - ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1); - ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2); - ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3); + ODR_MASK_ZERO(req->protocolVersion); + for (i = 0; iprotocolVersion, i); *req->maximumRecordSize = 1024*kilobytes; *req->preferredMessageSize = 1024*kilobytes; @@ -294,7 +296,7 @@ static void send_initRequest(const char* type_and_host) req->referenceId = set_refid (out); - if (yazProxy) + if (yazProxy && type_and_host) yaz_oi_set_string_oidval(&req->otherInfo, out, VAL_PROXY, 1, type_and_host); @@ -326,7 +328,7 @@ static void send_initRequest(const char* type_and_host) static void render_initUserInfo(Z_OtherInformation *ui1); static void render_diag(Z_DiagnosticFormat *diag); -static void pr_opt(const char *opt) +static void pr_opt(const char *opt, void *clientData) { printf (" %s", opt); } @@ -338,7 +340,7 @@ static int process_initResponse(Z_InitResponse *res) session_mem = odr_extract_mem(in); session = res; - for (ver = 0; ver<5; ver++) + for (ver = 0; ver < 8; ver++) if (!ODR_MASK_GET(res->protocolVersion, ver)) break; @@ -375,7 +377,7 @@ static int process_initResponse(Z_InitResponse *res) } } printf ("Options:"); - yaz_init_opt_decode(res->options, pr_opt); + yaz_init_opt_decode(res->options, pr_opt, 0); printf ("\n"); if (ODR_MASK_GET(res->options, Z_Options_namedResultSets)) @@ -709,7 +711,7 @@ static void display_record(Z_External *r) if (ent && r->which == Z_External_octet) { Z_ext_typeent *type = z_ext_getentbyref(ent->value); - void *rr; + char *rr; if (type) { @@ -718,7 +720,7 @@ static void display_record(Z_External *r) */ odr_setbuf(in, (char*)r->u.octet_aligned->buf, r->u.octet_aligned->len, 0); - if (!(*type->fun)(in, (char **)&rr, 0, 0)) + if (!(*type->fun)(in, &rr, 0, 0)) { odr_perror(in, "Decoding constructed record."); fprintf(stdout, "[Near %d]\n", odr_offset(in)); @@ -1206,6 +1208,9 @@ static int send_SRW_searchRequest(const char *arg) sr = yaz_srw_get(out, Z_SRW_searchRetrieve_request); sr->u.request->query_type = Z_SRW_query_type_cql; sr->u.request->query.cql = odr_strdup(out, arg); + + sr->u.request->maximumRecords = odr_intdup(out, 0); + if (record_schema) sr->u.request->recordSchema = record_schema; return send_srw(sr); @@ -2101,11 +2106,20 @@ static int cmd_itemorder(const char *arg) return 2; } -static void show_opt(const char *arg) +static void show_opt(const char *arg, void *clientData) { printf ("%s ", arg); } +static int cmd_zversion(const char *arg) +{ + if (*arg && arg) + z3950_version = atoi(arg); + else + printf ("version is %d\n", z3950_version); + return 0; +} + static int cmd_options(const char *arg) { if (*arg) @@ -2116,7 +2130,7 @@ static int cmd_options(const char *arg) } else { - yaz_init_opt_decode(&z3950_options, show_opt); + yaz_init_opt_decode(&z3950_options, show_opt, 0); printf ("\n"); } return 0; @@ -2143,7 +2157,15 @@ static int cmd_explain(const char *arg) #endif return 0; } - + +static int cmd_init(const char *arg) +{ + if (!conn || protocol != PROTO_Z3950) + return 0; + send_initRequest(0); + return 2; +} + static int cmd_find(const char *arg) { if (!*arg) @@ -3293,10 +3315,13 @@ static void handle_srw_response(Z_SRW_searchRetrieveResponse *res) for (i = 0; inum_diagnostics; i++) { - printf ("SRW diagnostic %d %s\n", - *res->diagnostics[i].code, - yaz_diag_srw_str(*res->diagnostics[i].code)); - + if (res->diagnostics[i].uri) + printf ("SRW diagnostic %s\n", + res->diagnostics[i].uri); + else + printf ("SRW diagnostic missing or could not be decoded\n"); + if (res->diagnostics[i].message) + printf ("Message: %s\n", res->diagnostics[i].message); if (res->diagnostics[i].details) printf ("Details: %s\n", res->diagnostics[i].details); } @@ -3799,7 +3824,9 @@ static struct { {"adm-startup", cmd_adm_startup, "",NULL,0,NULL}, {"explain", cmd_explain, "", NULL, 0, NULL}, {"options", cmd_options, "", NULL, 0, NULL}, + {"zversion", cmd_zversion, "", NULL, 0, NULL}, {"help", cmd_help, "", NULL,0,NULL}, + {"init", cmd_init, "", NULL,0,NULL}, {0,0,0,0,0,0} };