X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fmetaproxy_prog.cpp;h=11b04b23073902299a620f22074176d859c270d0;hb=10684c98b1ceadb16be96dd5e2ad9a5b22282155;hp=0aa04f4faf97fd1cbe6e763dd324b80ec28955e5;hpb=b0c61b7f8b17d876c88347a96c246c47493140da;p=metaproxy-moved-to-github.git diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp index 0aa04f4..11b04b2 100644 --- a/src/metaproxy_prog.cpp +++ b/src/metaproxy_prog.cpp @@ -27,14 +27,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" -#include "package.hpp" +#include +#include #include "router_flexml.hpp" #include "factory_static.hpp" #if HAVE_UNISTD_H #include #endif +#include #ifdef WIN32 #include #include @@ -43,10 +44,22 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA namespace mp = metaproxy_1; -static void handler(void *data) +mp::RouterFleXML *routerp = 0; + +static void sig_term_handler(int s) { - mp::RouterFleXML *routerp = (mp::RouterFleXML*) data; + if (routerp) + { + delete routerp; + } + exit(0); +} +static void handler(void *data) +{ + routerp = (mp::RouterFleXML*) data; + + signal(SIGTERM, sig_term_handler); mp::Package pack; pack.router(*routerp).move(); } @@ -150,12 +163,25 @@ 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 = + new mp::RouterFleXML(doc, factory, false, wrbuf_cstr(base_path)); + wrbuf_destroy(base_path); yaz_sc_running(s); - yaz_daemon("metaproxy", mode, handler, &router, pidfile, uid); + yaz_daemon("metaproxy", mode, handler, router, pidfile, uid); } catch (std::logic_error &e) { yaz_log (YLOG_FATAL,"std::logic error: %s" , e.what() );