X-Git-Url: http://git.indexdata.com/?p=yazproxy-moved-to-github.git;a=blobdiff_plain;f=src%2Fyaz-proxy-config.cpp;h=5bd08e3636c504a368934db35756af442ae1398e;hp=47b79b5620d0e2bd72e820382cdddefccbf7ff4a;hb=0864c203e6cb754b126e559e22d80bf3087fcc48;hpb=224b7274aec587e4154761688815d003d0327d2a diff --git a/src/yaz-proxy-config.cpp b/src/yaz-proxy-config.cpp index 47b79b5..5bd08e3 100644 --- a/src/yaz-proxy-config.cpp +++ b/src/yaz-proxy-config.cpp @@ -1,5 +1,5 @@ /* This file is part of YAZ proxy - Copyright (C) 1998-2009 Index Data + Copyright (C) 1998-2011 Index Data YAZ proxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -208,7 +208,7 @@ void Yaz_ProxyConfigP::return_limit(xmlNodePtr ptr, if (t) *limit_pdu = atoi(t); } - if (ptr->type == XML_ELEMENT_NODE + if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "search")) { const char *t = get_text(ptr); @@ -268,11 +268,11 @@ void Yaz_ProxyConfigP::return_target_info(xmlNodePtr ptr, return_limit(ptr, keepalive_limit_bw, keepalive_limit_pdu, &dummy, &dummy); } - if (ptr->type == XML_ELEMENT_NODE + if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "limit")) return_limit(ptr, limit_bw, limit_pdu, limit_req, limit_search); - if (ptr->type == XML_ELEMENT_NODE + if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "target-timeout")) { const char *t = get_text(ptr); @@ -729,7 +729,8 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, char **backend_type, char **backend_charset, char **usemarcon_ini_stage1, - char **usemarcon_ini_stage2 + char **usemarcon_ini_stage2, + char **backend_elementset ) { if (stylesheet) @@ -762,6 +763,8 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, xfree (*usemarcon_ini_stage2); *usemarcon_ini_stage2 = 0; } + xfree(*backend_elementset); + *backend_elementset = 0; #if YAZ_HAVE_XSLT int syntax_has_matched = 0; xmlNodePtr ptr; @@ -784,40 +787,49 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, const char *match_backend_charset = 0; const char *match_usemarcon_ini_stage1 = 0; const char *match_usemarcon_ini_stage2 = 0; + const char *match_elementset = 0; struct _xmlAttr *attr; for (attr = ptr->properties; attr; attr = attr->next) { if (!strcmp((const char *) attr->name, "type") && attr->children && attr->children->type == XML_TEXT_NODE) match_type = (const char *) attr->children->content; - if (!strcmp((const char *) attr->name, "error") && + else if (!strcmp((const char *) attr->name, "error") && attr->children && attr->children->type == XML_TEXT_NODE) match_error = (const char *) attr->children->content; - if (!strcmp((const char *) attr->name, "marcxml") && + else if (!strcmp((const char *) attr->name, "marcxml") && attr->children && attr->children->type == XML_TEXT_NODE) match_marcxml = (const char *) attr->children->content; - if (!strcmp((const char *) attr->name, "stylesheet") && + else if (!strcmp((const char *) attr->name, "stylesheet") && attr->children && attr->children->type == XML_TEXT_NODE) match_stylesheet = (const char *) attr->children->content; - if (!strcmp((const char *) attr->name, "identifier") && + else if (!strcmp((const char *) attr->name, "identifier") && attr->children && attr->children->type == XML_TEXT_NODE) match_identifier = (const char *) attr->children->content; - if (!strcmp((const char *) attr->name, "backendtype") && + else if (!strcmp((const char *) attr->name, "backendtype") && attr->children && attr->children->type == XML_TEXT_NODE) match_backend_type = (const char *) attr->children->content; - if (!strcmp((const char *) attr->name, "backendcharset") && + else if (!strcmp((const char *) attr->name, "backendcharset") && attr->children && attr->children->type == XML_TEXT_NODE) match_backend_charset = (const char *) attr->children->content; - if (!strcmp((const char *) attr->name, "usemarconstage1") && + else if (!strcmp((const char *) attr->name, "usemarconstage1") && attr->children && attr->children->type == XML_TEXT_NODE) match_usemarcon_ini_stage1 = (const char *) attr->children->content; - if (!strcmp((const char *) attr->name, "usemarconstage2") && + else if (!strcmp((const char *) attr->name, "usemarconstage2") && attr->children && attr->children->type == XML_TEXT_NODE) match_usemarcon_ini_stage2 = (const char *) attr->children->content; + else if (!strcmp((const char *) attr->name, "backendelementset") && + attr->children && attr->children->type == XML_TEXT_NODE) + match_elementset = (const char *) attr->children->content; + else + { + yaz_log(YLOG_WARN, "0 Unknown attribute %s in ", + (const char *) attr->name); + } } if (match_type) { @@ -830,7 +842,7 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, } else if (syntax) { - Odr_oid *match_oid + Odr_oid *match_oid = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_RECSYN, match_type, odr); @@ -867,6 +879,11 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, xfree(*backend_charset); *backend_charset = xstrdup(match_backend_charset); } + if (match_elementset) + { + xfree(*backend_elementset); + *backend_elementset = xstrdup(match_elementset); + } if (usemarcon_ini_stage1 && match_usemarcon_ini_stage1) { xfree(*usemarcon_ini_stage1); @@ -1277,11 +1294,11 @@ char *Yaz_ProxyConfig::get_explain_doc(ODR odr, const char *name, else { xmlNodePtr ptr2 = xmlCopyNode(ptr_explain, 1); - + xmlDocPtr doc = xmlNewDoc((const xmlChar *) "1.0"); - + xmlDocSetRootElement(doc, ptr2); - + xmlChar *buf_out; xmlDocDumpMemory(doc, &buf_out, len); char *content = (char*) odr_malloc(odr, *len);