Include conf from filters-enabled
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 28 Jan 2010 11:28:26 +0000 (12:28 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 28 Jan 2010 11:28:26 +0000 (12:28 +0100)
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
debian/control
debian/metaproxy.dirs [new file with mode: 0644]
debian/metaproxy.xml [new file with mode: 0644]
debian/rules
etc/Makefile.am
etc/config.debian.xml [deleted file]
src/ex_router_flexml.cpp
src/metaproxy_prog.cpp
src/router_flexml.cpp
src/router_flexml.hpp

index baada56..e9ff754 100644 (file)
@@ -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
index 593405d..7d5a971 100644 (file)
@@ -3,7 +3,7 @@ Section: devel
 Standards-Version: 3.6.2
 Maintainer: Adam Dickmeiss <adam@indexdata.dk>
 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 (file)
index 0000000..e92e2fd
--- /dev/null
@@ -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 (file)
index 0000000..d84a917
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<metaproxy xmlns="http://indexdata.com/metaproxy" version="1.0">
+  <dlpath>/usr/lib/metaproxy/modules</dlpath>
+  <start route="start"/>
+  <filters>
+    <filter id="frontend" type="frontend_net">
+      <threads>50</threads>
+      <port>@:9000</port>
+    </filter>
+  </filters>
+  <routes>  
+    <route id="start">
+      <filter refid="frontend"/>
+      <filter type="log">
+        <message>log</message>
+      </filter>
+      <include src="filters-enabled/*.xml"/>
+      <filter type="bounce"/>
+    </route>
+  </routes>
+</metaproxy>
+
index 8940b01..3fe8888 100755 (executable)
@@ -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       
index dcfd9de..fa62b18 100644 (file)
@@ -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 (file)
index d507854..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0"?>
-<metaproxy xmlns="http://indexdata.com/metaproxy" version="1.0">
-  <!-- Z39.50 proxy which relays to target specified in Init otherinfo 
-  (VAL_RPOXY). If no target is given, it relays to target
-  z3950.indexdata.dk -->
-  <dlpath>/usr/lib/metaproxy/modules</dlpath>
-  <start route="start"/>
-  <filters>
-    <filter id="frontend" type="frontend_net">
-      <threads>50</threads>
-      <port>@:9000</port>
-    </filter>
-    <filter id="backend" type="z3950_client">
-     <timeout>30</timeout>
-     <default_target>z3950.indexdata.dk</default_target>
-    </filter>
-  </filters>
-  <routes>  
-    <route id="start">
-      <filter refid="frontend"/>
-      <filter type="log">
-        <message>log</message>
-      </filter>
-      <filter refid="backend"/>
-      <filter type="bounce"/>
-    </route>
-  </routes>
-</metaproxy>
-
index e068e1e..c3efe78 100644 (file)
@@ -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;
         
index 9f144b7..ef4f8f1 100644 (file)
@@ -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);
 
index 8b30bef..759ef06 100644 (file)
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <map>
 #include <list>
 #include <yaz/log.h>
+#include <yaz/xml_include.h>
 
 #include <boost/shared_ptr.hpp>
 
@@ -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<std::string,
                          boost::shared_ptr<const mp::filter::Base > >
@@ -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);
     }
 }
index 0fccd8a..79b921b 100644 (file)
@@ -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();