NeoMutt  2025-12-11-980-ge38c27
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
message.c File Reference

Maildir Message. More...

#include "config.h"
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <utime.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "message.h"
#include "edata.h"
#include "globals.h"
#include "hcache.h"
#include "mx.h"
#include "shared.h"
+ Include dependency graph for message.c:

Go to the source code of this file.

Functions

int nm_update_filename (struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e)
 Change the filename.
 
static int maildir_sort_flags (const void *a, const void *b, void *sdata)
 Compare two flag characters - Implements sort_t -.
 
void maildir_gen_flags (char *dest, size_t destlen, struct Email *e)
 Generate the Maildir flags for an email.
 
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.
 
FILE * maildir_open_find_message (const char *folder, const char *msg, char **newname)
 Find a message by name.
 
static int maildir_sync_message (struct Mailbox *m, struct Email *e)
 Sync an email to a Maildir folder.
 
bool maildir_sync_mailbox_message (struct Mailbox *m, struct Email *e, struct HeaderCache *hc)
 Save changes to the mailbox.
 
static int maildir_commit_message (struct Mailbox *m, struct Message *msg, struct Email *e)
 Commit a message to a maildir folder.
 
int maildir_rewrite_message (struct Mailbox *m, struct Email *e)
 Sync a message in an Maildir folder.
 
bool maildir_msg_open (struct Mailbox *m, struct Message *msg, struct Email *e)
 Open an email message in a Mailbox - Implements MxOps::msg_open() -.
 
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() -.
 
int maildir_msg_commit (struct Mailbox *m, struct Message *msg)
 Save changes to an email - Implements MxOps::msg_commit() -.
 
int maildir_msg_close (struct Mailbox *m, struct Message *msg)
 Close an email - Implements MxOps::msg_close() -.
 
int maildir_msg_save_hcache (struct Mailbox *m, struct Email *e)
 Save message to the header cache - Implements MxOps::msg_save_hcache() -.
 

Detailed Description

Maildir Message.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file message.c.

Function Documentation

◆ nm_update_filename()

int nm_update_filename ( struct Mailbox * m,
const char * old_file,
const char * new_file,
struct Email * e )

Change the filename.

Parameters
mMailbox
old_fileOld filename
new_fileNew filename
eEmail
Return values
0Success
-1Failure

Definition at line 1811 of file notmuch.c.

1813{
1814 char buf[PATH_MAX] = { 0 };
1815 struct NmMboxData *mdata = nm_mdata_get(m);
1816 if (!mdata || !new_file)
1817 return -1;
1818
1819 if (!old_file && nm_edata_get(e))
1820 {
1821 email_get_fullpath(e, buf, sizeof(buf));
1822 old_file = buf;
1823 }
1824
1825 int rc = rename_filename(m, old_file, new_file, e);
1826
1827 nm_db_release(m);
1828 mdata->mtime.tv_sec = mutt_date_now();
1829 mdata->mtime.tv_nsec = 0;
1830 return rc;
1831}
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Definition date.c:459
#define PATH_MAX
Definition mutt.h:49
int nm_db_release(struct Mailbox *m)
Close the Notmuch database.
Definition db.c:245
struct NmEmailData * nm_edata_get(struct Email *e)
Get the Notmuch Email data.
Definition edata.c:72
struct NmMboxData * nm_mdata_get(struct Mailbox *m)
Get the Notmuch Mailbox data.
Definition mdata.c:96
static char * email_get_fullpath(struct Email *e, char *buf, size_t buflen)
Get the full path of an email.
Definition notmuch.c:230
static int rename_filename(struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e)
Rename the file.
Definition notmuch.c:1367
void * mdata
Driver specific data.
Definition mailbox.h:134
Notmuch-specific Mailbox data -.
Definition mdata.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maildir_gen_flags()

void maildir_gen_flags ( char * dest,
size_t destlen,
struct Email * e )

Generate the Maildir flags for an email.

Parameters
destBuffer for the result
destlenLength of buffer
eEmail

Definition at line 71 of file message.c.

72{
73 *dest = '\0';
74
75 const char *flags = NULL;
76
78 if (edata)
79 flags = edata->custom_flags;
80
81 /* The maildir specification requires that all files in the cur
82 * subdirectory have the :unique string appended, regardless of whether
83 * or not there are any flags. If .old is set, we know that this message
84 * will end up in the cur directory, so we include it in the following
85 * test even though there is no associated flag. */
86
87 if (e->flagged || e->replied || e->read || e->deleted || e->old || flags)
88 {
89 char tmp[1024] = { 0 };
90 snprintf(tmp, sizeof(tmp), "%s%s%s%s%s", e->flagged ? "F" : "", e->replied ? "R" : "",
91 e->read ? "S" : "", e->deleted ? "T" : "", NONULL(flags));
92 if (flags)
93 mutt_qsort_r(tmp, strlen(tmp), 1, maildir_sort_flags, NULL);
94
95 const char c_maildir_field_delimiter = *cc_maildir_field_delimiter();
96 snprintf(dest, destlen, "%c2,%s", c_maildir_field_delimiter, tmp);
97 }
98}
const char * cc_maildir_field_delimiter(void)
Get the cached value of $maildir_field_delimiter.
static int maildir_sort_flags(const void *a, const void *b, void *sdata)
Compare two flag characters - Implements sort_t -.
Definition message.c:60
struct MaildirEmailData * maildir_edata_get(struct Email *e)
Get the private data for this Email.
Definition edata.c:63
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.
Definition qsort_r.c:72
#define NONULL(x)
Definition string2.h:44
bool read
Email is read.
Definition email.h:50
void * edata
Driver-specific data.
Definition email.h:74
bool old
Email is seen, but unread.
Definition email.h:49
bool flagged
Marked important?
Definition email.h:47
bool replied
Email has been replied to.
Definition email.h:51
bool deleted
Email is deleted.
Definition email.h:78
Maildir-specific Email data -.
Definition edata.h:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maildir_open_find_message_dir()

static FILE * maildir_open_find_message_dir ( const char * folder,
const char * unique,
const char * subfolder,
char ** newname )
static

Find a message in a maildir folder.

Parameters
[in]folderBase folder
[in]uniqueUnique part of filename
[in]subfolderSubfolder to search, e.g. 'cur'
[out]newnameFile's new name
Return values
ptrFile handle

These functions try to find a message in a maildir folder when it has moved under our feet. Note that this code is rather expensive, but then again, it's called rarely.

Definition at line 112 of file message.c.

114{
115 struct Buffer *dirname = buf_pool_get();
116 struct Buffer *tunique = buf_pool_get();
117 struct Buffer *fname = buf_pool_get();
118
119 struct dirent *de = NULL;
120
121 FILE *fp = NULL;
122 int oe = ENOENT;
123
124 buf_printf(dirname, "%s/%s", folder, subfolder);
125
127 if (!dir)
128 {
129 errno = ENOENT;
130 goto cleanup;
131 }
132
133 while ((de = readdir(dir)))
134 {
135 maildir_canon_filename(tunique, de->d_name);
136
137 if (mutt_str_equal(buf_string(tunique), unique))
138 {
139 buf_printf(fname, "%s/%s/%s", folder, subfolder, de->d_name);
140 fp = mutt_file_fopen(buf_string(fname), "r");
141 oe = errno;
142 break;
143 }
144 }
145
146 closedir(dir);
147
148 if (newname && fp)
149 *newname = buf_strdup(fname);
150
151 errno = oe;
152
153cleanup:
154 buf_pool_release(&dirname);
155 buf_pool_release(&tunique);
156 buf_pool_release(&fname);
157
158 return fp;
159}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:168
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition buffer.c:577
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
DIR * mutt_file_opendir(const char *path, enum MuttOpenDirMode mode)
Open a directory.
Definition file.c:535
@ MUTT_OPENDIR_CREATE
Create the directory if it doesn't exist.
Definition file.h:69
#define mutt_file_fopen(PATH, MODE)
Definition file.h:143
void maildir_canon_filename(struct Buffer *dest, const char *src)
Generate the canonical filename for a Maildir folder.
Definition shared.c:72
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:666
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
String manipulation buffer.
Definition buffer.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maildir_open_find_message()

FILE * maildir_open_find_message ( const char * folder,
const char * msg,
char ** newname )

Find a message by name.

Parameters
[in]folderMaildir path
[in]msgEmail path
[out]newnameNew name, if it has moved
Return values
ptrFile handle

Definition at line 168 of file message.c.

169{
170 static unsigned int new_hits = 0;
171 static unsigned int cur_hits = 0; /* simple dynamic optimization */
172
173 struct Buffer *unique = buf_pool_get();
174 maildir_canon_filename(unique, msg);
175
176 /* Prevent counter saturation by halving both when either gets large */
177 if ((new_hits > (UINT_MAX / 2)) || (cur_hits > (UINT_MAX / 2)))
178 {
179 new_hits /= 2;
180 cur_hits /= 2;
181 }
182
183 FILE *fp = maildir_open_find_message_dir(folder, buf_string(unique),
184 (new_hits > cur_hits) ? "new" : "cur", newname);
185 if (fp || (errno != ENOENT))
186 {
187 if (new_hits > cur_hits)
188 new_hits++;
189 else
190 cur_hits++;
191
192 goto cleanup;
193 }
194 fp = maildir_open_find_message_dir(folder, buf_string(unique),
195 (new_hits > cur_hits) ? "cur" : "new", newname);
196 if (fp || (errno != ENOENT))
197 {
198 if (new_hits > cur_hits)
199 cur_hits++;
200 else
201 new_hits++;
202
203 goto cleanup;
204 }
205
206 fp = NULL;
207
208cleanup:
209 buf_pool_release(&unique);
210
211 return fp;
212}
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.
Definition message.c:112
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maildir_sync_message()

static int maildir_sync_message ( struct Mailbox * m,
struct Email * e )
static

Sync an email to a Maildir folder.

Parameters
mMailbox
eEmail
Return values
0Success
-1Error

Definition at line 221 of file message.c.

222{
223 if (!m || !e)
224 return -1;
225
226 struct Buffer *newpath = NULL;
227 struct Buffer *partpath = NULL;
228 struct Buffer *fullpath = NULL;
229 struct Buffer *oldpath = NULL;
230 char suffix[PATH_MAX] = { 0 };
231 int rc = 0;
232
233 if (e->attach_del || e->env->changed)
234 {
235 /* when doing attachment deletion/rethreading, fall back to the maildir case. */
236 if (maildir_rewrite_message(m, e) != 0)
237 return -1;
238 e->env->changed = false;
239 }
240 else
241 {
242 /* we just have to rename the file. */
243
244 char *p = strrchr(e->path, '/');
245 if (!p)
246 {
247 mutt_debug(LL_DEBUG1, "%s: unable to find subdir!\n", e->path);
248 return -1;
249 }
250 p++;
251 newpath = buf_pool_get();
252 partpath = buf_pool_get();
253 fullpath = buf_pool_get();
254 oldpath = buf_pool_get();
255
256 buf_strcpy(newpath, p);
257
258 /* kill the previous flags */
259 const char c_maildir_field_delimiter = *cc_maildir_field_delimiter();
260 p = strchr(newpath->data, c_maildir_field_delimiter);
261 if (p)
262 {
263 *p = '\0';
264 newpath->dptr = p; /* fix buffer up, just to be safe */
265 }
266
267 maildir_gen_flags(suffix, sizeof(suffix), e);
268
269 buf_printf(partpath, "%s/%s%s", (e->read || e->old) ? "cur" : "new",
270 buf_string(newpath), suffix);
271 buf_printf(fullpath, "%s/%s", mailbox_path(m), buf_string(partpath));
272 buf_printf(oldpath, "%s/%s", mailbox_path(m), e->path);
273
274 if (mutt_str_equal(buf_string(fullpath), buf_string(oldpath)))
275 {
276 /* message hasn't really changed */
277 goto cleanup;
278 }
279
280 /* record that the message is possibly marked as trashed on disk */
281 e->trash = e->deleted;
282
283 struct stat st = { 0 };
284 if (stat(buf_string(oldpath), &st) == -1)
285 {
286 mutt_debug(LL_DEBUG1, "File already removed (just continuing)\n");
287 goto cleanup;
288 }
289
290 if (rename(buf_string(oldpath), buf_string(fullpath)) != 0)
291 {
292 mutt_perror("rename");
293 rc = -1;
294 goto cleanup;
295 }
296 mutt_str_replace(&e->path, buf_string(partpath));
297 }
298
299cleanup:
300 buf_pool_release(&newpath);
301 buf_pool_release(&partpath);
302 buf_pool_release(&fullpath);
303 buf_pool_release(&oldpath);
304
305 return rc;
306}
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:401
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:216
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
#define mutt_perror(...)
Definition logging2.h:95
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
int maildir_rewrite_message(struct Mailbox *m, struct Email *e)
Sync a message in an Maildir folder.
Definition message.c:468
void maildir_gen_flags(char *dest, size_t destlen, struct Email *e)
Generate the Maildir flags for an email.
Definition message.c:71
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:284
char * dptr
Current read/write position.
Definition buffer.h:38
char * data
Pointer to data.
Definition buffer.h:37
struct Envelope * env
Envelope information.
Definition email.h:68
bool attach_del
Has an attachment marked for deletion.
Definition email.h:99
char * path
Path of Email (for local Mailboxes)
Definition email.h:70
bool trash
Message is marked as trashed on disk (used by the maildir_trash option)
Definition email.h:53
unsigned char changed
Changed fields, e.g. MUTT_ENV_CHANGED_SUBJECT.
Definition envelope.h:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maildir_sync_mailbox_message()

bool maildir_sync_mailbox_message ( struct Mailbox * m,
struct Email * e,
struct HeaderCache * hc )

Save changes to the mailbox.

Parameters
mMailbox
eEmail
hcHeader cache handle
Return values
trueSuccess
falseError

Definition at line 316 of file message.c.

317{
318 if (!e)
319 return false;
320
321 const bool c_maildir_trash = cs_subset_bool(NeoMutt->sub, "maildir_trash");
322 if (e->deleted && !c_maildir_trash)
323 {
324 char path[PATH_MAX] = { 0 };
325 snprintf(path, sizeof(path), "%s/%s", mailbox_path(m), e->path);
327 unlink(path);
328 }
329 else if (e->changed || e->attach_del ||
330 ((c_maildir_trash || e->trash) && (e->deleted != e->trash)))
331 {
332 if (maildir_sync_message(m, e) == -1)
333 return false;
334 }
335
336 if (e->changed)
338
339 return true;
340}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
int maildir_hcache_store(struct HeaderCache *hc, struct Email *e)
Save an Email to the Header Cache.
Definition hcache.c:163
int maildir_hcache_delete(struct HeaderCache *hc, struct Email *e)
Delete an Email from the Header Cache.
Definition hcache.c:89
static int maildir_sync_message(struct Mailbox *m, struct Email *e)
Sync an email to a Maildir folder.
Definition message.c:221
bool changed
Email has been edited.
Definition email.h:77
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maildir_commit_message()

static int maildir_commit_message ( struct Mailbox * m,
struct Message * msg,
struct Email * e )
static

Commit a message to a maildir folder.

Parameters
mMailbox
msgMessage to commit
eEmail
Return values
0Success
-1Failure

msg->path contains the file name of a file in tmp/. We take the flags from this file's name.

m is the mail folder we commit to.

e is a header structure to which we write the message's new file name. This is used in the maildir folder sync routines. When this routine is invoked from mx_msg_commit(), e is NULL.

msg->path looks like this:

tmp/{cur,new}.neomutt-HOSTNAME-PID-COUNTER:flags

See also maildir_msg_open_new().

Definition at line 365 of file message.c.

366{
367 char subdir[4] = { 0 };
368 char suffix[PATH_MAX] = { 0 };
369 int rc = 0;
370
371 if (mutt_file_fsync_close(&msg->fp))
372 {
373 mutt_perror(_("Could not flush message to disk"));
374 return -1;
375 }
376
377 /* extract the subdir */
378 char *s = strrchr(msg->path, '/');
379 if (!s)
380 {
381 mutt_debug(LL_DEBUG1, "path '%s' lacks expected '/'\n", msg->path);
382 return -1;
383 }
384 s++;
385 mutt_str_copy(subdir, s, 4);
386
387 /* extract the flags */
388 const char c_maildir_field_delimiter = *cc_maildir_field_delimiter();
389 s = strchr(s, c_maildir_field_delimiter);
390 if (s)
391 mutt_str_copy(suffix, s, sizeof(suffix));
392 else
393 suffix[0] = '\0';
394
395 /* construct a new file name. */
396 struct Buffer *path = buf_pool_get();
397 struct Buffer *full = buf_pool_get();
398 for (int retries = 0; retries < 16; retries++)
399 {
400 buf_printf(path, "%s/%lld.R%" PRIu64 ".%s%s", subdir, (long long) mutt_date_now(),
401 mutt_rand64(), NONULL(ShortHostname), suffix);
402 buf_printf(full, "%s/%s", mailbox_path(m), buf_string(path));
403
404 mutt_debug(LL_DEBUG2, "renaming %s to %s\n", msg->path, buf_string(full));
405
406 if (mutt_file_safe_rename(msg->path, buf_string(full)) == 0)
407 {
408 /* Adjust the mtime on the file to match the time at which this
409 * message was received. Currently this is only set when copying
410 * messages between mailboxes, so we test to ensure that it is
411 * actually set. */
412 if (msg->received != 0)
413 {
414 struct utimbuf ut = { 0 };
415 int rc_utime;
416
417 ut.actime = msg->received;
418 ut.modtime = msg->received;
419 do
420 {
421 rc_utime = utime(buf_string(full), &ut);
422 } while ((rc_utime == -1) && (errno == EINTR));
423 if (rc_utime == -1)
424 {
425 mutt_perror(_("maildir_commit_message(): unable to set time on file"));
426 rc = -1;
427 goto cleanup;
428 }
429 }
430
431#ifdef USE_NOTMUCH
432 if (m->type == MUTT_NOTMUCH)
433 nm_update_filename(m, e->path, buf_string(full), e);
434#endif
435 if (e)
436 mutt_str_replace(&e->path, buf_string(path));
438 FREE(&msg->path);
439
440 goto cleanup;
441 }
442 else if (errno != EEXIST)
443 {
444 mutt_perror("%s", mailbox_path(m));
445 rc = -1;
446 goto cleanup;
447 }
448 }
449
450 /* All retries exhausted */
451 mutt_debug(LL_DEBUG1, "failed after 16 retries\n");
452 rc = -1;
453
454cleanup:
455 buf_pool_release(&path);
456 buf_pool_release(&full);
457
458 return rc;
459}
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition mailbox.h:50
int mutt_file_safe_rename(const char *src, const char *target)
NFS-safe renaming of files.
Definition file.c:310
int mutt_file_fsync_close(FILE **fp)
Flush the data, before closing a file (and NULL the pointer)
Definition file.c:128
char * ShortHostname
Short version of the hostname.
Definition globals.c:36
@ LL_DEBUG2
Log at debug level 2.
Definition logging2.h:46
int nm_update_filename(struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e)
Change the filename.
Definition notmuch.c:1811
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define _(a)
Definition message.h:28
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition string.c:587
uint64_t mutt_rand64(void)
Create a 64-bit random number.
Definition random.c:123
enum MailboxType type
Mailbox type.
Definition mailbox.h:104
FILE * fp
pointer to the message data
Definition message.h:35
char * path
path to temp file
Definition message.h:36
char * committed_path
the final path generated by mx_msg_commit()
Definition message.h:37
time_t received
Time at which this message was received.
Definition message.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maildir_rewrite_message()

int maildir_rewrite_message ( struct Mailbox * m,
struct Email * e )

Sync a message in an Maildir folder.

Parameters
mMailbox
eEmail
Return values
0Success
-1Error

Definition at line 468 of file message.c.

469{
470 if (!m || !e)
471 return -1;
472
473 bool restore = true;
474
475 long old_body_offset = e->body->offset;
476 long old_body_length = e->body->length;
477 long old_hdr_lines = e->lines;
478
479 struct Message *src = mx_msg_open(m, e);
480 struct Message *dest = mx_msg_open_new(m, e, MUTT_MSG_NONE);
481 if (!src || !dest)
482 {
483 mx_msg_close(m, &src);
484 mx_msg_close(m, &dest);
485 return -1;
486 }
487
488 int rc = mutt_copy_message(dest->fp, e, src, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN, 0);
489 if (rc == 0)
490 {
491 char oldpath[PATH_MAX] = { 0 };
492 char partpath[PATH_MAX] = { 0 };
493 snprintf(oldpath, sizeof(oldpath), "%s/%s", mailbox_path(m), e->path);
494 mutt_str_copy(partpath, e->path, sizeof(partpath));
495
496 rc = maildir_commit_message(m, dest, e);
497
498 if (rc == 0)
499 {
500 unlink(oldpath);
501 restore = false;
502 }
503 }
504 mx_msg_close(m, &src);
505 mx_msg_close(m, &dest);
506
507 if ((rc == -1) && restore)
508 {
509 e->body->offset = old_body_offset;
510 e->body->length = old_body_length;
511 e->lines = old_hdr_lines;
512 }
513
515 return rc;
516}
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.
Definition copy_email.c:920
@ MUTT_CM_UPDATE
Update structs on sync.
Definition copy_email.h:46
@ CH_UPDATE
Update the status and x-status fields?
Definition copy_email.h:66
@ CH_UPDATE_LEN
Update Lines: and Content-Length:
Definition copy_email.h:76
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition body.c:58
static int maildir_commit_message(struct Mailbox *m, struct Message *msg, struct Email *e)
Commit a message to a maildir folder.
Definition message.c:365
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
Definition mx.c:1185
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
Definition mx.c:1139
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
Definition mx.c:1044
@ MUTT_MSG_NONE
No flags are set.
Definition mx.h:42
struct Body * parts
parts of a multipart or message/rfc822
Definition body.h:73
LOFF_T offset
offset where the actual data begins
Definition body.h:52
LOFF_T length
length (in bytes) of attachment
Definition body.h:53
int lines
How many lines in the body of this message?
Definition email.h:62
struct Body * body
List of MIME parts.
Definition email.h:69
A local copy of an email.
Definition message.h:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function: