Browse Source

* set default score for filters

master
Alex 'AdUser' Z 4 years ago
parent
commit
d56feb497e
  1. 6
      src/filters/pcre.c
  2. 7
      src/filters/preg.c
  3. 2
      src/mod-defs.h

6
src/filters/pcre.c

@ -44,6 +44,7 @@ create(const char *id) {
cfg->logcb = &logcb_stub;
cfg->flags |= MOD_TYPE_FILTER;
cfg->defscore = MATCH_DEFSCORE;
return cfg;
}
@ -72,6 +73,10 @@ config(cfg_t *cfg, const char *key, const char *value) {
#endif
return true;
}
if (strcmp(key, "defscore") == 0) {
cfg->defscore = atoi(value);
return true;
}
return false;
}
@ -126,6 +131,7 @@ append(cfg_t *cfg, const char *pattern) {
}
}
regex->score = cfg->defscore;
regex->ftag = fnv_32a_str(pattern, FNV1_32A_INIT);
regex->next = cfg->regexps;
cfg->regexps = regex;

7
src/filters/preg.c

@ -17,6 +17,7 @@ struct _regexp {
rx_t *next;
uint32_t ftag;
int matches;
short int score;
regex_t regex;
char pattern[PATTERN_MAX];
};
@ -42,6 +43,7 @@ create(const char *id) {
cfg->logcb = &logcb_stub;
cfg->flags |= MOD_TYPE_FILTER;
cfg->defscore = MATCH_DEFSCORE;
return cfg;
}
@ -55,6 +57,10 @@ config(cfg_t *cfg, const char *key, const char *value) {
cfg->icase = (strcmp(value, "yes") == 0) ? true : false;
return true;
}
if (strcmp(key, "defscore") == 0) {
cfg->defscore = atoi(value);
return true;
}
return false;
}
@ -89,6 +95,7 @@ append(cfg_t *cfg, const char *pattern) {
return false;
if ((ret = regcomp(&regex->regex, buf, flags)) == 0) {
regex->score = cfg->defscore;
regex->ftag = fnv_32a_str(pattern, FNV1_32A_INIT);
regex->next = cfg->regexps;
cfg->regexps = regex;

2
src/mod-defs.h

@ -7,3 +7,5 @@
#define MOD_TYPE_SOURCE 1024
#define MOD_TYPE_FILTER 2048
#define MOD_TYPE_BACKEND 4096
#define MATCH_DEFSCORE 10

Loading…
Cancel
Save