101 (
struct Mapping *) &MboxTypeMap,
143 for (
const struct MxOps **ops = mx_ops; *ops; ops++)
144 if ((*ops)->type == type)
163 const bool is_spool =
190 return access(path, flags);
275 const bool new_account = !a;
322 const bool newly_linked_account = !m->
account;
323 if (newly_linked_account)
405 if ((rc == 0) || (rc == -2))
435 if (newly_linked_account)
520 int opt_confappend, rc;
543 if (delmsgcount == 0)
557 mutt_error(ngettext(
"message not deleted",
"messages not deleted", delmsgcount));
561 if ((lstat(
mailbox_path(m), &stc) == 0) && (stc.st_ino == st.st_ino) &&
562 (stc.st_dev == st.st_dev) && (stc.st_rdev == st.st_rdev))
576 const bool old_append = m_trash->
append;
581 for (
int i = first_del; i < m->
msg_count; i++)
592 m_trash->
append = old_append;
599 m_trash->
append = old_append;
651 int i, read_msgs = 0;
655 struct Buffer *mbox = NULL;
715 ngettext(
"Move %d read message to %s?",
716 "Move %d read messages to %s?", read_msgs),
729 ngettext(
"Purge %d deleted message?",
834 if (purge && (m->
msg_deleted != 0) && (m != m_trash))
949 char buf[256], tmp[256];
951 snprintf(tmp,
sizeof(tmp),
_(
" Press '%s' to toggle write"), buf);
953 mutt_str_copy(tmp,
_(
"Use 'toggle-write' to re-enable write"),
sizeof(tmp));
955 mutt_error(
_(
"Mailbox is marked unwritable. %s"), tmp);
975 snprintf(buf,
sizeof(buf),
976 ngettext(
"Purge %d deleted message?",
"Purge %d deleted messages?", m->
msg_deleted),
1008 if (purge && (m->
msg_deleted != 0) && (m != m_trash))
1032 mutt_message(
_(
"%d kept, %d deleted"), msgcount - deleted, deleted);
1119 locale_t loc = newlocale(LC_TIME_MASK,
"C", 0);
1120 char buf[64] = { 0 };
1122 strftime_l(buf,
sizeof(buf),
"%a %b %e %H:%M:%S %Y", &tm, loc);
1207 if (!m || !msg || !*msg)
1218 unlink((*msg)->path);
1219 FREE(&(*msg)->path);
1222 FREE(&(*msg)->committed_path);
1233 size_t s =
MAX(
sizeof(
struct Email *),
sizeof(
int));
1235 if ((m->
email_max + 25) * s < m->email_max * s)
1252 for (
int i = m->
email_max - 25; i < m->email_max; i++)
1268 if (!path || (*path ==
'\0'))
1297 mutt_message(
_(
"Folder doesn't support tagging, aborting"));
1311 if (!m || !e || !tags)
1317 mutt_message(
_(
"Folder doesn't support tagging, aborting"));
1344 for (
const struct MxOps **ops = mx_ops; *ops; ops++)
1346 if ((*ops)->is_local)
1348 rc = (*ops)->path_probe(path, NULL);
1353 struct stat st = { 0 };
1354 if (stat(path, &st) != 0)
1356 mutt_debug(
LL_DEBUG1,
"unable to stat %s: %s (errno %d)\n", path, strerror(errno), errno);
1360 if (S_ISFIFO(st.st_mode))
1362 mutt_error(
_(
"Can't open %s: it is a pipe"), path);
1367 for (
const struct MxOps **ops = mx_ops; *ops; ops++)
1369 if (!(*ops)->is_local)
1371 rc = (*ops)->path_probe(path, &st);
1387 for (
size_t i = 0; i < 3; i++)
1390 if ((buf[0] ==
'!') && (buf[1] ==
'!'))
1392 if (((buf[2] ==
'/') || (buf[2] ==
'\0')))
1397 else if ((buf[0] ==
'+') || (buf[0] ==
'='))
1400 if ((folder_len > 0) && (folder[folder_len - 1] !=
'/'))
1410 else if ((buf[1] ==
'/') || (buf[1] ==
'\0'))
1416 else if (buf[0] ==
'-')
1420 else if (buf[0] ==
'<')
1424 else if (buf[0] ==
'>')
1428 else if (buf[0] ==
'^')
1432 else if (buf[0] ==
'~')
1437 else if (buf[0] ==
'@')
1599 struct Url *url_p = NULL;
1600 struct Url *url_a = NULL;
#define MUTT_APPEND
Open mailbox for appending messages.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
struct Email ** emails
Array of Emails.
Convenience wrapper for the gui headers.
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
int mx_path_is_empty(const char *path)
Is the mailbox empty.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
#define MUTT_APPENDNEW
Set in mx_open_mailbox_append if the mailbox doesn't exist.
int ctx_mailbox_observer(struct NotifyCallback *nc)
Watch for changes affecting the Context - Implements observer_t.
int(* msg_commit)(struct Mailbox *m, struct Message *msg)
Save changes to an email.
const struct MxOps * mx_get_ops(enum MailboxType type)
Get mailbox operations.
enum MailboxType type
Mailbox type.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
int msg_count
Total number of messages.
#define mutt_set_flag(m, e, flag, bf)
off_t size
Size of the Mailbox.
int msg_in_pager
Message currently shown in the pager.
bool C_MarkOld
Config: Mark new emails as old when leaving the mailbox.
The envelope/body of an email.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
#define TAILQ_FIRST(head)
void email_free(struct Email **ptr)
Free an Email.
Clear the 'last-tagged' pointer.
WHERE bool C_SaveEmpty
Config: (mbox,mmdf) Preserve empty mailboxes.
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
#define TAILQ_FOREACH(var, head, field)
int msg_deleted
Number of deleted messages.
int msg_unread
Number of unread messages.
int mx_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Wrapper for MxOps::ac_add()
int mx_path_canon2(struct Mailbox *m, const char *folder)
Canonicalise the path to realpath.
'NNTP' (Usenet) Mailbox type
int mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Structs that make up an email.
void mbox_reset_atime(struct Mailbox *m, struct stat *st)
Reset the access time on the mailbox file.
struct MxOps MxNotmuchOps
Notmuch Mailbox - Implements MxOps.
The "currently-open" mailbox.
struct MxOps MxMhOps
MH Mailbox - Implements MxOps.
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
int mx_path_pretty(char *buf, size_t buflen, const char *folder)
Abbreviate a mailbox path - Wrapper for MxOps::path_pretty()
struct HashTable * label_hash
Hash Table for x-labels.
struct MxOps MxCompOps
Compressed Mailbox - Implements MxOps.
int mx_path_parent(char *buf, size_t buflen)
Find the parent of a mailbox path - Wrapper for MxOps::path_parent()
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
#define mutt_message(...)
int msg_flagged
Number of flagged messages.
A parsed URL proto://user:password@host:port/path?a=1&b=2
static int sync_mailbox(struct Mailbox *m)
save changes to disk
struct AccountList accounts
List of all Accounts.
static struct Mailbox * mx_mbox_find_by_name(const char *name)
Find a Mailbox with given name.
void mutt_sort_headers(struct Mailbox *m, struct ThreadsContext *threads, bool init, off_t *vsize)
Sort emails by their headers.
static int trash_append(struct Mailbox *m)
move deleted mails to the trash folder
bool peekonly
Just taking a glance, revert atime.
struct NntpAccountData * adata
enum UrlScheme scheme
Scheme, e.g. U_SMTPS.
unsigned char C_Move
Config: Move emails from $spoolfile to $mbox when read.
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
struct MailboxList mailboxes
List of Mailboxes.
struct ThreadsContext * threads
Threads context.
A group of associated Mailboxes.
struct MxOps MxMaildirOps
Maildir Mailbox - Implements MxOps.
String manipulation buffer.
void mx_alloc_memory(struct Mailbox *m)
Create storage for the emails.
Mailbox wasn't recognised.
Error occurred examining Mailbox.
struct MxOps MxNntpOps
NNTP Mailbox - Implements MxOps.
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
Find a Mailbox on an Account.
static struct Mailbox * mx_mbox_find_by_name_ac(struct Account *a, const char *name)
Find a Mailbox with given name under an Account.
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
char * mailbox
Mailbox and host address.
Messages to be purged (bypass trash)
int(* ac_add)(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account.
bool(* ac_owns_path)(struct Account *a, const char *path)
Check whether an Account owns a Mailbox path.
void emaillist_clear(struct EmailList *el)
Drop a private list of Emails.
Index panel (list of emails)
uint8_t OpenMailboxFlags
Flags for mutt_open_mailbox(), e.g. MUTT_NOSORT.
int(* path_is_empty)(const char *path)
Is the Mailbox empty?
void url_free(struct Url **ptr)
Free the contents of a URL.
#define MUTT_READONLY
Open in read-only mode.
enum MailboxType type
Type of Mailboxes this Account contains.
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
int mx_save_hcache(struct Mailbox *m, struct Email *e)
Save message to the header cache - Wrapper for MxOps::msg_save_hcache()
struct Mailbox * mx_mbox_find2(const char *path)
Find a Mailbox on an Account.
WHERE bool OptNeedRescore
(pseudo) set when the 'score' command is used
struct Account * mx_ac_find(struct Mailbox *m)
Find the Account owning a Mailbox.
void mutt_default_save(char *path, size_t pathlen, struct Email *e)
Find the default save path for an email.
All user-callable functions.
#define MUTT_CM_NO_FLAGS
No flags are set.
Container for Accounts, Notifications.
int mutt_save_confirm(const char *s, struct stat *st)
Ask the user to save.
int vcount
The number of virtual messages.
QuadOption
Possible values for a quad-option.
#define MUTT_SET_DRAFT
set the message draft flag
int mx_mbox_sync(struct Mailbox *m)
Save changes to mailbox.
int imap_sync_mailbox(struct Mailbox *m, bool expunge, bool close)
Sync all the changes to the server.
char * HomeDir
User's home directory.
struct Email * email_new(void)
Create a new Email.
Assorted sorting methods.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
WHERE char * Username
User's login name.
int(* mbox_open)(struct Mailbox *m)
Open a Mailbox.
int(* mbox_open_append)(struct Mailbox *m, OpenMailboxFlags flags)
Open a Mailbox for appending.
Some miscellaneous functions.
bool has_new
Mailbox has new mail.
char * C_Trash
Config: Folder to put deleted emails.
int(* path_canon)(char *buf, size_t buflen)
Canonicalise a Mailbox path.
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
bool tagged
Email is tagged.
char * name
A short name for the Mailbox.
void mutt_sleep(short s)
Sleep for a while.
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
struct HashTable * id_hash
Hash Table by msg id.
Parse and execute user-defined hooks.
Many unsorted constants and some structs.
bool old
Email is seen, but unread.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
#define MUTT_PEEK
Revert atime back after taking a look (if applicable)
void mutt_file_unlink_empty(const char *path)
Delete a file if it's empty.
struct AddressList from
Email's 'From' list.
struct AddressList * alias_lookup(const char *name)
Find an Alias.
bool readonly
Don't allow changes to the mailbox.
The Context has been opened.
struct Mailbox * mx_resolve(const char *path_or_name)
Get a Mailbox from either a path or name.
struct Envelope * env
Envelope information.
Convenience wrapper for the core headers.
int mx_tags_commit(struct Mailbox *m, struct Email *e, char *tags)
Save tags to the Mailbox - Wrapper for MxOps::tags_commit()
struct Notify * notify
Notifications handler.
void mx_fastclose_mailbox(struct Mailbox *m)
free up memory associated with the Mailbox
struct MxOps MxImapOps
IMAP Mailbox - Implements MxOps.
struct MxOps MxPopOps
POP Mailbox - Implements MxOps.
int opened
Number of times mailbox is opened.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
User aborted the question (with Ctrl-G)
unsigned char C_CatchupNewsgroup
Config: (nntp) Mark all articles as read when leaving a newsgroup.
Compressed mbox local mailbox type.
int(* msg_padding_size)(struct Mailbox *m)
Bytes of padding between messages.
void * mdata
Driver specific data.
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
struct Envelope * mutt_env_new(void)
Create a new Envelope.
int mx_mbox_check_stats(struct Mailbox *m, uint8_t flags)
Check the statistics for a mailbox - Wrapper for MxOps::mbox_check_stats()
struct HashTable * subj_hash
Hash Table by subject.
#define MUTT_MBOX_HOOK
mbox-hook: move messages after reading them
'Maildir' Mailbox type
Usenet network mailbox type; talk to an NNTP server.
enum MailboxType type
Mailbox type, e.g. MUTT_IMAP.
int imap_mxcmp(const char *mx1, const char *mx2)
Compare mailbox names, giving priority to INBOX.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
struct Keymap * km_find_func(enum MenuType menu, int func)
Find a function's mapping in a Menu.
off_t vsize
Size (in bytes) of the messages shown.
Email list needs resorting.
int(* mbox_check)(struct Mailbox *m)
Check for new mail.
WHERE bool OptForceRefresh
(pseudo) refresh even during macros
Prototypes for many functions.
Notmuch virtual mailbox type.
int(* tags_edit)(struct Mailbox *m, const char *tags, char *buf, size_t buflen)
Prompt and validate new messages tags.
struct Context * ctx_new(struct Mailbox *m)
Create a new Context.
A local copy of an email.
int email_max
Number of pointers in emails.
int imap_copy_messages(struct Mailbox *m, struct EmailList *el, const char *dest, bool delete_original)
Server COPY messages to another folder.
void ctx_update(struct Context *ctx)
Update the Context's message counts.
int imap_access(const char *path)
Check permissions on an IMAP mailbox with a new connection.
char * mutt_find_hook(HookFlags type, const char *pat)
Find a matching hook.
#define MUTT_NOSORT
Do not sort the mailbox after opening it.
#define CH_NO_FLAGS
No flags are set.
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
struct MxOps MxMmdfOps
MMDF Mailbox - Implements MxOps.
int(* mbox_sync)(struct Mailbox *m)
Save changes to the Mailbox.
bool dontwrite
Don't write the mailbox on close.
int(* msg_save_hcache)(struct Mailbox *m, struct Email *e)
Save message to the header cache.
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
'mmdf' Mailbox type
int(* msg_open)(struct Mailbox *m, struct Message *msg, int msgno)
Open an email message in a Mailbox.
Compressed file Mailbox type.
bool append
Mailbox is opened in append mode.
'MH' Mailbox type
bool verbose
Display status messages?
const struct MxOps * mx_ops
MXAPI callback functions.
#define CH_UPDATE_LEN
Update Lines: and Content-Length:
bool purge
Skip trash folder when deleting.
int mx_tags_edit(struct Mailbox *m, const char *tags, char *buf, size_t buflen)
start the tag editor of the mailbox
unsigned char C_MboxType
Config: Default type for creating new mailboxes.
int msg_tagged
How many messages are tagged?
WHERE bool C_MailCheckRecent
Config: Notify the user about new mail since the last time the mailbox was opened.
#define MUTT_QUIET
Do not print any messages.
AclFlags rights
ACL bits, see AclFlags.
#define STAILQ_FOREACH(var, head, field)
struct Account * account_new(const char *name, struct ConfigSubset *sub)
Create a new Account.
int mx_mbox_check(struct Mailbox *m)
Check for new mail - Wrapper for MxOps::mbox_check()
int emaillist_add_email(struct EmailList *el, struct Email *e)
Add an Email to a list.
uint8_t MsgOpenFlags
Flags for mx_msg_open_new(), e.g. MUTT_ADD_FROM.
NNTP-specific Mailbox data -.
Maildir local mailbox type.
WHERE char * LastFolder
Previously selected mailbox.
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
'mbox' Mailbox type
bool write
nonzero if message is open for writing
void mutt_exit(int code)
Leave NeoMutt NOW.
int * v2r
Mapping from virtual to real msgno.
uint8_t flags
e.g. MB_NORMAL
WHERE char * C_Record
Config: Folder to save 'sent' messages.
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
WHERE unsigned char C_Delete
Config: Really delete messages, when the mailbox is closed.
bool mutt_path_canon(char *buf, size_t buflen, const char *homedir, bool is_dir)
Create the canonical version of a path.
Context has changed, NotifyContext, EventContext.
Duplicate the structure of an entire email.
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
MailboxType
Supported mailbox formats.
struct AddressList return_path
Return path for the Email.
struct Account * account
Account that owns this Mailbox.
WHERE char * C_Spoolfile
Config: Inbox.
bool flagged
Marked important?
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
int(* msg_open_new)(struct Mailbox *m, struct Message *msg, const struct Email *e)
Open a new message in a Mailbox.
int(* mbox_close)(struct Mailbox *m)
Close a Mailbox.
static int mx_open_mailbox_append(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox for appending.
int msg_new
Number of new messages.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
bool collapsed
Are all threads collapsed?
bool deleted
Email is deleted.
int(* path_pretty)(char *buf, size_t buflen, const char *folder)
Abbreviate a Mailbox path.
bool C_MaildirTrash
Config: Use the maildir 'trashed' flag, rather than deleting.
bool replied
Email has been replied to.
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
WHERE char * CurrentFolder
Currently selected mailbox.
int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Append a message.
FILE * fp
pointer to the message data
bool account_mailbox_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account.
int(* msg_close)(struct Mailbox *m, struct Message *msg)
Close an email.
bool account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Mailbox has changed, NotifyMailbox, EventMailbox.
Mapping between user-readable string and a constant.
int mx_access(const char *path, int flags)
Wrapper for access, checks permissions on a given mailbox.
bool mx_mbox_ac_link(struct Mailbox *m)
Link a Mailbox to an existing or new Account.
#define STAILQ_EMPTY(head)
time_t received
the time at which this message was received
struct MxOps MxMboxOps
Mbox Mailbox - Implements MxOps.
#define STAILQ_HEAD_INITIALIZER(head)
bool neomutt_account_remove(struct NeoMutt *n, struct Account *a)
Remove an Account from the global list.
User answered 'No', or assume 'No'.
struct AddressList to
Email's 'To' list.
struct AddressList sender
Email's sender.
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
bool changed
Mailbox has been modified.
void ctx_free(struct Context **ptr)
Free a Context.
Hundreds of global variables to back the user variables.
Handling of global boolean variables.
#define mutt_debug(LEVEL,...)
void mutt_mailbox_set_notified(struct Mailbox *m)
Note when the user was last notified of new mail.
struct ConfigSubset * sub
Inherited config items.
int mx_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Wrapper for MxOps::msg_padding_size()
New mail received in Mailbox.
bool mutt_str_inline_replace(char *buf, size_t buflen, size_t xlen, const char *rstr)
Replace the beginning of a string.
bool mx_tags_is_supported(struct Mailbox *m)
return true if mailbox support tagging
struct Notify * notify
Notifications handler.
bool C_KeepFlagged
Config: Don't move flagged messages from $spoolfile to $mbox
An Event that happened to an Context.
#define TAILQ_EMPTY(head)
#define MUTT_NEWFOLDER
Create a new folder - same as MUTT_APPEND,.
bool neomutt_account_add(struct NeoMutt *n, struct Account *a)
Add an Account to the global list.
int mx_ac_remove(struct Mailbox *m)
Remove a Mailbox from an Account and delete Account if empty.
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Convenience wrapper for the library headers.
int(* mbox_check_stats)(struct Mailbox *m, uint8_t flags)
Check the Mailbox statistics.
#define MUTT_ADD_FROM
add a From_ line
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
'IMAP' Mailbox type
int mx_path_canon(char *buf, size_t buflen, const char *folder, enum MailboxType *type)
Canonicalise a mailbox path - Wrapper for MxOps::path_canon()
int imap_fast_trash(struct Mailbox *m, char *dest)
Use server COPY command to copy deleted messages to trash.
WHERE char * C_Mbox
Config: Folder that receives read emails (see Move)
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
static bool mutt_is_spool(const char *str)
Is this the spoolfile?
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
time_t received
Time when the message was placed in the mailbox.
char * path
path to temp file
bool mutt_comp_can_append(struct Mailbox *m)
Can we append to this path?
User answered 'Yes', or assume 'Yes'.
struct Mailbox * mailbox
Mailbox in the list.
struct Url * url_parse(const char *src)
Fill in Url.
int(* tags_commit)(struct Mailbox *m, struct Email *e, char *buf)
Save the tags to a message.
WHERE bool C_Confirmappend
Config: Confirm before appending emails to a mailbox.
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.