|
|
|
@ -19,6 +19,7 @@
|
|
|
|
|
|
|
|
|
|
typedef struct f2b_regex_t { |
|
|
|
|
struct f2b_regex_t *next; |
|
|
|
|
char pattern[PATTERN_MAX]; |
|
|
|
|
int matches; |
|
|
|
|
regex_t regex; |
|
|
|
|
} f2b_regex_t; |
|
|
|
@ -28,6 +29,7 @@ struct _config {
|
|
|
|
|
char error[256]; |
|
|
|
|
bool icase; |
|
|
|
|
f2b_regex_t *regexps; |
|
|
|
|
f2b_regex_t *statp; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
cfg_t * |
|
|
|
@ -86,6 +88,7 @@ append(cfg_t *cfg, const char *pattern) {
|
|
|
|
|
if (regcomp(®ex->regex, buf, flags) == 0) { |
|
|
|
|
regex->next = cfg->regexps; |
|
|
|
|
cfg->regexps = regex; |
|
|
|
|
snprintf(regex->pattern, sizeof(regex->pattern), "%s", pattern); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -101,6 +104,23 @@ ready(cfg_t *cfg) {
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
stats(cfg_t *cfg, int *matches, char **pattern, bool reset) { |
|
|
|
|
assert(cfg != NULL); |
|
|
|
|
|
|
|
|
|
if (reset) |
|
|
|
|
cfg->statp = cfg->regexps; |
|
|
|
|
|
|
|
|
|
if (cfg->statp) { |
|
|
|
|
*matches = cfg->statp->matches; |
|
|
|
|
*pattern = cfg->statp->pattern; |
|
|
|
|
cfg->statp = cfg->statp->next; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const char * |
|
|
|
|
error(cfg_t *cfg) { |
|
|
|
|
assert(cfg != NULL); |
|
|
|
|