X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fex_router_flexml.cpp;h=dfe11b766881460801e148b13f03f210e73cc27e;hb=b70b9ec78f0ab1c3ed3b432de986159129a0e4ed;hp=c7cffb36eb72e4c2c87a67a89c7ea0c2fc4cb08e;hpb=35f51b468b01c18772b50d15a4586a15fe4f6b50;p=metaproxy-moved-to-github.git diff --git a/src/ex_router_flexml.cpp b/src/ex_router_flexml.cpp index c7cffb3..dfe11b7 100644 --- a/src/ex_router_flexml.cpp +++ b/src/ex_router_flexml.cpp @@ -1,45 +1,83 @@ -/* $Id: ex_router_flexml.cpp,v 1.2 2005-10-31 11:59:08 marc Exp $ - Copyright (c) 2005, Index Data. +/* $Id: ex_router_flexml.cpp,v 1.10 2007-01-25 14:05:54 adam Exp $ + Copyright (c) 2005-2007, Index Data. -%LICENSE% + See the LICENSE file for details */ +#include "config.hpp" + +#include +namespace po = boost::program_options; + #include #include -#include "config.hpp" #include "filter.hpp" +#include "package.hpp" #include "router_flexml.hpp" +#include "factory_static.hpp" + +namespace mp = metaproxy_1; int main(int argc, char **argv) { try - { - - std::string xmlconf = "\n" - "\n" - "\n" - "\n" - "\n" - "210\n" - "\n" - "\n" - "mylog.log\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n"; - - yp2::RouterFleXML rflexml(xmlconf); - - - - } + { + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "produce help message") + ("config", po::value< std::vector >(), "xml config") + ; + + po::positional_options_description p; + p.add("config", -1); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(desc).positional(p).run(), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 1; + } + + xmlDocPtr doc = 0; + if (vm.count("config")) + { + std::vector config_fnames = + vm["config"].as< std::vector >(); + + if (config_fnames.size() != 1) + { + std::cerr << "Only one configuration must be given\n"; + std::exit(1); + } + + doc = xmlParseFile(config_fnames[0].c_str()); + if (!doc) + { + std::cerr << "xmlParseFile failed\n"; + std::exit(1); + } + } + else + { + std::cerr << "No configuration given\n"; + std::exit(1); + } + if (doc) + { + mp::FactoryStatic factory; + mp::RouterFleXML router(doc, factory); + + mp::Package pack; + + pack.router(router).move(); + + xmlFreeDoc(doc); + } + } catch ( ... ) { std::cerr << "Unknown Exception" << std::endl; throw; @@ -49,8 +87,6 @@ int main(int argc, char **argv) } - - /* * Local variables: * c-basic-offset: 4