57#define MMC_NEW_DIR (1 << 0)
58#define MMC_CUR_DIR (1 << 1)
93 char *p = strrchr(
path, c_maildir_field_delimiter);
99 q =
edata->custom_flags;
120 if (!e->
flagged || !c_flag_safe)
136 if (q ==
edata->custom_flags)
155 if (!fp || !fname || !e)
270 const char *subdir,
struct Progress *progress)
272 struct dirent *de = NULL;
276 struct Email *e = NULL;
290 while (((de = readdir(dir))) && !
SigInt)
292 if (*de->d_name ==
'.')
308 entry->
inode = de->d_ino;
335 struct Progress *progress)
386 bool check_new,
bool check_stats)
389 struct dirent *de = NULL;
391 struct stat st = { 0 };
400 if (check_new && c_mail_check_recent)
409 if (!(check_new || check_stats))
421 char delimiter_version[8] = { 0 };
422 snprintf(delimiter_version,
sizeof(delimiter_version),
"%c2,", c_maildir_field_delimiter);
423 while ((de = readdir(dir)))
425 if (*de->d_name ==
'.')
428 p = strstr(de->d_name, delimiter_version);
429 if (p && strchr(p + 3,
'T'))
435 if (p && strchr(p + 3,
'F'))
438 if (!p || !strchr(p + 3,
'S'))
444 if (c_mail_check_recent)
488 struct Progress *progress = NULL;
541 struct stat st_new = { 0 };
542 struct stat st_cur = { 0 };
546 bool flags_changed =
false;
644 flags_changed =
true;
651 flags_changed =
true;
719 struct stat st = { 0 };
722 snprintf(buf,
sizeof(buf),
"%s/%s",
mailbox_path(m),
"cur");
723 if (stat(buf, &st) == 0)
726 snprintf(buf,
sizeof(buf),
"%s/%s",
mailbox_path(m),
"new");
727 if (stat(buf, &st) == 0)
764 if ((mkdir(tmp, S_IRWXU) != 0) && (errno != EEXIST))
773 if ((mkdir(tmp, S_IRWXU) != 0) && (errno != EEXIST))
784 if ((mkdir(tmp, S_IRWXU) != 0) && (errno != EEXIST))
812 bool check_new =
true;
825 check_new = !m->
has_new && c_maildir_check_cur;
826 if (check_new || check_stats)
846 struct Progress *progress = NULL;
876 for (
int i = 0, j = 0; i < m->
msg_count; i++)
882 if (!e->
deleted || c_maildir_trash)
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
#define ARRAY_SIZE(head)
The number of elements stored.
#define ARRAY_FREE(head)
Release all memory.
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
const char * cc_maildir_field_delimiter(void)
Get the cached value of $maildir_field_delimiter.
void mailbox_size_add(struct Mailbox *m, const struct Email *e)
Add an email's size to the total size of a Mailbox.
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
@ NT_MAILBOX_RESORT
Email list needs resorting.
@ NT_MAILBOX_INVALID
Email list was changed.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
struct Email * email_new(void)
Create a new Email.
void email_free(struct Email **ptr)
Free an Email.
Structs that make up an email.
struct Envelope * mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed)
Parses an RFC822 header.
void mutt_file_get_stat_timespec(struct timespec *dest, struct stat *st, enum MuttStatType type)
Read the stat() time into a time value.
int mutt_file_mkdir(const char *path, mode_t mode)
Recursively create directories.
long mutt_file_get_size_fp(FILE *fp)
Get the size of a file.
DIR * mutt_file_opendir(const char *path, enum MuttOpenDirMode mode)
Open a directory.
int mutt_file_stat_timespec_compare(struct stat *st, enum MuttStatType type, struct timespec *b)
Compare stat info with a time value.
@ MUTT_OPENDIR_CREATE
Create the directory if it doesn't exist.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
@ MUTT_STAT_CTIME
File/dir's ctime - creation time.
@ MUTT_STAT_MTIME
File/dir's mtime - last modified time.
void maildir_edata_free(void **ptr)
Free the private Email data - Implements Email::edata_free() -.
#define mutt_debug(LEVEL,...)
void maildir_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free() -.
enum MxStatus maildir_mbox_check_stats(struct Mailbox *m, uint8_t flags)
Check the Mailbox statistics - Implements MxOps::mbox_check_stats() -.
enum MxStatus maildir_mbox_check(struct Mailbox *m)
Check for new mail - Implements MxOps::mbox_check() -.
enum MxStatus maildir_mbox_close(struct Mailbox *m)
Close a Mailbox - Implements MxOps::mbox_close() -.
bool maildir_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags)
Open a Mailbox for appending - Implements MxOps::mbox_open_append() -.
enum MxOpenReturns maildir_mbox_open(struct Mailbox *m)
Open a Mailbox - Implements MxOps::mbox_open() -.
enum MxStatus maildir_mbox_sync(struct Mailbox *m)
Save changes to the Mailbox - Implements MxOps::mbox_sync() -.
static int maildir_sort_inode(const void *a, const void *b, void *sdata)
Compare two Maildirs by inode number - Implements sort_t -.
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
struct HashTable * mutt_hash_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with string keys)
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
#define MUTT_HASH_NO_FLAGS
No flags are set.
@ LL_DEBUG2
Log at debug level 2.
struct MaildirEmailData * maildir_edata_get(struct Email *e)
Get the private data for this Email.
struct MaildirEmailData * maildir_edata_new(void)
Create a new MaildirEmailData object.
int maildir_hcache_store(struct HeaderCache *hc, struct Email *e)
Save an Email to the Header Cache.
struct Email * maildir_hcache_read(struct HeaderCache *hc, struct Email *e, const char *fn)
Read an Email from the Header Cache.
struct HeaderCache * maildir_hcache_open(struct Mailbox *m)
Open the Header Cache.
void maildir_hcache_close(struct HeaderCache **ptr)
Close the Header Cache.
static enum MxStatus maildir_check(struct Mailbox *m)
Check for new mail.
static void maildir_delayed_parsing(struct Mailbox *m, struct MdEmailArray *mda, struct Progress *progress)
This function does the second parsing pass.
static int maildir_read_dir(struct Mailbox *m, const char *subdir)
Read a Maildir style mailbox.
bool maildir_parse_message(const char *fname, bool is_old, struct Email *e)
Actually parse a maildir message.
void maildir_update_mtime(struct Mailbox *m)
Update our record of the Maildir modification time.
static int maildir_move_to_mailbox(struct Mailbox *m, const struct MdEmailArray *mda)
Copy the Maildir list to the Mailbox.
#define MMC_CUR_DIR
'cur' directory changed
struct Email * maildir_email_new(void)
Create a Maildir Email.
#define MMC_NO_DIRS
No directories changed.
static void maildir_check_dir(struct Mailbox *m, const char *dir_name, bool check_new, bool check_stats)
Check for new mail / mail counts.
static int maildir_parse_dir(struct Mailbox *m, struct MdEmailArray *mda, const char *subdir, struct Progress *progress)
Read a Maildir mailbox.
#define MMC_NEW_DIR
'new' directory changed
bool maildir_parse_stream(FILE *fp, const char *fname, bool is_old, struct Email *e)
Parse a Maildir message.
void maildir_parse_flags(struct Email *e, const char *path)
Parse Maildir file flags.
struct MaildirMboxData * maildir_mdata_get(struct Mailbox *m)
Get the private data for this Mailbox.
struct MaildirMboxData * maildir_mdata_new(void)
Create a new MaildirMboxData object.
bool maildir_sync_mailbox_message(struct Mailbox *m, struct Email *e, struct HeaderCache *hc)
Save changes to the mailbox.
bool maildir_update_flags(struct Mailbox *m, struct Email *e_old, struct Email *e_new)
Update the mailbox flags.
mode_t maildir_umask(struct Mailbox *m)
Create a umask from the mailbox directory.
void maildir_canon_filename(struct Buffer *dest, const char *src)
Generate the canonical filename for a Maildir folder.
struct MdEmail * maildir_entry_new(void)
Create a new Maildir entry.
void maildirarray_clear(struct MdEmailArray *mda)
Free a Maildir array.
bool MonitorCurMboxChanged
Set to true when the current mailbox has changed.
Monitor files for changes.
Convenience wrapper for the library headers.
bool mutt_path_tidy(struct Buffer *path, bool is_dir)
Remove unnecessary parts of a path.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
void mx_alloc_memory(struct Mailbox *m, int req_size)
Create storage for the emails.
uint8_t OpenMailboxFlags
Flags for mutt_open_mailbox(), e.g. MUTT_NOSORT.
#define MUTT_NEWFOLDER
Create a new folder - same as MUTT_APPEND, but uses mutt_file_fopen() with mode "w" for mbox-style fo...
#define MUTT_MAILBOX_CHECK_STATS
Ignore mail_check_stats and calculate statistics (used by <check-stats>)
#define MUTT_APPEND
Open mailbox for appending messages.
MxOpenReturns
Return values for mbox_open()
@ MX_OPEN_ERROR
Open failed with an error.
@ MX_OPEN_OK
Open succeeded.
#define MUTT_APPENDNEW
Set in mx_open_mailbox_append if the mailbox doesn't exist.
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_sync(), and mbox_close()
@ MX_STATUS_ERROR
An error occurred.
@ MX_STATUS_OK
No changes.
@ MX_STATUS_FLAGS
Nondestructive flags change (IMAP)
@ MX_STATUS_REOPENED
Mailbox was reopened.
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Notmuch-specific Mailbox data.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
@ MUTT_PROGRESS_READ
Progress tracks elements, according to $read_inc
@ MUTT_PROGRESS_WRITE
Progress tracks elements, according to $write_inc
struct Progress * progress_new(enum ProgressType type, size_t size)
Create a new Progress Bar.
void progress_free(struct Progress **ptr)
Free a Progress Bar.
void progress_set_message(struct Progress *progress, const char *fmt,...) __attribute__((__format__(__printf__
bool progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
volatile sig_atomic_t SigInt
true after SIGINT is received
Assorted sorting methods.
#define mutt_numeric_cmp(a, b)
LOFF_T offset
offset where the actual data begins
LOFF_T length
length (in bytes) of attachment
String manipulation buffer.
The envelope/body of an email.
bool purge
Skip trash folder when deleting.
struct Envelope * env
Envelope information.
void * edata
Driver-specific data.
struct Body * body
List of MIME parts.
bool old
Email is seen, but unread.
void(* edata_free)(void **ptr)
bool changed
Email has been edited.
bool flagged
Marked important?
time_t date_sent
Time when the message was sent (UTC)
bool replied
Email has been replied to.
char * path
Path of Email (for local Mailboxes)
bool deleted
Email is deleted.
int index
The absolute (unsorted) message number.
bool trash
Message is marked as trashed on disk (used by the maildir_trash option)
time_t received
Time when the message was placed in the mailbox.
void(* mdata_free)(void **ptr)
bool changed
Mailbox has been modified.
bool has_new
Mailbox has new mail.
int msg_new
Number of new messages.
int msg_count
Total number of messages.
enum MailboxType type
Mailbox type.
void * mdata
Driver specific data.
struct Email ** emails
Array of Emails.
struct Buffer pathbuf
Path of the Mailbox.
int msg_deleted
Number of deleted messages.
int msg_flagged
Number of flagged messages.
struct timespec last_visited
Time of last exit from this mailbox.
bool verbose
Display status messages?
int msg_unread
Number of unread messages.
Maildir-specific Email data -.
Maildir-specific Mailbox data -.
struct timespec mtime_cur
Timestamp of the 'cur' dir.
mode_t umask
umask to use when creating files
struct timespec mtime
Time Mailbox was last changed.
bool header_parsed
Has the Email header been parsed?
char * canon_fname
Canonical filename for hashing.
struct Email * email
Temporary Email.
ino_t inode
Inode number of the file.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.