From: Vsevolod Stakhov Date: Tue, 7 Apr 2020 20:37:47 +0000 (+0100) Subject: [Minor] Add a small helper function X-Git-Tag: 2.6~552 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e31ed502be8b5109ad10f6e7bc078ecceb0c9a4d;p=thirdparty%2Frspamd.git [Minor] Add a small helper function --- diff --git a/src/libmime/scan_result.c b/src/libmime/scan_result.c index 1af2905e7a..8599053863 100644 --- a/src/libmime/scan_result.c +++ b/src/libmime/scan_result.c @@ -886,4 +886,23 @@ rspamd_task_symbol_result_foreach (struct rspamd_task *task, func ((gpointer)kk, (gpointer)&res, ud); }); } +} + +struct rspamd_scan_result * +rspamd_find_metric_result (struct rspamd_task *task, + const gchar *name) +{ + struct rspamd_scan_result *res; + + if (name == NULL) { + return task->result; + } + + DL_FOREACH (task->result, res) { + if (res->name && strcmp (res->name, name) == 0) { + return res; + } + } + + return NULL; } \ No newline at end of file diff --git a/src/libmime/scan_result.h b/src/libmime/scan_result.h index fd3b8f896f..dcae2609c1 100644 --- a/src/libmime/scan_result.h +++ b/src/libmime/scan_result.h @@ -99,6 +99,15 @@ struct rspamd_scan_result { struct rspamd_scan_result *rspamd_create_metric_result (struct rspamd_task *task, const gchar *name, gint lua_sym_cbref); +/** + * Find result with a specific name (NULL means the default result) + * @param task + * @param name + * @return + */ +struct rspamd_scan_result *rspamd_find_metric_result (struct rspamd_task *task, + const gchar *name); + /** * Adds a new passthrough result to a task * @param task