summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-12-08 23:59:22 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-12-08 23:59:22 +0000
commit57f75fe9eb0a652f0742c47030a40714cd0a79ab (patch)
tree5d1287a194d01d3730b91d9ed56529928fef7bb8
parentparser now supports comments (diff)
advanced new lines
ipv4 and ipv6 case insensitive git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@40 e61f0598-a718-4e21-a8f0-0aadfa62ad6b
-rw-r--r--src/cfg_parser.rl15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cfg_parser.rl b/src/cfg_parser.rl
index 31104bf..ad11b08 100644
--- a/src/cfg_parser.rl
+++ b/src/cfg_parser.rl
@@ -112,17 +112,17 @@ static int owrt_string(char** dest, char* start, char* end)
}
newline = '\n' @{cur_line++;};
- ws = ( " " | "\t" );
+ ws = [ \t];
comment = '#' [^\n]* newline;
- ign = ( ws | comment | newline );
+ ign = ( ws | comment | newline | [\v\f\r] );
number = [0-9]+;
ipv4_addr = [0-9.]+;
ipv6_addr = [0-9a-fA-F:]+;
name = [a-zA-Z0-9\-]+;
host_name = [a-zA-Z0-9\-.]+;
- tok_ipv4 = "ipv4";
- tok_ipv6 = "ipv6";
+ tok_ipv4 = "ipv4"i;
+ tok_ipv6 = "ipv6"i;
host_or_addr = ( host_name | ipv4_addr | ipv6_addr );
service = ( number | name );
@@ -160,6 +160,7 @@ int parse_listener(char* p, char* pe, listeners_t* listener)
struct listener lst;
init_listener_struct(&lst);
+ char* eof = pe;
%% write exec;
if(cs == cfg_parser_error) {
@@ -167,6 +168,12 @@ int parse_listener(char* p, char* pe, listeners_t* listener)
ret = 1;
}
+ // we only have one file so if we aren't there something is wrong
+ if(cs != cfg_parser_first_final) {
+ log_printf(ERROR, "config file syntax error: unexpected end of file");
+ ret = 1;
+ }
+
clear_listener_struct(&lst);
return ret;