From 740e75b5db4ad3280a622192ff370a9e6e45b6da Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 11 Feb 2011 20:26:41 +0300 Subject: [PATCH] Handle emails with common hostname. --- src/protocol.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/protocol.c b/src/protocol.c index f5ef6bac2..38d6d4423 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -486,6 +486,32 @@ compare_url_func (gconstpointer a, gconstpointer b) } } +static gint +compare_email_func (gconstpointer a, gconstpointer b) +{ + const struct uri *u1 = a, *u2 = b; + gint r; + + if (u1->hostlen != u2->hostlen) { + return u1->hostlen - u2->hostlen; + } + else { + if ((r = memcmp (u1->host, u2->host, u1->hostlen)) == 0){ + if (u1->userlen != u2->userlen) { + return u1->userlen - u2->userlen; + } + else { + return memcmp (u1->user, u2->user, u1->userlen); + } + } + else { + return r; + } + } + + return 0; +} + static gboolean show_url_header (struct worker_task *task) { @@ -561,7 +587,7 @@ show_email_header (struct worker_task *task) GTree *url_tree; r = rspamd_snprintf (outbuf, sizeof (outbuf), "Emails: "); - url_tree = g_tree_new (compare_url_func); + url_tree = g_tree_new (compare_email_func); cur = task->emails; while (cur) { url = cur->data; -- 2.39.5