From: Adam Dickmeiss Date: Fri, 14 Oct 2005 13:22:57 +0000 (+0000) Subject: Use boost::program_options in ex_filter_frontend_net program. X-Git-Tag: YP2.0.0.2~208 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=fb02f5d8ceb8c0062dd976626c8517f7d78280ea;p=metaproxy-moved-to-github.git Use boost::program_options in ex_filter_frontend_net program. --- diff --git a/src/ex_filter_frontend_net.cpp b/src/ex_filter_frontend_net.cpp index f8cbf5a..4ae21fa 100644 --- a/src/ex_filter_frontend_net.cpp +++ b/src/ex_filter_frontend_net.cpp @@ -3,6 +3,9 @@ #include #include +#include +namespace po = boost::program_options; + #include "config.hpp" #include "filter_frontend_net.hpp" @@ -51,7 +54,7 @@ public: break; } odr_destroy(odr); - } + } return package.move(); }; }; @@ -60,6 +63,22 @@ 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") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 1; + } + { yp2::RouterChain router; @@ -68,7 +87,10 @@ int main(int argc, char **argv) filter_front.listen_address() = "tcp:@:9999"; // 0=no time, >0 timeout in seconds - filter_front.listen_duration() = 0; + if (vm.count("duration")) { + filter_front.listen_duration() = + vm["duration"].as(); + } router.rule(filter_front); // put in a backend @@ -86,6 +108,7 @@ int main(int argc, char **argv) std::cerr << "unknown exception\n"; std::exit(1); } + std::exit(0); } /*