Prevent multiplexing for cookie sessions
[yazpp-moved-to-github.git] / src / yaz-proxy-config.cpp
index d1ba17c..5fc164b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1998-2003, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-proxy-config.cpp,v 1.4 2003-10-06 08:08:49 adam Exp $
+ * $Id: yaz-proxy-config.cpp,v 1.6 2003-10-08 09:32:49 adam Exp $
  */
 
 #include <ctype.h>
@@ -126,6 +126,7 @@ void Yaz_ProxyConfig::return_target_info(xmlNodePtr ptr,
                                         int *target_idletime,
                                         int *client_idletime)
 {
+    int no_url = 0;
     ptr = ptr->children;
     for (; ptr; ptr = ptr->next)
     {
@@ -133,8 +134,11 @@ void Yaz_ProxyConfig::return_target_info(xmlNodePtr ptr,
            && !strcmp((const char *) ptr->name, "url"))
        {
            const char *t = get_text(ptr);
-           if (t)
-               *url = t;
+           if (t && no_url < MAX_ZURL_PLEX)
+           {
+               url[no_url++] = t;
+               url[no_url] = 0;
+           }
        }
        if (ptr->type == XML_ELEMENT_NODE 
            && !strcmp((const char *) ptr->name, "keepalive"))
@@ -326,6 +330,70 @@ int Yaz_ProxyConfig::check_query(ODR odr, const char *name, Z_Query *query,
     return 0;
 }
 
+int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
+                                 Odr_oid *syntax, char **addinfo)
+{
+#if HAVE_XML2
+    xmlNodePtr ptr;
+    
+    ptr = find_target_node(name);
+    if (!ptr)
+       return 0;
+    for(ptr = ptr->children; ptr; ptr = ptr->next)
+    {
+       if (ptr->type == XML_ELEMENT_NODE &&
+           !strcmp((const char *) ptr->name, "syntax"))
+       {
+           int match = 0;  // if we match record syntax
+           const char *match_type = 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, "error") &&
+                   attr->children && attr->children->type == XML_TEXT_NODE)
+                   match_error = (const char *) attr->children->content;
+           }
+           if (match_type)
+           {
+               if (!strcmp(match_type, "*"))
+                   match = 1;
+               else if (!strcmp(match_type, "none"))
+               {
+                   if (syntax == 0)
+                       match = 1;
+               }
+               else if (syntax)
+               {
+                   int match_oid[OID_SIZE];
+                   oid_name_to_oid(CLASS_RECSYN, match_type, match_oid);
+                   if (oid_oidcmp(match_oid, syntax) == 0)
+                       match = 1;
+               }
+           }
+           if (match)
+           {
+               if (match_error)
+               {
+                   if (syntax)
+                   {
+                       char dotoid_str[100];
+                       oid_to_dotstring(syntax, dotoid_str);
+                       *addinfo = odr_strdup(odr, dotoid_str);
+                   }
+                   return atoi(match_error);
+               }
+               return 0;
+           }
+       }
+    }
+#endif
+    return 0;
+}
+
 #if HAVE_XML2
 xmlNodePtr Yaz_ProxyConfig::find_target_node(const char *name)
 {
@@ -388,9 +456,11 @@ void Yaz_ProxyConfig::get_target_info(const char *name,
     xmlNodePtr ptr;
     if (!m_proxyPtr)
     {
-       *url = name;
+       url[0] = name;
+       url[1] = 0;
        return;
     }
+    url[0] = 0;
     for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next)
     {
        if (ptr->type == XML_ELEMENT_NODE &&
@@ -409,7 +479,10 @@ void Yaz_ProxyConfig::get_target_info(const char *name,
     if (ptr)
     {
        if (name)
-           *url = name;
+       {
+           url[0] = name;
+           url[1] = 0;
+       }
        return_target_info(ptr, url, keepalive, limit_bw, limit_pdu, limit_req,
                           target_idletime, client_idletime);
     }