From: Marc Cromme Date: Fri, 13 Apr 2007 11:13:08 +0000 (+0000) Subject: added initialization of char *recsyn = 0; and char *piggyback = 0; X-Git-Tag: PAZPAR2.1.0.0~305 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=b498c11176b1f53f6483824d0fc4e85a8e55aede;p=pazpar2-moved-to-github.git added initialization of char *recsyn = 0; and char *piggyback = 0; added iconv query encoding according to the target's setting, assuming that pazpar2 internal encoding is always UTF-8. This gives _much_ nicer record matches in the Greek UOC project! --- diff --git a/src/pazpar2.c b/src/pazpar2.c index b5c638f..99cc6a7 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.77 2007-04-12 13:46:28 adam Exp $ +/* $Id: pazpar2.c,v 1.78 2007-04-13 11:13:08 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -39,6 +39,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include +#include #include #if YAZ_VERSIONL >= 0x020163 #include @@ -246,8 +247,10 @@ static void send_search(IOCHAN i) Z_Query *zquery; struct ccl_rpn_node *cn; int ssub = 0, lslb = 100000, mspn = 10; - char *recsyn; - char *piggyback; + char *recsyn = 0; + char *piggyback = 0; + char *queryenc = 0; + yaz_iconv_t iconv = 0; yaz_log(YLOG_DEBUG, "Sending search to %s", cl->database->database->url); @@ -264,12 +267,26 @@ static void send_search(IOCHAN i) se->expected_maxrecs); } + // constructing RPN query a->u.searchRequest->query = zquery = odr_malloc(global_parameters.odr_out, sizeof(Z_Query)); zquery->which = Z_Query_type_1; zquery->u.type_1 = ccl_rpn_query(global_parameters.odr_out, cn); ccl_rpn_delete(cn); + // converting to target encoding + if ((queryenc = session_setting_oneval(sdb, PZ_QUERYENCODING))){ + iconv = yaz_iconv_open(queryenc, "UTF-8"); + if (iconv){ + yaz_query_charset_convert_rpnquery(zquery->u.type_1, + global_parameters.odr_out, + iconv); + yaz_iconv_close(iconv); + } else + yaz_log(YLOG_WARN, "Query encoding failed %s %s", + cl->database->database->url, queryenc); + } + for (ndb = 0; sdb->database->databases[ndb]; ndb++) ; databaselist = odr_malloc(global_parameters.odr_out, sizeof(char*) * ndb); @@ -304,18 +321,23 @@ static void send_search(IOCHAN i) WRBUF wbquery = wrbuf_alloc(); yaz_query_to_wrbuf(wbquery, zquery); + if (send_apdu(cl, a) >= 0) { iochan_setflags(i, EVENT_INPUT); cl->state = Client_Searching; cl->requestid = se->requestid; - yaz_log(YLOG_LOG, "SearchRequest %s %s", - cl->database->database->url, wrbuf_cstr(wbquery)); + yaz_log(YLOG_LOG, "SearchRequest %s %s %s", + cl->database->database->url, + queryenc ? queryenc : "UTF-8", + wrbuf_cstr(wbquery)); } else { cl->state = Client_Error; - yaz_log(YLOG_WARN, "Failed SearchRequest %s %s", - cl->database->database->url, wrbuf_cstr(wbquery)); + yaz_log(YLOG_WARN, "Failed SearchRequest %s %s %s", + cl->database->database->url, + queryenc ? queryenc : "UTF-8", + wrbuf_cstr(wbquery)); } wrbuf_destroy(wbquery);