X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mime%2Frfc822address.c;h=6c11e631352b80012f4e5f9aec7bf67544ec2a88;hp=e4bf97676415ac793a91f139fb0fa0d29ceef9db;hb=129050c6742f6be13fa5635ba03542b7fb2a9525;hpb=cb4704c68992fe6e12cd153a693508b04bc7a470 diff --git a/lib-mime/rfc822address.c b/lib-mime/rfc822address.c index e4bf976..6c11e63 100644 --- a/lib-mime/rfc822address.c +++ b/lib-mime/rfc822address.c @@ -26,14 +26,7 @@ * please see the file GPL in the top level source directory. */ -#include -#include -#include - -#include -#include -#include -#include +#include #include "mutt_idna.h" @@ -51,7 +44,7 @@ void rfc822_qualify(address_t *addr, const char *host) } } -address_t *address_dup(address_t *addr) +address_t *address_dup(const address_t *addr) { address_t *res = address_new(); @@ -61,7 +54,7 @@ address_t *address_dup(address_t *addr) return res; } -address_t *address_list_dup(address_t *addr) +address_t *address_list_dup(const address_t *addr) { address_t *res = NULL, **resp = &res; @@ -73,6 +66,26 @@ address_t *address_list_dup(address_t *addr) return res; } +/* given a list of addresses, return a list of unique addresses */ +void address_list_uniq(address_t *a) +{ + for (; a; a = a->next) { + address_t **b = &a->next; + + if (!a->mailbox) + continue; + + while (*b) { + if ((*b)->mailbox && !ascii_strcasecmp((*b)->mailbox, a->mailbox)) + { + address_t *pop = address_list_pop(b); + address_delete(&pop); + } else { + b = &(*b)->next; + } + } + } +} /****************************************************************************/ /* Parsing functions */ @@ -242,7 +255,7 @@ parse_address(const char *s, static_buf *comment, address_t *cur) return s; } -address_t **rfc822_eotoken(address_t **last, static_buf *phrase, static_buf *comment) +static address_t **rfc822_eotoken(address_t **last, static_buf *phrase, static_buf *comment) { if (phrase->len) { const char *s; @@ -250,7 +263,7 @@ address_t **rfc822_eotoken(address_t **last, static_buf *phrase, static_buf *com s = parse_address(phrase->buf, comment, cur); if (s && *s && *s != ',' && *s != ';') { - address_delete(&cur); + address_list_wipe(&cur); return last; } @@ -281,7 +294,7 @@ address_t *rfc822_parse_adrlist(address_t *top, const char *s) stbuf_append_sp(&phrase); s = next_phrase(s, &phrase); if (!s) { - address_delete(&top); + address_list_wipe(&top); return NULL; } continue; @@ -290,7 +303,7 @@ address_t *rfc822_parse_adrlist(address_t *top, const char *s) stbuf_append_sp(&comment); s = parse_comment(s + 1, &comment); if (!s) { - address_delete(&top); + address_list_wipe(&top); return NULL; } continue; @@ -305,8 +318,8 @@ address_t *rfc822_parse_adrlist(address_t *top, const char *s) s = parse_address(skipspaces(s + 1), &comment, cur); if (!s || *s != '>' || !cur->mailbox) { - address_delete(&top); - address_delete(&cur); + address_list_wipe(&top); + address_list_wipe(&cur); return NULL; }