#include <ctype.h>
#include <stdlib.h>
+#include <lib-lib/mem.h>
+#include <lib-lib/str.h>
+#include <lib-lib/ascii.h>
+#include <lib-lib/macros.h>
+
#include "mutt.h"
-#include "ascii.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)
while (*p) {
t = *p;
*p = (*p)->next;
- mem_free (&t->personal);
- mem_free (&t->mailbox);
- mem_free (&t);
+ p_delete(&t->personal);
+ p_delete(&t->mailbox);
+ p_delete(&t);
}
}
const char *ps;
while (*s) {
- SKIPWS (s);
+ s = vskipspaces(s);
if (strchr (nonspecial, *s) == NULL && is_special (*s))
return s;
}
terminate_string (token, *tokenlen, tokenmax);
- addr->mailbox = str_dup (token);
+ addr->mailbox = m_strdup(token);
if (*commentlen && !addr->personal) {
terminate_string (comment, *commentlen, commentmax);
- addr->personal = str_dup (comment);
+ addr->personal = m_strdup(comment);
}
return s;
char token[STRING];
size_t tokenlen = 0;
- SKIPWS (s);
+ s = vskipspaces(s);
/* find the end of the route */
if (*s == '@') {
}
if (!addr->mailbox)
- addr->mailbox = str_dup ("@");
+ addr->mailbox = m_strdup("@");
s++;
return s;
ws_pending = isspace ((unsigned char) *s);
- SKIPWS (s);
- begin = s;
+ begin = s = vskipspaces(s);
while (*s) {
if (*s == ',') {
if (phraselen) {
}
else if (commentlen && last && !last->personal) {
terminate_buffer (comment, commentlen);
- last->personal = str_dup (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)
else if (*s == ':') {
cur = rfc822_new_address ();
terminate_buffer (phrase, phraselen);
- cur->mailbox = str_dup (phrase);
+ cur->mailbox = m_strdup(phrase);
cur->group = 1;
if (last)
phraselen = 0;
commentlen = 0;
s++;
- begin = s;
- SKIPWS (begin);
+ begin = vskipspaces(s);
}
else if (*s == ';') {
if (phraselen) {
}
else if (commentlen && last && !last->personal) {
terminate_buffer (comment, commentlen);
- last->personal = str_dup (comment);
+ last->personal = m_strdup(comment);
}
/* add group terminator */
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)
- mem_free (&cur->personal);
+ p_delete(&cur->personal);
/* if we get something like "Michael R. Elkins" remove the quotes */
rfc822_dequote_comment (phrase);
- cur->personal = str_dup (phrase);
+ cur->personal = m_strdup(phrase);
}
if ((ps =
parse_route_addr (s + 1, comment, &commentlen,
s = ps;
}
ws_pending = isspace ((unsigned char) *s);
- SKIPWS (s);
+ s = vskipspaces(s);
}
if (phraselen) {
}
else if (commentlen && last && !last->personal) {
terminate_buffer (comment, commentlen);
- last->personal = str_dup (comment);
+ last->personal = m_strdup(comment);
}
return top;
for (; addr; addr = addr->next)
if (!addr->group && addr->mailbox && strchr (addr->mailbox, '@') == NULL) {
- p = mem_malloc (str_len (addr->mailbox) + str_len (host) + 2);
+ p = p_new(char, m_strlen(addr->mailbox) + m_strlen(host) + 2);
sprintf (p, "%s@%s", addr->mailbox, host); /* __SPRINTF_CHECKED__ */
- mem_free (&addr->mailbox);
+ p_delete(&addr->mailbox);
addr->mailbox = p;
}
}
}
*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,
else {
if (!buflen)
goto done;
- strfcpy (pbuf, addr->personal, buflen);
- len = str_len (pbuf);
+ m_strcpy(pbuf, buflen, addr->personal);
+ len = m_strlen(pbuf);
pbuf += len;
buflen -= len;
}
if (!buflen)
goto done;
if (ascii_strcmp (addr->mailbox, "@") && !display) {
- strfcpy (pbuf, addr->mailbox, buflen);
- len = str_len (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 = str_len (pbuf);
+ m_strcpy(pbuf, buflen, mutt_addr_for_display(addr));
+ len = m_strlen(pbuf);
}
else {
*pbuf = '\0';
int display)
{
char *pbuf = buf;
- size_t len = str_len (buf);
+ size_t len = m_strlen(buf);
buflen--; /* save room for the terminal nul */
/* 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 = str_len (pbuf);
+ len = m_strlen(pbuf);
pbuf += len;
buflen -= len;
{
ADDRESS *p = rfc822_new_address ();
- p->personal = str_dup (addr->personal);
- p->mailbox = str_dup (addr->mailbox);
+ p->personal = m_strdup(addr->personal);
+ p->mailbox = m_strdup(addr->mailbox);
p->group = addr->group;
return p;
}