]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add a small helper function
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Apr 2020 20:37:47 +0000 (21:37 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Apr 2020 20:37:47 +0000 (21:37 +0100)
src/libmime/scan_result.c
src/libmime/scan_result.h

index 1af2905e7a4dbf2d137919a54b6d219a31cceb15..8599053863a4ec2d96f0aa96f08e6090039601aa 100644 (file)
@@ -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
index fd3b8f896f37170849dfb673911e108c2927eba6..dcae2609c17910689e76e9b2a613ebe91f7c844a 100644 (file)
@@ -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