*/
static short mhs_check(struct MhSequences *mhs, int i)
{
- if (!mhs->flags || i > mhs->max)
+ if (!mhs->flags || (i > mhs->max))
return 0;
else
return mhs->flags[i];
if (p)
{
*p++ = '\0';
- if (mutt_str_atoi(t, first) < 0 || mutt_str_atoi(p, last) < 0)
+ if ((mutt_str_atoi(t, first) < 0) || (mutt_str_atoi(p, last) < 0))
return -1;
}
else
{
int line = 1;
char *buf = NULL;
- char *t = NULL;
size_t sz = 0;
short f;
while ((buf = mutt_file_read_line(buf, &sz, fp, &line, 0)))
{
- t = strtok(buf, " \t:");
+ char *t = strtok(buf, " \t:");
if (!t)
continue;
*/
static inline mode_t mh_umask(struct Mailbox *mailbox)
{
- struct stat st;
struct MhData *data = mh_data(mailbox);
-
if (data && data->mh_umask)
return data->mh_umask;
+ struct stat st;
if (stat(mailbox->path, &st))
{
mutt_debug(1, "stat failed on %s\n", mailbox->path);
{
int fd;
char path[PATH_MAX];
- mode_t omask;
- omask = umask(mh_umask(mailbox));
+ mode_t omask = umask(mh_umask(mailbox));
while (true)
{
snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, mailbox->path,
*/
static void mhs_write_one_sequence(FILE *fp, struct MhSequences *mhs, short f, const char *tag)
{
- int first, last;
fprintf(fp, "%s:", tag);
- first = -1;
- last = -1;
+ int first = -1;
+ int last = -1;
for (int i = 0; i <= mhs->max; i++)
{
static void mh_sequences_add_one(struct Mailbox *mailbox, int n, bool unseen,
bool flagged, bool replied)
{
- short unseen_done = 0;
- short flagged_done = 0;
- short replied_done = 0;
+ bool unseen_done = false;
+ bool flagged_done = false;
+ bool replied_done = false;
FILE *ofp = NULL, *nfp = NULL;
if (unseen && (strncmp(buf, seq_unseen, mutt_str_strlen(seq_unseen)) == 0))
{
fprintf(nfp, "%s %d\n", buf, n);
- unseen_done = 1;
+ unseen_done = true;
}
else if (flagged && (strncmp(buf, seq_flagged, mutt_str_strlen(seq_flagged)) == 0))
{
fprintf(nfp, "%s %d\n", buf, n);
- flagged_done = 1;
+ flagged_done = true;
}
else if (replied && (strncmp(buf, seq_replied, mutt_str_strlen(seq_replied)) == 0))
{
fprintf(nfp, "%s %d\n", buf, n);
- replied_done = 1;
+ replied_done = true;
}
else
fprintf(nfp, "%s\n", buf);
static void mh_update_maildir(struct Maildir *md, struct MhSequences *mhs)
{
int i;
- short f;
- char *p = NULL;
for (; md; md = md->next)
{
- p = strrchr(md->h->path, '/');
+ char *p = strrchr(md->h->path, '/');
if (p)
p++;
else
if (mutt_str_atoi(p, &i) < 0)
continue;
- f = mhs_check(mhs, i);
+ short f = mhs_check(mhs, i);
md->h->read = (f & MH_SEQ_UNSEEN) ? false : true;
md->h->flagged = (f & MH_SEQ_FLAGGED) ? true : false;
*/
static void maildir_free_maildir(struct Maildir **md)
{
- struct Maildir *p = NULL, *q = NULL;
-
if (!md || !*md)
return;
+ struct Maildir *p = NULL, *q = NULL;
+
for (p = *md; p; p = q)
{
q = p->next;
static int maildir_parse_dir(struct Mailbox *mailbox, struct Maildir ***last,
const char *subdir, int *count, struct Progress *progress)
{
- DIR *dirp = NULL;
struct dirent *de = NULL;
char buf[PATH_MAX];
int is_old = 0;
else
mutt_str_strfcpy(buf, mailbox->path, sizeof(buf));
- dirp = opendir(buf);
+ DIR *dirp = opendir(buf);
if (!dirp)
return -1;
struct Maildir *md = NULL;
struct MhSequences mhs = { 0 };
struct Maildir **last = NULL;
- struct MhData *data = NULL;
- int count;
char msgbuf[STRING];
struct Progress progress;
{
ctx->mailbox->data = mutt_mem_calloc(1, sizeof(struct MhData));
}
- data = mh_data(ctx->mailbox);
+ struct MhData *data = mh_data(ctx->mailbox);
maildir_update_mtime(ctx->mailbox);
md = NULL;
last = &md;
- count = 0;
+ int count = 0;
if (maildir_parse_dir(ctx->mailbox, &last, subdir, &count, &progress) < 0)
return -1;
/* maildir looks sort of like MH, except that there are two subdirectories
* of the main folder path from which to read messages
*/
- if (mh_read_dir(ctx, "new") == -1 || mh_read_dir(ctx, "cur") == -1)
+ if ((mh_read_dir(ctx, "new") == -1) || (mh_read_dir(ctx, "cur") == -1))
return -1;
return 0;
static int mh_commit_msg(struct Mailbox *mailbox, struct Message *msg,
struct Header *hdr, bool updseq)
{
- DIR *dirp = NULL;
struct dirent *de = NULL;
char *cp = NULL, *dep = NULL;
unsigned int n, hi = 0;
return -1;
}
- dirp = opendir(mailbox->path);
+ DIR *dirp = opendir(mailbox->path);
if (!dirp)
{
mutt_perror(mailbox->path);
char suffix[16];
char path[PATH_MAX];
char full[PATH_MAX];
- char *s = NULL;
if (mutt_file_fsync_close(&msg->fp))
{
}
/* extract the subdir */
- s = strrchr(msg->path, '/') + 1;
+ char *s = strrchr(msg->path, '/') + 1;
mutt_str_strfcpy(subdir, s, 4);
/* extract the flags */
* end of list block if required.
*/
bool context_changed = ctx->mailbox->changed;
- bool header_changed;
/* user didn't modify this message. alter the flags to match the
* current state on disk. This may not actually do
* context to match the current on-disk state of the
* message.
*/
- header_changed = o->changed;
+ bool header_changed = o->changed;
o->changed = false;
/* if the mailbox was not modified before we made these
}
/**
- * maildir_mbox_open - Open a Maildir mailbox
- * @param ctx Mailbox
- * @retval 0 Success
- * @retval -1 Failure
+ * maildir_mbox_open - Implements MxOps::mbox_open()
*/
static int maildir_mbox_open(struct Context *ctx)
{
char path[PATH_MAX];
char suffix[16];
char subdir[16];
- mode_t omask;
if (hdr)
{
else
mutt_str_strfcpy(subdir, "new", sizeof(subdir));
- omask = umask(mh_umask(ctx->mailbox));
+ mode_t omask = umask(mh_umask(ctx->mailbox));
while (true)
{
snprintf(path, sizeof(path), "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s",
struct MhSequences mhs = { 0 };
int count = 0;
struct Hash *fnames = NULL;
- int i;
struct MhData *data = mh_data(ctx->mailbox);
if (!CheckNew)
/* create .mh_sequences when there isn't one. */
snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->mailbox->path);
- i = stat(buf, &st_cur);
+ int i = stat(buf, &st_cur);
if ((i == -1) && (errno == ENOENT))
{
char *tmp = NULL;
}
/**
- * mh_msg_close - Close a message
- * @param ctx Mailbox
- * @param msg Message to close
- * @retval 0 Success
- * @retval EOF Error, see errno
+ * mh_msg_close - Implements MxOps::msg_close()
*
* @note May also return EOF Failure, see errno
*/