X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Fex_router_flexml.cpp;h=f2db2ef56c84182f3c557d672f7e30438de8e691;hb=637a685d61a9ff0e3f398a59da426979815c4d68;hp=a1c1a0d9515732c65fa22acd15a92b8276b72b9c;hpb=c859210e9c315c0f15c93fc6f65477a6c3e65d14;p=metaproxy-moved-to-github.git diff --git a/src/ex_router_flexml.cpp b/src/ex_router_flexml.cpp index a1c1a0d..f2db2ef 100644 --- a/src/ex_router_flexml.cpp +++ b/src/ex_router_flexml.cpp @@ -1,54 +1,105 @@ -/* $Id: ex_router_flexml.cpp,v 1.1 2005-10-26 14:12:00 marc Exp $ - Copyright (c) 2005, Index Data. +/* $Id: ex_router_flexml.cpp,v 1.11 2007-05-09 21:23:09 adam Exp $ + Copyright (c) 2005-2007, Index Data. -%LICENSE% +This file is part of Metaproxy. + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Metaproxy; see the file LICENSE. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +#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"; + try + { + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "produce help message") + ("config", po::value< std::vector >(), "xml config") + ; - yp2::RouterFleXML rflexml(xmlconf); + 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); - // } - //catch ( ... ) { - //std::cerr << "Unknown Exception" << std::endl; - //throw(); - //std::exit(1); - //} - std::exit(0); -} - + mp::Package pack; + + pack.router(router).move(); + xmlFreeDoc(doc); + } + } + catch ( ... ) { + std::cerr << "Unknown Exception" << std::endl; + throw; + std::exit(1); + } + std::exit(0); +} /*