#include <lib-lib/mem.h>
#include <lib-lib/str.h>
#include <lib-lib/macros.h>
+#include <lib-lib/file.h>
#include "mutt.h"
#include "mx.h"
if (!(t = strtok (buff, " \t:")))
continue;
- if (!str_cmp (t, MhUnseen))
+ if (!m_strcmp(t, MhUnseen))
f = MH_SEQ_UNSEEN;
- else if (!str_cmp (t, MhFlagged))
+ else if (!m_strcmp(t, MhFlagged))
f = MH_SEQ_FLAGGED;
- else if (!str_cmp (t, MhReplied))
+ else if (!m_strcmp(t, MhReplied))
f = MH_SEQ_REPLIED;
else /* unknown sequence */
continue;
int i, r = 0;
struct mh_sequences mhs;
- memset (&mhs, 0, sizeof (mhs));
+ p_clear(&mhs, 1);
mh_read_sequences (&mhs, path);
for (i = 0; !r && i <= mhs.max; i++)
int fd;
char path[_POSIX_PATH_MAX];
- FOREVER {
+ for (;;) {
snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%d",
dest->path, NONULL (Hostname), (int) getpid (), Counter++);
umask (Umask);
struct mh_sequences mhs;
- memset (&mhs, 0, sizeof (mhs));
+ p_clear(&mhs, 1);
snprintf (seq_unseen, sizeof (seq_unseen), "%s:", NONULL (MhUnseen));
snprintf (seq_replied, sizeof (seq_replied), "%s:", NONULL (MhReplied));
/* first, copy unknown sequences */
if ((ofp = fopen (sequences, "r"))) {
while ((buff = mutt_read_line (buff, &s, ofp, &l))) {
- if (!str_ncmp (buff, seq_unseen, m_strlen(seq_unseen)))
+ if (!m_strncmp(buff, seq_unseen, m_strlen(seq_unseen)))
continue;
- if (!str_ncmp (buff, seq_flagged, m_strlen(seq_flagged)))
+ if (!m_strncmp(buff, seq_flagged, m_strlen(seq_flagged)))
continue;
- if (!str_ncmp (buff, seq_replied, m_strlen(seq_replied)))
+ if (!m_strncmp(buff, seq_replied, m_strlen(seq_replied)))
continue;
fprintf (nfp, "%s\n", buff);
h->read = 0;
h->replied = 0;
- if ((p = strrchr (path, ':')) != NULL && str_ncmp (p + 1, "2,", 2) == 0) {
+ if ((p = strrchr (path, ':')) != NULL && m_strncmp(p + 1, "2,", 2) == 0) {
p += 3;
str_replace (&h->maildir_flags, p);
if (stat (buf, &st) == 0)
ctx->mtime_cur = st.st_mtime;
- strfcpy (buf, ctx->path, sizeof (buf));
+ m_strcpy(buf, sizeof(buf), ctx->path);
}
if (stat (buf, &st) == 0)
if (subdir) {
snprintf (buf, sizeof (buf), "%s/%s", ctx->path, subdir);
- is_old = (str_cmp ("cur", subdir) == 0);
+ is_old = (m_strcmp("cur", subdir) == 0);
}
else
- strfcpy (buf, ctx->path, sizeof (buf));
+ m_strcpy(buf, sizeof(buf), ctx->path);
if ((dirp = opendir (buf)) == NULL)
return -1;
int count;
- memset (&mhs, 0, sizeof (mhs));
+ p_clear(&mhs, 1);
maildir_update_mtime (ctx);
*suffix = '\0';
if (hdr && (hdr->read || hdr->old))
- strfcpy (subdir, "cur", sizeof (subdir));
+ m_strcpy(subdir, sizeof(subdir), "cur");
else
- strfcpy (subdir, "new", sizeof (subdir));
+ m_strcpy(subdir, sizeof(subdir), "new");
- FOREVER {
+ for (;;) {
snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%u_%d.%s%s",
dest->path, subdir, (long) time (NULL),
(unsigned int) getpid (), Counter++, NONULL (Hostname), suffix);
/* extract the subdir */
s = strrchr (msg->path, '/') + 1;
- strfcpy (subdir, s, 4);
+ m_strcpy(subdir, sizeof(subdir), s);
/* extract the flags */
if ((s = strchr (s, ':')))
- strfcpy (suffix, s, sizeof (suffix));
+ m_strcpy(suffix, sizeof(suffix), s);
else
suffix[0] = '\0';
/* construct a new file name. */
- FOREVER {
+ for (;;) {
snprintf (path, _POSIX_PATH_MAX, "%s/%ld.%u_%d.%s%s", subdir,
(long) time (NULL), (unsigned int) getpid (), Counter++,
NONULL (Hostname), suffix);
* slot.
*/
- FOREVER {
+ for (;;) {
hi++;
snprintf (tmp, sizeof (tmp), "%d", hi);
snprintf (path, sizeof (path), "%s/%s", ctx->path, tmp);
if ((rc = mutt_copy_message (dest->fp, ctx, h,
M_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN)) == 0)
{
- snprintf (oldpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path);
- strfcpy (partpath, h->path, _POSIX_PATH_MAX);
+ snprintf (oldpath, sizeof(oldpath), "%s/%s", ctx->path, h->path);
+ m_strcpy(partpath, sizeof(partpath), h->path);
if (ctx->magic == M_MAILDIR)
rc = maildir_commit_message (dest, ctx, h);
return (-1);
}
p++;
- strfcpy (newpath, p, sizeof (newpath));
+ m_strcpy(newpath, sizeof(newpath), p);
/* kill the previous flags */
if ((p = strchr (newpath, ':')) != NULL)
snprintf (fullpath, sizeof (fullpath), "%s/%s", ctx->path, partpath);
snprintf (oldpath, sizeof (oldpath), "%s/%s", ctx->path, h->path);
- if (str_cmp (fullpath, oldpath) == 0) {
+ if (m_strcmp(fullpath, oldpath) == 0) {
/* message hasn't really changed */
return 0;
}
if ((t = strrchr (src, '/')))
src = t + 1;
- strfcpy (dest, src, l);
+ m_strcpy(dest, l, src);
if ((u = strrchr (dest, ':')))
*u = '\0';
/* check to see if the message has moved to a different
* subdirectory. If so, update the associated filename.
*/
- if (str_cmp (ctx->hdrs[i]->path, p->h->path))
+ if (m_strcmp(ctx->hdrs[i]->path, p->h->path))
str_replace (&ctx->hdrs[i]->path, p->h->path);
/* if the user hasn't modified the flags on this message, update
if (!option (OPTCHECKNEW))
return 0;
- strfcpy (buf, ctx->path, sizeof (buf));
+ m_strcpy(buf, sizeof(buf), ctx->path);
if (stat (buf, &st) == -1)
return -1;
ctx->mtime_cur = st_cur.st_mtime;
ctx->mtime = st.st_mtime;
- memset (&mhs, 0, sizeof (mhs));
+ p_clear(&mhs, 1);
md = NULL;
last = &md;
while ((de = readdir (dp))) {
maildir_canon_filename (tunique, de->d_name, sizeof (tunique));
- if (!str_cmp (tunique, unique)) {
+ if (!m_strcmp(tunique, unique)) {
snprintf (fname, sizeof (fname), "%s/%s/%s", folder, subfolder,
de->d_name);
fp = fopen (fname, "r"); /* __FOPEN_CHECKED__ */