... | ... |
@@ -42,6 +42,7 @@ |
42 | 42 |
#include "mem/mem.h" |
43 | 43 |
#include "ut.h" |
44 | 44 |
|
45 |
+#include <regex.h> |
|
45 | 46 |
#include <dlfcn.h> |
46 | 47 |
#include <strings.h> |
47 | 48 |
#include <stdlib.h> |
... | ... |
@@ -580,3 +581,41 @@ int fixup_int_2(void** param, int param_no) |
580 | 581 |
|
581 | 582 |
return 0; |
582 | 583 |
} |
584 |
+ |
|
585 |
+ |
|
586 |
+int fixup_regex_12(void** param, int param_no) |
|
587 |
+{ |
|
588 |
+ regex_t* re; |
|
589 |
+ |
|
590 |
+ if ((re=pkg_malloc(sizeof(regex_t)))==0) return E_OUT_OF_MEM; |
|
591 |
+ if (regcomp(re, *param, REG_EXTENDED|REG_ICASE|REG_NEWLINE) ){ |
|
592 |
+ pkg_free(re); |
|
593 |
+ LOG(L_ERR, "ERROR: fixup_regex_12: Bad regular expression '%s'\n", (char*)*param); |
|
594 |
+ return E_BAD_RE; |
|
595 |
+ } |
|
596 |
+ /* free string */ |
|
597 |
+ pkg_free(*param); |
|
598 |
+ /* replace it with the compiled re */ |
|
599 |
+ *param=re; |
|
600 |
+ return 0; |
|
601 |
+} |
|
602 |
+ |
|
603 |
+ |
|
604 |
+int fixup_regex_1(void** param, int param_no) |
|
605 |
+{ |
|
606 |
+ if (param_no == 1) { |
|
607 |
+ return fixup_regex_12(param, param_no); |
|
608 |
+ } |
|
609 |
+ |
|
610 |
+ return 0; |
|
611 |
+} |
|
612 |
+ |
|
613 |
+ |
|
614 |
+int fixup_regex_2(void** param, int param_no) |
|
615 |
+{ |
|
616 |
+ if (param_no == 2) { |
|
617 |
+ return fixup_regex_12(param, param_no); |
|
618 |
+ } |
|
619 |
+ |
|
620 |
+ return 0; |
|
621 |
+} |
... | ... |
@@ -183,4 +183,13 @@ int fixup_int_1(void** param, int param_no); |
183 | 183 |
/* Convert second parameter from char* to long */ |
184 | 184 |
int fixup_int_2(void** param, int param_no); |
185 | 185 |
|
186 |
+/* Compile regular expressions in both parameters */ |
|
187 |
+int fixup_regex_12(void** param, int param_no); |
|
188 |
+ |
|
189 |
+/* Compile regular expression in first parameter */ |
|
190 |
+int fixup_regex_1(void** param, int param_no); |
|
191 |
+ |
|
192 |
+/* Compile regular expression in second parameter */ |
|
193 |
+int fixup_regex_2(void** param, int param_no); |
|
194 |
+ |
|
186 | 195 |
#endif /* sr_module_h */ |