From d8c09f27e7a06712a0c76adb1ff3a366fb69edf0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 24 Oct 2003 10:21:23 +0000 Subject: [PATCH] Fix attribute type checking --- TODO | 2 -- etc/Makefile.am | 2 +- etc/voyager.xml | 76 +++++++++++++++++++++++++++++++++++++++++ src/voyager.xml | 53 ----------------------------- src/yaz-proxy-config.cpp | 85 +++++++++++++++++++++++++--------------------- 5 files changed, 123 insertions(+), 95 deletions(-) create mode 100644 etc/voyager.xml delete mode 100644 src/voyager.xml diff --git a/TODO b/TODO index f0e3293..e6f713c 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ Control the various optimizations with config.. -Control the various logging facilities APDU, etc. in XML configuration. - Handle invalidate sessions (-1 hit, control-number search). Live status (via search, present). diff --git a/etc/Makefile.am b/etc/Makefile.am index d57e0cc..20c9eb3 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = config.xml yaz-proxy.sh +EXTRA_DIST = config.xml voyager.xml yaz-proxy.sh noinst_SCRIPTS = yaz-proxy.sh diff --git a/etc/voyager.xml b/etc/voyager.xml new file mode 100644 index 0000000..0cf0f32 --- /dev/null +++ b/etc/voyager.xml @@ -0,0 +1,76 @@ + + + + + + + z3950.loc.gov:7090 + z3950.loc.gov:7094 + + + 300 + + + 180 + + + + 500000 + 500 + + + + + 200000 + 31 + 20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + 500 + + + client-requests server-requests + diff --git a/src/voyager.xml b/src/voyager.xml deleted file mode 100644 index 4dd975c..0000000 --- a/src/voyager.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - z3950.loc.gov:7090 - z3950.loc.gov:7094 - - - 300 - - - 180 - - - - 500000 - 500 - - - - - 200000 - 31 - 20 - - - - - - - - - - - - - - - 2 - - - - 500 - - - client-requests server-requests - diff --git a/src/yaz-proxy-config.cpp b/src/yaz-proxy-config.cpp index 1e75fde..1742cf8 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.12 2003-10-20 18:31:44 adam Exp $ + * $Id: yaz-proxy-config.cpp,v 1.13 2003-10-24 10:21:24 adam Exp $ */ #include @@ -213,60 +213,67 @@ int Yaz_ProxyConfig::match_list(int v, const char *m) } #if HAVE_XML2 -int Yaz_ProxyConfig::check_type_1_attributes(ODR odr, xmlNodePtr ptr, +int Yaz_ProxyConfig::check_type_1_attributes(ODR odr, xmlNodePtr ptrl, Z_AttributeList *attrs, char **addinfo) { - for(ptr = ptr->children; ptr; ptr = ptr->next) + int i; + for (i = 0; inum_attributes; i++) { - if (ptr->type == XML_ELEMENT_NODE && - !strcmp((const char *) ptr->name, "attribute")) + Z_AttributeElement *el = attrs->attributes[i]; + + if (!el->attributeType) + continue; + int type = *el->attributeType; + int *value = 0; + + if (el->which == Z_AttributeValue_numeric && el->value.numeric) + value = el->value.numeric; + + xmlNodePtr ptr; + for(ptr = ptrl->children; ptr; ptr = ptr->next) { - const char *match_type = 0; - const char *match_value = 0; - const char *match_error = 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, "value") && - attr->children && attr->children->type == XML_TEXT_NODE) - match_value = (const char *) attr->children->content; - if (!strcmp((const char *) attr->name, "error") && - attr->children && attr->children->type == XML_TEXT_NODE) - match_error = (const char *) attr->children->content; - } - int i; - - if (match_type && match_value) + if (ptr->type == XML_ELEMENT_NODE && + !strcmp((const char *) ptr->name, "attribute")) { - for (i = 0; inum_attributes; i++) + const char *match_type = 0; + const char *match_value = 0; + const char *match_error = 0; + struct _xmlAttr *attr; + for (attr = ptr->properties; attr; attr = attr->next) { - Z_AttributeElement *el = attrs->attributes[i]; - char value_str[20]; - - value_str[0] = '\0'; - if (!el->attributeType) - continue; - int type = *el->attributeType; - + 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, "value") && + attr->children && attr->children->type == XML_TEXT_NODE) + match_value = (const char *) attr->children->content; + if (!strcmp((const char *) attr->name, "error") && + attr->children && attr->children->type == XML_TEXT_NODE) + match_error = (const char *) attr->children->content; + } + if (match_type && match_value) + { + char addinfo_str[20]; if (!match_list(type, match_type)) continue; - if (el->which == Z_AttributeValue_numeric && - el->value.numeric) + + *addinfo_str = '\0'; + if (!strcmp(match_type, "*")) + sprintf (addinfo_str, "%d", type); + else if (value) { - if (!match_list(*el->value.numeric, match_value)) + if (!match_list(*value, match_value)) continue; - sprintf (value_str, "%d", *el->value.numeric); + sprintf (addinfo_str, "%d", *value); } else continue; + if (match_error) { - if (*value_str) - *addinfo = odr_strdup(odr, value_str); + if (*addinfo_str) + *addinfo = odr_strdup(odr, addinfo_str); return atoi(match_error); } return 0; -- 1.7.10.4