From 28fd39060f79afa6bdc0fe9c8018fc0b10164473 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 30 Dec 2008 06:23:03 +0000 Subject: fixed some out of memory errors options parser gives now a hint where the error happened added build instructions for OpenBSD to Readme --- src/uanytun.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/uanytun.c') diff --git a/src/uanytun.c b/src/uanytun.c index fa2a207..7c49934 100644 --- a/src/uanytun.c +++ b/src/uanytun.c @@ -179,16 +179,22 @@ int main(int argc, char* argv[]) log_init("uanytun", DAEMON); signal_init(); - log_printf(NOTICE, "just started..."); - options_t* opt; int ret = options_parse(&opt, argc, argv); if(ret) { - options_print_usage(); - log_printf(ERR, "error on options_parse, exitting"); + options_clear(&opt); + if(ret > 0) + fprintf(stderr, "syntax error near: %s\n\n", argv[ret]); + if(ret == -2) + fprintf(stderr, "memory error on options_parse, exitting\n"); + + if(ret == -1 || ret > 0) + options_print_usage(); + exit(ret); } + log_printf(NOTICE, "just started..."); tun_device_t* dev; tun_init(&dev, opt->dev_name_, opt->dev_type_, opt->ifconfig_param_local_, opt->ifconfig_param_remote_netmask_); -- cgit v1.2.3