X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fex_router_flexml.cpp;h=3d77c98fde210af02f2a7d17dd84474fc9e1447a;hb=f47e8cf4cde2ba5465106e219c803e6424a4f177;hp=6fdb856c97d21bd3cc2ea0e10777c1a27c52c173;hpb=14d0e634d5061208301502d813d488d1e82f190b;p=metaproxy-moved-to-github.git diff --git a/src/ex_router_flexml.cpp b/src/ex_router_flexml.cpp index 6fdb856..3d77c98 100644 --- a/src/ex_router_flexml.cpp +++ b/src/ex_router_flexml.cpp @@ -1,46 +1,81 @@ -/* $Id: ex_router_flexml.cpp,v 1.5 2006-01-04 14:30:51 adam Exp $ +/* $Id: ex_router_flexml.cpp,v 1.7 2006-01-16 11:22:56 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% */ +#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" int main(int argc, char **argv) { try { + 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; + } - 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::FactoryFilter factory; - yp2::RouterFleXML rflexml(xmlconf, factory); - - - - } + 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) + { + yp2::FactoryStatic factory; + yp2::RouterFleXML router(doc, factory); + + yp2::Package pack; + + pack.router(router).move(); + + xmlFreeDoc(doc); + } + } catch ( ... ) { std::cerr << "Unknown Exception" << std::endl; throw; @@ -50,8 +85,6 @@ int main(int argc, char **argv) } - - /* * Local variables: * c-basic-offset: 4