]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Add method to get headers as array for speed
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Mar 2016 15:53:30 +0000 (16:53 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Mar 2016 15:53:30 +0000 (16:53 +0100)
src/libmime/message.c
src/libmime/message.h

index 9c50750d945cc345a4dc6ed7b81ab938e43969d8..f14c3b1857d72db6cc1d3a6f7bca352d2aa04a40 100644 (file)
@@ -1962,3 +1962,31 @@ rspamd_message_get_header (struct rspamd_task *task,
 
        return gret;
 }
+
+GPtrArray *
+rspamd_message_get_header_array (struct rspamd_task *task,
+               const gchar *field,
+               gboolean strong)
+{
+       GPtrArray *ret;
+       struct raw_header *rh, *cur;
+       guint nelems = 0;
+
+       rh = g_hash_table_lookup (task->raw_headers, field);
+
+       if (rh == NULL) {
+               return NULL;
+       }
+
+       LL_FOREACH (rh, cur) {
+               nelems ++;
+       }
+
+       ret = g_ptr_array_sized_new (nelems);
+
+       LL_FOREACH (rh, cur) {
+               g_ptr_array_add (ret, cur);
+       }
+
+       return ret;
+}
index 13ccaa4fa3fbbcb4905c30427f41d7e50b757410..06ff78e7af4491841c736dd912cbe0c708ef6866 100644 (file)
@@ -87,4 +87,8 @@ GList * rspamd_message_get_header (struct rspamd_task *task,
        const gchar *field,
        gboolean strong);
 
+GPtrArray *rspamd_message_get_header_array (struct rspamd_task *task,
+               const gchar *field,
+               gboolean strong);
+
 #endif