127#define GNULIB_defined_setlocale
139#include <sys/utsname.h>
188#if defined(USE_DEBUG_NOTIFY) || defined(USE_DEBUG_BACKTRACE)
202#define MUTT_CLI_NO_FLAGS 0
203#define MUTT_CLI_IGNORE (1 << 0)
204#define MUTT_CLI_MAILBOX (1 << 1)
205#define MUTT_CLI_NOSYSRC (1 << 2)
206#define MUTT_CLI_RO (1 << 3)
207#define MUTT_CLI_SELECT (1 << 4)
208#define MUTT_CLI_NEWS (1 << 5)
249static char *
find_cfg(
const char *home,
const char *xdg_cfg_home)
251 const char *names[] = {
257 const char *locations[][2] = {
258 { xdg_cfg_home,
"neomutt/" },
259 { xdg_cfg_home,
"mutt/" },
260 { home,
".neomutt/" },
266 for (
int i = 0; locations[i][0] || locations[i][1]; i++)
268 if (!locations[i][0])
271 for (
int j = 0; names[j]; j++)
273 char buf[256] = { 0 };
275 snprintf(buf,
sizeof(buf),
"%s/%s%s", locations[i][0], locations[i][1], names[j]);
276 if (access(buf, F_OK) == 0)
292 char *mailname = NULL;
293 static const char *mn_files[] = {
"/etc/mailname",
"/etc/mail/mailname" };
304 if (mailname && *mailname)
325 const char *short_host = NULL;
326 struct utsname utsname = { 0 };
331 short_host = c_hostname;
338 if ((uname(&utsname)) == -1)
340 mutt_perror(
_(
"unable to determine nodename via uname()"));
344 short_host = utsname.nodename;
348 char *dot = strchr(short_host,
'.');
409 bool skip_sys_rc,
struct ListHead *commands)
411 bool need_pause =
false;
416#ifdef NEOMUTT_DIRECT_COLORS
427 if (COLORS == 16777216)
432 if (env_colorterm && (
mutt_str_equal(env_colorterm,
"truecolor") ||
472 struct Slist *sl_mc = NULL;
507 char name[256] = { 0 };
511 struct passwd *pw = getpwuid(getuid());
521 if (getsid(0) == getpid())
564 if (access(np->
data, F_OK))
657 mutt_error(
_(
"Can't create %s: %s"), c_tmp_dir, strerror(errno));
709 static const char *names[] = {
"folder",
"mbox",
"postponed",
"record" };
746 const char *l10n = gettext(
buf_string(value));
766 puts(
_(
" neomutt [-CEn] [-e <command>] [-F <config>] [-H <draft>] [-i <include>]\n"
767 " [-b <address>] [-c <address>] [-s <subject>] [-a <file> [...] --]\n"
768 " <address> [...]"));
769 puts(
_(
" neomutt [-Cn] [-e <command>] [-F <config>] [-b <address>] [-c <address>]\n"
770 " [-s <subject>] [-a <file> [...] --] <address> [...] < message"));
771 puts(
_(
" neomutt [-nRy] [-e <command>] [-F <config>] [-f <mailbox>] [-m <type>]"));
772 puts(
_(
" neomutt [-n] [-e <command>] [-F <config>] -A <alias>"));
773 puts(
_(
" neomutt [-n] [-e <command>] [-F <config>] -D [-D] [-O] [-S]"));
774 puts(
_(
" neomutt [-n] [-e <command>] [-F <config>] -d <level> -l <file>"));
775 puts(
_(
" neomutt [-n] [-e <command>] [-F <config>] -G"));
776 puts(
_(
" neomutt [-n] [-e <command>] [-F <config>] -g <server>"));
777 puts(
_(
" neomutt [-n] [-e <command>] [-F <config>] -p"));
778 puts(
_(
" neomutt [-n] [-e <command>] [-F <config>] -Q <variable> [-O]"));
779 puts(
_(
" neomutt [-n] [-e <command>] [-F <config>] -Z"));
780 puts(
_(
" neomutt [-n] [-e <command>] [-F <config>] -z [-f <mailbox>]"));
781 puts(
_(
" neomutt -v[v]\n"));
785 puts(
_(
" -- Special argument forces NeoMutt to stop option parsing and treat\n"
786 " remaining arguments as addresses even if they start with a dash"));
787 puts(
_(
" -A <alias> Print an expanded version of the given alias to stdout and exit"));
788 puts(
_(
" -a <file> Attach one or more files to a message (must be the last option)\n"
789 " Add any addresses after the '--' argument"));
790 puts(
_(
" -b <address> Specify a blind carbon copy (Bcc) recipient"));
791 puts(
_(
" -c <address> Specify a carbon copy (Cc) recipient"));
792 puts(
_(
" -C Enable Command-line Crypto (signing/encryption)"));
793 puts(
_(
" -D Dump all config variables as 'name=value' pairs to stdout"));
794 puts(
_(
" -D -D (or -DD) Like -D, but only show changed config"));
795 puts(
_(
" -D -O Like -D, but show one-liner documentation"));
796 puts(
_(
" -D -S Like -D, but hide the value of sensitive variables"));
797 puts(
_(
" -d <level> Log debugging output to a file (default is \"~/.neomuttdebug0\")\n"
798 " The level can range from 1-5 and affects verbosity"));
799 puts(
_(
" -E Edit draft (-H) or include (-i) file during message composition"));
800 puts(
_(
" -e <command> Specify a command to be run after reading the config files"));
801 puts(
_(
" -F <config> Specify an alternative initialization file to read"));
802 puts(
_(
" -f <mailbox> Specify a mailbox (as defined with 'mailboxes' command) to load"));
803 puts(
_(
" -G Start NeoMutt with a listing of subscribed newsgroups"));
804 puts(
_(
" -g <server> Like -G, but start at specified news server"));
805 puts(
_(
" -H <draft> Specify a draft file with header and body for message composing"));
806 puts(
_(
" -h Print this help message and exit"));
807 puts(
_(
" -i <include> Specify an include file to be embedded in the body of a message"));
808 puts(
_(
" -l <file> Specify a file for debugging output (default \"~/.neomuttdebug0\")"));
809 puts(
_(
" -m <type> Specify a default mailbox format type for newly created folders\n"
810 " The type is either MH, MMDF, Maildir or mbox (case-insensitive)"));
811 puts(
_(
" -n Do not read the system-wide configuration file"));
812 puts(
_(
" -p Resume a prior postponed message, if any"));
813 puts(
_(
" -Q <variable> Query a configuration variable and print its value to stdout\n"
814 " (after the config has been read and any commands executed)\n"
815 " Add -O for one-liner documentation"));
816 puts(
_(
" -R Open mailbox in read-only mode"));
817 puts(
_(
" -s <subject> Specify a subject (must be enclosed in quotes if it has spaces)"));
818 puts(
_(
" -v Print the NeoMutt version and compile-time definitions and exit"));
819 puts(
_(
" -vv Print the NeoMutt license and copyright information and exit"));
820 puts(
_(
" -y Start NeoMutt with a listing of all defined mailboxes"));
821 puts(
_(
" -Z Open the first mailbox with new message or exit immediately with\n"
822 " exit code 1 if none is found in all defined mailboxes"));
823 puts(
_(
" -z Open the first or specified (-f) mailbox if it holds any message\n"
824 " or exit immediately with exit code 1 otherwise"));
828 return !ferror(stdout);
851 keypad(stdscr,
true);
870 setlocale(LC_ALL,
"");
875 bindtextdomain(PACKAGE, domdir);
877 bindtextdomain(PACKAGE, MUTTLOCALEDIR);
901 struct passwd *pw = getpwuid(getuid());
909 shell = pw->pw_shell;
920 mutt_error(
_(
"unable to determine home directory"));
939 const char *header =
"";
941 const char *label =
"Language:";
946 lang += strlen(label);
948 char *nl = strchr(lang,
'\n');
967 bool true_color =
false;
968#ifdef NEOMUTT_DIRECT_COLORS
988 static time_t last_run = 0;
998 if (now < (last_run + c_timeout))
1023int main(
int argc,
char *argv[],
char *envp[])
1025 char *subject = NULL;
1026 char *include_file = NULL;
1027 char *draft_file = NULL;
1028 char *new_type = NULL;
1029 char *dlevel = NULL;
1031 const char *cli_nntp = NULL;
1032 struct Email *e = NULL;
1043 bool explicit_folder =
false;
1044 bool dump_variables =
false;
1045 bool dump_changed =
false;
1046 bool one_liner =
false;
1047 bool hide_sensitive =
false;
1048 bool edit_infile =
false;
1049 int double_dash = argc, nargc = 1;
1051 bool repeat_error =
false;
1060 if (getegid() != getgid())
1062 mutt_error(
"%s: I don't want to run with privileges!", (argc != 0) ? argv[0] :
"neomutt");
1080 for (optind = 1; optind < double_dash;)
1086 for (; optind < argc; optind++)
1088 if ((argv[optind][0] ==
'-') && (argv[optind][1] !=
'\0'))
1090 if ((argv[optind][1] ==
'-') && (argv[optind][2] ==
'\0'))
1091 double_dash = optind;
1099 argv[nargc++] = argv[optind];
1102 i = getopt(argc, argv,
"+A:a:b:F:f:Cc:Dd:l:Ee:g:GH:i:hm:nOpQ:RSs:TvyzZ");
1124 dump_changed =
true;
1126 dump_variables =
true;
1142 explicit_folder =
true;
1152 draft_file = optarg;
1155 include_file = optarg;
1179 hide_sensitive =
true;
1207 while (optind < argc)
1208 argv[nargc++] = argv[optind++];
1233#ifdef USE_DEBUG_NOTIFY
1251 if (!mutt_str_atos_full(dlevel, &num) || (num <
LL_MESSAGE) || (num >=
LL_MAX))
1253 mutt_error(
_(
"Error: value '%s' is invalid for -d"), dlevel);
1287 if (!isatty(STDIN_FILENO) || !
STAILQ_EMPTY(&queries) ||
1348 if (c_virtual_spool_file)
1371 char buf[1024] = { 0 };
1386 const bool tty = isatty(STDOUT_FILENO);
1416 for (; optind < argc; optind++)
1462 struct stat st = { 0 };
1472 if (!skip && (stat(
buf_string(fpath), &st) == -1) && (errno == ENOENT))
1474 char msg2[256] = { 0 };
1475 snprintf(msg2,
sizeof(msg2),
_(
"%s does not exist. Create it?"), c_folder);
1478 if ((mkdir(
buf_string(fpath), 0700) == -1) && (errno != EEXIST))
1479 mutt_error(
_(
"Can't create %s: %s"), c_folder, strerror(errno));
1501 repeat_error =
true;
1504 else if (subject || e || draft_file || include_file ||
1508 FILE *fp_out = NULL;
1509 char *infile = NULL;
1510 char *bodytext = NULL;
1511 const char *bodyfile = NULL;
1522 for (i = optind; i < argc; i++)
1557 infile = draft_file;
1558 include_file = NULL;
1560 else if (include_file)
1562 infile = include_file;
1566 edit_infile =
false;
1569 if (infile || bodytext)
1629 fputs(bodytext, fp_out);
1648 struct stat st = { 0 };
1657 if (fstat(fileno(fp_in), &st) != 0)
1668 mutt_error(
_(
"Can't parse message template: %s"), draft_file);
1675 struct ListNode *np = NULL, *tmp = NULL;
1681 if (c_resume_edited_draft_files)
1699 else if (edit_infile)
1720 while (b && b->
next)
1757 if (truncate(
buf_string(expanded_infile), 0) == -1)
1784 c_crypt_protected_headers_read &&
1788 if (c_resume_edited_draft_files)
1789 fprintf(fp_out,
"X-Mutt-Resume-Draft: 1\n");
1790 fputc(
'\n', fp_out);
1829 repeat_error =
true;
1918 repeat_error =
true;
1928 repeat_error =
false;
1930 if (m || !explicit_folder)
1943 repeat_error =
false;
1946#ifdef USE_SASL_CYRUS
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
size_t mutt_addrlist_write(const struct AddressList *al, struct Buffer *buf, bool display)
Write an Address to a buffer.
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
void alias_cleanup(void)
Clean up the Alias globals.
struct AddressList * alias_lookup(const char *name)
Find an Alias.
void alias_init(void)
Set up the Alias globals.
void alternates_cleanup(void)
Free the alternates lists.
void alternates_init(void)
Set up the alternates lists.
Alternate address handling.
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
#define ARRAY_FREE(head)
Release all memory.
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
GUI display the mailboxes in a side panel.
void attach_init(void)
Set up the attachments lists.
void attach_cleanup(void)
Free the attachments lists.
Autocrypt end-to-end encryption.
void mutt_autocrypt_cleanup(void)
Shutdown Autocrypt.
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Select a Mailbox from a list.
#define MUTT_SEL_MAILBOX
Select a mailbox.
#define MUTT_SEL_FOLDER
Select a local directory.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
void buf_seek(struct Buffer *buf, size_t offset)
Set current read/write position to offset from beginning.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
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.
size_t buf_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Color and attribute parsing.
void colors_cleanup(void)
Cleanup all the colours.
void colors_init(void)
Initialize colours.
@ MT_COLOR_NORMAL
Plain text.
CommandResult
Error codes for command_t parse functions.
@ MUTT_CMD_ERROR
Error: Can't help the user.
@ MUTT_CMD_WARNING
Warning: Help given to the user.
void source_stack_cleanup(void)
Free memory from the stack used for the source command.
bool commands_init(void)
Initialize commands array and register default commands.
int source_rc(const char *rcfile_path, struct Buffer *err)
Read an initialization file.
Functions to parse commands in a config file.
void mutt_comp_init(void)
Setup Compressed Mailbox commands.
Compressed mbox local mailbox type.
bool dump_config(struct ConfigSet *cs, struct HashElemArray *hea, ConfigDumpFlags flags, FILE *fp)
Write all the config to a file.
#define CS_DUMP_HIDE_SENSITIVE
Obscure sensitive information like passwords.
uint16_t ConfigDumpFlags
Flags for dump_config(), e.g. CS_DUMP_ONLY_CHANGED.
#define CS_DUMP_LINK_DOCS
Link to the online docs.
#define CS_DUMP_NO_FLAGS
No flags are set.
#define CS_DUMP_SHOW_DOCS
Show one-liner documentation for the config item.
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
const char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path config item by name.
bool config_str_set_initial(struct ConfigSet *cs, const char *name, const char *value)
Set the initial value of a Config Option.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
bool config_he_set_initial(struct ConfigSet *cs, struct HashElem *he, const char *value)
Set the initial value of a Config Option.
Convenience wrapper for the config headers.
int cs_str_initial_get(const struct ConfigSet *cs, const char *name, struct Buffer *result)
Get the initial, or parent, value of a config item.
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
void cs_free(struct ConfigSet **ptr)
Free a Config Set.
int cs_str_reset(const struct ConfigSet *cs, const char *name, struct Buffer *err)
Reset a config item to its initial value.
struct ConfigSet * cs_new(size_t size)
Create a new Config Set.
int cs_str_string_set(const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
int cs_str_native_set(const struct ConfigSet *cs, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
int cs_he_initial_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result)
Get the initial, or parent, value of a config item.
void config_cache_cleanup(void)
Cleanup the cache of charset config variables.
bool account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
void commands_clear(struct CommandArray *ca)
Clear an Array of Commands.
Convenience wrapper for the core headers.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
struct Mailbox * mailbox_find_name(const char *name)
Find the mailbox with a given name.
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
@ MUTT_POP
'POP3' Mailbox type
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
@ MUTT_IMAP
'IMAP' Mailbox type
bool mutt_should_hide_protected_subject(struct Email *e)
Should NeoMutt hide the protected subject?
void crypto_module_cleanup(void)
Clean up the crypto modules.
void crypt_cleanup(void)
Clean up backend.
void crypt_init(void)
Initialise the crypto backends.
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
void mutt_endwin(void)
Shutdown curses.
void mutt_flushinp(void)
Empty all the keyboard buffers.
Convenience wrapper for the debug headers.
int debug_all_observer(struct NotifyCallback *nc)
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
void dialog_pop(void)
Hide a Window from the user.
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
void mutt_browser_cleanup(void)
Clean up working Buffers.
struct MuttWindow * index_pager_init(void)
Allocate the Windows for the Index/Pager.
struct Body * mutt_body_new(void)
Create a new Body.
struct Email * email_new(void)
Create a new Email.
void email_free(struct Email **ptr)
Free an Email.
struct ReplaceList SpamList
List of regexes to match subscribed mailing lists.
struct RegexList SubscribedLists
List of header patterns to unignore (see)
struct RegexList UnSubscribedLists
struct RegexList UnMailLists
List of regexes to exclude false matches in SubscribedLists.
struct RegexList MailLists
List of permitted fields in a mailto: url.
struct ListHead MailToAllow
List of regexes to identify non-spam emails.
struct ListHead Ignore
List of regexes to match mailing lists.
struct RegexList NoSpamList
List of regexes and patterns to match spam emails.
struct ListHead UnIgnore
List of regexes to exclude false matches in MailLists.
Structs that make up an email.
bool mutt_parse_mailto(struct Envelope *env, char **body, const char *src)
Parse a mailto:// url.
void mutt_filter_commandline_header_value(char *header)
Sanitise characters in a header value.
int mutt_env_to_intl(struct Envelope *env, const char **tag, char **err)
Convert an Envelope's Address fields to Punycode format.
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
struct Envelope * mutt_env_new(void)
Create a new Envelope.
void mutt_env_set_subject(struct Envelope *env, const char *subj)
Set both subject and real_subj to subj.
void envlist_free(char ***envp)
Free the private copy of the environment.
char ** envlist_init(char **envp)
Create a copy of the environment.
void external_cleanup(void)
Clean up commands globals.
Manage where the email is piped to external commands.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
char * mutt_file_read_keyword(const char *file, char *buf, size_t buflen)
Read a keyword from a file.
int mutt_file_mkdir(const char *path, mode_t mode)
Recursively create directories.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
#define MUTT_RL_NO_FLAGS
No flags are set.
int getdnsdomainname(struct Buffer *result)
Lookup the host's name using DNS.
bool OptNews
(pseudo) used to change reader mode
char * LastFolder
Previously selected mailbox.
char * ShortHostname
Short version of the hostname.
bool OptNoCurses
(pseudo) when sending in batch mode
struct ListHead MimeLookupList
List of mime types that that shouldn't use the mailcap entry.
struct ListHead AlternativeOrderList
List of preferred mime types to display.
struct ListHead AutoViewList
List of mime types to auto view.
char ErrorBuf[1024]
Copy of the last error message.
bool ErrorBufMessage
true if the last message was an error
char * CurrentFolder
Currently selected mailbox.
struct ListHead UserHeader
List of custom headers to add to outgoing emails.
struct ListHead Muttrc
List of config files to read.
struct ListHead HeaderOrderList
List of header fields in the order they should be displayed.
void mutt_grouplist_init(void)
Initialize the GroupList singleton.
void mutt_grouplist_cleanup(void)
Free GroupList singleton resource.
enum CommandResult parse_my_hdr(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'my_hdr' command - Implements Command::parse() -.
void dlg_browser(struct Buffer *file, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
Let the user select a file -.
struct Mailbox * dlg_index(struct MuttWindow *dlg, struct Mailbox *m_init)
Display a list of emails -.
int log_disp_queue(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...)
Save a log line to an internal queue - Implements log_dispatcher_t -.
#define mutt_warning(...)
int log_disp_terminal(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...)
Save a log line to the terminal - Implements log_dispatcher_t -.
int log_disp_curses(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...)
Display a log line in the message line - Implements log_dispatcher_t -.
#define mutt_message(...)
#define mutt_debug(LEVEL,...)
enum MailboxType nntp_path_probe(const char *path, const struct stat *st)
Is this an NNTP Mailbox? - Implements MxOps::path_probe() -.
enum MailboxType pop_path_probe(const char *path, const struct stat *st)
Is this a POP Mailbox? - Implements MxOps::path_probe() -.
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe() -.
int main_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
int main_hist_observer(struct NotifyCallback *nc)
Notification that a Config Variable has change - Implements observer_t -.
static int main_timeout_observer(struct NotifyCallback *nc)
Notification that a timeout has occurred - Implements observer_t -.
int main_log_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
void mutt_gsasl_cleanup(void)
Shutdown GNU SASL library.
Convenience wrapper for the gui headers.
Read/write command history from/to a file.
void mutt_hist_read_file(void)
Read the History from a file.
void mutt_hist_init(void)
Create a set of empty History ring buffers.
void mutt_hist_cleanup(void)
Free all the history lists.
void mutt_timeout_hook(void)
Execute any timeout hooks.
void mutt_startup_shutdown_hook(HookFlags type)
Execute any startup/shutdown hooks.
void mutt_delete_hooks(HookFlags type)
Delete matching hooks.
void mutt_folder_hook(const char *path, const char *desc)
Perform a folder hook.
void hooks_init(void)
Setup feature commands.
Parse and execute user-defined hooks.
#define MUTT_STARTUP_HOOK
startup-hook: run when starting NeoMutt
#define MUTT_HOOK_NO_FLAGS
No flags are set.
void imap_logout_all(void)
Close all open connections.
void imap_init(void)
Setup feature commands.
GUI manage the main index (list of emails)
void km_init(void)
Initialise all the menu keybindings.
void mutt_keys_cleanup(void)
Free the key maps.
void init_extended_keys(void)
Initialise map of ncurses extended keys.
void mutt_init_abort_key(void)
Parse the abort_key config string.
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
int(*) log_dispatcher_ MuttLogger)
@ LL_DEBUG3
Log at debug level 3.
@ LL_DEBUG5
Log at debug level 5.
@ LL_MESSAGE
Log informational message.
@ LL_DEBUG1
Log at debug level 1.
@ LL_NOTIFY
Log of notifications.
static char * find_cfg(const char *home, const char *xdg_cfg_home)
Find a config file.
#define MUTT_CLI_SELECT
-y Start with a list of all mailboxes
static void init_locale(void)
Initialise the Locale/NLS settings.
static char * getmailname(void)
Try to retrieve the FQDN from mailname files.
static void localise_config(struct ConfigSet *cs)
Localise some config.
uint8_t CliFlags
Flags for command line options, e.g. MUTT_CLI_IGNORE.
static void log_translation(void)
Log the translation being used.
#define MUTT_CLI_MAILBOX
-Z Open first mailbox if is has new mail
static int execute_commands(struct ListHead *p)
Execute a set of NeoMutt commands.
static void log_gui(void)
Log info about the GUI.
static void reset_tilde(struct ConfigSet *cs)
Temporary measure.
static bool usage(void)
Display NeoMutt command line.
static int get_elem_queries(struct ListHead *queries, struct HashElemArray *hea)
Lookup the HashElems for a set of queries.
static int start_curses(void)
Start the Curses UI.
static int mutt_init(struct ConfigSet *cs, const char *dlevel, const char *dfile, bool skip_sys_rc, struct ListHead *commands)
Initialise NeoMutt.
bool StartupComplete
When the config has been read.
static bool get_user_info(struct ConfigSet *cs)
Find the user's name, home and shell.
#define MUTT_CLI_RO
-R Open mailbox in read-only mode
static bool get_hostname(struct ConfigSet *cs)
Find the Fully-Qualified Domain Name.
#define MUTT_CLI_NO_FLAGS
No flags are set.
int main(int argc, char *argv[], char *envp[])
Start NeoMutt.
#define MUTT_CLI_IGNORE
-z Open first mailbox if it has mail
#define MUTT_CLI_NEWS
-g/-G Start with a list of all newsgroups
#define MUTT_CLI_NOSYSRC
-n Do not read the system-wide config file
bool OptLocales
(pseudo) set if user has valid locale definition
#define mutt_array_size(x)
struct Body * mutt_make_multipart(struct Body *b)
Create a multipart email.
char * mutt_ch_get_langinfo_charset(void)
Get the user's choice of character set.
void mutt_ch_cache_cleanup(void)
Clean up the cached iconv handles and charset strings.
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Convenience wrapper for the library headers.
void log_queue_empty(void)
Free the contents of the queue.
void log_queue_set_max_size(int size)
Set a upper limit for the queue length.
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
struct Slist * slist_parse(const char *str, uint32_t flags)
Parse a list of strings into a list.
void slist_free(struct Slist **ptr)
Free an Slist object.
int slist_to_buffer(const struct Slist *list, struct Buffer *buf)
Export an Slist to a Buffer.
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
char * mutt_str_dup(const char *str)
Copy a string, safely.
int mutt_str_asprintf(char **strp, const char *fmt,...)
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
const char * mutt_str_getenv(const char *name)
Get an environment variable.
const char * mutt_istr_find(const char *haystack, const char *needle)
Find first occurrence of string (ignoring case)
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Many unsorted constants and some structs.
void mutt_temp_attachments_cleanup(void)
Delete all temporary attachments.
void init_config(struct ConfigSet *cs)
Initialise the config system.
enum MuttCursorState mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
const struct AttrColor * mutt_curses_set_color_by_id(enum ColorId cid)
Set the colour and attributes by the Colour ID.
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size.
@ MUTT_CURSOR_INVISIBLE
Hide the cursor.
@ MUTT_CURSOR_VISIBLE
Display a normal cursor.
void mutt_log_stop(void)
Close the log file.
int mutt_log_start(void)
Enable file logging.
void mutt_log_prep(void)
Prepare to log.
void mutt_lua_init(void)
Setup feature commands.
Integrated Lua scripting.
int mutt_mailbox_check(struct Mailbox *m_cur, CheckStatsFlags flags)
Check all all Mailboxes for new mail.
struct Mailbox * mutt_mailbox_next(struct Mailbox *m_cur, struct Buffer *s)
Incoming folders completion routine.
Mailbox helper functions.
void mutt_signal_init(void)
Initialise the signal handling.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
@ WT_DLG_INDEX
Index Dialog, dlg_index()
char * mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw)
Lookup a user's real name in /etc/passwd.
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
void buf_expand_path_regex(struct Buffer *buf, bool regex)
Create the canonical path (with regex char escaping)
const char * mutt_make_version(void)
Generate the NeoMutt version string.
int mutt_set_xdg_path(enum XdgType type, struct Buffer *buf)
Find an XDG path or its fallback.
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Some miscellaneous functions.
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
struct Mailbox * mx_resolve(const char *path_or_name)
Get a Mailbox from either a path or name.
int mx_path_is_empty(struct Buffer *path)
Is the mailbox empty.
#define MUTT_READONLY
Open in read-only mode.
#define MUTT_MAILBOX_CHECK_IMMEDIATE
Don't postpone the actual checking.
#define MUTT_OPEN_NO_FLAGS
No flags are set.
uint8_t CheckStatsFlags
Flags for mutt_mailbox_check.
API for encryption/signing of emails.
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
struct NeoMutt * neomutt_new(struct ConfigSet *cs)
Create the main NeoMutt object.
void neomutt_free(struct NeoMutt **ptr)
Free a NeoMutt.
@ NT_GLOBAL_STARTUP
NeoMutt is initialised.
Nntp-specific Account data.
Usenet network mailbox type; talk to an NNTP server.
void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct)
Make fully qualified url from newsgroup name.
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
struct NntpAccountData * nntp_select_server(struct Mailbox *m, const char *server, bool leave_lock)
Open a connection to an NNTP server.
@ NT_TIMEOUT
Timeout has occurred.
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
@ NT_ALL
Register for all notifications.
@ NT_GLOBAL
Not object-related, NotifyGlobal.
@ NT_RESIZE
Window has been resized.
Notmuch virtual mailbox type.
void nm_init(void)
Setup feature commands.
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 buf_pool_cleanup(void)
Release the Buffer pool.
int mutt_prepare_template(FILE *fp, struct Mailbox *m, struct Email *e_new, struct Email *e, bool resend)
Prepare a message template.
void mutt_prex_cleanup(void)
Cleanup heap memory allocated by compiled regexes.
Prototypes for many functions.
@ XDG_CONFIG_DIRS
XDG system dir: /etc/xdg.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
enum QuadOption query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
#define STAILQ_REMOVE(head, elm, type, field)
#define STAILQ_HEAD_INITIALIZER(head)
#define STAILQ_FIRST(head)
#define STAILQ_FOREACH(var, head, field)
#define STAILQ_EMPTY(head)
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
#define TAILQ_EMPTY(head)
enum CommandResult parse_rc_line(const char *line, struct Buffer *err)
Parse a line of user config.
void rootwin_cleanup(void)
Free all the default Windows.
struct MuttWindow * RootWindow
Parent of all Windows.
void rootwin_new(void)
Create the default Windows.
void mutt_sasl_cleanup(void)
Invoke when processing is complete.
int mutt_write_mime_body(struct Body *b, FILE *fp, struct ConfigSubset *sub)
Write a MIME part.
Convenience wrapper for the send headers.
void mutt_encode_descriptions(struct Body *b, bool recurse, struct ConfigSubset *sub)
RFC2047 encode the content-descriptions.
int mutt_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Mailbox *m, struct EmailArray *ea, struct ConfigSubset *sub)
Send an email.
#define SEND_BATCH
Send email in batch mode (without user interaction)
#define SEND_NO_FREE_HEADER
Used by the -E flag.
#define SEND_DRAFT_FILE
Used by the -H flag.
uint32_t SendFlags
Flags for mutt_send_message(), e.g. SEND_REPLY.
#define SEND_POSTPONED
Recall a postponed email.
#define SEND_CONSUMED_STDIN
stdin has been read; don't read it twice
#define SEND_CLI_CRYPTO
Enable message security in modes that by default don't enable it.
#define SEND_NO_FLAGS
No flags are set.
struct Body * mutt_make_file_attach(const char *path, struct ConfigSubset *sub)
Create a file attachment.
void mutt_prepare_envelope(struct Envelope *env, bool final, struct ConfigSubset *sub)
Prepare an email header.
LOFF_T length
length (in bytes) of attachment
struct Body * next
next attachment in the list
String manipulation buffer.
size_t dsize
Length of data.
char * data
Pointer to data.
Container for lots of config items.
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
struct ConfigSet * cs
Parent ConfigSet.
struct ConnAccount account
Account details: username, password, etc.
The envelope/body of an email.
struct Envelope * env
Envelope information.
struct Body * body
List of MIME parts.
LOFF_T offset
Where in the stream does this message begin?
struct ListHead userhdrs
user defined headers
char *const subject
Email's subject.
struct AddressList to
Email's 'To' list.
struct AddressList cc
Email's 'Cc' list.
struct AddressList bcc
Email's 'Bcc' list.
The item stored in a Hash Table.
int type
Type of data stored in Hash Table, e.g. DT_STRING.
struct Mailbox * mailbox
Mailbox in the list.
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
char * name
A short name for the Mailbox.
struct Account * account
Account that owns this Mailbox.
struct WindowState state
Current state of the Window.
struct MuttWindow * focus
Focused Window.
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Container for Accounts, Notifications.
struct CommandArray commands
NeoMutt commands.
struct Notify * notify_resize
Window resize notifications handler.
char ** env
Private copy of the environment variables.
char * username
User's login name.
struct AccountList accounts
List of all Accounts.
mode_t user_default_umask
User's default file writing permissions (inferred from umask)
char * home_dir
User's home directory.
struct Notify * notify
Notifications handler.
struct ConfigSubset * sub
Inherited config items.
struct Connection * conn
Connection to NNTP Server.
Data passed to a notification function.
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
void subjrx_init(void)
Create new Subject Regex List.
void subjrx_cleanup(void)
Free the Subject Regex List.
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
struct HashElemArray get_elem_list(struct ConfigSet *cs, enum GetElemListFlags flags)
Create a sorted list of all config items.
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
GetElemListFlags
Flags for get_elem_list()
@ GEL_CHANGED_CONFIG
Only config that has been changed.
@ GEL_ALL_CONFIG
All the normal config (no synonyms or deprecated)
bool TsSupported
Terminal Setting is supported.
bool mutt_ts_capability(void)
Check terminal capabilities.
#define D_SLIST_SEP_COLON
Slist items are colon-separated.
#define D_INTERNAL_DEPRECATED
Config item shouldn't be used any more.
#define D_L10N_STRING
String can be localised.
enum UrlScheme url_check_scheme(const char *str)
Check the protocol of a URL.
@ U_MAILTO
Url is mailto://.
bool print_copyright(void)
Print copyright message.
bool print_version(FILE *fp)
Print system and compile info to a file.
Display version and copyright about NeoMutt.