summaryrefslogtreecommitdiff
path: root/src/sp_config_scanner.re
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp_config_scanner.re')
-rw-r--r--src/sp_config_scanner.re26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/sp_config_scanner.re b/src/sp_config_scanner.re
index 063d332..b0ee5d5 100644
--- a/src/sp_config_scanner.re
+++ b/src/sp_config_scanner.re
@@ -4,6 +4,8 @@
4 4
5#define cs_log_error(fmt, ...) sp_log_err("config", fmt, ##__VA_ARGS__) 5#define cs_log_error(fmt, ...) sp_log_err("config", fmt, ##__VA_ARGS__)
6#define cs_log_info(fmt, ...) sp_log_msg("config", SP_LOG_INFO, fmt, ##__VA_ARGS__) 6#define cs_log_info(fmt, ...) sp_log_msg("config", SP_LOG_INFO, fmt, ##__VA_ARGS__)
7#define cs_log_warning(fmt, ...) sp_log_warn("config", fmt, ##__VA_ARGS__)
8
7 9
8zend_string *sp_get_arg_string(sp_parsed_keyword *kw) { 10zend_string *sp_get_arg_string(sp_parsed_keyword *kw) {
9 if (!kw || !kw->arg) { 11 if (!kw || !kw->arg) {
@@ -126,6 +128,12 @@ static int sy_apply_op(char op, int a, int b) {
126 int res = sy_apply_op(op, a, b); \ 128 int res = sy_apply_op(op, a, b); \
127 sy_res_push(res); 129 sy_res_push(res);
128 130
131#define TMPSTR(tmpstr, t2, t1) \
132 char tmpstr[1024]; \
133 size_t tmplen = MIN(t2-t1-2, 1023); \
134 strncpy(tmpstr, t1+1, tmplen); \
135 tmpstr[tmplen] = 0;
136
129 137
130zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_keyword*)) 138zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_keyword*))
131{ 139{
@@ -186,14 +194,22 @@ zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_key
186 } 194 }
187 <init> "@condition" ws+ { goto yyc_cond; } 195 <init> "@condition" ws+ { goto yyc_cond; }
188 <init> "@end_condition" ws* ";" { cond_res[0] = 1; goto yyc_init; } 196 <init> "@end_condition" ws* ";" { cond_res[0] = 1; goto yyc_init; }
189 <init> "@log" ws+ @t1 string? @t2 { 197 <init> ( "@log" | "@info" ) ws+ @t1 string @t2 {
190 char tmpstr[1024]; 198 TMPSTR(tmpstr, t2, t1);
191 size_t tmplen = MIN(t2-t1-2, 1023);
192 strncpy(tmpstr, t1+1, tmplen);
193 tmpstr[tmplen] = 0;
194 cs_log_info("[line %d]: %s", lineno, tmpstr); 199 cs_log_info("[line %d]: %s", lineno, tmpstr);
195 goto yyc_init; 200 goto yyc_init;
196 } 201 }
202 <init> ( "@warn" | "@warning" ) ws+ @t1 string @t2 {
203 TMPSTR(tmpstr, t2, t1);
204 cs_log_warning("[line %d]: %s", lineno, tmpstr);
205 goto yyc_init;
206 }
207 <init> ( "@err" | "@error" ) ws+ @t1 string @t2 {
208 TMPSTR(tmpstr, t2, t1);
209 cs_log_error("[line %d]: %s", lineno, tmpstr);
210 goto out;
211 }
212
197 213
198 <cond> ws+ { goto yyc_cond; } 214 <cond> ws+ { goto yyc_cond; }
199 <cond> nl { lineno++; goto yyc_cond; } 215 <cond> nl { lineno++; goto yyc_cond; }