X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Fmetaproxy_prog.cpp;h=3bf08c481ef1c3238abea6a832a73d2889aff0fb;hb=0ab6e8aba7de1ea5cf109de175f56c9d8f7f49bc;hp=9151d0b2e2dba50bf62d470a7bcbf8a9c96cf124;hpb=79100c2ae2dac4bdde4f4d46b69e147562b4ec6c;p=metaproxy-moved-to-github.git diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp index 9151d0b..3bf08c4 100644 --- a/src/metaproxy_prog.cpp +++ b/src/metaproxy_prog.cpp @@ -1,7 +1,22 @@ -/* $Id: metaproxy_prog.cpp,v 1.1 2006-03-16 10:40:59 adam Exp $ - Copyright (c) 2005-2006, Index Data. +/* $Id: metaproxy_prog.cpp,v 1.10 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" @@ -11,6 +26,7 @@ namespace po = boost::program_options; #include #include +#include #include "filter.hpp" #include "package.hpp" @@ -25,7 +41,8 @@ int main(int argc, char **argv) { po::options_description desc("Allowed options"); desc.add_options() - ("help", "produce help message") + ("help,h", "produce help message") + ("version,V", "show version") ("config", po::value< std::vector >(), "xml config") ; @@ -35,13 +52,16 @@ int main(int argc, char **argv) po::variables_map vm; po::store(po::command_line_parser(argc, argv). options(desc).positional(p).run(), vm); - po::notify(vm); + po::notify(vm); if (vm.count("help")) { std::cout << desc << "\n"; return 1; } - + if (vm.count("version")) { + std::cout << "Metaproxy " VERSION "\n"; + return 0; + } xmlDocPtr doc = 0; if (vm.count("config")) { @@ -54,12 +74,23 @@ int main(int argc, char **argv) std::exit(1); } - doc = xmlParseFile(config_fnames[0].c_str()); + // need to parse with xinclude tags + // XML_PARSE_XINCLUDE XML_PARSE_NOBLANKS + // XML_PARSE_NSCLEAN XML_PARSE_NONET + doc = xmlReadFile(config_fnames[0].c_str(), + NULL, + XML_PARSE_XINCLUDE + XML_PARSE_NOBLANKS + + XML_PARSE_NSCLEAN + XML_PARSE_NONET ); + if (!doc) { - std::cerr << "xmlParseFile failed\n"; + std::cerr << "XML parsing failed\n"; std::exit(1); } + // and perform Xinclude then + if (xmlXIncludeProcess(doc) > 0) { + std::cerr << "processing XInclude directive\n"; + } } else { @@ -75,12 +106,24 @@ int main(int argc, char **argv) pack.router(router).move(); } catch (std::runtime_error &e) { - std::cout << "std::runtime error: " << e.what() << "\n"; - exit(1); + std::cerr << "std::runtime error: " << e.what() << "\n"; + std::exit(1); } xmlFreeDoc(doc); } } + catch (po::unknown_option &e) { + std::cerr << e.what() << "; use --help for list of options\n"; + std::exit(1); + } + catch (std::logic_error &e) { + std::cerr << "std::logic error: " << e.what() << "\n"; + std::exit(1); + } + catch (std::runtime_error &e) { + std::cerr << "std::runtime error: " << e.what() << "\n"; + std::exit(1); + } catch ( ... ) { std::cerr << "Unknown Exception" << std::endl; std::exit(1);