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/cfg_parse.y | |
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/cfg_parse.y')
-rw-r--r-- | src/cfg_parse.y | 21 |
1 files changed, 8 insertions, 13 deletions
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 <rtype> resolv_type %type <string> service %type <string> 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); } |