1 /* $Id: metaproxy_prog.cpp,v 1.15 2008-02-26 23:56:05 adam Exp $
2 Copyright (c) 2005-2008, Index Data.
4 This file is part of Metaproxy.
6 Metaproxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #include <yaz/options.h>
26 #include <yaz/daemon.h>
30 #include <libxml/xinclude.h>
33 #include "package.hpp"
34 #include "router_flexml.hpp"
35 #include "factory_static.hpp"
37 namespace mp = metaproxy_1;
39 static void handler(void *data)
41 mp::RouterFleXML *routerp = (mp::RouterFleXML*) data;
44 pack.router(*routerp).move();
47 int main(int argc, char **argv)
51 const char *fname = 0;
55 const char *pidfile = 0;
58 while ((ret = options("c{config}:Dh{help}l:p:u:V{version}X",
59 argv, argc, &arg)) != -2)
67 mode = YAZ_DAEMON_FORK|YAZ_DAEMON_KEEPALIVE;
70 std::cerr << "metaproxy\n"
72 " -V|--version version\n"
73 " -c|--config f config filename\n"
74 " -D daemon and keepalive operation\n"
77 " -u id change uid to id\n"
78 " -X debug mode (no fork/daemon mode)\n"
82 yaz_log_init_file(arg);
91 std::cout << "Metaproxy " VERSION "\n";
94 mode = YAZ_DAEMON_DEBUG;
97 std::cerr << "bad option: " << arg << std::endl;
103 std::cerr << "No configuration given\n";
107 yaz_log(YLOG_LOG, "Metaproxy " VERSION " started");
108 xmlDocPtr doc = xmlReadFile(fname,
110 XML_PARSE_XINCLUDE + XML_PARSE_NOBLANKS
111 + XML_PARSE_NSCLEAN + XML_PARSE_NONET );
115 std::cerr << "XML parsing failed\n";
118 // and perform Xinclude then
119 if (xmlXIncludeProcess(doc) > 0) {
120 std::cerr << "processing XInclude directive\n";
122 mp::FactoryStatic factory;
123 mp::RouterFleXML router(doc, factory, false);
125 yaz_daemon("metaproxy", mode, handler, &router, pidfile, uid);
127 catch (std::logic_error &e) {
128 std::cerr << "std::logic error: " << e.what() << "\n";
131 catch (std::runtime_error &e) {
132 std::cerr << "std::runtime error: " << e.what() << "\n";
136 std::cerr << "Unknown Exception" << std::endl;
146 * indent-tabs-mode: nil
147 * c-file-style: "stroustrup"
149 * vim: shiftwidth=4 tabstop=8 expandtab