#include "config.h"
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "lib.h"
#include "copy.h"
#include "mutt_globals.h"
#include "mutt_header.h"
#include "muttlib.h"
#include "mx.h"
#include "progress.h"
#include "protos.h"
#include "sort.h"
Go to the source code of this file.
|
struct | MUpdate |
| Store of new offsets, used by mutt_sync_mailbox() More...
|
|
|
static void | mbox_adata_free (void **ptr) |
| Free the private Account data - Implements Account::adata_free() More...
|
|
static struct MboxAccountData * | mbox_adata_new (void) |
| Create a new MboxAccountData struct. More...
|
|
static struct MboxAccountData * | mbox_adata_get (struct Mailbox *m) |
| Get the private data associated with a Mailbox. More...
|
|
static int | init_mailbox (struct Mailbox *m) |
| Add Mbox data to the Mailbox. More...
|
|
static int | mbox_lock_mailbox (struct Mailbox *m, bool excl, bool retry) |
| Lock a mailbox. More...
|
|
static void | mbox_unlock_mailbox (struct Mailbox *m) |
| Unlock a mailbox. More...
|
|
static enum MxOpenReturns | mmdf_parse_mailbox (struct Mailbox *m) |
| Read a mailbox in MMDF format. More...
|
|
static enum MxOpenReturns | mbox_parse_mailbox (struct Mailbox *m) |
| Read a mailbox from disk. More...
|
|
static int | reopen_mailbox (struct Mailbox *m) |
| Close and reopen a mailbox. More...
|
|
static bool | mbox_has_new (struct Mailbox *m) |
| Does the mailbox have new mail. More...
|
|
static int | fseek_last_message (FILE *fp) |
| Find the last message in the file. More...
|
|
static bool | test_last_status_new (FILE *fp) |
| Is the last message new. More...
|
|
bool | mbox_test_new_folder (const char *path) |
| Test if an mbox or mmdf mailbox has new mail. More...
|
|
void | mbox_reset_atime (struct Mailbox *m, struct stat *st) |
| Reset the access time on the mailbox file. More...
|
|
static bool | mbox_ac_owns_path (struct Account *a, const char *path) |
| Check whether an Account owns a Mailbox path - Implements MxOps::ac_owns_path() More...
|
|
static bool | mbox_ac_add (struct Account *a, struct Mailbox *m) |
| Add a Mailbox to an Account - Implements MxOps::ac_add() More...
|
|
static FILE * | mbox_open_readwrite (struct Mailbox *m) |
| Open an mbox read-write. More...
|
|
static FILE * | mbox_open_readonly (struct Mailbox *m) |
| Open an mbox read-only. More...
|
|
static enum MxOpenReturns | mbox_mbox_open (struct Mailbox *m) |
| Open a Mailbox - Implements MxOps::mbox_open() More...
|
|
static bool | mbox_mbox_open_append (struct Mailbox *m, OpenMailboxFlags flags) |
| Open a Mailbox for appending - Implements MxOps::mbox_open_append() More...
|
|
static enum MxStatus | mbox_mbox_check (struct Mailbox *m) |
| Check for new mail - Implements MxOps::mbox_check() More...
|
|
static enum MxStatus | mbox_mbox_sync (struct Mailbox *m) |
| Save changes to the Mailbox - Implements MxOps::mbox_sync() More...
|
|
static enum MxStatus | mbox_mbox_close (struct Mailbox *m) |
| Close a Mailbox - Implements MxOps::mbox_close() More...
|
|
static bool | mbox_msg_open (struct Mailbox *m, struct Message *msg, int msgno) |
| Open an email message in a Mailbox - Implements MxOps::msg_open() More...
|
|
static bool | mbox_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() More...
|
|
static int | mbox_msg_commit (struct Mailbox *m, struct Message *msg) |
| Save changes to an email - Implements MxOps::msg_commit() More...
|
|
static int | mbox_msg_close (struct Mailbox *m, struct Message *msg) |
| Close an email - Implements MxOps::msg_close() More...
|
|
static int | mbox_msg_padding_size (struct Mailbox *m) |
| Bytes of padding between messages - Implements MxOps::msg_padding_size() More...
|
|
enum MailboxType | mbox_path_probe (const char *path, const struct stat *st) |
| Is this an mbox Mailbox? - Implements MxOps::path_probe() More...
|
|
static int | mbox_path_canon (char *buf, size_t buflen) |
| Canonicalise a Mailbox path - Implements MxOps::path_canon() More...
|
|
static int | mbox_path_pretty (char *buf, size_t buflen, const char *folder) |
| Abbreviate a Mailbox path - Implements MxOps::path_pretty() More...
|
|
static int | mbox_path_parent (char *buf, size_t buflen) |
| Find the parent of a Mailbox path - Implements MxOps::path_parent() More...
|
|
static int | mbox_path_is_empty (const char *path) |
| Is the mailbox empty - Implements MxOps::path_is_empty() More...
|
|
static int | mmdf_msg_commit (struct Mailbox *m, struct Message *msg) |
| Save changes to an email - Implements MxOps::msg_commit() More...
|
|
static int | mmdf_msg_padding_size (struct Mailbox *m) |
| Bytes of padding between messages - Implements MxOps::msg_padding_size() More...
|
|
static enum MxStatus | mbox_mbox_check_stats (struct Mailbox *m, uint8_t flags) |
| Check the Mailbox statistics - Implements MxOps::mbox_check_stats() More...
|
|
Mbox local mailbox type
- Authors
- Michael R. Elkins
- Richard Russon
- Pietro Cerutti
- Copyright
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
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 mbox.c.
◆ mbox_adata_free()
static void mbox_adata_free |
( |
void ** |
ptr | ) |
|
|
static |
◆ mbox_adata_new()
◆ mbox_adata_get()
Get the private data associated with a Mailbox.
- Parameters
-
- Return values
-
Definition at line 100 of file mbox.c.
◆ init_mailbox()
static int init_mailbox |
( |
struct Mailbox * |
m | ) |
|
|
static |
Add Mbox data to the Mailbox.
- Parameters
-
- Return values
-
0 | Success |
-1 | Error Bad format |
Definition at line 118 of file mbox.c.
◆ mbox_lock_mailbox()
static int mbox_lock_mailbox |
( |
struct Mailbox * |
m, |
|
|
bool |
excl, |
|
|
bool |
retry |
|
) |
| |
|
static |
Lock a mailbox.
- Parameters
-
m | Mailbox to lock |
excl | Exclusive lock? |
retry | Should retry if unable to lock? |
- Return values
-
Definition at line 140 of file mbox.c.
148 adata->locked =
true;
149 else if (retry && !excl)
◆ mbox_unlock_mailbox()
static void mbox_unlock_mailbox |
( |
struct Mailbox * |
m | ) |
|
|
static |
Unlock a mailbox.
- Parameters
-
Definition at line 162 of file mbox.c.
173 adata->locked =
false;
◆ mmdf_parse_mailbox()
Read a mailbox in MMDF format.
- Parameters
-
- Return values
-
Definition at line 182 of file mbox.c.
192 char return_path[1024];
197 struct Email *e = NULL;
208 m->
size = sb.st_size;
210 buf[
sizeof(buf) - 1] =
'\0';
221 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
229 loc = ftello(adata->
fp);
244 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
251 return_path[0] =
'\0';
253 if (!
is_from(buf, return_path,
sizeof(return_path), &t))
255 if (fseeko(adata->
fp, loc, SEEK_SET) != 0)
267 loc = ftello(adata->
fp);
275 if ((tmploc > 0) && (tmploc < m->
size))
277 if ((fseeko(adata->
fp, tmploc, SEEK_SET) != 0) ||
280 if (fseeko(adata->
fp, loc, SEEK_SET) != 0)
296 loc = ftello(adata->
fp);
299 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
◆ mbox_parse_mailbox()
Read a mailbox from disk.
- Parameters
-
- Return values
-
Note that this function is also called when new mail is appended to the currently open folder, and NOT just when the mailbox is initially read.
- Note
- It is assumed that the mailbox being read has been locked before this routine gets called. Strange things could happen if it's not!
Definition at line 344 of file mbox.c.
354 char buf[8192], return_path[256];
355 struct Email *e_cur = NULL;
357 int count = 0,
lines = 0;
368 m->
size = sb.st_size;
382 loc = ftello(adata->
fp);
383 while ((fgets(buf,
sizeof(buf), adata->
fp)) && (
SigInt != 1))
385 if (
is_from(buf, return_path,
sizeof(return_path), &t))
406 (
int) (ftello(adata->
fp) / (m->
size / 100 + 1)));
427 loc = ftello(adata->
fp);
433 if ((tmploc > 0) && (tmploc < m->
size))
437 if ((fseeko(adata->
fp, tmploc, SEEK_SET) != 0) ||
444 if ((loc < 0) || (fseeko(adata->
fp, loc, SEEK_SET) != 0))
451 else if (tmploc != m->
size)
462 if (e_cur->
lines == 0)
467 if ((loc < 0) || (fseeko(adata->
fp, loc, SEEK_SET) != 0))
471 if (fgetc(adata->
fp) ==
'\n')
477 if (fseeko(adata->
fp, tmploc, SEEK_SET) != 0)
497 loc = ftello(adata->
fp);
◆ reopen_mailbox()
static int reopen_mailbox |
( |
struct Mailbox * |
m | ) |
|
|
static |
Close and reopen a mailbox.
- Parameters
-
- Return values
-
Definition at line 533 of file mbox.c.
542 bool (*cmp_headers)(
const struct Email *,
const struct Email *) = NULL;
543 struct Email **e_old = NULL;
545 bool msg_mod =
false;
618 for (
int i = 0; i < old_msg_count; i++)
641 for (j = i; j < old_msg_count; j++)
645 if (cmp_headers(m->
emails[i], e_old[j]))
653 for (j = 0; (j < i) && (j < old_msg_count); j++)
657 if (cmp_headers(m->
emails[i], e_old[j]))
688 for (
int j = 0; j < old_msg_count; j++)
◆ mbox_has_new()
static bool mbox_has_new |
( |
struct Mailbox * |
m | ) |
|
|
static |
Does the mailbox have new mail.
- Parameters
-
- Return values
-
true | if the mailbox has at least 1 new messages (not old) |
false | otherwise |
Definition at line 711 of file mbox.c.
◆ fseek_last_message()
static int fseek_last_message |
( |
FILE * |
fp | ) |
|
|
static |
Find the last message in the file.
- Parameters
-
- Return values
-
0 | Success |
-1 | No message found |
Definition at line 730 of file mbox.c.
733 char buf[BUFSIZ + 9] = { 0 };
736 fseek(fp, 0, SEEK_END);
741 bytes_read = pos % BUFSIZ;
746 while ((pos -= bytes_read) >= 0)
749 strncpy(buf + BUFSIZ, buf, 5 + 2);
750 fseeko(fp, pos, SEEK_SET);
751 bytes_read = fread(buf,
sizeof(
char), bytes_read, fp);
755 for (
int i = bytes_read; i >= 0; i--)
759 fseeko(fp, pos + i + 2, SEEK_SET);
769 fseek(fp, 0, SEEK_SET);
◆ test_last_status_new()
static bool test_last_status_new |
( |
FILE * |
fp | ) |
|
|
static |
Is the last message new.
- Parameters
-
- Return values
-
true | if the last message is new |
Definition at line 781 of file mbox.c.
783 struct Email *e = NULL;
784 struct Envelope *tmp_envelope = NULL;
◆ mbox_test_new_folder()
bool mbox_test_new_folder |
( |
const char * |
path | ) |
|
Test if an mbox or mmdf mailbox has new mail.
- Parameters
-
- Return values
-
bool | true if the folder contains new mail |
Definition at line 806 of file mbox.c.
815 FILE *fp = fopen(path,
"rb");
◆ mbox_reset_atime()
void mbox_reset_atime |
( |
struct Mailbox * |
m, |
|
|
struct stat * |
st |
|
) |
| |
Reset the access time on the mailbox file.
- Parameters
-
if mailbox has at least 1 new message, sets mtime > atime of mailbox so mailbox check reports new mail
Definition at line 833 of file mbox.c.
835 struct utimbuf utimebuf;
845 utimebuf.actime = st->st_atime;
846 utimebuf.modtime = st->st_mtime;
852 utimebuf.actime = utimebuf.modtime - 1;
◆ mbox_ac_owns_path()
static bool mbox_ac_owns_path |
( |
struct Account * |
a, |
|
|
const char * |
path |
|
) |
| |
|
static |
◆ mbox_ac_add()
◆ mbox_open_readwrite()
static FILE* mbox_open_readwrite |
( |
struct Mailbox * |
m | ) |
|
|
static |
Open an mbox read-write.
- Parameters
-
- Return values
-
This function ensures that the FILE and readonly flag are changed atomically.
Definition at line 888 of file mbox.c.
◆ mbox_open_readonly()
static FILE* mbox_open_readonly |
( |
struct Mailbox * |
m | ) |
|
|
static |
Open an mbox read-only.
- Parameters
-
- Return values
-
This function ensures that the FILE and readonly flag are changed atomically.
Definition at line 903 of file mbox.c.
◆ mbox_mbox_open()
◆ mbox_mbox_open_append()
◆ mbox_mbox_check()
Check for new mail - Implements MxOps::mbox_check()
- Parameters
-
- Return values
-
Definition at line 1012 of file mbox.c.
1026 bool unlock =
false;
1027 bool modified =
false;
1032 (st.st_size == m->
size))
1037 if (st.st_size == m->
size)
1044 if (st.st_size > m->
size)
1066 if (fseeko(adata->
fp, m->
size, SEEK_SET) != 0)
1068 if (fgets(buf,
sizeof(buf), adata->
fp))
1073 if (fseeko(adata->
fp, m->
size, SEEK_SET) != 0)
◆ mbox_mbox_sync()
Save changes to the Mailbox - Implements MxOps::mbox_sync()
Definition at line 1135 of file mbox.c.
1141 struct Buffer *tempfile = NULL;
1145 bool unlink_tempfile =
false;
1149 struct stat statbuf;
1150 struct MUpdate *new_offset = NULL;
1151 struct MUpdate *old_offset = NULL;
1172 mutt_error(
_(
"Fatal error! Could not reopen mailbox!"));
1202 if ((fd == -1) || !(fp = fdopen(fd,
"w")))
1207 unlink_tempfile =
true;
1212 unlink_tempfile =
true;
1228 _(
"sync: mbox modified, but no modified messages (report this bug)"));
1254 for (i = first, j = 0; i < m->
msg_count; i++)
1261 old_offset[i - first].
valid =
true;
1283 new_offset[i - first].
hdr = ftello(fp) + offset;
1310 if (fputs(
"\n", fp) == EOF)
1333 unlink_tempfile =
false;
1347 if ((fseeko(adata->
fp, offset, SEEK_SET) != 0) ||
1349 !fgets(buf,
sizeof(buf), adata->
fp) ||
1359 if (fseeko(adata->
fp, offset, SEEK_SET) != 0)
1372 if (ferror(adata->
fp))
1377 m->
size = ftello(adata->
fp);
1378 if ((m->
size < 0) || (ftruncate(fileno(adata->
fp), m->
size) != 0))
1423 mutt_error(
_(
"Fatal error! Could not reopen mailbox!"));
1430 for (i = first, j = first; i < m->
msg_count; i++)
1459 if (tempfile && unlink_tempfile)
1463 if ((first >= 0) && old_offset)
1465 for (i = first; (i < m->
msg_count) && old_offset[i - first].valid; i++)
◆ mbox_mbox_close()
◆ mbox_msg_open()
static bool mbox_msg_open |
( |
struct Mailbox * |
m, |
|
|
struct Message * |
msg, |
|
|
int |
msgno |
|
) |
| |
|
static |
◆ mbox_msg_open_new()
static bool mbox_msg_open_new |
( |
struct Mailbox * |
m, |
|
|
struct Message * |
msg, |
|
|
const struct Email * |
e |
|
) |
| |
|
static |
◆ mbox_msg_commit()
static int mbox_msg_commit |
( |
struct Mailbox * |
m, |
|
|
struct Message * |
msg |
|
) |
| |
|
static |
Save changes to an email - Implements MxOps::msg_commit()
Definition at line 1575 of file mbox.c.
1577 if (fputc(
'\n', msg->
fp) == EOF)
1580 if ((fflush(msg->
fp) == EOF) || (fsync(fileno(msg->
fp)) == -1))
◆ mbox_msg_close()
static int mbox_msg_close |
( |
struct Mailbox * |
m, |
|
|
struct Message * |
msg |
|
) |
| |
|
static |
◆ mbox_msg_padding_size()
static int mbox_msg_padding_size |
( |
struct Mailbox * |
m | ) |
|
|
static |
◆ mbox_path_probe()
enum MailboxType mbox_path_probe |
( |
const char * |
path, |
|
|
const struct stat * |
st |
|
) |
| |
Is this an mbox Mailbox? - Implements MxOps::path_probe()
Definition at line 1615 of file mbox.c.
1620 if (S_ISDIR(st->st_mode))
1623 if (st->st_size == 0)
1626 FILE *
fp = fopen(path,
"r");
1631 while ((ch = fgetc(
fp)) != EOF)
1636 if ((ch !=
'\n') && (ch !=
'\r'))
1645 if (fgets(tmp,
sizeof(tmp),
fp))
1659 #ifdef HAVE_UTIMENSAT
1663 utimensat(AT_FDCWD, path, ts, 0);
1665 struct utimbuf times;
1666 times.actime = st->st_atime;
1667 times.modtime = st->st_mtime;
1668 utime(path, ×);
◆ mbox_path_canon()
static int mbox_path_canon |
( |
char * |
buf, |
|
|
size_t |
buflen |
|
) |
| |
|
static |
◆ mbox_path_pretty()
static int mbox_path_pretty |
( |
char * |
buf, |
|
|
size_t |
buflen, |
|
|
const char * |
folder |
|
) |
| |
|
static |
◆ mbox_path_parent()
static int mbox_path_parent |
( |
char * |
buf, |
|
|
size_t |
buflen |
|
) |
| |
|
static |
◆ mbox_path_is_empty()
static int mbox_path_is_empty |
( |
const char * |
path | ) |
|
|
static |
◆ mmdf_msg_commit()
static int mmdf_msg_commit |
( |
struct Mailbox * |
m, |
|
|
struct Message * |
msg |
|
) |
| |
|
static |
Save changes to an email - Implements MxOps::msg_commit()
Definition at line 1726 of file mbox.c.
1731 if ((fflush(msg->
fp) == EOF) || (fsync(fileno(msg->
fp)) == -1))
◆ mmdf_msg_padding_size()
static int mmdf_msg_padding_size |
( |
struct Mailbox * |
m | ) |
|
|
static |
◆ mbox_mbox_check_stats()
static enum MxStatus mbox_mbox_check_stats |
( |
struct Mailbox * |
m, |
|
|
uint8_t |
flags |
|
) |
| |
|
static |
Check the Mailbox statistics - Implements MxOps::mbox_check_stats()
Definition at line 1753 of file mbox.c.
1755 struct stat sb = { 0 };
1759 bool new_or_changed;
1762 new_or_changed = (sb.st_size > m->
size);
1783 m->
size = (off_t) sb.st_size;
1786 if (m->
newly_created && ((sb.st_ctime != sb.st_mtime) || (sb.st_ctime != sb.st_atime)))
◆ MxMboxOps
Initial value:= {
.name = "mbox",
.is_local = true,
.msg_save_hcache = NULL,
.tags_edit = NULL,
.tags_commit = NULL,
}
Mbox Mailbox - Implements MxOps.
Definition at line 1807 of file mbox.c.
◆ MxMmdfOps
Initial value:= {
.name = "mmdf",
.is_local = true,
.msg_save_hcache = NULL,
.tags_edit = NULL,
.tags_commit = NULL,
}
MMDF Mailbox - Implements MxOps.
Definition at line 1837 of file mbox.c.
long hdr_offset
Offset in stream where the headers begin.
struct HashTable * subj_hash
Hash Table by subject.
@ MX_STATUS_LOCKED
Couldn't lock the Mailbox.
#define CH_FROM
Retain the "From " message separator?
#define MUTT_PEEK
Revert atime back after taking a look (if applicable)
int mutt_file_lock(int fd, bool excl, bool timeout)
(try to) lock a file using fcntl()
static FILE * mbox_open_readwrite(struct Mailbox *m)
Open an mbox read-write.
static struct MboxAccountData * mbox_adata_get(struct Mailbox *m)
Get the private data associated with a Mailbox.
WHERE SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
static bool mbox_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
Open an email message in a Mailbox - Implements MxOps::msg_open()
@ MUTT_FLAG
Flagged messages.
@ MUTT_MMDF
'mmdf' Mailbox type
MxStatus
Return values from mx_mbox_check(), mx_mbox_sync(), and mx_mbox_close()
void mbox_reset_atime(struct Mailbox *m, struct stat *st)
Reset the access time on the mailbox file.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
int lines
How many lines in the body of this message?
static bool mbox_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 * v2r
Mapping from virtual to real msgno.
struct Email ** emails
Array of Emails.
@ NT_MAILBOX_INVALID
Email list was changed.
String manipulation buffer.
bool mutt_path_abbr_folder(char *buf, size_t buflen, const char *folder)
Create a folder abbreviation.
enum MailboxType type
Type of Mailboxes this Account contains.
LOFF_T offset
offset where the actual data begins
static int mmdf_msg_commit(struct Mailbox *m, struct Message *msg)
Save changes to an email - Implements MxOps::msg_commit()
int msg_deleted
Number of deleted messages.
void mutt_sig_unblock(void)
Restore previously blocked signals.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
void mutt_buffer_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
static int mbox_lock_mailbox(struct Mailbox *m, bool excl, bool retry)
Lock a mailbox.
void mutt_sig_block(void)
Block signals during critical operations.
static int mbox_msg_close(struct Mailbox *m, struct Message *msg)
Close an email - Implements MxOps::msg_close()
@ MUTT_STAT_MTIME
File/dir's mtime - last modified time.
static bool mbox_has_new(struct Mailbox *m)
Does the mailbox have new mail.
MxOpenReturns
Return values for mbox_open()
@ MUTT_PROGRESS_WRITE
Progress tracks elements, according to $write_inc
#define mutt_buffer_mktemp(buf)
#define TAILQ_EMPTY(head)
LOFF_T offset
Where in the stream does this message begin?
@ MUTT_STAT_ATIME
File/dir's atime - last accessed time.
SortType
Methods for sorting.
static FILE * mbox_open_readonly(struct Mailbox *m)
Open an mbox read-only.
static int init_mailbox(struct Mailbox *m)
Add Mbox data to the Mailbox.
#define MUTT_NEWFOLDER
Create a new folder - same as MUTT_APPEND,.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
@ LL_DEBUG1
Log at debug level 1.
off_t size
Size of the Mailbox.
bool has_new
Mailbox has new mail.
#define STAILQ_FIRST(head)
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
@ MX_OPEN_OK
Open succeeded.
bool C_CheckMboxSize
Config: (mbox,mmdf) Use mailbox size as an indicator of new mail.
bool mutt_path_canon(char *buf, size_t buflen, const char *homedir, bool is_dir)
Create the canonical version of a path.
struct Mailbox * mailbox
Mailbox in the list.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
static int mbox_path_canon(char *buf, size_t buflen)
Canonicalise a Mailbox path - Implements MxOps::path_canon()
WHERE char * Username
User's login name.
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
struct Email * email_new(void)
Create a new Email.
void mutt_body_free(struct Body **ptr)
Free a Body.
@ MUTT_STAT_CTIME
File/dir's ctime - creation time.
struct HashTable * label_hash
Hash Table for x-labels.
int vcount
The number of virtual messages.
@ MX_STATUS_REOPENED
Mailbox was reopened.
void(* adata_free)(void **ptr)
Free the private data attached to the Account.
@ MUTT_READ
Messages that have been read.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
static int mmdf_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Implements MxOps::msg_padding_size()
void mutt_file_touch_atime(int fd)
Set the access time to current time.
bool old
Email is seen, but unread.
time_t received
Time when the message was placed in the mailbox.
void mutt_progress_init(struct Progress *progress, const char *msg, enum ProgressType type, size_t size)
Set up a progress bar.
@ MUTT_PURGE
Messages to be purged (bypass trash)
static enum MxStatus mbox_mbox_check_stats(struct Mailbox *m, uint8_t flags)
Check the Mailbox statistics - Implements MxOps::mbox_check_stats()
static int fseek_last_message(FILE *fp)
Find the last message in the file.
void mx_alloc_memory(struct Mailbox *m)
Create storage for the emails.
enum MailboxType mbox_path_probe(const char *path, const struct stat *st)
Is this an mbox Mailbox? - Implements MxOps::path_probe()
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
int mutt_file_check_empty(const char *path)
Is the mailbox empty.
enum MailboxType type
Mailbox type.
@ NT_MAILBOX_UPDATE
Update internal tables.
struct timespec stats_last_checked
Mtime of mailbox the last time stats where checked.
A group of associated Mailboxes.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
bool write
nonzero if message is open for writing
int mutt_file_unlock(int fd)
Unlock a file previously locked by mutt_file_lock()
enum MxStatus mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
LOFF_T length
length (in bytes) of attachment
bool changed
Mailbox has been modified.
static struct MboxAccountData * mbox_adata_new(void)
Create a new MboxAccountData struct.
struct Account * account
Account that owns this Mailbox.
struct MailboxList mailboxes
List of Mailboxes.
bool is_from(const char *s, char *path, size_t pathlen, time_t *tp)
Is a string a 'From' header line?
int msg_count
Total number of messages.
static void mbox_unlock_mailbox(struct Mailbox *m)
Unlock a mailbox.
struct timespec mtime
Time Mailbox was last changed.
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
time_t mutt_date_local_tz(time_t t)
Calculate the local timezone in seconds east of UTC.
Mbox-specific Account data -.
bool newly_created
Mbox or mmdf just popped into existence.
#define MUTT_NOSORT
Do not sort the mailbox after opening it.
bool locked
is the mailbox locked?
struct Body * parts
parts of a multipart or message/rfc822
@ MUTT_PROGRESS_READ
Progress tracks elements, according to $read_inc
struct Envelope * env
Envelope information.
#define mutt_debug(LEVEL,...)
int email_max
Number of pointers in emails.
@ MUTT_REPLIED
Messages that have been replied to.
void mailbox_update(struct Mailbox *m)
Get the mailbox's current size.
char * C_Tmpdir
Config: Directory for temporary files.
#define CH_UPDATE
Update the status and x-status fields?
static bool mbox_ac_owns_path(struct Account *a, const char *path)
Check whether an Account owns a Mailbox path - Implements MxOps::ac_owns_path()
int msg_flagged
Number of flagged messages.
FILE * fp
pointer to the message data
@ MX_STATUS_ERROR
An error occurred.
#define MUTT_QUIET
Do not print any messages.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
bool verbose
Display status messages?
static int mbox_path_pretty(char *buf, size_t buflen, const char *folder)
Abbreviate a Mailbox path - Implements MxOps::path_pretty()
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
int mutt_file_stat_compare(struct stat *sba, enum MuttStatType sba_type, struct stat *sbb, enum MuttStatType sbb_type)
Compare two stat infos.
static bool mbox_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Implements MxOps::ac_add()
static enum MxStatus mbox_mbox_check(struct Mailbox *m)
Check for new mail - Implements MxOps::mbox_check()
bool deleted
Email is deleted.
int mutt_file_mkdir(const char *path, mode_t mode)
Recursively create directories.
bool readonly
Don't allow changes to the mailbox.
static enum MxOpenReturns mmdf_parse_mailbox(struct Mailbox *m)
Read a mailbox in MMDF format.
struct AddressList from
Email's 'From' list.
bool mutt_path_parent(char *buf, size_t buflen)
Find the parent of a path.
@ MUTT_DELETE
Messages to be deleted.
char * HomeDir
User's home directory.
WHERE bool C_MailCheckRecent
Config: Notify the user about new mail since the last time the mailbox was opened.
WHERE short C_Sort
Config: Sort method for the index.
WHERE char * ShortHostname
Short version of the hostname.
int mutt_file_timespec_compare(struct timespec *a, struct timespec *b)
Compare to time values.
struct timespec last_visited
Time of last exit from this mailbox.
@ MUTT_TAG
Tagged messages.
static int mbox_path_parent(char *buf, size_t buflen)
Find the parent of a Mailbox path - Implements MxOps::path_parent()
static enum MxOpenReturns mbox_parse_mailbox(struct Mailbox *m)
Read a mailbox from disk.
static enum MxOpenReturns mbox_mbox_open(struct Mailbox *m)
Open a Mailbox - Implements MxOps::mbox_open()
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
static enum MxStatus mbox_mbox_close(struct Mailbox *m)
Close a Mailbox - Implements MxOps::mbox_close()
#define MUTT_CM_UPDATE
Update structs on sync.
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
static enum MxStatus mbox_mbox_sync(struct Mailbox *m)
Save changes to the Mailbox - Implements MxOps::mbox_sync()
void mutt_file_get_stat_timespec(struct timespec *dest, struct stat *sb, enum MuttStatType type)
Read the stat() time into a time value.
static void mbox_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
void * adata
Private data (for Mailbox backends)
@ MX_OPEN_ABORT
Open was aborted.
MailboxType
Supported mailbox formats.
Store of new offsets, used by mutt_sync_mailbox()
static bool mbox_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags)
Open a Mailbox for appending - Implements MxOps::mbox_open_append()
int index
The absolute (unsorted) message number.
struct Envelope * mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed)
parses an RFC822 header
bool email_cmp_strict(const struct Email *e1, const struct Email *e2)
Strictly compare message emails.
void email_free(struct Email **ptr)
Free an Email.
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
int msg_unread
Number of unread messages.
int msg_tagged
How many messages are tagged?
static int mbox_path_is_empty(const char *path)
Is the mailbox empty - Implements MxOps::path_is_empty()
struct AddressList return_path
Return path for the Email.
struct timespec atime
File's last-access time.
bool attach_del
Has an attachment marked for deletion.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
void mx_fastclose_mailbox(struct Mailbox *m)
free up memory associated with the Mailbox
bool mutt_path_pretty(char *buf, size_t buflen, const char *homedir, bool is_dir)
Tidy a filesystem path.
Time value with nanosecond precision.
static int mbox_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Implements MxOps::msg_padding_size()
static bool test_last_status_new(FILE *fp)
Is the last message new.
static int mbox_msg_commit(struct Mailbox *m, struct Message *msg)
Save changes to an email - Implements MxOps::msg_commit()
static int reopen_mailbox(struct Mailbox *m)
Close and reopen a mailbox.
The envelope/body of an email.
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
#define mutt_message(...)
#define mutt_set_flag(m, e, flag, bf)
int msg_new
Number of new messages.
@ MX_OPEN_ERROR
Open failed with an error.
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
int mutt_file_stat_timespec_compare(struct stat *sba, enum MuttStatType type, struct timespec *b)
Compare stat info with a time value.
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
@ NT_MAILBOX_RESORT
Email list needs resorting.
#define CH_UPDATE_LEN
Update Lines: and Content-Length:
@ MUTT_MBOX
'mbox' Mailbox type
struct HashTable * id_hash
Hash Table by msg id.
bool peekonly
Just taking a glance, revert atime.
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
bool changed
Email has been edited.
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
@ MX_STATUS_OK
No changes.
struct Body * body
List of MIME parts.
char * mutt_path_dirname(const char *path)
Return a path up to, but not including, the final '/'.