X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffilter_sru_to_z3950.cpp;h=494a9447e4ac5ec154d8e7f679d5ee3276d67489;hb=54c6c2c4fa4378ced846240bea454bc9583f48da;hp=44b72bfb60cd1ca9a93650078a088cfdfbab65e4;hpb=6d9867ed4cbb68635f4819a9a9c104a219160780;p=metaproxy-moved-to-github.git diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index 44b72bf..494a944 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -94,7 +94,7 @@ namespace metaproxy_1 { Z_SRW_PDU *sru_pdu_res, Z_SRW_searchRetrieveRequest const *sr_req, std::string zurl, - const char *db_append + std::string db_append ) const; bool z3950_present_request( @@ -225,7 +225,7 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) bool enable_package_log = false; std::string zurl; - const char *dbargs = 0; + std::string dbargs; Z_SRW_extra_arg *arg; for ( arg = sru_pdu_req->extra_args; arg; arg = arg->next) @@ -249,9 +249,13 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) package.log_enable(); } } - else if (!strcmp(arg->name, "x-dbargs")) + else if (!strncmp(arg->name, "x-client-", 9) && arg->value) { - dbargs = arg->value; + if (dbargs.length()) + dbargs += '&'; + dbargs += mp_util::uri_encode(arg->name + 9); + dbargs += '='; + dbargs += mp_util::uri_encode(arg->value); } assert(sru_pdu_req); @@ -557,7 +561,7 @@ bool yf::SRUtoZ3950::Impl::z3950_search_request(mp::Package &package, Z_SRW_searchRetrieveRequest const *sr_req, std::string zurl, - const char *dbappend) const + std::string dbappend) const { assert(sru_pdu_res->u.response); @@ -583,7 +587,7 @@ bool yf::SRUtoZ3950::Impl::z3950_search_request(mp::Package &package, else db = "Default"; - if (dbappend) + if (dbappend.length()) { db += ","; db += dbappend; @@ -865,7 +869,13 @@ int yf::SRUtoZ3950::Impl::z3950_build_query( const Z_SRW_searchRetrieveRequest *req ) const { - if (req->query_type == Z_SRW_query_type_cql) + if ( +#ifdef Z_SRW_query_type_cql + req->query_type == Z_SRW_query_type_cql +#else + !strcmp(req->queryType, "cql") +#endif + ) { Z_External *ext = (Z_External *) odr_malloc(odr_en, sizeof(*ext)); @@ -874,22 +884,39 @@ int yf::SRUtoZ3950::Impl::z3950_build_query( ext->indirect_reference = 0; ext->descriptor = 0; ext->which = Z_External_CQL; - ext->u.cql = odr_strdup(odr_en, req->query.cql); + ext->u.cql = odr_strdup(odr_en, +#ifdef Z_SRW_query_type_cql + req->query.cql +#else + req->query +#endif + ); z_query->which = Z_Query_type_104; z_query->u.type_104 = ext; return 0; } - if (req->query_type == Z_SRW_query_type_pqf) + if ( +#ifdef Z_SRW_query_type_pqf + req->query_type == Z_SRW_query_type_pqf +#else + !strcmp(req->queryType, "pqf") +#endif + ) { Z_RPNQuery *RPNquery; YAZ_PQF_Parser pqf_parser; pqf_parser = yaz_pqf_create (); - RPNquery = yaz_pqf_parse (pqf_parser, odr_en, req->query.pqf); - + RPNquery = yaz_pqf_parse (pqf_parser, odr_en, +#ifdef Z_SRW_query_type_pqf + req->query.pqf +#else + req->query +#endif + ); yaz_pqf_destroy(pqf_parser); if (!RPNquery) @@ -942,7 +969,7 @@ static mp::filter::Base* filter_creator() } extern "C" { - struct metaproxy_1_filter_struct metaproxy_1_filter_sru_to_z3950 = { + struct metaproxy_1_filter_struct metaproxy_1_filter_sru_z3950 = { 0, "sru_z3950", filter_creator