From 126d4a93355f95766cd1501ed1255b92e6171f33 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 28 Jan 2010 12:28:26 +0100 Subject: [PATCH] Include conf from filters-enabled Debian package now installs /etc/metaproxy/metaproxy.xml which includes all XML files /etc/metaproxy/filters-enabled . The include facility uses YAZ' yaz_xml_include_simple (YAZ 4.0.1). --- configure.ac | 2 +- debian/control | 2 +- debian/metaproxy.dirs | 2 ++ debian/metaproxy.xml | 22 ++++++++++++++++++++++ debian/rules | 2 +- etc/Makefile.am | 3 +-- etc/config.debian.xml | 29 ----------------------------- src/ex_router_flexml.cpp | 2 +- src/metaproxy_prog.cpp | 14 +++++++++++++- src/router_flexml.cpp | 27 +++++++++++++++++++-------- src/router_flexml.hpp | 2 +- 11 files changed, 62 insertions(+), 45 deletions(-) create mode 100644 debian/metaproxy.dirs create mode 100644 debian/metaproxy.xml delete mode 100644 etc/config.debian.xml diff --git a/configure.ac b/configure.ac index baada56..e9ff754 100644 --- a/configure.ac +++ b/configure.ac @@ -36,7 +36,7 @@ AC_CHECK_LIB([m],[main]) AC_CHECK_FUNCS([localtime_r]) ## YAZPP checks -YAZPP_INIT([threads],[1.1.4]) +YAZPP_INIT([threads],[1.2.1]) if test -z "$YAZPPLIB"; then AC_MSG_ERROR([YAZ++ development libraries missing]) fi diff --git a/debian/control b/debian/control index 593405d..7d5a971 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: devel Standards-Version: 3.6.2 Maintainer: Adam Dickmeiss Priority: extra -Build-Depends: debhelper (>= 4), libyaz4-dev, libyazpp4-dev (>= 1.2.0), libxslt1-dev, libboost-dev, libboost-thread-dev, libboost-test-dev, libgnutls-dev +Build-Depends: debhelper (>= 4), libyaz4-dev, libyazpp4-dev (>= 1.2.1), libxslt1-dev, libboost-dev, libboost-thread-dev, libboost-test-dev, libgnutls-dev Package: metaproxy Section: net diff --git a/debian/metaproxy.dirs b/debian/metaproxy.dirs new file mode 100644 index 0000000..e92e2fd --- /dev/null +++ b/debian/metaproxy.dirs @@ -0,0 +1,2 @@ +etc/metaproxy/filters-enabled +etc/metaproxy/filters-available diff --git a/debian/metaproxy.xml b/debian/metaproxy.xml new file mode 100644 index 0000000..d84a917 --- /dev/null +++ b/debian/metaproxy.xml @@ -0,0 +1,22 @@ + + + /usr/lib/metaproxy/modules + + + + 50 + @:9000 + + + + + + + log + + + + + + + diff --git a/debian/rules b/debian/rules index 8940b01..3fe8888 100755 --- a/debian/rules +++ b/debian/rules @@ -83,7 +83,7 @@ binary-arch: build install dh_installexamples mv debian/tmp/usr/share/doc/metaproxy debian/tmp/usr/share/doc/metaproxy-doc mkdir -p debian/tmp/etc/metaproxy - cp debian/tmp/usr/share/metaproxy/etc/config.debian.xml debian/tmp/etc/metaproxy/metaproxy.xml + cp debian/metaproxy.xml debian/tmp/etc/metaproxy/metaproxy.xml dh_install # dh_installmenu # dh_installdebconf diff --git a/etc/Makefile.am b/etc/Makefile.am index dcfd9de..fa62b18 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -19,8 +19,7 @@ xmlconfig = $(srcdir)/config-bytarget.xml \ $(srcdir)/config3.xml \ $(srcdir)/config4.xml \ $(srcdir)/config5.xml \ - $(srcdir)/retrieval-info.xml \ - $(srcdir)/config.debian.xml + $(srcdir)/retrieval-info.xml config = example.simple-auth example.target-auth pqf2pqf.xsl explain.xml diff --git a/etc/config.debian.xml b/etc/config.debian.xml deleted file mode 100644 index d507854..0000000 --- a/etc/config.debian.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - /usr/lib/metaproxy/modules - - - - 50 - @:9000 - - - 30 - z3950.indexdata.dk - - - - - - - log - - - - - - - diff --git a/src/ex_router_flexml.cpp b/src/ex_router_flexml.cpp index e068e1e..c3efe78 100644 --- a/src/ex_router_flexml.cpp +++ b/src/ex_router_flexml.cpp @@ -74,7 +74,7 @@ int main(int argc, char **argv) if (doc) { mp::FactoryStatic factory; - mp::RouterFleXML router(doc, factory, false); + mp::RouterFleXML router(doc, factory, false, 0); mp::Package pack; diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp index 9f144b7..ef4f8f1 100644 --- a/src/metaproxy_prog.cpp +++ b/src/metaproxy_prog.cpp @@ -150,8 +150,20 @@ static int sc_main( yaz_log(YLOG_FATAL, "XInclude processing failed"); return 1; } + WRBUF base_path = wrbuf_alloc(); + const char *last_p = strrchr(fname, +#ifdef WIN32 + '\\' +#else + '/' +#endif + ); + if (last_p) + wrbuf_write(base_path, fname, last_p - fname); + mp::FactoryStatic factory; - mp::RouterFleXML router(doc, factory, false); + mp::RouterFleXML router(doc, factory, false, wrbuf_cstr(base_path)); + wrbuf_destroy(base_path); yaz_sc_running(s); diff --git a/src/router_flexml.cpp b/src/router_flexml.cpp index 8b30bef..759ef06 100644 --- a/src/router_flexml.cpp +++ b/src/router_flexml.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include @@ -47,7 +48,8 @@ namespace metaproxy_1 { friend class RouterFleXML::Pos; Rep(); - void base(xmlDocPtr doc, mp::FactoryFilter &factory, bool test_only); + void base(xmlDocPtr doc, mp::FactoryFilter &factory, bool test_only, + const char *file_include_path); typedef std::map > @@ -61,7 +63,8 @@ namespace metaproxy_1 { std::string m_dl_path; - void parse_xml_config_dom(xmlDocPtr doc, bool test_only); + void parse_xml_config_dom(xmlDocPtr doc, bool test_only, + const char *file_include_path); void parse_xml_filters(xmlDocPtr doc, const xmlNode *node, bool test_only); @@ -235,12 +238,20 @@ void mp::RouterFleXML::Rep::parse_xml_routes(xmlDocPtr doc, } void mp::RouterFleXML::Rep::parse_xml_config_dom(xmlDocPtr doc, - bool test_only) + bool test_only, + const char *file_include_path) { if (!doc) throw mp::XMLError("Empty XML Document"); const xmlNode* root = xmlDocGetRootElement(doc); + + if (file_include_path) + { + int r = yaz_xml_include_simple((xmlNode *) root, file_include_path); + if (r) + throw mp::XMLError("YAZ XML Include failed"); + } mp::xml::check_element_mp(root, "metaproxy"); @@ -300,18 +311,18 @@ mp::RouterFleXML::Rep::Rep() : m_xinclude(false) } void mp::RouterFleXML::Rep::base(xmlDocPtr doc, mp::FactoryFilter &factory, - bool test_only) + bool test_only, const char *file_include_path) { m_factory = &factory; - parse_xml_config_dom(doc, test_only); + parse_xml_config_dom(doc, test_only, file_include_path); m_start_route = "start"; } mp::RouterFleXML::RouterFleXML(xmlDocPtr doc, mp::FactoryFilter &factory, - bool test_only) + bool test_only, const char *file_include_path) : m_p(new Rep) { - m_p->base(doc, factory, test_only); + m_p->base(doc, factory, test_only, file_include_path); } mp::RouterFleXML::RouterFleXML(std::string xmlconf, mp::FactoryFilter &factory, @@ -326,7 +337,7 @@ mp::RouterFleXML::RouterFleXML(std::string xmlconf, mp::FactoryFilter &factory, throw mp::XMLError("xmlParseMemory failed"); else { - m_p->base(doc, factory, test_only); + m_p->base(doc, factory, test_only, 0); xmlFreeDoc(doc); } } diff --git a/src/router_flexml.hpp b/src/router_flexml.hpp index 0fccd8a..79b921b 100644 --- a/src/router_flexml.hpp +++ b/src/router_flexml.hpp @@ -38,7 +38,7 @@ namespace metaproxy_1 RouterFleXML(std::string xmlconf, metaproxy_1::FactoryFilter &factory, bool test_only); RouterFleXML(xmlDocPtr doc, metaproxy_1::FactoryFilter &factory, - bool test_only); + bool test_only, const char *file_include_path); ~RouterFleXML(); -- 1.7.10.4