From: Adam Dickmeiss Date: Wed, 30 May 2007 21:56:59 +0000 (+0000) Subject: Changed the way yaz-client encodes charset negotiation information X-Git-Tag: YAZ.3.0.10~73 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=3ebf9c87afb52af8cc6e696ffbb040aeca68b3f4 Changed the way yaz-client encodes charset negotiation information to target when no negoatitionCharset is set by user using command negcharset. In YAZ 3.0.0 and later the negotation information was simply omitted. Now the OriginProposal is sent anway but with proposedCharSets and proposedlanaguages omitted (both are optional). YAZ Frontend server is also modified to deal with this: omitted proposedCharSets in the OriginProposal will make the frontend server return default character set for target if that is supplied by the backend init handler (member query_charset). --- diff --git a/client/client.c b/client/client.c index f66d601..82c78ca 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: client.c,v 1.341 2007-05-30 08:40:26 adam Exp $ + * $Id: client.c,v 1.342 2007-05-30 21:56:59 adam Exp $ */ /** \file client.c * \brief yaz-client program @@ -186,6 +186,7 @@ char **readline_completer(char *text, int start, int end); #endif static char *command_generator(const char *text, int state); int cmd_register_tab(const char* arg); +int cmd_querycharset(const char *arg); static void close_session (void); @@ -363,6 +364,21 @@ static void send_initRequest(const char* type_and_host) negotiationCharsetRecords); } } + else if (ODR_MASK_GET(req->options, Z_Options_negotiationModel)) + { + Z_OtherInformation **p; + Z_OtherInformationUnit *p0; + + yaz_oi_APDU(apdu, &p); + + if ((p0=yaz_oi_update(p, out, NULL, 0, 0))) + { + p0->which = Z_OtherInfo_externallyDefinedInfo; + p0->information.externallyDefinedInfo = + yaz_set_proposal_charneg(out, 0, 0, 0, 0, 0); + } + + } if (send_apdu(apdu)) printf("Sent initrequest.\n"); } @@ -454,27 +470,30 @@ static int process_initResponse(Z_InitResponse *res) Z_CharSetandLanguageNegotiation *p = yaz_get_charneg_record(res->otherInfo); - if (p) { - + if (p) + { char *charset=NULL, *lang=NULL; int selected; yaz_get_response_charneg(session_mem, p, &charset, &lang, &selected); - printf("Accepted character set : %s\n", charset); - printf("Accepted code language : %s\n", lang ? lang : "none"); + printf("Accepted character set : %s\n", charset ? charset:"none"); + printf("Accepted code language : %s\n", lang ? lang:"none"); printf("Accepted records in ...: %d\n", selected ); - if (outputCharset && negotiationCharset) { + if (outputCharset && charset) + { printf("Converting between %s and %s\n", - outputCharset, negotiationCharset); - odr_set_charset (out, charset, outputCharset); - odr_set_charset (in, outputCharset, charset); + outputCharset, charset); + odr_set_charset(out, charset, outputCharset); + odr_set_charset(in, outputCharset, charset); + cmd_querycharset(charset); } - else { - odr_set_charset (out, 0, 0); - odr_set_charset (in, 0, 0); + else + { + odr_set_charset(out, 0, 0); + odr_set_charset(in, 0, 0); } } } @@ -3348,7 +3367,7 @@ int cmd_marccharset(const char *arg) } xfree (marcCharset); marcCharset = 0; - if (strcmp(l1, "-")) + if (strcmp(l1, "-") && strcmp(l1, "none")) marcCharset = xstrdup(l1); return 1; } @@ -3366,7 +3385,7 @@ int cmd_querycharset(const char *arg) } xfree (queryCharset); queryCharset = 0; - if (strcmp(l1, "-")) + if (strcmp(l1, "-") && strcmp(l1, "none")) queryCharset = xstrdup(l1); return 1; } @@ -3409,11 +3428,14 @@ int cmd_negcharset(const char *arg) if (sscanf(arg, "%29s %d %d", l1, &negotiationCharsetRecords, &negotiationCharsetVersion) < 1) { - printf("Current negotiation character set is `%s'\n", + printf("Negotiation character set `%s'\n", negotiationCharset ? negotiationCharset: "none"); - printf("Records in charset %s\n", negotiationCharsetRecords ? - "yes" : "no"); - printf("Charneg version %d\n", negotiationCharsetVersion); + if (negotiationCharset) + { + printf("Records in charset %s\n", negotiationCharsetRecords ? + "yes" : "no"); + printf("Charneg version %d\n", negotiationCharsetVersion); + } } else { @@ -3430,14 +3452,15 @@ int cmd_negcharset(const char *arg) int cmd_charset(const char* arg) { - char l1[30], l2[30], l3[30]; + char l1[30], l2[30], l3[30], l4[30]; - *l1 = *l2 = *l3 = 0; - if (sscanf(arg, "%29s %29s %29s", l1, l2, l3) < 1) + *l1 = *l2 = *l3 = *l4 = '\0'; + if (sscanf(arg, "%29s %29s %29s %29s", l1, l2, l3, l4) < 1) { cmd_negcharset(""); cmd_displaycharset(""); cmd_marccharset(""); + cmd_querycharset(""); } else { @@ -3446,6 +3469,8 @@ int cmd_charset(const char* arg) cmd_displaycharset(l2); if (*l3) cmd_marccharset(l3); + if (*l4) + cmd_querycharset(l4); } return 1; } @@ -3453,7 +3478,7 @@ int cmd_charset(const char* arg) int cmd_lang(const char* arg) { if (*arg == '\0') { - printf("Current language is `%s'\n", (yazLang)?yazLang:NULL); + printf("Current language is `%s'\n", yazLang ? yazLang : "none"); return 1; } xfree (yazLang); diff --git a/src/seshigh.c b/src/seshigh.c index 11ffa72..999d1ba 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.120 2007-05-30 08:12:17 adam Exp $ + * $Id: seshigh.c,v 1.121 2007-05-30 21:56:59 adam Exp $ */ /** * \file seshigh.c @@ -2290,36 +2290,32 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) strcat(options, " sort"); } - if (!assoc->init->charneg_response && !assoc->init->charneg_request) + if (ODR_MASK_GET(req->options, Z_Options_negotiationModel)) { - if (assoc->init->query_charset) + Z_OtherInformationUnit *p0; + + if (!assoc->init->charneg_response) { - assoc->init->charneg_response = yaz_set_response_charneg( - assoc->encode, assoc->init->query_charset, 0, - assoc->init->records_in_same_charset); + if (assoc->init->query_charset) + { + assoc->init->charneg_response = yaz_set_response_charneg( + assoc->encode, assoc->init->query_charset, 0, + assoc->init->records_in_same_charset); + } + else + { + yaz_log(YLOG_WARN, "default query_charset not defined by backend"); + } } - else + if (assoc->init->charneg_response + && (p0=yaz_oi_update(&resp->otherInfo, assoc->encode, NULL, 0, 0))) { - yaz_log(YLOG_WARN, "default query_charset not defined by backend"); - } - } - if (assoc->init->charneg_response - && ODR_MASK_GET(req->options, Z_Options_negotiationModel)) - { - Z_OtherInformation **p; - Z_OtherInformationUnit *p0; - - yaz_oi_APDU(apdu, &p); - - if ((p0=yaz_oi_update(p, assoc->encode, NULL, 0, 0))) { - ODR_MASK_SET(resp->options, Z_Options_negotiationModel); - p0->which = Z_OtherInfo_externallyDefinedInfo; p0->information.externallyDefinedInfo = assoc->init->charneg_response; + ODR_MASK_SET(resp->options, Z_Options_negotiationModel); + strcat(options, " negotiation"); } - ODR_MASK_SET(resp->options, Z_Options_negotiationModel); - strcat(options, " negotiation"); } if (ODR_MASK_GET(req->options, Z_Options_triggerResourceCtrl)) ODR_MASK_SET(resp->options, Z_Options_triggerResourceCtrl); @@ -2359,7 +2355,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) assoc->init->implementation_name, odr_prepend(assoc->encode, "GFS", resp->implementationName)); - version = odr_strdup(assoc->encode, "$Revision: 1.120 $"); + version = odr_strdup(assoc->encode, "$Revision: 1.121 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; resp->implementationVersion = odr_prepend(assoc->encode,