diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-07 21:22:34 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-07 21:22:34 +0100 |
commit | e9418b12ff5cab4c366af3751906f5e95ba3df7a (patch) | |
tree | f83defcc32c8d172d536986d92df9a00a25a9227 /src/libmime | |
parent | e7c1a6a9a153a5832fd7748927961949b63728cb (diff) | |
download | rspamd-e9418b12ff5cab4c366af3751906f5e95ba3df7a.tar.gz rspamd-e9418b12ff5cab4c366af3751906f5e95ba3df7a.zip |
[Project] Rework scan result functions to support shadow results
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/mime_expressions.c | 2 | ||||
-rw-r--r-- | src/libmime/scan_result.c | 30 | ||||
-rw-r--r-- | src/libmime/scan_result.h | 8 |
3 files changed, 24 insertions, 16 deletions
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c index a0c499882..6ff656cdb 100644 --- a/src/libmime/mime_expressions.c +++ b/src/libmime/mime_expressions.c @@ -2328,7 +2328,7 @@ rspamd_has_symbol_expr (struct rspamd_task *task, symbol_str = (const gchar *)sym_arg->data; - if (rspamd_task_find_symbol_result (task, symbol_str)) { + if (rspamd_task_find_symbol_result (task, symbol_str, NULL)) { return TRUE; } diff --git a/src/libmime/scan_result.c b/src/libmime/scan_result.c index a27c3b0b2..1af2905e7 100644 --- a/src/libmime/scan_result.c +++ b/src/libmime/scan_result.c @@ -847,19 +847,22 @@ rspamd_check_action_metric (struct rspamd_task *task, return noaction->action; } -struct rspamd_symbol_result* -rspamd_task_find_symbol_result (struct rspamd_task *task, const char *sym) +struct rspamd_symbol_result * +rspamd_task_find_symbol_result (struct rspamd_task *task, const char *sym, + struct rspamd_scan_result *result) { struct rspamd_symbol_result *res = NULL; khiter_t k; + if (result == NULL) { + /* Use default result */ + result = task->result; + } - if (task->result) { - k = kh_get (rspamd_symbols_hash, task->result->symbols, sym); + k = kh_get (rspamd_symbols_hash, result->symbols, sym); - if (k != kh_end (task->result->symbols)) { - res = &kh_value (task->result->symbols, k); - } + if (k != kh_end (result->symbols)) { + res = &kh_value (result->symbols, k); } return res; @@ -867,14 +870,19 @@ rspamd_task_find_symbol_result (struct rspamd_task *task, const char *sym) void rspamd_task_symbol_result_foreach (struct rspamd_task *task, - GHFunc func, - gpointer ud) + struct rspamd_scan_result *result, GHFunc func, + gpointer ud) { const gchar *kk; struct rspamd_symbol_result res; - if (func && task->result) { - kh_foreach (task->result->symbols, kk, res, { + if (result == NULL) { + /* Use default result */ + result = task->result; + } + + if (func) { + kh_foreach (result->symbols, kk, res, { func ((gpointer)kk, (gpointer)&res, ud); }); } diff --git a/src/libmime/scan_result.h b/src/libmime/scan_result.h index cdd6fe38b..fd3b8f896 100644 --- a/src/libmime/scan_result.h +++ b/src/libmime/scan_result.h @@ -159,8 +159,9 @@ gboolean rspamd_task_add_result_option (struct rspamd_task *task, * @param sym * @return */ -struct rspamd_symbol_result *rspamd_task_find_symbol_result ( - struct rspamd_task *task, const char *sym); +struct rspamd_symbol_result * +rspamd_task_find_symbol_result (struct rspamd_task *task, const char *sym, + struct rspamd_scan_result *result); /** * Compatibility function to iterate on symbols hash @@ -168,8 +169,7 @@ struct rspamd_symbol_result *rspamd_task_find_symbol_result ( * @param func * @param ud */ -void rspamd_task_symbol_result_foreach (struct rspamd_task *task, - GHFunc func, +void rspamd_task_symbol_result_foreach (struct rspamd_task *task, struct rspamd_scan_result *result, GHFunc func, gpointer ud); /** |