commit e31ed50: [Minor] Add a small helper function

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Apr 7 20:42:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-04-07 21:37:47 +0100
URL: https://github.com/rspamd/rspamd/commit/e31ed502be8b5109ad10f6e7bc078ecceb0c9a4d (HEAD -> master)

[Minor] Add a small helper function

---
 src/libmime/scan_result.c | 19 +++++++++++++++++++
 src/libmime/scan_result.h |  9 +++++++++
 2 files changed, 28 insertions(+)

diff --git a/src/libmime/scan_result.c b/src/libmime/scan_result.c
index 1af2905e7..859905386 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 fd3b8f896..dcae2609c 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


More information about the Commits mailing list