From: Adam Dickmeiss Date: Wed, 20 Feb 2008 10:51:11 +0000 (+0000) Subject: Use YAZ' options X-Git-Tag: METAPROXY.1.0.13~13 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=57986809b87d5223f962099176c69346da43eb99;p=metaproxy-moved-to-github.git Use YAZ' options --- diff --git a/src/ex_filter_frontend_net.cpp b/src/ex_filter_frontend_net.cpp index e402e68..f832472 100644 --- a/src/ex_filter_frontend_net.cpp +++ b/src/ex_filter_frontend_net.cpp @@ -1,4 +1,4 @@ -/* $Id: ex_filter_frontend_net.cpp,v 1.30 2007-05-09 21:23:09 adam Exp $ +/* $Id: ex_filter_frontend_net.cpp,v 1.31 2008-02-20 10:51:11 adam Exp $ Copyright (c) 2005-2007, Index Data. This file is part of Metaproxy. @@ -25,10 +25,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include -#include -namespace po = boost::program_options; - - +#include #include "util.hpp" #include "filter_frontend_net.hpp" #include "filter_z3950_client.hpp" @@ -74,32 +71,34 @@ int main(int argc, char **argv) { try { - po::options_description desc("Allowed options"); - desc.add_options() - ("help", "produce help message") - ("duration", po::value(), - "number of seconds for server to exist") - ("port", po::value< std::vector >(), "listener port") - ; - - po::positional_options_description p; - p.add("port", -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::vector ports; + int duration = -1; + int ret; + char *arg; - if (vm.count("port")) + while ((ret = options("h{help}d{duration}:p{port}:", + argv, argc, &arg)) != -2) + { + switch(ret) + { + case -1: + std::cerr << "bad option " << arg << std::endl; + case 'h': + std::cerr << "ex_filter_frontend_net\n" + " -h|--help help\n" + " -d|--duration n duration\n" + " -p|--port n port number\n" + << std::endl; + break; + case 'p': + ports.push_back(arg); + break; + case 'd': + duration = atoi(arg); + break; + } + } { - std::vector ports = - vm["port"].as< std::vector >(); - for (size_t i = 0; i0 timeout in seconds - if (vm.count("duration")) { - filter_front.listen_duration() = vm["duration"].as(); - } + if (duration != -1) + filter_front.listen_duration() = duration; + router.append(filter_front); // put log filter in router diff --git a/src/ex_router_flexml.cpp b/src/ex_router_flexml.cpp index f2db2ef..e318c15 100644 --- a/src/ex_router_flexml.cpp +++ b/src/ex_router_flexml.cpp @@ -1,4 +1,4 @@ -/* $Id: ex_router_flexml.cpp,v 1.11 2007-05-09 21:23:09 adam Exp $ +/* $Id: ex_router_flexml.cpp,v 1.12 2008-02-20 10:51:11 adam Exp $ Copyright (c) 2005-2007, Index Data. This file is part of Metaproxy. @@ -21,8 +21,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "config.hpp" -#include -namespace po = boost::program_options; +#include #include #include @@ -38,38 +37,32 @@ 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; - } - - xmlDocPtr doc = 0; - if (vm.count("config")) - { - std::vector config_fnames = - vm["config"].as< std::vector >(); + int ret; + char *arg; + char *fname = 0; - if (config_fnames.size() != 1) + while ((ret = options("h{help}c{config}:", + argv, argc, &arg)) != -2) + { + switch(ret) { - std::cerr << "Only one configuration must be given\n"; + case -1: + std::cerr << "bad option " << arg << std::endl; + case 'h': + std::cerr << "ex_router_flexml\n" + " -h|--help help\n" + " -c|--config fname configuation\n" + << std::endl; std::exit(1); + case 'c': + fname = arg; } - - doc = xmlParseFile(config_fnames[0].c_str()); + } + + xmlDocPtr doc = 0; + if (fname) + { + doc = xmlParseFile(fname); if (!doc) { std::cerr << "xmlParseFile failed\n";