371 char *subject = NULL;
372 char *include_file = NULL;
373 char *draft_file = NULL;
374 char *new_type = NULL;
378 char *cli_nntp = NULL;
380 struct Email *e = NULL;
391 bool explicit_folder =
false;
392 bool dump_variables =
false;
393 bool one_liner =
false;
394 bool hide_sensitive =
false;
395 bool batch_mode =
false;
396 bool edit_infile =
false;
397 #ifdef USE_DEBUG_PARSE_TEST 398 bool test_config =
false;
400 int double_dash = argc, nargc = 1;
402 bool repeat_error =
false;
411 if (getegid() != getgid())
413 mutt_error(
"%s: I don't want to run with privileges!", argv[0]);
422 for (optind = 1; optind < double_dash;)
428 for (; optind < argc; optind++)
430 if ((argv[optind][0] ==
'-') && (argv[optind][1] !=
'\0'))
432 if ((argv[optind][1] ==
'-') && (argv[optind][2] ==
'\0'))
433 double_dash = optind;
441 argv[nargc++] = argv[optind];
445 i = getopt(argc, argv,
"+A:a:Bb:F:f:c:Dd:l:Ee:g:GH:i:hm:nOpQ:RSs:TvxyzZ");
466 dump_variables =
true;
482 explicit_folder =
true;
496 include_file = optarg;
520 hide_sensitive =
true;
525 #ifdef USE_DEBUG_PARSE_TEST 551 while (optind < argc)
552 argv[nargc++] = argv[optind++];
575 #ifdef USE_DEBUG_NOTIFY 582 #ifdef USE_DEBUG_PARSE_TEST 606 mutt_error(
_(
"Error: value '%s' is invalid for -d"), dlevel);
643 dump_variables || batch_mode)
743 for (; optind < argc; optind++)
758 printf(
"%s\n", np->
data);
803 snprintf(msg2,
sizeof(msg2),
_(
"%s does not exist. Create it?"),
C_Folder);
838 else if (subject || e || sendflags || draft_file || include_file ||
844 char *bodytext = NULL;
845 const char *bodyfile = NULL;
856 for (i = optind; i < argc; i++)
887 else if (include_file)
888 infile = include_file;
892 if (infile || bodytext)
943 fputs(bodytext, fp_out);
974 if (fstat(fileno(fp_in), &st) != 0)
985 mutt_error(
_(
"Can't parse message template: %s"), draft_file);
992 struct ListNode *np = NULL, *tmp = NULL;
1017 else if (edit_infile)
1032 while (b && b->
next)
1069 else if (draft_file)
1101 fprintf(fp_out,
"X-Mutt-Resume-Draft: 1\n");
1102 fputc(
'\n', fp_out);
1218 repeat_error =
true;
1228 repeat_error =
false;
1230 if (
Context || !explicit_folder)
1244 repeat_error =
false;
1252 #ifdef USE_AUTOCRYPT #define CSR_SUCCESS
Action completed successfully.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
enum UrlScheme url_check_scheme(const char *str)
Check the protocol of a URL.
#define MUTT_OPEN_NO_FLAGS
No flags are set.
int mx_path_is_empty(const char *path)
Is the mailbox empty.
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
uint8_t CliFlags
Flags for command line options, e.g. MUTT_CLI_IGNORE.
#define MUTT_CLI_NOSYSRC
-n Do not read the system-wide config file
#define mutt_buffer_mktemp(buf)
Container for lots of config items.
#define STAILQ_REMOVE(head, elm, type, field)
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
int log_disp_curses(time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...)
Display a log line in the message line - Implements log_dispatcher_t.
bool C_ResumeEditedDraftFiles
Config: Resume editing previously saved draft files.
The envelope/body of an email.
int mutt_log_start(void)
Enable file logging.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
void email_free(struct Email **ptr)
Free an Email.
void crypt_cleanup(void)
Clean up backend.
struct Notify * notify
Notifications system.
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
struct ConnAccount account
Account details: username, password, etc.
void mutt_window_init(void)
Create the default Windows.
struct Body * body
List of MIME parts.
void mutt_browser_cleanup(void)
Clean up working Buffers.
struct Mailbox * ctx_mailbox(struct Context *ctx)
wrapper to get the mailbox in a Context, or NULL
'NNTP' (Usenet) Mailbox type
void mutt_buffer_select_file(struct Buffer *file, SelectFileFlags flags, char ***files, int *numfiles)
Let the user select a file.
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
#define mutt_message(...)
struct AccountList accounts
List of all Accounts.
struct AddressList bcc
Email's 'Bcc' list.
#define SEND_DRAFT_FILE
Used by the -H flag.
bool C_Autocrypt
Config: Enables the Autocrypt feature.
int mutt_write_mime_body(struct Body *a, FILE *fp, struct ConfigSubset *sub)
Write a MIME part.
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
void mutt_window_free_all(void)
Free all the default Windows.
bool mutt_ts_capability(void)
Check terminal capabilities.
void mutt_flushinp(void)
Empty all the keyboard buffers.
bool mutt_should_hide_protected_subject(struct Email *e)
Should NeoMutt hide the protected subject?
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
int log_disp_terminal(time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...)
Save a log line to the terminal - Implements log_dispatcher_t.
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.
void mutt_envlist_init(char *envp[])
Create a copy of the environment.
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
void print_version(FILE *fp)
Print system and compile info to a file.
void neomutt_free(struct NeoMutt **ptr)
Free a NeoMutt.
String manipulation buffer.
bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
char * mutt_str_dup(const char *str)
Copy a string, safely.
struct ListHead userhdrs
user defined headers
static void log_translation(void)
Log the translation being used.
struct Body * next
next attachment in the list
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
A division of the screen.
char * C_NewsServer
Config: (nntp) Url of the news server.
int cs_str_string_set(const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Log informational message.
WHERE char ErrorBuf[256]
Copy of the last error message.
#define MUTT_READONLY
Open in read-only mode.
struct Mailbox * mutt_mailbox_next(struct Mailbox *m_cur, struct Buffer *s)
incoming folders completion routine
void mutt_unlink_temp_attachments(void)
Delete all temporary attachments.
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
An Event that happened to a Mailbox.
uint16_t SendFlags
Flags for mutt_send_message(), e.g. SEND_REPLY.
log_dispatcher_t MuttLogger
The log dispatcher.
int mutt_env_to_intl(struct Envelope *env, const char **tag, char **err)
Convert an Envelope's Address fields to Punycode format.
int mutt_str_atos(const char *str, short *dst)
Convert ASCII string to a short.
#define SEND_POSTPONED
Recall a postponed email.
Container for Accounts, Notifications.
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
#define CS_DUMP_HIDE_SENSITIVE
Obscure sensitive information like passwords.
#define MUTT_SEL_FOLDER
Select a local directory.
void imap_logout_all(void)
close all open connections
char * HomeDir
User's home directory.
const char * mutt_str_getenv(const char *name)
Get an environment variable.
struct Email * email_new(void)
Create a new Email.
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
#define SEND_NO_FLAGS
No flags are set.
static void reset_tilde(struct ConfigSet *cs)
Temporary measure.
WHERE char * Username
User's login name.
struct Body * mutt_body_new(void)
Create a new Body.
void mutt_folder_hook(const char *path, const char *desc)
Perform a folder hook.
size_t dsize
Length of data.
void mutt_startup_shutdown_hook(HookFlags type)
Execute any startup/shutdown hooks.
static bool get_user_info(struct ConfigSet *cs)
Find the user's name, home and shell.
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
struct Notify * notify
Notifications system.
void mutt_prepare_envelope(struct Envelope *env, bool final, struct ConfigSubset *sub)
Prepare an email header.
bool mutt_parse_mailto(struct Envelope *e, char **body, const char *src)
Parse a mailto:// url.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
void mutt_addrlist_write_file(const struct AddressList *al, FILE *fp, int start_col, bool display)
Wrapper for mutt_write_address()
struct AddressList * alias_lookup(const char *name)
Find an Alias.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
struct Mailbox * mx_resolve(const char *path_or_name)
Get a Mailbox from either a path or name.
struct Envelope * env
Envelope information.
struct Body * mutt_make_file_attach(const char *path, struct ConfigSubset *sub)
Create a file attachment.
struct MyVarList MyVars
List of all the user's custom config variables.
#define MUTT_CLI_RO
-R Open mailbox in read-only mode
struct AddressList cc
Email's 'Cc' list.
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
int cs_str_initial_set(const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err)
Set the initial value of a config item.
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
WHERE bool C_ReadOnly
Config: Open folders in read-only mode.
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.
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
struct NntpAccountData * nntp_select_server(struct Mailbox *m, const char *server, bool leave_lock)
Open a connection to an NNTP server.
static int start_curses(void)
Start the curses or slang UI.
struct Body * mutt_make_multipart(struct Body *b)
Create a multipart email.
void test_parse_set(void)
Test the config parsing.
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
#define MUTT_CLI_SELECT
-y Start with a list of all mailboxes
void mutt_autocrypt_cleanup(void)
Shutdown Autocrypt.
void mutt_init_abort_key(void)
Parse the abort_key config string.
int mutt_reply_observer(struct NotifyCallback *nc)
Listen for config changes to "reply_regex" - Implements observer_t.
void log_queue_set_max_size(int size)
Set a upper limit for the queue length.
int mutt_query_variables(struct ListHead *queries, bool show_docs)
Implement the -Q command line flag.
bool C_ImapPassive
Config: (imap) Reuse an existing IMAP connection to check for new mail.
void mutt_window_set_root(int cols, int rows)
Set the dimensions of the Root Window.
int mutt_init(struct ConfigSet *cs, bool skip_sys_rc, struct ListHead *commands)
Initialise NeoMutt.
'POP3' Mailbox type
void mutt_endwin(void)
Shutdown curses/slang.
struct Mailbox * mailbox_find_name(const char *name)
Find the mailbox with a given name.
LOFF_T length
length (in bytes) of attachment
void mutt_keys_free(void)
Free the key maps.
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
#define CS_DUMP_NO_FLAGS
No flags are set.
void myvarlist_free(struct MyVarList *list)
Free a List of MyVars.
#define MUTT_CLI_MAILBOX
-Z Open first mailbox if is has new mail
enum MailboxType nntp_path_probe(const char *path, const struct stat *st)
Is this an NNTP Mailbox? - Implements MxOps::path_probe()
int mutt_abort_key_config_observer(struct NotifyCallback *nc)
Listen for abort_key config changes - Implements observer_t.
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
void log_queue_empty(void)
Free the contents of the queue.
char * data
Pointer to data.
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
struct ConfigSet * init_config(size_t size)
Initialise the config system.
Not object-related, NotifyGlobal.
bool dump_config(struct ConfigSet *cs, ConfigDumpFlags flags, FILE *fp)
Write all the config to a file.
WHERE bool C_Autoedit
Config: Skip the initial compose menu and edit the email.
void myvar_set(const char *var, const char *val)
Set the value of a "my_" variable.
#define CS_DUMP_SHOW_DOCS
Show one-liner documentation for the config item.
void mutt_log_stop(void)
Close the log file.
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
void crypt_init(void)
Initialise the crypto backends.
#define STAILQ_FOREACH(var, head, field)
struct Notify * notify
Notifications handler.
bool TsSupported
Terminal Setting is supported.
enum MailboxType pop_path_probe(const char *path, const struct stat *st)
Is this a POP Mailbox? - Implements MxOps::path_probe()
int mutt_index_menu(struct MuttWindow *dlg)
Display a list of emails.
void mutt_opts_free(void)
clean up before quitting
void mutt_envlist_free(void)
Free the private copy of the environment.
char * mutt_file_read_keyword(const char *file, char *buf, size_t buflen)
Read a keyword from a file.
WHERE char * LastFolder
Previously selected mailbox.
#define SEND_NO_FREE_HEADER
Used by the -E flag.
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
LOFF_T offset
Where in the stream does this message begin?
Config has changed, NotifyConfig, EventConfig.
#define MUTT_SEL_MAILBOX
Select a mailbox.
#define MUTT_CLI_NO_FLAGS
No flags are set.
void cs_free(struct ConfigSet **ptr)
Free a Config Set.
char * subject
Email's subject.
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
struct Account * account
Account that owns this Mailbox.
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
WHERE char * C_Spoolfile
Config: Inbox.
Register for all notifications.
static void usage(void)
Display NeoMutt command line.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
void mutt_prex_free(void)
Cleanup heap memory allocated by compiled regexes.
void mutt_sasl_done(void)
Invoke when processing is complete.
Current Mailbox has changed.
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
static void init_locale(void)
Initialise the Locale/NLS settings.
void dialog_pop(void)
Hide a Window from the user.
uint16_t ConfigDumpFlags
Flags for dump_config(), e.g. CS_DUMP_ONLY_CHANGED.
WHERE char * CurrentFolder
Currently selected mailbox.
#define MUTT_CLI_NEWS
-g/-G Start with a list of all newsgroups
bool account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
Mailbox has changed, NotifyMailbox, EventMailbox.
int mutt_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Context *ctx, struct EmailList *el, struct ConfigSubset *sub)
Send an email.
#define STAILQ_EMPTY(head)
#define STAILQ_HEAD_INITIALIZER(head)
void index_pager_shutdown(struct MuttWindow *dlg)
Clear up any non-Window parts.
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
void mutt_commands_cleanup(void)
Clean up commands globals.
void crypto_module_free(void)
Clean up the crypto modules.
struct AddressList to
Email's 'To' list.
int mutt_hist_observer(struct NotifyCallback *nc)
Listen for config changes affecting the history - Implements observer_t.
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.
void mutt_log_prep(void)
Prepare to log.
struct MuttWindow * index_pager_init(void)
Allocate the Windows for the Index/Pager.
int cs_str_reset(const struct ConfigSet *cs, const char *name, struct Buffer *err)
Reset a config item to its initial value.
void ctx_free(struct Context **ptr)
Free a Context.
struct ConfigSubset * sub
Inherited config items.
WHERE bool ErrorBufMessage
true if the last message was an error
#define TAILQ_EMPTY(head)
void mutt_buffer_pool_free(void)
Release the Buffer pool.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
int log_disp_queue(time_t stamp, const char *file, int line, const char *function, enum LogLevel level,...)
Save a log line to an internal queue - Implements log_dispatcher_t.
void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct)
Make fully qualified url from newsgroup name.
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
int mutt_log_observer(struct NotifyCallback *nc)
Listen for config changes affecting the log file - Implements observer_t.
'IMAP' Mailbox type
struct NeoMutt * neomutt_new(struct ConfigSet *cs)
Create the main NeoMutt object.
WHERE bool OptNews
(pseudo) used to change reader mode
void mutt_encode_descriptions(struct Body *b, bool recurse, struct ConfigSubset *sub)
rfc2047 encode the content-descriptions
#define MUTT_CLI_IGNORE
-z Open first mailbox if it has mail
#define MUTT_STARTUP_HOOK
startup-hook: run when starting NeoMutt
int debug_notify_observer(struct NotifyCallback *nc)
int mutt_prepare_template(FILE *fp, struct Mailbox *m, struct Email *e_new, struct Email *e, bool resend)
Prepare a message template.
#define SEND_BATCH
Send email in batch mode (without user interaction)
User answered 'Yes', or assume 'Yes'.
void mutt_buffer_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
void print_copyright(void)
Print copyright message.