#include "mutt.h"
#include "mutt_curses.h"
#include "mime.h"
-#include "mailbox.h"
#include "mx.h"
#include "url.h"
#ifdef USE_IMAP
#include "imap.h"
+#include "imap/mx_imap.h"
#endif
#include "mutt_crypt.h"
+#include "lib/mem.h"
+#include "lib/intl.h"
+#include "lib/str.h"
+
#include <string.h>
#include <ctype.h>
#include <unistd.h>
mktemp (s);
if (period != NULL) {
*period = '.';
- sl = mutt_strlen (s);
+ sl = safe_strlen (s);
strfcpy (s + sl, period, l - sl);
}
}
int mutt_matches_ignore (const char *s, LIST * t)
{
for (; t; t = t->next) {
- if (!ascii_strncasecmp (s, t->data, mutt_strlen (t->data))
+ if (!ascii_strncasecmp (s, t->data, safe_strlen (t->data))
|| *t->data == '*')
return 1;
}
{
#ifdef USE_IMAP
/* if folder = {host} or imap[s]://host/: don't append slash */
- if (mx_is_imap (NONULL (Maildir)) &&
- (Maildir[strlen (Maildir) - 1] == '}' ||
- Maildir[strlen (Maildir) - 1] == '/'))
+ if (imap_is_magic (NONULL (Maildir), NULL) == M_IMAP &&
+ (Maildir[safe_strlen (Maildir) - 1] == '}' ||
+ Maildir[safe_strlen (Maildir) - 1] == '/'))
strfcpy (p, NONULL (Maildir), sizeof (p));
else
#endif
#ifdef USE_IMAP
/* Rewrite IMAP path in canonical form - aids in string comparisons of
* folders. May possibly fail, in which case s should be the same. */
- if (mx_is_imap (s))
+ if (imap_is_magic (s, NULL) == M_IMAP)
imap_expand_path (s, slen);
#endif
else
strfcpy (dest, pw->pw_gecos, destlen);
- pwnl = strlen (pw->pw_name);
+ pwnl = safe_strlen (pw->pw_name);
for (idx = 0; dest[idx]; idx++) {
if (dest[idx] == '&') {
for (q = *p; q; q = q->next) {
if (ascii_strcasecmp (attribute, q->attribute) == 0) {
- mutt_str_replace (&q->value, value);
+ str_replace (&q->value, value);
return;
}
}
void _mutt_mktemp (char *s, const char *src, int line)
{
- snprintf (s, _POSIX_PATH_MAX, "%s/mutt-%s-%d-%d-%d", NONULL (Tempdir),
+ snprintf (s, _POSIX_PATH_MAX, "%s/muttng-%s-%d-%d-%d", NONULL (Tempdir),
NONULL (Hostname), (int) getuid (), (int) getpid (), Counter++);
dprint (1,
(debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
}
*q = 0;
- if (mutt_strncmp (s, Maildir, (len = mutt_strlen (Maildir))) == 0 &&
+ if (safe_strncmp (s, Maildir, (len = safe_strlen (Maildir))) == 0 &&
s[len] == '/') {
*s++ = '=';
- memmove (s, s + len, mutt_strlen (s + len) + 1);
+ memmove (s, s + len, safe_strlen (s + len) + 1);
}
- else if (mutt_strncmp (s, Homedir, (len = mutt_strlen (Homedir))) == 0 &&
+ else if (safe_strncmp (s, Homedir, (len = safe_strlen (Homedir))) == 0 &&
s[len] == '/') {
*s++ = '~';
- memmove (s, s + len - 1, mutt_strlen (s + len - 1) + 1);
+ memmove (s, s + len - 1, safe_strlen (s + len - 1) + 1);
}
}
size_t slen;
int found = 0;
- slen = mutt_strlen (src);
+ slen = safe_strlen (src);
destlen--;
for (p = fmt, d = dest; destlen && *p; p++) {
(_("File is a directory, save under it? [(y)es, (n)o, (a)ll]"),
_("yna"))) {
case 3: /* all */
- mutt_str_replace (directory, fname);
+ str_replace (directory, fname);
break;
case 1: /* yes */
FREE (directory);
if ((p = strpbrk (d, "%@")))
*p = 0;
}
- mutt_strlower (d);
+ str_tolower (d);
}
else
*d = 0;
ret++;
s++;
}
- return (mutt_strlen (p));
+ return (safe_strlen (p));
}
void mutt_FormatString (char *dest, /* output buffer */
if (count > col) {
count -= col; /* how many columns left on this line */
mutt_FormatString (buf, sizeof (buf), src, callback, data, flags);
- wid = mutt_strlen (buf);
+ wid = safe_strlen (buf);
if (count > wid) {
count -= wid; /* how many chars to pad */
memset (wptr, ch, count);
data, flags);
if (tolower)
- mutt_strlower (buf);
+ str_tolower (buf);
if (nodots) {
char *p = buf;
*p = '_';
}
- if ((len = mutt_strlen (buf)) + wlen > destlen)
+ if ((len = safe_strlen (buf)) + wlen > destlen)
len = (destlen - wlen > 0) ? (destlen - wlen) : 0;
memcpy (wptr, buf, len);
FILE *f;
struct stat s;
- int len = mutt_strlen (path);
+ int len = safe_strlen (path);
if (path[len - 1] == '|') {
/* read from a pipe */
}
if (option (OPTCONFIRMAPPEND) &&
- (!TrashPath || (mutt_strcmp (s, TrashPath) != 0)))
+ (!TrashPath || (safe_strcmp (s, TrashPath) != 0)))
/* if we're appending to the trash, there's no point in asking */
{
snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s);
if (s->flags & M_PENDINGPREFIX) {
int i;
- i = strlen (Quotebuf);
+ i = safe_strlen (Quotebuf);
Quotebuf[i++] = c;
Quotebuf[i] = '\0';
if (i == sizeof (Quotebuf) - 1 || c == '\n') {
void state_mark_attach (STATE * s)
{
- if ((s->flags & M_DISPLAY) && !mutt_strcmp (Pager, "builtin"))
+ if ((s->flags & M_DISPLAY) && !safe_strcmp (Pager, "builtin"))
state_puts (AttachmentMarker, s);
}
return NULL;
}
else {
- safe_free (b->data);
+ FREE(&b->data);
}
memset (b, 0, sizeof (BUFFER));
return b;
b = mutt_buffer_init (b);
b->data = safe_strdup (seed);
- b->dsize = mutt_strlen (seed);
+ b->dsize = safe_strlen (seed);
b->dptr = (char *) b->data + b->dsize;
return b;
}
void mutt_buffer_addstr (BUFFER * buf, const char *s)
{
- mutt_buffer_add (buf, s, mutt_strlen (s));
+ mutt_buffer_add (buf, s, safe_strlen (s));
}
void mutt_buffer_addch (BUFFER * buf, char c)
return vstring;
}
-REGEXP *mutt_compile_regexp (const char *s, int flags)
-{
- REGEXP *pp = safe_calloc (sizeof (REGEXP), 1);
-
- pp->pattern = safe_strdup (s);
- pp->rx = safe_calloc (sizeof (regex_t), 1);
- if (REGCOMP (pp->rx, NONULL (s), flags) != 0)
- mutt_free_regexp (&pp);
-
- return pp;
-}
-
-void mutt_free_regexp (REGEXP ** pp)
-{
- FREE (&(*pp)->pattern);
- regfree ((*pp)->rx);
- FREE (&(*pp)->rx);
- FREE (pp);
-}
-
-void mutt_free_rx_list (RX_LIST ** list)
-{
- RX_LIST *p;
-
- if (!list)
- return;
- while (*list) {
- p = *list;
- *list = (*list)->next;
- mutt_free_regexp (&p->rx);
- FREE (&p);
- }
-}
-
void mutt_free_spam_list (SPAM_LIST ** list)
{
SPAM_LIST *p;
while (*list) {
p = *list;
*list = (*list)->next;
- mutt_free_regexp (&p->rx);
- safe_free (&p->template);
- FREE (&p);
+ rx_free (&p->rx);
+ FREE(&p->template);
+ FREE(&p);
}
}
-int mutt_match_rx_list (const char *s, RX_LIST * l)
-{
- if (!s)
- return 0;
-
- for (; l; l = l->next) {
- if (regexec (l->rx->rx, s, (size_t) 0, (regmatch_t *) 0, (int) 0) == 0) {
- dprint (5,
- (debugfile, "mutt_match_rx_list: %s matches %s\n", s,
- l->rx->pattern));
- return 1;
- }
- }
-
- return 0;
-}
-
int mutt_match_spam_list (const char *s, SPAM_LIST * l, char *text, int x)
{
static regmatch_t *pmatch = NULL;