X-Git-Url: http://git.indexdata.com/?p=yazproxy-moved-to-github.git;a=blobdiff_plain;f=src%2Fyaz-proxy-config.cpp;h=dbf03a58fb42e5e30c9220e16e08642c9fa01a0f;hp=219bf9a1ebfc22530ee505c804ceec672aea479c;hb=b276287e0e21b0bb267c5d5a7d87254ee1f5e29f;hpb=9c4af9d938abac93a949d756353c1bd89b769012 diff --git a/src/yaz-proxy-config.cpp b/src/yaz-proxy-config.cpp index 219bf9a..dbf03a5 100644 --- a/src/yaz-proxy-config.cpp +++ b/src/yaz-proxy-config.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy-config.cpp,v 1.26 2006-03-30 10:35:15 adam Exp $ +/* $Id: yaz-proxy-config.cpp,v 1.30 2006-04-06 16:25:21 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -55,6 +55,7 @@ class Yaz_ProxyConfigP { xmlNodePtr find_target_node(const char *name, const char *db); xmlNodePtr find_target_db(xmlNodePtr ptr, const char *db); const char *get_text(xmlNodePtr ptr); + void get_period(xmlNodePtr ptr, int *period); int check_type_1_attributes(ODR odr, xmlNodePtr ptr, Z_AttributeList *attrs, char **addinfo); @@ -165,6 +166,18 @@ const char *Yaz_ProxyConfigP::get_text(xmlNodePtr ptr) } return 0; } + +void Yaz_ProxyConfigP::get_period(xmlNodePtr ptr, int *period) +{ + struct _xmlAttr *attr; + *period = 60; + for (attr = ptr->properties; attr; attr = attr->next) + { + if (!strcmp((const char *) attr->name, "period") && + attr->children && attr->children->type == XML_TEXT_NODE) + *period = atoi((const char *) attr->children->content); + } +} #endif #if HAVE_XSLT @@ -536,6 +549,8 @@ const char *Yaz_ProxyConfig::check_mime_type(const char *path) {".jpg", "image/jpeg"}, {".png", "image/png"}, {".gif", "image/gif"}, + {".css", "text/css"}, + {".pdf", "application/pdf"}, {0, "text/plain"}, {0, 0}, }; @@ -981,11 +996,36 @@ int Yaz_ProxyConfigP::mycmp(const char *hay, const char *item, size_t len) return 0; } +int Yaz_ProxyConfig::get_file_access_info(const char *path) +{ +#if HAVE_XSLT + xmlNodePtr ptr; + if (!m_cp->m_proxyPtr) + return 0; + for (ptr = m_cp->m_proxyPtr->children; ptr; ptr = ptr->next) + { + if (ptr->type == XML_ELEMENT_NODE + && !strcmp((const char *) ptr->name, "docpath")) + { + const char *docpath = m_cp->get_text(ptr); + size_t docpath_len = strlen(docpath); + if (docpath_len < strlen(path) && path[docpath_len] == '/' + && !memcmp(docpath, path, docpath_len)) + return 1; + } + } +#endif + return 0; +} + void Yaz_ProxyConfig::get_generic_info(int *log_mask, int *max_clients, - int *max_connect) + int *max_connect, + int *limit_connect, + int *period_connect) { *max_connect = 0; + *limit_connect = 0; #if HAVE_XSLT xmlNodePtr ptr; if (!m_cp->m_proxyPtr) @@ -1011,6 +1051,8 @@ void Yaz_ProxyConfig::get_generic_info(int *log_mask, *log_mask |= PROXY_LOG_REQ_CLIENT; if (m_cp->mycmp(v, "server-requests", len)) *log_mask |= PROXY_LOG_REQ_SERVER; + if (m_cp->mycmp(v, "client-ip", len)) + *log_mask |= PROXY_LOG_IP_CLIENT; if (isdigit(*v)) *log_mask |= atoi(v); if (*cp == ',') @@ -1020,7 +1062,7 @@ void Yaz_ProxyConfig::get_generic_info(int *log_mask, v = cp; } } - if (ptr->type == XML_ELEMENT_NODE && + else if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "max-clients")) { const char *t = m_cp->get_text(ptr); @@ -1031,12 +1073,41 @@ void Yaz_ProxyConfig::get_generic_info(int *log_mask, *max_clients = 1; } } - if (ptr->type == XML_ELEMENT_NODE && + else if (ptr->type == XML_ELEMENT_NODE && + !strcmp((const char *) ptr->name, "period-connect")) + { + const char *t = m_cp->get_text(ptr); + if (t) + *period_connect = atoi(t); + } + else if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "max-connect")) { const char *t = m_cp->get_text(ptr); if (t) + { *max_connect = atoi(t); + } + } + else if (ptr->type == XML_ELEMENT_NODE && + !strcmp((const char *) ptr->name, "limit-connect")) + { + const char *t = m_cp->get_text(ptr); + if (t) + { + *limit_connect = atoi(t); + } + } + else if (ptr->type == XML_ELEMENT_NODE && + !strcmp((const char *) ptr->name, "target")) + ; + else if (ptr->type == XML_ELEMENT_NODE && + !strcmp((const char *) ptr->name, "docpath")) + ; + else if (ptr->type == XML_ELEMENT_NODE) + { + yaz_log(YLOG_WARN, "0 Unknown element %s in yazproxy config", + ptr->name); } } #endif