X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-proxy-config.cpp;h=88449f35a9dc02a1ea1710179a98971f2e2661d6;hb=d3d51bee2100324025f7530d4e3ff3502397fd83;hp=0e5fe3188e6cc71fbadafdb4a68d9d0382d1f98e;hpb=1cfab015d330b201317e6437fb144c9ea4cb2cd6;p=yazpp-moved-to-github.git diff --git a/src/yaz-proxy-config.cpp b/src/yaz-proxy-config.cpp index 0e5fe31..88449f3 100644 --- a/src/yaz-proxy-config.cpp +++ b/src/yaz-proxy-config.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy-config.cpp,v 1.20 2004-01-07 11:10:55 adam Exp $ + * $Id: yaz-proxy-config.cpp,v 1.27 2004-01-30 00:38:28 adam Exp $ */ #include @@ -346,12 +346,10 @@ int Yaz_ProxyConfig::check_query(ODR odr, const char *name, Z_Query *query, #if HAVE_XSLT int Yaz_ProxyConfig::check_schema(xmlNodePtr ptr, Z_RecordComposition *comp, - const char **found_schema, const char *schema_identifier) { char *esn = 0; int default_match = 1; - *found_schema = schema_identifier; // may be NULL if (comp && comp->which == Z_RecordComp_simple && comp->u.simple && comp->u.simple->which == Z_ElementSetNames_generic) { @@ -363,7 +361,6 @@ int Yaz_ProxyConfig::check_schema(xmlNodePtr ptr, Z_RecordComposition *comp, // check if schema identifier match if (schema_identifier && !strcmp(esn, schema_identifier)) return 1; - *found_schema = esn; // Check each name element for (; ptr; ptr = ptr->next) { @@ -459,12 +456,11 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, match = 1; } } - const char *match_schema = 0; if (match) { - syntax_has_matched = 1; - match = check_schema(ptr->children, comp, &match_schema, - match_identifier); + if (!match_error) + syntax_has_matched = 1; + match = check_schema(ptr->children, comp, match_identifier); } if (match) { @@ -473,21 +469,18 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, xfree(*stylesheet); *stylesheet = xstrdup(match_stylesheet); } - if (schema && match_schema) + if (schema && match_identifier) { - yaz_log(LOG_LOG, "Match_schema=%s", match_schema); xfree(*schema); - *schema = xstrdup(match_schema); + *schema = xstrdup(match_identifier); } - else - yaz_log(LOG_LOG, "NO SCHEMA"); if (match_marcxml) { return -1; } if (match_error) { - if (syntax_has_matched) // if syntax did match, schema/ESN was bad + if (syntax_has_matched) // if syntax OK, bad schema/ESN return 25; if (syntax) { @@ -701,6 +694,30 @@ char *Yaz_ProxyConfig::get_explain(ODR odr, const char *name, const char *db, if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "explain")) { + xmlNodePtr ptr1 = ptr->children; + if (db) + { + for (; ptr1; ptr1 = ptr1->next) + if (ptr1->type == XML_ELEMENT_NODE && + !strcmp((const char *) ptr1->name, "serverInfo")) + break; + if (!ptr1) + continue; + for (ptr1 = ptr1->children; ptr1; ptr1 = ptr1->next) + if (ptr1->type == XML_ELEMENT_NODE && + !strcmp((const char *) ptr1->name, "database")) + break; + + if (!ptr1) + continue; + for (ptr1 = ptr1->children; ptr1; ptr1 = ptr1->next) + if (ptr1->type == XML_TEXT_NODE && + ptr1->content && + !strcmp((const char *) ptr1->content, db)) + break; + if (!ptr1) + continue; + } xmlNodePtr ptr2 = xmlCopyNode(ptr, 1); xmlDocPtr doc = xmlNewDoc((const xmlChar *) "1.0"); @@ -708,7 +725,6 @@ char *Yaz_ProxyConfig::get_explain(ODR odr, const char *name, const char *db, xmlDocSetRootElement(doc, ptr2); xmlChar *buf_out; - int len_out; xmlDocDumpMemory(doc, &buf_out, len); char *content = (char*) odr_malloc(odr, *len); memcpy(content, buf_out, *len); @@ -718,11 +734,7 @@ char *Yaz_ProxyConfig::get_explain(ODR odr, const char *name, const char *db, return content; } } - else - yaz_log(LOG_WARN, "No explain node 1"); - #endif - yaz_log(LOG_WARN, "No explain node"); return 0; }