Version 1.0.23. Bump copyright year.
[metaproxy-moved-to-github.git] / src / ex_router_flexml.cpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 2005-2010 Index Data
3
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #include "config.hpp"
20
21 #include <yaz/options.h>
22
23 #include <iostream>
24 #include <stdexcept>
25
26 #include "filter.hpp"
27 #include "package.hpp"
28 #include "router_flexml.hpp"
29 #include "factory_static.hpp"
30
31 namespace mp = metaproxy_1;
32
33 int main(int argc, char **argv)
34 {
35     try 
36     {
37         int ret;
38         char *arg;
39         char *fname = 0;
40
41         while ((ret = options("h{help}c{config}:", 
42                               argv, argc, &arg)) != -2)
43         {
44             switch(ret)
45             {
46             case -1:
47                 std::cerr << "bad option " << arg << std::endl;
48             case 'h':
49                 std::cerr << "ex_router_flexml\n"
50                     " -h|--help         help\n"
51                     " -c|--config fname configuation\n"
52                           << std::endl;
53                 std::exit(1);
54             case 'c':
55                 fname = arg;
56             }
57         }
58
59         xmlDocPtr doc = 0;
60         if (fname)
61         {
62             doc = xmlParseFile(fname);
63             if (!doc)
64             {
65                 std::cerr << "xmlParseFile failed\n";
66                 std::exit(1);
67             }
68         }
69         else
70         {
71             std::cerr << "No configuration given\n";
72             std::exit(1);
73         }
74         if (doc)
75         {
76             mp::FactoryStatic factory;
77             mp::RouterFleXML router(doc, factory, false);
78
79             mp::Package pack;
80          
81             pack.router(router).move();
82
83             xmlFreeDoc(doc);
84         }
85     }
86     catch ( ... ) {
87         std::cerr << "Unknown Exception" << std::endl;
88         throw;
89         std::exit(1);
90     }
91     std::exit(0);
92 }
93
94
95 /*
96  * Local variables:
97  * c-basic-offset: 4
98  * c-file-style: "Stroustrup"
99  * indent-tabs-mode: nil
100  * End:
101  * vim: shiftwidth=4 tabstop=8 expandtab
102  */
103