The configure method takes test_only flag so we can avoid
[metaproxy-moved-to-github.git] / src / ex_router_flexml.cpp
1 /* $Id: ex_router_flexml.cpp,v 1.13 2008-02-20 15:07:51 adam Exp $
2    Copyright (c) 2005-2007, Index Data.
3
4 This file is part of Metaproxy.
5
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
9 version.
10
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
14 for more details.
15
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
19 02111-1307, USA.
20  */
21
22 #include "config.hpp"
23
24 #include <yaz/options.h>
25
26 #include <iostream>
27 #include <stdexcept>
28
29 #include "filter.hpp"
30 #include "package.hpp"
31 #include "router_flexml.hpp"
32 #include "factory_static.hpp"
33
34 namespace mp = metaproxy_1;
35
36 int main(int argc, char **argv)
37 {
38     try 
39     {
40         int ret;
41         char *arg;
42         char *fname = 0;
43
44         while ((ret = options("h{help}c{config}:", 
45                               argv, argc, &arg)) != -2)
46         {
47             switch(ret)
48             {
49             case -1:
50                 std::cerr << "bad option " << arg << std::endl;
51             case 'h':
52                 std::cerr << "ex_router_flexml\n"
53                     " -h|--help         help\n"
54                     " -c|--config fname configuation\n"
55                           << std::endl;
56                 std::exit(1);
57             case 'c':
58                 fname = arg;
59             }
60         }
61
62         xmlDocPtr doc = 0;
63         if (fname)
64         {
65             doc = xmlParseFile(fname);
66             if (!doc)
67             {
68                 std::cerr << "xmlParseFile failed\n";
69                 std::exit(1);
70             }
71         }
72         else
73         {
74             std::cerr << "No configuration given\n";
75             std::exit(1);
76         }
77         if (doc)
78         {
79             mp::FactoryStatic factory;
80             mp::RouterFleXML router(doc, factory, false);
81
82             mp::Package pack;
83          
84             pack.router(router).move();
85
86             xmlFreeDoc(doc);
87         }
88     }
89     catch ( ... ) {
90         std::cerr << "Unknown Exception" << std::endl;
91         throw;
92         std::exit(1);
93     }
94     std::exit(0);
95 }
96
97
98 /*
99  * Local variables:
100  * c-basic-offset: 4
101  * indent-tabs-mode: nil
102  * c-file-style: "stroustrup"
103  * End:
104  * vim: shiftwidth=4 tabstop=8 expandtab
105  */