X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mime%2Frfc822.c;h=e73b408124db66837f04b75c280808a153d7553e;hp=674d681fd16594b066fbf76d1bea0fb96ab04aa2;hb=33d07d4040a973a004c4a729fd1f56a63a7203e6;hpb=cfc49a0d8c3ac2c0bd4b217026d0740c55f2e5db diff --git a/lib-mime/rfc822.c b/lib-mime/rfc822.c index 674d681..e73b408 100644 --- a/lib-mime/rfc822.c +++ b/lib-mime/rfc822.c @@ -39,11 +39,47 @@ void address_wipe(address_t *addr) { - address_delete(&addr->next); p_delete(&addr->personal); p_delete(&addr->mailbox); + address_delete(&addr->next); +} + + +void rfc822_qualify(address_t *addr, const char *host) +{ + char *p; + + for (; addr; addr = addr->next) { + if (!addr->group && addr->mailbox && strchr(addr->mailbox, '@') == NULL) { + p = p_new(char, m_strlen(addr->mailbox) + m_strlen(host) + 2); + sprintf(p, "%s@%s", addr->mailbox, host); /* __SPRINTF_CHECKED__ */ + p_delete(&addr->mailbox); + addr->mailbox = p; + } + } +} + +address_t *address_dup(address_t *addr) +{ + address_t *res = address_new(); + + res->personal = m_strdup(addr->personal); + res->mailbox = m_strdup(addr->mailbox); + res->group = addr->group; + return res; } +address_t *address_list_dup(address_t *addr) +{ + address_t *res = NULL, **resp = &res; + + for (; addr; addr = addr->next) { + *resp = address_dup(addr); + resp = &(*resp)->next; + } + + return res; +} #define terminate_string(a, b, c) do { if ((b) < (c)) a[(b)] = 0; else \ a[(c)] = 0; } while (0) @@ -446,19 +482,6 @@ address_t *rfc822_parse_adrlist (address_t * top, const char *s) return top; } -void rfc822_qualify (address_t * addr, const char *host) -{ - char *p; - - for (; addr; addr = addr->next) - if (!addr->group && addr->mailbox && strchr (addr->mailbox, '@') == NULL) { - p = p_new(char, m_strlen(addr->mailbox) + m_strlen(host) + 2); - sprintf (p, "%s@%s", addr->mailbox, host); /* __SPRINTF_CHECKED__ */ - p_delete(&addr->mailbox); - addr->mailbox = p; - } -} - void rfc822_cat (char *buf, size_t buflen, const char *value, const char *specials) { @@ -641,47 +664,3 @@ done: *pbuf = 0; } -/* this should be rfc822_cpy_adr */ -address_t *rfc822_cpy_adr_real (address_t * addr) -{ - address_t *p = address_new (); - - p->personal = m_strdup(addr->personal); - p->mailbox = m_strdup(addr->mailbox); - p->group = addr->group; - return p; -} - -/* this should be rfc822_cpy_adrlist */ -address_t *rfc822_cpy_adr (address_t * addr) -{ - address_t *top = NULL, *last = NULL; - - for (; addr; addr = addr->next) { - if (last) { - last->next = rfc822_cpy_adr_real (addr); - last = last->next; - } - else - top = last = rfc822_cpy_adr_real (addr); - } - return top; -} - -/* append list 'b' to list 'a' and return the last element in the new list */ -address_t *rfc822_append (address_t ** a, address_t * b) -{ - address_t *tmp = *a; - - while (tmp && tmp->next) - tmp = tmp->next; - if (!b) - return tmp; - if (tmp) - tmp->next = rfc822_cpy_adr (b); - else - tmp = *a = rfc822_cpy_adr (b); - while (tmp && tmp->next) - tmp = tmp->next; - return tmp; -}