From 4a6fdccc8260e867fbf4dfd53b029ba085840f51 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 5 Dec 2010 08:15:54 +0000 Subject: cleaned parser a bit better warnings if local-port and config-file are specified git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@30 e61f0598-a718-4e21-a8f0-0aadfa62ad6b --- src/options.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/options.c') diff --git a/src/options.c b/src/options.c index bc49a44..b905426 100644 --- a/src/options.c +++ b/src/options.c @@ -219,6 +219,11 @@ int options_parse(options_t* opt, int argc, char* argv[]) string_list_add(&opt->log_targets_, "syslog:3,tcpproxy,daemon"); } + if(!opt->local_port_ && !opt->config_file_) { + opt->config_file_ = strdup(CONFFILE); + if(!opt->config_file_) return -2; + } + return 0; } @@ -227,6 +232,10 @@ void options_parse_post(options_t* opt) if(!opt) return; + if(opt->config_file_ && opt->local_port_) { + log_printf(WARNING, "local port and config file specified, will ignore config file"); + } + if(opt->buffer_size_ <= 0) { log_printf(WARNING, "illegal buffer size %d using default buffer size", opt->buffer_size_); opt->buffer_size_ = 10 * 1024; @@ -251,7 +260,7 @@ void options_default(options_t* opt) opt->rresolv_type_ = ANY; opt->remote_port_ = NULL; opt->source_addr_ = NULL; - opt->config_file_ = strdup(CONFFILE); + opt->config_file_ = NULL; string_list_init(&opt->log_targets_); opt->buffer_size_ = 10 * 1024; opt->debug_ = 0; -- cgit v1.2.3