From ce3b3ef890c54b53b9a438737a9b045e5c2b45b4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 11 Jul 2014 14:23:37 +0200 Subject: [PATCH] GFS: client_query_charset conversion YAZ-777 This is a feature for Z39.50 clients that sends queries that are not UTF-8 encoded. WIth client_query_charset, GFS will convert from the encoding given to UTF-8. --- doc/gfs-virtual.xml | 10 ++++++++++ etc/yazgfs.xml | 1 + src/seshigh.c | 15 ++++++++++++++- src/session.h | 1 + src/statserv.c | 7 +++++++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/doc/gfs-virtual.xml b/doc/gfs-virtual.xml index 11125f3..66f0bd8 100644 --- a/doc/gfs-virtual.xml +++ b/doc/gfs-virtual.xml @@ -156,6 +156,16 @@ + element client_query_charset (optional) + + + If specified, a conversion from the character set given to UTF-8 is + performed by the generic frontend server. It is only executed for + Z39.50 search requests (SRU/Solr are assumed to be UTF-8 encoded already). + + + + element docpath (optional) diff --git a/etc/yazgfs.xml b/etc/yazgfs.xml index e498549..c3215cd 100644 --- a/etc/yazgfs.xml +++ b/etc/yazgfs.xml @@ -7,6 +7,7 @@ zebra.cfg pqf.properties xsl + iso-8859-1 xsl/default.xsl 2000000 diff --git a/src/seshigh.c b/src/seshigh.c index eb99a79..6e18d01 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -74,7 +74,7 @@ #include #include #include - +#include #include #include #include @@ -2707,6 +2707,19 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb) bsrr->search_input = req->otherInfo; bsrr->present_number = *req->mediumSetPresentNumber; + if (assoc->server && assoc->server->client_query_charset && + req->query->which == Z_Query_type_1) + { + yaz_iconv_t cd = + yaz_iconv_open("UTF-8", assoc->server->client_query_charset); + if (cd) + { + yaz_query_charset_convert_rpnquery(req->query->u.type_1, + assoc->decode, cd); + yaz_iconv_close(cd); + } + } + if (assoc->server && assoc->server->cql_transform && req->query->which == Z_Query_type_104 && req->query->u.type_104->which == Z_External_CQL) diff --git a/src/session.h b/src/session.h index 56b10b4..61bf84d 100644 --- a/src/session.h +++ b/src/session.h @@ -51,6 +51,7 @@ struct gfs_server { char *directory; char *docpath; char *stylesheet; + char *client_query_charset; yaz_retrieval_t retrieval; struct gfs_server *next; }; diff --git a/src/statserv.c b/src/statserv.c index 59bb868..815b2e9 100644 --- a/src/statserv.c +++ b/src/statserv.c @@ -226,6 +226,7 @@ static struct gfs_server * gfs_server_new(const char *id) n->directory = 0; n->docpath = 0; n->stylesheet = 0; + n->client_query_charset = 0; n->id = nmem_strdup_null(gfs_nmem, id); n->retrieval = yaz_retrieval_create(); return n; @@ -490,6 +491,12 @@ static void xml_config_read(const char *base_path) nmem_malloc(gfs_nmem, strlen(s) + 2); sprintf(gfs->stylesheet, "/%s", s); } + else if (!strcmp((const char *) ptr->name, + "client_query_charset")) + { + gfs->client_query_charset = + nmem_dup_xml_content(gfs_nmem, ptr->children); + } else if (!strcmp((const char *) ptr->name, "explain")) { ; /* being processed separately */ -- 1.7.10.4