extern struct MxOps mx_maildir_ops;
extern struct MxOps mx_mh_ops;
-int maildir_check_empty(const char *path);
-void maildir_gen_flags(char *dest, size_t destlen, struct Email *e);
-FILE * maildir_open_find_message(const char *folder, const char *msg, char **newname);
-void maildir_parse_flags(struct Email *e, const char *path);
+int maildir_check_empty(const char *path);
+void maildir_gen_flags(char *dest, size_t destlen, struct Email *e);
+FILE * maildir_open_find_message(const char *folder, const char *msg, char **newname);
+void maildir_parse_flags(struct Email *e, const char *path);
struct Email *maildir_parse_message(enum MailboxType magic, const char *fname, bool is_old, struct Email *e);
struct Email *maildir_parse_stream(enum MailboxType magic, FILE *f, const char *fname, bool is_old, struct Email *e);
-bool maildir_update_flags(struct Context *ctx, struct Email *o, struct Email *n);
+bool maildir_update_flags(struct Context *ctx, struct Email *o, struct Email *n);
-bool mh_mailbox(struct Mailbox *mailbox, bool check_stats);
-int mh_check_empty(const char *path);
+bool mh_mailbox(struct Mailbox *mailbox, bool check_stats);
+int mh_check_empty(const char *path);
-int maildir_path_probe(const char *path, const struct stat *st);
-int mh_path_probe(const char *path, const struct stat *st);
+int maildir_path_probe(const char *path, const struct stat *st);
+int mh_path_probe(const char *path, const struct stat *st);
#ifdef USE_HCACHE
-int mh_sync_mailbox_message(struct Context *ctx, int msgno, header_cache_t *hc);
+int mh_sync_mailbox_message(struct Context *ctx, int msgno, header_cache_t *hc);
#else
-int mh_sync_mailbox_message(struct Context *ctx, int msgno);
+int mh_sync_mailbox_message(struct Context *ctx, int msgno);
#endif
#endif /* MUTT_MAILDIR_MAILDIR_H */
};
/**
- * struct MhData - MH-specific mailbox data
+ * struct MaildirMboxData - Maildir-specific mailbox data
*/
-struct MhData
+struct MaildirMboxData
{
struct timespec mtime_cur;
mode_t mh_umask;
};
/**
- * mh_data - Extract the MhData from the mailbox
- * @param mailbox Mailbox
- * @retval ptr MhData
+ * maildir_get_mdata - Get the private data for this Mailbox
+ * @param m Mailbox
+ * @retval ptr MaildirMboxData
*/
-static inline struct MhData *mh_data(struct Mailbox *mailbox)
+static struct MaildirMboxData *maildir_get_mdata(struct Mailbox *m)
{
- return mailbox->data;
+ if (!m || ((m->magic != MUTT_MAILDIR) && (m->magic != MUTT_MH)))
+ return NULL;
+ return m->data;
}
/**
*/
static inline mode_t mh_umask(struct Mailbox *mailbox)
{
- struct MhData *data = mh_data(mailbox);
- if (data && data->mh_umask)
- return data->mh_umask;
+ struct MaildirMboxData *mdata = maildir_get_mdata(mailbox);
+ if (mdata && mdata->mh_umask)
+ return mdata->mh_umask;
struct stat st;
if (stat(mailbox->path, &st))
{
char buf[PATH_MAX];
struct stat st;
- struct MhData *data = mh_data(mailbox);
+ struct MaildirMboxData *mdata = maildir_get_mdata(mailbox);
if (mailbox->magic == MUTT_MAILDIR)
{
snprintf(buf, sizeof(buf), "%s/%s", mailbox->path, "cur");
if (stat(buf, &st) == 0)
- mutt_get_stat_timespec(&data->mtime_cur, &st, MUTT_STAT_MTIME);
+ mutt_get_stat_timespec(&mdata->mtime_cur, &st, MUTT_STAT_MTIME);
snprintf(buf, sizeof(buf), "%s/%s", mailbox->path, "new");
}
else
{
snprintf(buf, sizeof(buf), "%s/.mh_sequences", mailbox->path);
if (stat(buf, &st) == 0)
- mutt_get_stat_timespec(&data->mtime_cur, &st, MUTT_STAT_MTIME);
+ mutt_get_stat_timespec(&mdata->mtime_cur, &st, MUTT_STAT_MTIME);
mutt_str_strfcpy(buf, mailbox->path, sizeof(buf));
}
if (!ctx->mailbox->data)
{
- ctx->mailbox->data = mutt_mem_calloc(1, sizeof(struct MhData));
+ ctx->mailbox->data = mutt_mem_calloc(1, sizeof(struct MaildirMboxData));
}
- struct MhData *data = mh_data(ctx->mailbox);
+ struct MaildirMboxData *mdata = maildir_get_mdata(ctx->mailbox);
maildir_update_mtime(ctx->mailbox);
maildir_move_to_context(ctx, &md);
- if (!data->mh_umask)
- data->mh_umask = mh_umask(ctx->mailbox);
+ if (!mdata->mh_umask)
+ mdata->mh_umask = mh_umask(ctx->mailbox);
return 0;
}
int count = 0;
struct Hash *fnames = NULL; /* hash table for quickly looking up the base filename
for a maildir message */
- struct MhData *data = mh_data(ctx->mailbox);
+ struct MaildirMboxData *mdata = maildir_get_mdata(ctx->mailbox);
/* XXX seems like this check belongs in mx_mbox_check() rather than here. */
if (!CheckNew)
/* determine which subdirectories need to be scanned */
if (mutt_stat_timespec_compare(&st_new, MUTT_STAT_MTIME, &ctx->mailbox->mtime) > 0)
changed = 1;
- if (mutt_stat_timespec_compare(&st_cur, MUTT_STAT_MTIME, &data->mtime_cur) > 0)
+ if (mutt_stat_timespec_compare(&st_cur, MUTT_STAT_MTIME, &mdata->mtime_cur) > 0)
changed |= 2;
if (!changed)
else
#endif
{
- mutt_get_stat_timespec(&data->mtime_cur, &st_cur, MUTT_STAT_MTIME);
+ mutt_get_stat_timespec(&mdata->mtime_cur, &st_cur, MUTT_STAT_MTIME);
mutt_get_stat_timespec(&ctx->mailbox->mtime, &st_new, MUTT_STAT_MTIME);
}
struct MhSequences mhs = { 0 };
int count = 0;
struct Hash *fnames = NULL;
- struct MhData *data = mh_data(ctx->mailbox);
+ struct MaildirMboxData *mdata = maildir_get_mdata(ctx->mailbox);
if (!CheckNew)
return 0;
modified = true;
if ((mutt_stat_timespec_compare(&st, MUTT_STAT_MTIME, &ctx->mailbox->mtime) > 0) ||
- (mutt_stat_timespec_compare(&st_cur, MUTT_STAT_MTIME, &data->mtime_cur) > 0))
+ (mutt_stat_timespec_compare(&st_cur, MUTT_STAT_MTIME, &mdata->mtime_cur) > 0))
{
modified = true;
}
else
#endif
{
- mutt_get_stat_timespec(&data->mtime_cur, &st_cur, MUTT_STAT_MTIME);
+ mutt_get_stat_timespec(&mdata->mtime_cur, &st_cur, MUTT_STAT_MTIME);
mutt_get_stat_timespec(&ctx->mailbox->mtime, &st, MUTT_STAT_MTIME);
}