83 struct stat st = { 0 };
85 if ((snprintf(path,
sizeof(path),
"%s/%d",
mailbox_path(m), msgno) <
sizeof(path)) &&
86 (stat(path, &st) == 0))
106 if (!isdigit((
unsigned char) *s))
121 struct dirent *de = NULL;
127 while ((de = readdir(dir)))
147 struct dirent *de = NULL;
165 bool check_new =
true;
166 for (
int i = mhs.
max; i > 0; i--)
195 while ((de = readdir(dir)))
197 if (*de->d_name ==
'.')
227 if (!mutt_str_atoi_full(p, &i))
248 struct dirent *de = NULL;
249 char *cp = NULL, *dep = NULL;
250 unsigned int n, hi = 0;
252 char tmp[16] = { 0 };
268 while ((de = readdir(dir)))
276 if (!isdigit((
unsigned char) *cp))
296 snprintf(tmp,
sizeof(tmp),
"%u", hi);
297 snprintf(path,
sizeof(path),
"%s/%s",
mailbox_path(m), tmp);
306 else if (errno != EEXIST)
335 long old_hdr_lines = e->
lines;
382 if ((rc == -1) && restore)
386 e->
lines = old_hdr_lines;
422 struct stat st = { 0 };
425 snprintf(buf,
sizeof(buf),
"%s/.mh_sequences",
mailbox_path(m));
426 if (stat(buf, &st) == 0)
431 if (stat(buf, &st) == 0)
446 struct dirent *de = NULL;
449 struct Email *e = NULL;
461 while (((de = readdir(dir))) && !
SigInt)
550 struct Progress *progress)
571 size_t keylen = strlen(key);
591 keylen = strlen(key);
671 struct Progress *progress = NULL;
743 const char *key = e->
path;
744 size_t keylen = strlen(key);
758 if (rename(path, tmp) != 0)
774 const char *key = e->
path;
775 size_t keylen = strlen(key);
837 snprintf(tmp,
sizeof(tmp),
"%s/.mh_sequences",
mailbox_path(m));
838 const int i = creat(tmp, S_IRWXU);
865 bool context_changed = m->
changed;
878 if (e_old->
old != e_new->
old)
885 bool header_changed = e_old->
changed;
891 if (!context_changed)
894 return header_changed;
912 struct stat st = { 0 };
913 struct stat st_cur = { 0 };
914 bool modified =
false, occult =
false, flags_changed =
false;
925 if (stat(buf, &st) == -1)
929 snprintf(buf,
sizeof(buf),
"%s/.mh_sequences",
mailbox_path(m));
930 int rc = stat(buf, &st_cur);
931 if ((rc == -1) && (errno == ENOENT))
945 if ((rc == -1) && (stat(buf, &st_cur) == -1))
1010 flags_changed =
true;
1077 struct Progress *progress = NULL;
1111 for (
int i = 0, j = 0; i < m->
msg_count; i++)
1201 if (!st || !S_ISDIR(st->st_mode))
1206 snprintf(tmp,
sizeof(tmp),
"%s/.mh_sequences",
path);
1207 if (access(tmp, F_OK) == 0)
1210 snprintf(tmp,
sizeof(tmp),
"%s/.xmhcache",
path);
1211 if (access(tmp, F_OK) == 0)
1214 snprintf(tmp,
sizeof(tmp),
"%s/.mew_cache",
path);
1215 if (access(tmp, F_OK) == 0)
1218 snprintf(tmp,
sizeof(tmp),
"%s/.mew-cache",
path);
1219 if (access(tmp, F_OK) == 0)
1222 snprintf(tmp,
sizeof(tmp),
"%s/.sylpheed_cache",
path);
1223 if (access(tmp, F_OK) == 0)
1229 snprintf(tmp,
sizeof(tmp),
"%s/.overview",
path);
1230 if (access(tmp, F_OK) == 0)
1256 .msg_padding_size = NULL,
1259 .tags_commit = NULL,
#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.
const char * mutt_str_atoui(const char *str, unsigned int *dst)
Convert ASCII string to an unsigned integer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Convenience wrapper for the config headers.
char * HomeDir
User's home directory.
int mutt_copy_message(FILE *fp_out, struct Email *e, struct Message *msg, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
Duplicate the structure of an entire email.
#define MUTT_CM_UPDATE
Update structs on sync.
#define CH_UPDATE
Update the status and x-status fields?
#define CH_UPDATE_LEN
Update Lines: and Content-Length:
Convenience wrapper for the core headers.
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.
MailboxType
Supported mailbox formats.
@ MUTT_MH
'MH' Mailbox type
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
void mutt_body_free(struct Body **ptr)
Free a Body.
bool email_cmp_strict(const struct Email *e1, const struct Email *e2)
Strictly compare message emails.
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.
EmailSortType
Methods for sorting Emails.
@ EMAIL_SORT_UNSORTED
Sort by the order the messages appear in the mailbox.
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_safe_rename(const char *src, const char *target)
NFS-safe renaming of files.
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.
int mutt_file_fsync_close(FILE **fp)
Flush the data, before closing a file (and NULL the pointer)
@ MUTT_OPENDIR_NONE
Plain opendir()
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
@ MUTT_STAT_MTIME
File/dir's mtime - last modified time.
void mutt_set_flag(struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool upd_mbox)
Set a flag on an email.
#define mutt_debug(LEVEL,...)
void mh_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free() -.
static bool mh_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Implements MxOps::ac_add() -.
static bool mh_ac_owns_path(struct Account *a, const char *path)
Check whether an Account owns a Mailbox path - Implements MxOps::ac_owns_path() -.
const struct MxOps MxMhOps
MH Mailbox - Implements MxOps -.
static enum MxStatus mh_mbox_check_stats(struct Mailbox *m, uint8_t flags)
Check the Mailbox statistics - Implements MxOps::mbox_check_stats() -.
static enum MxStatus mh_mbox_check(struct Mailbox *m)
Check for new mail - Implements MxOps::mbox_check() -.
static enum MxStatus mh_mbox_close(struct Mailbox *m)
Close a Mailbox - Implements MxOps::mbox_close() -.
static bool mh_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags)
Open a Mailbox for appending - Implements MxOps::mbox_open_append() -.
static enum MxOpenReturns mh_mbox_open(struct Mailbox *m)
Open a Mailbox - Implements MxOps::mbox_open() -.
static enum MxStatus mh_mbox_sync(struct Mailbox *m)
Save changes to the Mailbox - Implements MxOps::mbox_sync() -.
static int mh_msg_close(struct Mailbox *m, struct Message *msg)
Close an email - Implements MxOps::msg_close() -.
static int mh_msg_commit(struct Mailbox *m, struct Message *msg)
Save changes to an email - Implements MxOps::msg_commit() -.
static bool mh_msg_open_new(struct Mailbox *m, struct Message *msg, const struct Email *e)
Open a new message in a Mailbox - Implements MxOps::msg_open_new() -.
static bool mh_msg_open(struct Mailbox *m, struct Message *msg, struct Email *e)
Open an email message in a Mailbox - Implements MxOps::msg_open() -.
static int mh_msg_save_hcache(struct Mailbox *m, struct Email *e)
Save message to the header cache - Implements MxOps::msg_save_hcache() -.
static int mh_path_canon(struct Buffer *path)
Canonicalise a Mailbox path - Implements MxOps::path_canon() -.
static enum MailboxType mh_path_probe(const char *path, const struct stat *st)
Is this an mh Mailbox? - Implements MxOps::path_probe() -.
static int mh_sort_path(const void *a, const void *b, void *sdata)
Compare two Mh Mailboxes by path - 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.
struct HeaderCache * hcache_open(const char *path, const char *folder, hcache_namer_t namer, bool create)
Multiplexor for StoreOps::open.
int hcache_delete_email(struct HeaderCache *hc, const char *key, size_t keylen)
Multiplexor for StoreOps::delete_record.
void hcache_close(struct HeaderCache **ptr)
Multiplexor for StoreOps::close.
struct HCacheEntry hcache_fetch_email(struct HeaderCache *hc, const char *key, size_t keylen, uint32_t uidvalidity)
Multiplexor for StoreOps::fetch.
int hcache_store_email(struct HeaderCache *hc, const char *key, size_t keylen, struct Email *e, uint32_t uidvalidity)
Multiplexor for StoreOps::store.
Header cache multiplexor.
@ LL_DEBUG3
Log at debug level 3.
@ LL_DEBUG2
Log at debug level 2.
struct MhMboxData * mh_mdata_get(struct Mailbox *m)
Get the private data for this Mailbox.
struct MhMboxData * mh_mdata_new(void)
Create a new MhMboxData object.
bool mh_mkstemp(struct Mailbox *m, FILE **fp, char **tgt)
Create a temporary file.
mode_t mh_umask(struct Mailbox *m)
Create a umask from the mailbox directory.
static bool mh_update_flags(struct Mailbox *m, struct Email *e_old, struct Email *e_new)
Update the mailbox flags.
static void mh_update_mtime(struct Mailbox *m)
Update our record of the mailbox modification time.
int mh_check_empty(struct Buffer *path)
Is mailbox empty.
static bool mh_valid_message(const char *s)
Is this a valid MH message filename.
static int mh_parse_dir(struct Mailbox *m, struct MhEmailArray *mha, struct Progress *progress)
Read an Mh mailbox.
static int mh_sync_message(struct Mailbox *m, struct Email *e)
Sync an email to an MH folder.
static enum MxStatus mh_check(struct Mailbox *m)
Check for new mail.
int mh_sync_mailbox_message(struct Mailbox *m, struct Email *e, struct HeaderCache *hc)
Save changes to the mailbox.
static int mh_commit_msg(struct Mailbox *m, struct Message *msg, struct Email *e, bool updseq)
Commit a message to an MH folder.
static int mh_already_notified(struct Mailbox *m, int msgno)
Has the message changed.
static void mh_delayed_parsing(struct Mailbox *m, struct MhEmailArray *mha, struct Progress *progress)
This function does the second parsing pass.
static void mh_update_emails(struct MhEmailArray *mha, struct MhSequences *mhs)
Update our record of flags.
static bool mh_read_dir(struct Mailbox *m)
Read an MH mailbox.
static int mh_move_to_mailbox(struct Mailbox *m, const struct MhEmailArray *mha)
Copy the Mh list to the Mailbox.
static struct Email * mh_parse_message(const char *fname, struct Email *e)
Actually parse an MH message.
static int mh_rewrite_message(struct Mailbox *m, struct Email *e)
Sync a message in an MH folder.
struct MhEmail * mh_entry_new(void)
Create a new Mh entry.
void mharray_clear(struct MhEmailArray *mha)
Free a Mh 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_path_canon(struct Buffer *path, const char *homedir, bool is_dir)
Create the canonical version of a path.
int mutt_str_cmp(const char *a, const char *b)
Compare two strings, safely.
char * mutt_str_dup(const char *str)
Copy a string, safely.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Many unsorted constants and some structs.
@ MUTT_READ
Messages that have been read.
@ MUTT_FLAG
Flagged messages.
@ MUTT_REPLIED
Messages that have been replied to.
void mx_alloc_memory(struct Mailbox *m, int req_size)
Create storage for the emails.
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
#define MUTT_MSG_NO_FLAGS
No flags are set.
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...
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.
Prototypes for many functions.
void mh_seq_add_one(struct Mailbox *m, int n, bool unseen, bool flagged, bool replied)
Update the flags for one sequence.
MhSeqFlags mh_seq_check(struct MhSequences *mhs, int i)
Get the flags for a given sequence.
void mh_seq_free(struct MhSequences *mhs)
Free some sequences.
int mh_seq_changed(struct Mailbox *m)
Has the mailbox changed.
void mh_seq_update(struct Mailbox *m)
Update sequence numbers.
int mh_seq_read(struct MhSequences *mhs, const char *path)
Read a set of MH sequences.
#define MH_SEQ_UNSEEN
Email hasn't been read.
#define MH_SEQ_REPLIED
Email has been replied to.
uint8_t MhSeqFlags
Flags, e.g. MH_SEQ_UNSEEN.
#define MH_SEQ_FLAGGED
Email is flagged.
volatile sig_atomic_t SigInt
true after SIGINT is received
A group of associated Mailboxes.
struct Body * parts
parts of a multipart or message/rfc822
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.
struct Envelope * env
Envelope information.
int lines
How many lines in the body of this message?
struct Body * body
List of MIME parts.
bool old
Email is seen, but unread.
bool changed
Email has been edited.
bool attach_del
Has an attachment marked for deletion.
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.
time_t received
Time when the message was placed in the mailbox.
unsigned char changed
Changed fields, e.g. MUTT_ENV_CHANGED_SUBJECT.
Wrapper for Email retrieved from the header cache.
struct Email * email
Retrieved email.
void(* mdata_free)(void **ptr)
bool changed
Mailbox has been modified.
bool has_new
Mailbox has new mail.
int msg_count
Total number of messages.
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.
A local copy of an email.
FILE * fp
pointer to the message data
char * path
path to temp file
bool replied
Message has been replied to.
char * committed_path
the final path generated by mx_msg_commit()
bool flagged
Message is flagged.
bool read
Message has been read.
struct Message::@0 flags
Flags for the Message.
bool header_parsed
Has the Email header been parsed?
struct Email * email
Temporary Email.
char * canon_fname
Canonical filename for hashing.
Mh-specific Mailbox data -.
mode_t umask
umask to use when creating files
Set of MH sequence numbers.
int max
Number of flags stored.
enum MailboxType type
Mailbox type, e.g. MUTT_IMAP.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.