X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-proxy-config.cpp;h=2d5d22e7ceb8dc432b7aaba2cf631e0f803c773f;hb=a5b1e5653ae9b27e85c6fad5bec42b6fc5156fcb;hp=5fc164b9bbe6f4e6c059349a307d9c78f17f51eb;hpb=8cd77956b745e79b984bc0c9b74989aeae8dd49d;p=yazpp-moved-to-github.git diff --git a/src/yaz-proxy-config.cpp b/src/yaz-proxy-config.cpp index 5fc164b..2d5d22e 100644 --- a/src/yaz-proxy-config.cpp +++ b/src/yaz-proxy-config.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2003, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy-config.cpp,v 1.6 2003-10-08 09:32:49 adam Exp $ + * $Id: yaz-proxy-config.cpp,v 1.10 2003-10-16 13:40:41 adam Exp $ */ #include @@ -26,15 +26,6 @@ Yaz_ProxyConfig::~Yaz_ProxyConfig() #endif } -void Yaz_ProxyConfig::operator=(const Yaz_ProxyConfig &conf) -{ -#if HAVE_XML2 - m_docPtr = conf.m_docPtr; - m_proxyPtr = conf.m_proxyPtr; -#endif - m_copy = 1; -} - int Yaz_ProxyConfig::read_xml(const char *fname) { #if HAVE_XML2 @@ -119,18 +110,52 @@ void Yaz_ProxyConfig::return_limit(xmlNodePtr ptr, #if HAVE_XML2 void Yaz_ProxyConfig::return_target_info(xmlNodePtr ptr, const char **url, - int *keepalive, int *limit_bw, int *limit_pdu, int *limit_req, int *target_idletime, - int *client_idletime) + int *client_idletime, + int *keepalive_limit_bw, + int *keepalive_limit_pdu, + int *pre_init, + int *log_mask) { + *pre_init = 0; int no_url = 0; ptr = ptr->children; for (; ptr; ptr = ptr->next) { if (ptr->type == XML_ELEMENT_NODE + && !strcmp((const char *) ptr->name, "log")) + { + const char *v = get_text(ptr); + *log_mask = 0; + while (v && *v) + { + const char *cp = v; + while (*cp && *cp != ',' && !isspace(*cp)) + cp++; + size_t len = cp - v; + if (len == 4 && !memcmp(v, "apdu", 4)) + *log_mask |= PROXY_LOG_APDU; + if (len == 3 && !memcmp(v, "req", 3)) + *log_mask |= PROXY_LOG_REQ; + if (isdigit(*v)) + *log_mask |= atoi(v); + if (*cp == ',') + cp++; + while (*cp && isspace(*cp)) + cp++; + v = cp; + } + } + if (ptr->type == XML_ELEMENT_NODE + && !strcmp((const char *) ptr->name, "preinit")) + { + const char *v = get_text(ptr); + *pre_init = v ? atoi(v) : 1; + } + if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "url")) { const char *t = get_text(ptr); @@ -143,11 +168,11 @@ void Yaz_ProxyConfig::return_target_info(xmlNodePtr ptr, if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "keepalive")) { - const char *t = get_text(ptr); - if (!t || *t == '1') - *keepalive = 1; - else - *keepalive = 0; + int dummy; + *keepalive_limit_bw = 500000; + *keepalive_limit_pdu = 1000; + return_limit(ptr, keepalive_limit_bw, keepalive_limit_pdu, + &dummy); } if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "limit")) @@ -220,7 +245,7 @@ int Yaz_ProxyConfig::check_type_1_attributes(ODR odr, xmlNodePtr ptr, for(ptr = ptr->children; ptr; ptr = ptr->next) { if (ptr->type == XML_ELEMENT_NODE && - !strcmp((const char *) ptr->name, "query")) + !strcmp((const char *) ptr->name, "attribute")) { const char *match_type = 0; const char *match_value = 0; @@ -347,6 +372,7 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, int match = 0; // if we match record syntax const char *match_type = 0; const char *match_error = 0; + const char *match_marcxml = 0; struct _xmlAttr *attr; for (attr = ptr->properties; attr; attr = attr->next) { @@ -356,6 +382,9 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, 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") && + attr->children && attr->children->type == XML_TEXT_NODE) + match_marcxml = (const char *) attr->children->content; } if (match_type) { @@ -376,6 +405,10 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, } if (match) { + if (match_marcxml) + { + return -1; + } if (match_error) { if (syntax) @@ -398,6 +431,8 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, xmlNodePtr Yaz_ProxyConfig::find_target_node(const char *name) { xmlNodePtr ptr; + if (!m_proxyPtr) + return 0; for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next) { if (ptr->type == XML_ELEMENT_NODE && @@ -442,15 +477,64 @@ xmlNodePtr Yaz_ProxyConfig::find_target_node(const char *name) } #endif +int Yaz_ProxyConfig::get_target_no(int no, + const char **name, + const char **url, + int *limit_bw, + int *limit_pdu, + int *limit_req, + int *target_idletime, + int *client_idletime, + int *max_clients, + int *keepalive_limit_bw, + int *keepalive_limit_pdu, + int *pre_init, + int *log_mask) +{ +#if HAVE_XML2 + xmlNodePtr ptr; + if (!m_proxyPtr) + return 0; + int i = 0; + for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next) + if (ptr->type == XML_ELEMENT_NODE && + !strcmp((const char *) ptr->name, "target")) + { + if (i == no) + { + struct _xmlAttr *attr; + for (attr = ptr->properties; attr; attr = attr->next) + if (!strcmp((const char *) attr->name, "name")) + { + if (attr->children + && attr->children->type==XML_TEXT_NODE + && attr->children->content) + *name = (const char *) attr->children->content; + } + return_target_info(ptr, url, limit_bw, limit_pdu, limit_req, + target_idletime, client_idletime, + keepalive_limit_bw, keepalive_limit_pdu, + pre_init, log_mask); + return 1; + } + i++; + } +#endif + return 0; +} + void Yaz_ProxyConfig::get_target_info(const char *name, const char **url, - int *keepalive, int *limit_bw, int *limit_pdu, int *limit_req, int *target_idletime, int *client_idletime, - int *max_clients) + int *max_clients, + int *keepalive_limit_bw, + int *keepalive_limit_pdu, + int *pre_init, + int *log_mask) { #if HAVE_XML2 xmlNodePtr ptr; @@ -483,8 +567,10 @@ void Yaz_ProxyConfig::get_target_info(const char *name, url[0] = name; url[1] = 0; } - return_target_info(ptr, url, keepalive, limit_bw, limit_pdu, limit_req, - target_idletime, client_idletime); + return_target_info(ptr, url, limit_bw, limit_pdu, limit_req, + target_idletime, client_idletime, + keepalive_limit_bw, keepalive_limit_pdu, + pre_init, log_mask); } #else *url = name;