diff options
| author | Ben Fuhrmannek | 2021-12-20 19:47:56 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-12-20 19:47:56 +0100 |
| commit | 578f879e26ce4e3f1cd7693cb9d9a8a6f35cc389 (patch) | |
| tree | 8b60e4910f1229ee5639a72771bc94002fa4808b /src/sp_config_scanner.re | |
| parent | 2863344b21977bb5b1df276b2f17e2ac9572e42a (diff) | |
make set + @log/@info/@error conditional
Diffstat (limited to 'src/sp_config_scanner.re')
| -rw-r--r-- | src/sp_config_scanner.re | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/sp_config_scanner.re b/src/sp_config_scanner.re index b0ee5d5..6b52b20 100644 --- a/src/sp_config_scanner.re +++ b/src/sp_config_scanner.re | |||
| @@ -182,6 +182,7 @@ zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_key | |||
| 182 | <init> "sp" { kw_i = 0; goto yyc_rule; } | 182 | <init> "sp" { kw_i = 0; goto yyc_rule; } |
| 183 | <init> end { ret = SUCCESS; goto out; } | 183 | <init> end { ret = SUCCESS; goto out; } |
| 184 | <init> "set" ws+ @t1 keyword @t2 ws+ @t3 string @t4 ws* ";"? { | 184 | <init> "set" ws+ @t1 keyword @t2 ws+ @t3 string @t4 ws* ";"? { |
| 185 | if (!cond_res[0]) { goto yyc_init; } | ||
| 185 | char *key = (char*)t1; | 186 | char *key = (char*)t1; |
| 186 | int keylen = t2-t1; | 187 | int keylen = t2-t1; |
| 187 | zend_string *tmp = zend_hash_str_find_ptr(&vars, key, keylen); | 188 | zend_string *tmp = zend_hash_str_find_ptr(&vars, key, keylen); |
| @@ -192,19 +193,22 @@ zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_key | |||
| 192 | zend_hash_str_add_ptr(&vars, key, keylen, tmp); | 193 | zend_hash_str_add_ptr(&vars, key, keylen, tmp); |
| 193 | goto yyc_init; | 194 | goto yyc_init; |
| 194 | } | 195 | } |
| 195 | <init> "@condition" ws+ { goto yyc_cond; } | 196 | <init> "@condition" ws+ { cond_res_i = 0; goto yyc_cond; } |
| 196 | <init> "@end_condition" ws* ";" { cond_res[0] = 1; goto yyc_init; } | 197 | <init> "@end_condition" ws* ";" { cond_res[0] = 1; cond_res_i = 0; goto yyc_init; } |
| 197 | <init> ( "@log" | "@info" ) ws+ @t1 string @t2 { | 198 | <init> ( "@log" | "@info" ) ws+ @t1 string @t2 ";"? { |
| 199 | if (!cond_res[0]) { goto yyc_init; } | ||
| 198 | TMPSTR(tmpstr, t2, t1); | 200 | TMPSTR(tmpstr, t2, t1); |
| 199 | cs_log_info("[line %d]: %s", lineno, tmpstr); | 201 | cs_log_info("[line %d]: %s", lineno, tmpstr); |
| 200 | goto yyc_init; | 202 | goto yyc_init; |
| 201 | } | 203 | } |
| 202 | <init> ( "@warn" | "@warning" ) ws+ @t1 string @t2 { | 204 | <init> ( "@warn" | "@warning" ) ws+ @t1 string @t2 ";"? { |
| 205 | if (!cond_res[0]) { goto yyc_init; } | ||
| 203 | TMPSTR(tmpstr, t2, t1); | 206 | TMPSTR(tmpstr, t2, t1); |
| 204 | cs_log_warning("[line %d]: %s", lineno, tmpstr); | 207 | cs_log_warning("[line %d]: %s", lineno, tmpstr); |
| 205 | goto yyc_init; | 208 | goto yyc_init; |
| 206 | } | 209 | } |
| 207 | <init> ( "@err" | "@error" ) ws+ @t1 string @t2 { | 210 | <init> ( "@err" | "@error" ) ws+ @t1 string @t2 ";"? { |
| 211 | if (!cond_res[0]) { goto yyc_init; } | ||
| 208 | TMPSTR(tmpstr, t2, t1); | 212 | TMPSTR(tmpstr, t2, t1); |
| 209 | cs_log_error("[line %d]: %s", lineno, tmpstr); | 213 | cs_log_error("[line %d]: %s", lineno, tmpstr); |
| 210 | goto out; | 214 | goto out; |
