diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-05-05 19:02:21 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-05-05 19:02:21 +0100 |
commit | 53282bc59b9c7252c2a8e559f9fbbe801f913840 (patch) | |
tree | c65730fb43a2a2e260d418de3a61dd4bfcfab01f /src | |
parent | e2c6f2bb074092f929540107ff06e1e31bd5be43 (diff) | |
download | rspamd-53282bc59b9c7252c2a8e559f9fbbe801f913840.tar.gz rspamd-53282bc59b9c7252c2a8e559f9fbbe801f913840.zip |
Rework composites processing.
Diffstat (limited to 'src')
-rw-r--r-- | src/libmime/filter.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 7562cee94..ed5b2ec8f 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -481,26 +481,14 @@ rspamd_composite_expr_parse (const gchar *line, gsize len, return res; } + static gint -rspamd_composite_expr_process (gpointer input, rspamd_expression_atom_t *atom) +rspamd_composite_process_single_symbol (struct composites_data *cd, + const gchar *sym, struct symbol **pms) { - struct composites_data *cd = (struct composites_data *)input; - const gchar *sym = atom->data; - struct rspamd_composite *ncomp; - struct symbol_remove_data *rd; - struct symbol *ms; + struct symbol *ms = NULL; gint rc = 0; - gchar t = '\0'; - - if (isset (cd->checked, cd->composite->id * 2)) { - /* We have already checked this composite, so just return its value */ - rc = isset (cd->checked, cd->composite->id * 2 + 1); - return rc; - } - - if (*sym == '~' || *sym == '-') { - t = *sym ++; - } + struct rspamd_composite *ncomp; if ((ms = g_hash_table_lookup (cd->metric_res->symbols, sym)) == NULL) { if ((ncomp = @@ -526,6 +514,32 @@ rspamd_composite_expr_process (gpointer input, rspamd_expression_atom_t *atom) rc = 1; } + *pms = ms; + return rc; +} + +static gint +rspamd_composite_expr_process (gpointer input, rspamd_expression_atom_t *atom) +{ + struct composites_data *cd = (struct composites_data *)input; + const gchar *sym = atom->data; + struct symbol_remove_data *rd; + struct symbol *ms; + gint rc = 0; + gchar t = '\0'; + + if (isset (cd->checked, cd->composite->id * 2)) { + /* We have already checked this composite, so just return its value */ + rc = isset (cd->checked, cd->composite->id * 2 + 1); + return rc; + } + + if (*sym == '~' || *sym == '-') { + t = *sym ++; + } + + rc = rspamd_composite_process_single_symbol (cd, sym, &ms); + if (rc && ms) { /* * At this point we know that we need to do something about this symbol, |