From: Vsevolod Stakhov Date: Tue, 29 Mar 2016 15:53:30 +0000 (+0100) Subject: [Feature] Add method to get headers as array for speed X-Git-Tag: 1.2.2~20 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1ce182c9bb3c7fd436ac5b982905d0e3616cd7a8;p=rspamd.git [Feature] Add method to get headers as array for speed --- diff --git a/src/libmime/message.c b/src/libmime/message.c index 9c50750d9..f14c3b185 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -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; +} diff --git a/src/libmime/message.h b/src/libmime/message.h index 13ccaa4fa..06ff78e7a 100644 --- a/src/libmime/message.h +++ b/src/libmime/message.h @@ -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