diff options
author | Christian Pointner <equinox@spreadspace.org> | 2010-12-05 08:15:54 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2010-12-05 08:15:54 +0000 |
commit | 4a6fdccc8260e867fbf4dfd53b029ba085840f51 (patch) | |
tree | 8b3319d8613d02e5305d09d835e4c17bcf9bf4bb /src/options.c | |
parent | check wether config file was empty (diff) |
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
Diffstat (limited to 'src/options.c')
-rw-r--r-- | src/options.c | 11 |
1 files changed, 10 insertions, 1 deletions
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; |