+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,
+ const char **cql2rpn,
+ const char **zeerex)
+{
+#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, cql2rpn, zeerex);
+ return 1;
+ }
+ i++;
+ }
+#endif
+ return 0;
+}
+
+int Yaz_ProxyConfig::mycmp(const char *hay, const char *item, size_t len)
+{
+ if (len == strlen(item) && memcmp(hay, item, len) == 0)
+ return 1;
+ return 0;
+}
+
+void Yaz_ProxyConfig::get_generic_info(int *log_mask,
+ int *max_clients)
+{
+#if HAVE_XML2
+ xmlNodePtr ptr;
+ if (!m_proxyPtr)
+ return;
+ for (ptr = m_proxyPtr->children; 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 (mycmp(v, "client-apdu", len))
+ *log_mask |= PROXY_LOG_APDU_CLIENT;
+ if (mycmp(v, "server-apdu", len))
+ *log_mask |= PROXY_LOG_APDU_SERVER;
+ if (mycmp(v, "client-requests", len))
+ *log_mask |= PROXY_LOG_REQ_CLIENT;
+ if (mycmp(v, "server-requests", len))
+ *log_mask |= PROXY_LOG_REQ_SERVER;
+ 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, "max-clients"))
+ {
+ const char *t = get_text(ptr);
+ if (t)
+ {
+ *max_clients = atoi(t);
+ if (*max_clients < 1)
+ *max_clients = 1;
+ }
+ }
+ }
+#endif
+}
+