X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=rfc822.c;h=19fb086987af2cee09d9e34b32d7b9319f45742a;hp=6f92f730c264b5bc96098974a269812bedbbb149;hb=fb514a63a7f58b76577fb30bfa260ad1b9239c41;hpb=c3e57678c8be193fc137854020f3a90887be97c9 diff --git a/rfc822.c b/rfc822.c index 6f92f73..19fb086 100644 --- a/rfc822.c +++ b/rfc822.c @@ -15,21 +15,13 @@ #include #include -#ifndef TESTING #include "mutt.h" -#else -#define safe_strdup strdup -#define safe_malloc malloc -#define SKIPWS(x) while(isspace(*x))x++ -#define FREE(x) safe_free(x) -#define ISSPACE isspace -#define strfcpy(a,b,c) {if (c) {strncpy(a,b,c);a[c-1]=0;}} -#define STRING 128 -#include "rfc822.h" -#endif - #include "mutt_idna.h" +#include "lib/mem.h" +#include "lib/intl.h" +#include "lib/str.h" + #define terminate_string(a, b, c) do { if ((b) < (c)) a[(b)] = 0; else \ a[(c)] = 0; } while (0) @@ -78,9 +70,6 @@ void rfc822_free_address (ADDRESS ** p) while (*p) { t = *p; *p = (*p)->next; -#ifdef EXACT_ADDRESS - FREE (&t->val); -#endif FREE (&t->personal); FREE (&t->mailbox); FREE (&t); @@ -336,10 +325,6 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) last->personal = safe_strdup (comment); } -#ifdef EXACT_ADDRESS - if (last && !last->val) - last->val = mutt_substrdup (begin, s); -#endif commentlen = 0; phraselen = 0; s++; @@ -369,10 +354,6 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) top = cur; last = cur; -#ifdef EXACT_ADDRESS - last->val = mutt_substrdup (begin, s); -#endif - phraselen = 0; commentlen = 0; s++; @@ -389,10 +370,6 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) terminate_buffer (comment, commentlen); last->personal = safe_strdup (comment); } -#ifdef EXACT_ADDRESS - if (last && !last->val) - last->val = mutt_substrdup (begin, s); -#endif /* add group terminator */ cur = rfc822_new_address (); @@ -459,10 +436,6 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) terminate_buffer (comment, commentlen); last->personal = safe_strdup (comment); } -#ifdef EXACT_ADDRESS - if (last) - last->val = mutt_substrdup (begin, s); -#endif return top; } @@ -516,25 +489,6 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS * addr, buflen--; /* save room for the terminal nul */ -#ifdef EXACT_ADDRESS - if (addr->val) { - if (!buflen) - goto done; - strfcpy (pbuf, addr->val, buflen); - len = mutt_strlen (pbuf); - pbuf += len; - buflen -= len; - if (addr->group) { - if (!buflen) - goto done; - *pbuf++ = ':'; - buflen--; - *pbuf = 0; - } - return; - } -#endif - if (addr->personal) { if (strpbrk (addr->personal, RFC822Specials)) { if (!buflen) @@ -686,9 +640,6 @@ ADDRESS *rfc822_cpy_adr_real (ADDRESS * addr) { ADDRESS *p = rfc822_new_address (); -#ifdef EXACT_ADDRESS - p->val = safe_strdup (addr->val); -#endif p->personal = safe_strdup (addr->personal); p->mailbox = safe_strdup (addr->mailbox); p->group = addr->group; @@ -728,31 +679,3 @@ ADDRESS *rfc822_append (ADDRESS ** a, ADDRESS * b) tmp = tmp->next; return tmp; } - -#ifdef TESTING -int safe_free (void **p) -{ - free (*p); /* __MEM_CHECKED__ */ - *p = 0; -} - -int main (int argc, char **argv) -{ - ADDRESS *list; - char buf[256]; - -# if 0 - char *str = - "michael, Michael Elkins , testing a really complex address: this example <@contains.a.source.route,@with.multiple.hosts:address@example.com>;, lothar@of.the.hillpeople (lothar)"; -# else - char *str = "a b c "; -# endif - - list = rfc822_parse_adrlist (NULL, str); - buf[0] = 0; - rfc822_write_address (buf, sizeof (buf), list); - rfc822_free_address (&list); - puts (buf); - exit (0); -} -#endif