X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fex_filter_frontend_net.cpp;h=0a7940fcb563ba32aec499ac9dcd1c997dbdb92e;hb=47dbd1de7138760f24a41cbe0e3062b7e41aa409;hp=038178d2279536882a8c8584d97e1dacd4d7b344;hpb=79100c2ae2dac4bdde4f4d46b69e147562b4ec6c;p=metaproxy-moved-to-github.git diff --git a/src/ex_filter_frontend_net.cpp b/src/ex_filter_frontend_net.cpp index 038178d..0a7940f 100644 --- a/src/ex_filter_frontend_net.cpp +++ b/src/ex_filter_frontend_net.cpp @@ -1,8 +1,20 @@ -/* $Id: ex_filter_frontend_net.cpp,v 1.26 2006-03-16 10:40:59 adam Exp $ - Copyright (c) 2005-2006, Index Data. +/* This file is part of Metaproxy. + Copyright (C) 2005-2012 Index Data -%LICENSE% - */ +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 this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include "config.hpp" @@ -10,11 +22,8 @@ #include #include -#include -namespace po = boost::program_options; - - -#include "util.hpp" +#include +#include #include "filter_frontend_net.hpp" #include "filter_z3950_client.hpp" #include "filter_virt_db.hpp" @@ -22,8 +31,7 @@ namespace po = boost::program_options; #include "filter_log.hpp" #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include namespace mp = metaproxy_1; @@ -46,45 +54,49 @@ public: "Content-Type", "text/plain"); http_res->content_buf = - odr_strdup(odr, "Welcome to YP2"); + odr_strdup(odr, "Welcome to Metaproxy"); http_res->content_len = strlen(http_res->content_buf); package.response() = gdu; } return package.move(); }; + void configure(const xmlNode * ptr, bool test_only, + const char *path) { }; }; 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.set_listen_duration(duration); + router.append(filter_front); // put log filter in router @@ -105,7 +117,7 @@ int main(int argc, char **argv) router.append(filter_log_front); // put Virt db filter in router - mp::filter::Virt_db filter_virt_db; + mp::filter::VirtualDB filter_virt_db; filter_virt_db.add_map_db2target("gils", "indexdata.dk/gils", ""); filter_virt_db.add_map_db2target("Default", "localhost:9999/Default", @@ -144,8 +156,9 @@ int main(int argc, char **argv) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil - * c-file-style: "stroustrup" * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +