Browse Source

* ability to tune filter parameters from file with regexps (closes #9)

master
Alex 'AdUser' Z 4 years ago
parent
commit
bcd61bbdee
  1. 9
      src/filter.c

9
src/filter.c

@ -18,6 +18,7 @@
static bool static bool
f2b_filter_load_file(f2b_filter_t *filter, const char *path) { f2b_filter_load_file(f2b_filter_t *filter, const char *path) {
f2b_config_param_t *param;
FILE *f = NULL; FILE *f = NULL;
size_t linenum = 0; size_t linenum = 0;
char line[REGEX_LINE_MAX] = ""; char line[REGEX_LINE_MAX] = "";
@ -55,7 +56,13 @@ f2b_filter_load_file(f2b_filter_t *filter, const char *path) {
break; break;
case ';': case ';':
case '#': case '#':
/* comment line */ if ((p = strstr(p, "set: ")) != NULL) {
/* inline config line */
if ((param = f2b_config_param_create(p + 5)) != NULL) {
filter->config(filter->h, param->name, param->value);
free(param);
}
} /* else: just comment line */
break; break;
default: default:
if (strstr(p, HOST_TOKEN) == NULL) { if (strstr(p, HOST_TOKEN) == NULL) {

Loading…
Cancel
Save