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/cfg_parse.y | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/cfg_parse.y') diff --git a/src/cfg_parse.y b/src/cfg_parse.y index fb6d97b..a18abd5 100644 --- a/src/cfg_parse.y +++ b/src/cfg_parse.y @@ -39,7 +39,7 @@ void yyerror(const char *); int yylex(void); int line_cnt = 1; -options_t* gopt; +const char* config_file_; listeners_t* glisteners; struct listener { @@ -122,9 +122,9 @@ static void merge_listener_struct(struct listener* dest, struct listener* src) } -void yyinit(options_t* opt, listeners_t* listeners) +void yyinit(const char* config_file, listeners_t* listeners) { - gopt = opt; + config_file_ = config_file; glisteners = listeners; } @@ -167,8 +167,10 @@ void yyinit(options_t* opt, listeners_t* listeners) %type resolv_type %type service %type host_or_addr -%% +%error-verbose + +%% cfg: | cfg listen ; @@ -180,10 +182,7 @@ listen: listen_head TOK_OPEN listen_body TOK_CLOSE TOK_SEMICOLON int ret = listener_add(glisteners, $1->la_, $1->lrt_, $1->lp_, $1->ra_, $1->rrt_, $1->rp_, $1->sa_); clear_listener_struct($1); if(ret) { - listener_clear(glisteners); - options_clear(gopt); - log_close(); - exit(-1); + YYABORT; } } ; @@ -269,10 +268,6 @@ host_or_addr: TOK_NUMBER void yyerror (const char *string) { - log_printf(ERROR, "%s:%d %s\n", gopt->config_file_, line_cnt, string); - listener_clear(glisteners); - options_clear(gopt); - log_close(); - exit(1); + log_printf(ERROR, "%s:%d %s\n", config_file_, line_cnt, string); } -- cgit v1.2.3