X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=rfc822.c;h=30f137977c64379ef5ffc89141a6507689354626;hp=64b16067fd95e32a0380d7fd944cd6ef6e842d19;hb=c660c8cbae7f647c637502779862e4a36ad6a074;hpb=f997801a16ce4a8530cb30cddebfe6243cb3502d diff --git a/rfc822.c b/rfc822.c index 64b1606..30f1379 100644 --- a/rfc822.c +++ b/rfc822.c @@ -15,12 +15,14 @@ #include #include +#include +#include +#include +#include + #include "mutt.h" #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) @@ -70,9 +72,9 @@ void rfc822_free_address (ADDRESS ** p) while (*p) { t = *p; *p = (*p)->next; - FREE (&t->personal); - FREE (&t->mailbox); - FREE (&t); + p_delete(&t->personal); + p_delete(&t->mailbox); + p_delete(&t); } } @@ -163,7 +165,7 @@ static const char *parse_mailboxdomain (const char *s, const char *nonspecial, const char *ps; while (*s) { - SKIPWS (s); + s = vskipspaces(s); if (strchr (nonspecial, *s) == NULL && is_special (*s)) return s; @@ -205,11 +207,11 @@ static const char *parse_address (const char *s, } terminate_string (token, *tokenlen, tokenmax); - addr->mailbox = safe_strdup (token); + addr->mailbox = m_strdup(token); if (*commentlen && !addr->personal) { terminate_string (comment, *commentlen, commentmax); - addr->personal = safe_strdup (comment); + addr->personal = m_strdup(comment); } return s; @@ -222,7 +224,7 @@ static const char *parse_route_addr (const char *s, char token[STRING]; size_t tokenlen = 0; - SKIPWS (s); + s = vskipspaces(s); /* find the end of the route */ if (*s == '@') { @@ -254,7 +256,7 @@ static const char *parse_route_addr (const char *s, } if (!addr->mailbox) - addr->mailbox = safe_strdup ("@"); + addr->mailbox = m_strdup("@"); s++; return s; @@ -311,8 +313,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) ws_pending = isspace ((unsigned char) *s); - SKIPWS (s); - begin = s; + begin = s = vskipspaces(s); while (*s) { if (*s == ',') { if (phraselen) { @@ -322,14 +323,13 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) } else if (commentlen && last && !last->personal) { terminate_buffer (comment, commentlen); - last->personal = safe_strdup (comment); + last->personal = m_strdup(comment); } commentlen = 0; phraselen = 0; s++; - begin = s; - SKIPWS (begin); + begin = vskipspaces(s); } else if (*s == '(') { if (commentlen && commentlen < sizeof (comment) - 1) @@ -345,7 +345,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) else if (*s == ':') { cur = rfc822_new_address (); terminate_buffer (phrase, phraselen); - cur->mailbox = safe_strdup (phrase); + cur->mailbox = m_strdup(phrase); cur->group = 1; if (last) @@ -357,8 +357,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) phraselen = 0; commentlen = 0; s++; - begin = s; - SKIPWS (begin); + begin = vskipspaces(s); } else if (*s == ';') { if (phraselen) { @@ -368,7 +367,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) } else if (commentlen && last && !last->personal) { terminate_buffer (comment, commentlen); - last->personal = safe_strdup (comment); + last->personal = m_strdup(comment); } /* add group terminator */ @@ -381,18 +380,17 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) phraselen = 0; commentlen = 0; s++; - begin = s; - SKIPWS (begin); + begin = vskipspaces(s); } else if (*s == '<') { terminate_buffer (phrase, phraselen); cur = rfc822_new_address (); if (phraselen) { if (cur->personal) - FREE (&cur->personal); + p_delete(&cur->personal); /* if we get something like "Michael R. Elkins" remove the quotes */ rfc822_dequote_comment (phrase); - cur->personal = safe_strdup (phrase); + cur->personal = m_strdup(phrase); } if ((ps = parse_route_addr (s + 1, comment, &commentlen, @@ -423,7 +421,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) s = ps; } ws_pending = isspace ((unsigned char) *s); - SKIPWS (s); + s = vskipspaces(s); } if (phraselen) { @@ -434,7 +432,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) } else if (commentlen && last && !last->personal) { terminate_buffer (comment, commentlen); - last->personal = safe_strdup (comment); + last->personal = m_strdup(comment); } return top; @@ -446,9 +444,9 @@ void rfc822_qualify (ADDRESS * addr, const char *host) for (; addr; addr = addr->next) if (!addr->group && addr->mailbox && strchr (addr->mailbox, '@') == NULL) { - p = safe_malloc (safe_strlen (addr->mailbox) + safe_strlen (host) + 2); + p = p_new(char, m_strlen(addr->mailbox) + m_strlen(host) + 2); sprintf (p, "%s@%s", addr->mailbox, host); /* __SPRINTF_CHECKED__ */ - FREE (&addr->mailbox); + p_delete(&addr->mailbox); addr->mailbox = p; } } @@ -471,10 +469,10 @@ rfc822_cat (char *buf, size_t buflen, const char *value, const char *specials) } *pc++ = '"'; *pc = 0; - strfcpy (buf, tmp, buflen); + m_strcpy(buf, buflen, tmp); } else - strfcpy (buf, value, buflen); + m_strcpy(buf, buflen, value); } void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS * addr, @@ -515,8 +513,8 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS * addr, else { if (!buflen) goto done; - strfcpy (pbuf, addr->personal, buflen); - len = safe_strlen (pbuf); + m_strcpy(pbuf, buflen, addr->personal); + len = m_strlen(pbuf); pbuf += len; buflen -= len; } @@ -538,12 +536,12 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS * addr, if (!buflen) goto done; if (ascii_strcmp (addr->mailbox, "@") && !display) { - strfcpy (pbuf, addr->mailbox, buflen); - len = safe_strlen (pbuf); + m_strcpy(pbuf, buflen, addr->mailbox); + len = m_strlen(pbuf); } else if (ascii_strcmp (addr->mailbox, "@") && display) { - strfcpy (pbuf, mutt_addr_for_display (addr), buflen); - len = safe_strlen (pbuf); + m_strcpy(pbuf, buflen, mutt_addr_for_display(addr)); + len = m_strlen(pbuf); } else { *pbuf = '\0'; @@ -587,7 +585,7 @@ void rfc822_write_address (char *buf, size_t buflen, ADDRESS * addr, int display) { char *pbuf = buf; - size_t len = safe_strlen (buf); + size_t len = m_strlen(buf); buflen--; /* save room for the terminal nul */ @@ -614,7 +612,7 @@ void rfc822_write_address (char *buf, size_t buflen, ADDRESS * addr, /* this should be safe since we always have at least 1 char passed into the above call, which means `pbuf' should always be nul terminated */ - len = safe_strlen (pbuf); + len = m_strlen(pbuf); pbuf += len; buflen -= len; @@ -640,8 +638,8 @@ ADDRESS *rfc822_cpy_adr_real (ADDRESS * addr) { ADDRESS *p = rfc822_new_address (); - p->personal = safe_strdup (addr->personal); - p->mailbox = safe_strdup (addr->mailbox); + p->personal = m_strdup(addr->personal); + p->mailbox = m_strdup(addr->mailbox); p->group = addr->group; return p; }