56 const char *new_file,
struct Email *e);
76 const char *flags = NULL;
80 flags =
edata->custom_flags;
90 char tmp[1024] = { 0 };
91 snprintf(tmp,
sizeof(tmp),
"%s%s%s%s%s", e->
flagged ?
"F" :
"", e->
replied ?
"R" :
"",
97 snprintf(dest, destlen,
"%c2,%s", c_maildir_field_delimiter, tmp);
114 const char *subfolder,
char **newname)
120 struct dirent *de = NULL;
125 buf_printf(dirname,
"%s/%s", folder, subfolder);
134 while ((de = readdir(dir)))
140 buf_printf(fname,
"%s/%s/%s", folder, subfolder, de->d_name);
171 static unsigned int new_hits = 0, cur_hits = 0;
177 (new_hits > cur_hits) ?
"new" :
"cur", newname);
178 if (fp || (errno != ENOENT))
180 if ((new_hits < UINT_MAX) && (cur_hits < UINT_MAX))
182 new_hits += ((new_hits > cur_hits) ? 1 : 0);
183 cur_hits += ((new_hits > cur_hits) ? 0 : 1);
189 (new_hits > cur_hits) ?
"cur" :
"new", newname);
190 if (fp || (errno != ENOENT))
192 if ((new_hits < UINT_MAX) && (cur_hits < UINT_MAX))
194 new_hits += ((new_hits > cur_hits) ? 0 : 1);
195 cur_hits += ((new_hits > cur_hits) ? 1 : 0);
221 struct Buffer *newpath = NULL;
222 struct Buffer *partpath = NULL;
223 struct Buffer *fullpath = NULL;
224 struct Buffer *oldpath = NULL;
239 char *p = strrchr(e->
path,
'/');
255 p = strchr(newpath->
data, c_maildir_field_delimiter);
278 struct stat st = { 0 };
317 if (e->
deleted && !c_maildir_trash)
362 char subdir[4] = { 0 };
373 char *s = strrchr(msg->
path,
'/') + 1;
378 s = strchr(s, c_maildir_field_delimiter);
403 struct utimbuf ut = { 0 };
411 }
while ((rc_utime == -1) && (errno == EINTR));
414 mutt_perror(
_(
"maildir_commit_message(): unable to set time on file"));
431 else if (errno != EEXIST)
462 long old_hdr_lines = e->
lines;
488 if ((rc == -1) && restore)
492 e->
lines = old_hdr_lines;
511 if (!msg->
fp && (errno == ENOENT))
536 char subdir[16] = { 0 };
540 struct Email tmp = *e;
556 mode_t old_umask = umask(new_umask);
561 snprintf(
path,
sizeof(
path),
"%s/tmp/%s.%lld.R%" PRIu64
".%s%s",
567 fd = open(
path, O_WRONLY | O_EXCL | O_CREAT, 0666);
588 msg->
fp = fdopen(fd,
"w");
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into 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.
#define mutt_numeric_cmp(a, b)
const char * cc_maildir_field_delimiter(void)
Get the cached value of $maildir_field_delimiter.
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.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
void mutt_body_free(struct Body **ptr)
Free a Body.
Structs that make up an email.
int mutt_file_safe_rename(const char *src, const char *target)
NFS-safe renaming of files.
DIR * mutt_file_opendir(const char *path, enum MuttOpenDirMode mode)
Open a directory.
int mutt_file_fsync_close(FILE **fp)
Flush the data, before closing a file (and NULL the pointer)
@ MUTT_OPENDIR_CREATE
Create the directory if it doesn't exist.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
char * ShortHostname
Short version of the hostname.
#define mutt_debug(LEVEL,...)
int maildir_msg_close(struct Mailbox *m, struct Message *msg)
Close an email - Implements MxOps::msg_close() -.
int maildir_msg_commit(struct Mailbox *m, struct Message *msg)
Save changes to an email - Implements MxOps::msg_commit() -.
bool maildir_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() -.
bool maildir_msg_open(struct Mailbox *m, struct Message *msg, struct Email *e)
Open an email message in a Mailbox - Implements MxOps::msg_open() -.
int maildir_msg_save_hcache(struct Mailbox *m, struct Email *e)
Save message to the header cache - Implements MxOps::msg_save_hcache() -.
static int maildir_sort_flags(const void *a, const void *b, void *sdata)
Compare two flag characters - Implements sort_t -.
@ LL_DEBUG3
Log at debug level 3.
@ LL_DEBUG2
Log at debug level 2.
@ LL_DEBUG1
Log at debug level 1.
struct MaildirEmailData * maildir_edata_get(struct Email *e)
Get the private data for this Email.
int maildir_hcache_store(struct HeaderCache *hc, struct Email *e)
Save an Email to the Header Cache.
struct HeaderCache * maildir_hcache_open(struct Mailbox *m)
Open the Header Cache.
int maildir_hcache_delete(struct HeaderCache *hc, struct Email *e)
Delete an Email from the Header Cache.
void maildir_hcache_close(struct HeaderCache **ptr)
Close the Header Cache.
static int maildir_sync_message(struct Mailbox *m, struct Email *e)
Sync an email to a Maildir folder.
int nm_update_filename(struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e)
Change the filename.
int maildir_rewrite_message(struct Mailbox *m, struct Email *e)
Sync a message in an Maildir folder.
FILE * maildir_open_find_message(const char *folder, const char *msg, char **newname)
Find a message by name.
static FILE * maildir_open_find_message_dir(const char *folder, const char *unique, const char *subfolder, char **newname)
Find a message in a maildir folder.
bool maildir_sync_mailbox_message(struct Mailbox *m, struct Email *e, struct HeaderCache *hc)
Save changes to the mailbox.
void maildir_gen_flags(char *dest, size_t destlen, struct Email *e)
Generate the Maildir flags for an email.
static int maildir_commit_message(struct Mailbox *m, struct Message *msg, struct Email *e)
Commit a message to a maildir folder.
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.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Convenience wrapper for the library headers.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
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.
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.
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.
void mutt_qsort_r(void *base, size_t nmemb, size_t size, sort_t compar, void *sdata)
Sort an array, where the comparator has access to opaque data rather than requiring global variables.
uint64_t mutt_rand64(void)
Create a 64-bit random number.
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.
char * dptr
Current read/write position.
char * data
Pointer to data.
The envelope/body of an email.
struct Envelope * env
Envelope information.
void * edata
Driver-specific data.
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?
bool replied
Email has been replied to.
char * path
Path of Email (for local Mailboxes)
bool deleted
Email is deleted.
bool trash
Message is marked as trashed on disk (used by the maildir_trash option)
unsigned char changed
Changed fields, e.g. MUTT_ENV_CHANGED_SUBJECT.
enum MailboxType type
Mailbox type.
Maildir-specific Email data -.
A local copy of an email.
FILE * fp
pointer to the message data
char * path
path to temp file
char * committed_path
the final path generated by mx_msg_commit()
time_t received
Time at which this message was received.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.