diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-02-11 20:26:41 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-02-11 20:26:41 +0300 |
commit | 740e75b5db4ad3280a622192ff370a9e6e45b6da (patch) | |
tree | 7943b205798d121b4ada5c5e5ccd8e4766608cab | |
parent | 16b555a9fe150859dc6bce15827c6512488ce3a3 (diff) | |
download | rspamd-740e75b5db4ad3280a622192ff370a9e6e45b6da.tar.gz rspamd-740e75b5db4ad3280a622192ff370a9e6e45b6da.zip |
Handle emails with common hostname.
-rw-r--r-- | src/protocol.c | 28 |
1 files changed, 27 insertions, 1 deletions
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; |