# include "config.h"
#endif
+#include <lib-lib/mem.h>
+#include <lib-lib/ascii.h>
+#include <lib-lib/str.h>
+#include <lib-lib/macros.h>
+#include <lib-lib/file.h>
+
#include "mutt.h"
-#include "ascii.h"
#include "enter.h"
#include "mutt_curses.h"
#include "mutt_idna.h"
-#include "lib/mem.h"
-#include "lib/intl.h"
-#include "lib/str.h"
#include <stdio.h>
#include <string.h>
* SLcurses_waddnstr() can't take a "const char *", so this is only
* declared "static" (sigh)
*/
-static char *EditorHelp = N_("\
+static const char *EditorHelp = N_("\
~~ insert a line begining with a single ~\n\
~b users add users to the Bcc: field\n\
~c users add users to the Cc: field\n\
tmp[sizeof (tmp) - 1] = 0;
if (prefix) {
- strfcpy (tmp, NONULL (Prefix), sizeof (tmp));
- tmplen = str_len (tmp);
+ m_strcpy(tmp, sizeof(tmp), NONULL(Prefix));
+ tmplen = m_strlen(tmp);
p = tmp + tmplen;
tmplen = sizeof (tmp) - tmplen;
}
while (bytes > 0) {
if (fgets (p, tmplen - 1, f) == NULL)
break;
- bytes -= str_len (p);
+ bytes -= m_strlen(p);
if (*bufmax == *buflen)
- mem_realloc (&buf, sizeof (char *) * (*bufmax += 25));
- buf[(*buflen)++] = str_dup (tmp);
+ p_realloc(&buf, *bufmax += 25);
+ buf[(*buflen)++] = m_strdup(tmp);
}
if (buf && *bufmax == *buflen) { /* Do not smash memory past buf */
- mem_realloc (&buf, sizeof (char *) * (++*bufmax));
+ p_realloc(&buf, ++*bufmax);
}
if (buf)
buf[*buflen] = NULL;
static void be_free_memory (char **buf, int buflen)
{
while (buflen-- > 0)
- mem_free (&buf[buflen]);
+ p_delete(&buf[buflen]);
if (buf)
- mem_free (&buf);
+ p_delete(&buf);
}
static char **be_include_messages (char *msg, char **buf, int *bufmax,
}
if (*bufmax == *buflen)
- mem_realloc (&buf, sizeof (char *) * (*bufmax += 25));
- buf[(*buflen)++] = str_dup (tmp);
+ p_realloc(&buf, *bufmax += 25);
+ buf[(*buflen)++] = m_strdup(tmp);
bytes = Context->hdrs[n]->content->length;
if (inc_hdrs) {
pfx);
if (*bufmax == *buflen)
- mem_realloc (&buf, sizeof (char *) * (*bufmax += 25));
- buf[(*buflen)++] = str_dup ("\n");
+ p_realloc(&buf, *bufmax += 25);
+ buf[(*buflen)++] = m_strdup("\n");
}
else
printw (_("%d: invalid message number.\n"), n);
rfc822_write_address (tmp, sizeof (tmp), e->to, 0);
if (!e->to || force) {
if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 4, 0) == 0) {
- rfc822_free_address (&e->to);
+ address_delete (&e->to);
e->to = mutt_parse_adrlist (e->to, tmp);
e->to = mutt_expand_aliases (e->to);
mutt_addrlist_to_idna (e->to, NULL); /* XXX - IDNA error reporting? */
if (!e->subject || force) {
addstr ("Subject: ");
- strfcpy (tmp, e->subject ? e->subject : "", sizeof (tmp));
+ m_strcpy(tmp, sizeof(tmp), NONULL(e->subject));
if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 9, 0) == 0)
- str_replace (&e->subject, tmp);
+ m_strreplace(&e->subject, tmp);
addch ('\n');
}
mutt_addrlist_to_local (e->cc);
rfc822_write_address (tmp, sizeof (tmp), e->cc, 0);
if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 4, 0) == 0) {
- rfc822_free_address (&e->cc);
+ address_delete (&e->cc);
e->cc = mutt_parse_adrlist (e->cc, tmp);
e->cc = mutt_expand_aliases (e->cc);
tmp[0] = 0;
mutt_addrlist_to_local (e->bcc);
rfc822_write_address (tmp, sizeof (tmp), e->bcc, 0);
if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 5, 0) == 0) {
- rfc822_free_address (&e->bcc);
+ address_delete (&e->bcc);
e->bcc = mutt_parse_adrlist (e->bcc, tmp);
e->bcc = mutt_expand_aliases (e->bcc);
mutt_addrlist_to_idna (e->bcc, NULL);
if (EscChar && tmp[0] == EscChar[0] && tmp[1] != EscChar[0]) {
/* remove trailing whitespace from the line */
- p = tmp + str_len (tmp) - 1;
+ p = tmp + m_strlen(tmp) - 1;
while (p >= tmp && ISSPACE (*p))
*p-- = 0;
- p = tmp + 2;
- SKIPWS (p);
+ p = vskipspaces(tmp + 2);
switch (tmp[1]) {
case '?':
if (Context) {
if (!*p && cur) {
/* include the current message */
- p = tmp + str_len (tmp) + 1;
- snprintf (tmp + str_len (tmp),
- sizeof (tmp) - str_len (tmp), " %d",
+ p = tmp + m_strlen(tmp) + 1;
+ snprintf (tmp + m_strlen(tmp),
+ sizeof (tmp) - m_strlen(tmp), " %d",
cur->msgno + 1);
}
buf = be_include_messages (p, buf, &bufmax, &buflen,
break;
case 'r':
if (*p) {
- strncpy (tmp, p, sizeof (tmp));
+ m_strcpy(tmp, sizeof(tmp), p);
mutt_expand_path (tmp, sizeof (tmp));
buf = be_snarf_file (tmp, buf, &bufmax, &buflen, 1);
}
addstr (_("missing filename.\n"));
break;
case 's':
- str_replace (&msg->env->subject, p);
+ m_strreplace(&msg->env->subject, p);
break;
case 't':
msg->env->to = rfc822_parse_adrlist (msg->env->to, p);
case 'u':
if (buflen) {
buflen--;
- strfcpy (tmp, buf[buflen], sizeof (tmp));
- tmp[str_len (tmp) - 1] = 0;
- mem_free (&buf[buflen]);
+ m_strcpy(tmp, sizeof(tmp), buf[buflen]);
+ tmp[m_strlen(tmp) - 1] = 0;
+ p_delete(&buf[buflen]);
buf[buflen] = NULL;
continue;
}
case 'e':
case 'v':
if (be_barf_file (path, buf, buflen) == 0) {
- char *tag, *err;
+ const char *tag, *err;
be_free_memory (buf, buflen);
buf = NULL;
break;
}
}
- else if (str_cmp (".", tmp) == 0)
+ else if (m_strcmp(".", tmp) == 0)
done = 1;
else {
- str_cat (tmp, sizeof (tmp), "\n");
+ m_strcat(tmp, sizeof(tmp), "\n");
if (buflen == bufmax)
- mem_realloc (&buf, sizeof (char *) * (bufmax += 25));
- buf[buflen++] = str_dup (tmp[1] == '~' ? tmp + 1 : tmp);
+ p_realloc(&buf, bufmax += 25);
+ buf[buflen++] = m_strdup(tmp[1] == '~' ? tmp + 1 : tmp);
}
tmp[0] = 0;