57 const char *new_file,
struct Email *e);
77 const char *flags = NULL;
81 flags =
edata->custom_flags;
91 char tmp[1024] = { 0 };
92 snprintf(tmp,
sizeof(tmp),
"%s%s%s%s%s", e->
flagged ?
"F" :
"", e->
replied ?
"R" :
"",
98 snprintf(dest, destlen,
"%c2,%s", c_maildir_field_delimiter, tmp);
115 const char *subfolder,
char **newname)
121 struct dirent *de = NULL;
126 buf_printf(dirname,
"%s/%s", folder, subfolder);
135 while ((de = readdir(dir)))
141 buf_printf(fname,
"%s/%s/%s", folder, subfolder, de->d_name);
172 static unsigned int new_hits = 0, cur_hits = 0;
178 (new_hits > cur_hits) ?
"new" :
"cur", newname);
179 if (fp || (errno != ENOENT))
181 if ((new_hits < UINT_MAX) && (cur_hits < UINT_MAX))
183 new_hits += ((new_hits > cur_hits) ? 1 : 0);
184 cur_hits += ((new_hits > cur_hits) ? 0 : 1);
190 (new_hits > cur_hits) ?
"cur" :
"new", newname);
191 if (fp || (errno != ENOENT))
193 if ((new_hits < UINT_MAX) && (cur_hits < UINT_MAX))
195 new_hits += ((new_hits > cur_hits) ? 0 : 1);
196 cur_hits += ((new_hits > cur_hits) ? 1 : 0);
222 struct Buffer *newpath = NULL;
223 struct Buffer *partpath = NULL;
224 struct Buffer *fullpath = NULL;
225 struct Buffer *oldpath = NULL;
240 char *p = strrchr(e->
path,
'/');
256 p = strchr(newpath->
data, c_maildir_field_delimiter);
279 struct stat st = { 0 };
318 if (e->
deleted && !c_maildir_trash)
363 char subdir[4] = { 0 };
374 char *s = strrchr(msg->
path,
'/') + 1;
379 s = strchr(s, c_maildir_field_delimiter);
404 struct utimbuf ut = { 0 };
412 }
while ((rc_utime == -1) && (errno == EINTR));
415 mutt_perror(
_(
"maildir_commit_message(): unable to set time on file"));
432 else if (errno != EEXIST)
463 long old_hdr_lines = e->
lines;
489 if ((rc == -1) && restore)
493 e->
lines = old_hdr_lines;
512 if (!msg->
fp && (errno == ENOENT))
537 char subdir[16] = { 0 };
541 struct Email tmp = *e;
557 mode_t old_umask = umask(new_umask);
562 snprintf(
path,
sizeof(
path),
"%s/tmp/%s.%lld.R%" PRIu64
".%s%s",
568 fd = open(
path, O_WRONLY | O_EXCL | O_CREAT, 0666);
589 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.
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.
Assorted sorting methods.
#define mutt_numeric_cmp(a, b)
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.