From e901254a5c3f8fd05a373acacc6b0dccb1f1ef71 Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Sun, 23 Dec 2007 14:38:56 +0000 Subject: parser now understands lists send sync command on connection changes --- options.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'options.cpp') diff --git a/options.cpp b/options.cpp index 4bdefd0..bc72f91 100644 --- a/options.cpp +++ b/options.cpp @@ -29,6 +29,7 @@ */ #include +#include #include #include @@ -70,6 +71,19 @@ i+=2; \ } +#define PARSE_SCALAR_CSLIST(SHORT, LONG, LIST) \ + else if(str == SHORT || str == LONG) \ + { \ + if(argc < 1 || argv[i+1][0] == '-') \ + return false; \ + std::stringstream tmp; \ + tmp << argv[i+1]; \ + std::string tmp_line; \ + getline(tmp,tmp_line,','); \ + LIST.push(tmp_line); \ + argc--; \ + i++; \ + } Options::Options() { @@ -97,7 +111,7 @@ bool Options::parse(int argc, char* argv[]) progname_ = argv[0]; argc--; - + std::queue host_port_queue; for(int i=1; argc > 0; ++i) { std::string str(argv[i]); @@ -119,9 +133,21 @@ bool Options::parse(int argc, char* argv[]) PARSE_SCALAR_PARAM("-w","--window-size", seq_window_size_) PARSE_SCALAR_PARAM("-c","--cypher", cypher_) PARSE_SCALAR_PARAM("-a","--auth-algo", auth_algo_) + PARSE_SCALAR_CSLIST("-M","--sync-hosts", host_port_queue) else return false; } + while(!host_port_queue.empty()) + { + std::stringstream tmp_stream(host_port_queue.front()); + std::string host; + u_int16_t port; + getline(tmp_stream,host,':'); + if(!tmp_stream.good()) + return false; + tmp_stream >> port; + host_port_queue.pop(); + } return true; } -- cgit v1.2.3