1022{
1024
1025 struct Email *e = NULL;
1027 int rc = 1;
1028 bool repeat_error = false;
1033
1034
1035 if (getegid() != getgid())
1036 {
1037 mutt_error(
"%s: I don't want to run with privileges!", (argc != 0) ? argv[0] :
"neomutt");
1038 goto done;
1039 }
1040
1042
1045 goto done;
1046
1048
1050 {
1051 rc = 0;
1052 goto done;
1053 }
1054
1056
1057#ifdef USE_DEBUG_NOTIFY
1059#endif
1060
1063 goto done;
1064
1066 goto done;
1067
1070
1071
1074 {
1079 }
1080
1081
1082 if (
OptGui && !isatty(STDOUT_FILENO))
1083 goto done;
1084
1085
1086
1088 {
1090 if (crc != 0)
1091 goto done;
1092 }
1093
1094
1095
1098
1099
1103 if (rc2 != 0)
1104 goto done;
1105
1108
1110
1111
1113
1116 {
1117 goto done;
1118 }
1119
1121 {
1122 rc = 0;
1123 goto done;
1124 }
1125
1126#ifdef USE_AUTOCRYPT
1127
1128
1130 if (c_autocrypt)
1132#endif
1133
1134
1137 {
1138 struct stat st = { 0 };
1140
1143 bool skip = false;
1144
1148 if (!skip && (stat(
buf_string(fpath), &st) == -1) && (errno == ENOENT))
1149 {
1150 char msg2[256] = { 0 };
1151 snprintf(msg2,
sizeof(msg2),
_(
"%s does not exist. Create it?"), c_folder);
1153 {
1154 if ((mkdir(
buf_string(fpath), 0700) == -1) && (errno != EEXIST))
1155 mutt_error(
_(
"Can't create %s: %s"), c_folder, strerror(errno));
1156 }
1157 }
1159 }
1160
1162
1166
1168 {
1172 rc = 0;
1173
1174
1176 repeat_error = true;
1177 goto done;
1178 }
1180 {
1181 FILE *fp_in = NULL;
1182 FILE *fp_out = NULL;
1183 const char *infile = NULL;
1184 char *bodytext = NULL;
1185 const char *bodyfile = NULL;
1186 int rv = 0;
1187
1190
1193
1196
1197 const char **cp = NULL;
1199 {
1201 }
1202
1204 {
1206 }
1207
1209 {
1211 {
1213 {
1216 goto done;
1217 }
1218 }
1219 else
1220 {
1222 }
1223 }
1224
1228 {
1231 goto done;
1232 }
1233
1235 {
1236
1239 }
1240
1242 {
1244 }
1246 {
1248 }
1249 else
1250 {
1252 }
1253
1254 if (infile || bodytext)
1255 {
1256
1257 if (infile)
1258 {
1260 {
1262 {
1265 goto done;
1266 }
1267 fp_in = stdin;
1268 }
1269 else
1270 {
1274 if (!fp_in)
1275 {
1278 goto done;
1279 }
1280 }
1281 }
1282
1284 {
1285
1286
1288 }
1289 else
1290 {
1291
1292
1293
1295
1297 if (!fp_out)
1298 {
1302 goto done;
1303 }
1304 if (fp_in)
1305 {
1307 if (fp_in == stdin)
1309 else
1311 }
1312 else if (bodytext)
1313 {
1314 fputs(bodytext, fp_out);
1315 }
1317
1319 if (!fp_in)
1320 {
1323 goto done;
1324 }
1325 }
1326
1327
1328
1329
1331 {
1333 struct stat st = { 0 };
1334
1336
1337
1338
1342 if (fstat(fileno(fp_in), &st) != 0)
1343 {
1347 goto done;
1348 }
1350
1352 {
1357 goto done;
1358 }
1359
1360
1365 {
1367 {
1368 if (c_resume_edited_draft_files)
1370
1374 }
1375 }
1376
1382
1385 }
1387 {
1388
1389
1391 }
1392 else
1393 {
1394
1396 }
1397
1399 }
1400
1402
1404 {
1406
1407 while (b && b->
next)
1409
1411 {
1412 if (b)
1413 {
1416 }
1417 else
1418 {
1421 }
1422 if (!b)
1423 {
1426 goto done;
1427 }
1428 }
1429 }
1430
1432
1436
1438 {
1440 {
1441 if (truncate(
buf_string(expanded_infile), 0) == -1)
1442 {
1445 goto done;
1446 }
1448 if (!fp_out)
1449 {
1452 goto done;
1453 }
1454
1455
1456
1457 if (rv < 0)
1458 {
1464 }
1465
1468 c_crypt_protected_headers_read &&
1472 if (c_resume_edited_draft_files)
1473 fprintf(fp_out, "X-Mutt-Resume-Draft: 1\n");
1474 fputc('\n', fp_out);
1476 {
1479 goto done;
1480 }
1482 }
1483
1485 }
1486
1487
1490
1492
1493 if (rv != 0)
1494 goto done;
1495 }
1497 {
1498
1499
1501 goto done;
1502 }
1503 else
1504 {
1507
1509 {
1514 {
1516 goto done;
1517 }
1521 }
1523 {
1525 {
1531 goto done;
1532 }
1534 {
1536 goto done;
1537 }
1541 {
1542 rc = 0;
1543 goto done;
1544 }
1545 }
1546
1548 {
1550 if (c_spool_file)
1551 {
1552
1554 if (m_desc)
1556 else
1558 }
1559 else if (c_folder)
1560 {
1562 }
1563
1564 }
1565
1567 {
1573 }
1574 else
1575 {
1577 }
1578
1581
1583 {
1584
1586 {
1587 case -1:
1589 goto done;
1590 case 1:
1592 goto done;
1593 }
1594 }
1595
1597
1604
1607
1608 repeat_error = true;
1612 {
1615
1618 repeat_error = false;
1619 }
1620 if (m || !explicit_folder)
1621 {
1624
1629
1633 repeat_error = false;
1634 }
1636
1637
1638 }
1639 rc = 0;
1640
1641done:
1643
1646
1648 {
1652 }
1653
1661
1663
1667
1676 return rc;
1677}
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
@ MUTT_SEL_MAILBOX
Select a mailbox.
@ MUTT_SEL_FOLDER
Select a local directory.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
bool cli_parse(int argc, char *const *argv, struct CommandLine *cli)
Parse the Command Line.
@ CMD_STARTUP_HOOK
:startup-hook
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
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.
bool StartupComplete
When the config has been read.
void config_cache_cleanup(void)
Cleanup the cache of charset config variables.
void account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
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.
@ 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 crypt_init(void)
Initialise the crypto backends.
int debug_all_observer(struct NotifyCallback *nc)
Debug observer for all notifications.
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
void dialog_pop(void)
Hide a Window from the user.
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.
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.
void external_cleanup(void)
Clean up commands globals.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
static const struct Module * Modules[]
All the library Modules.
void mutt_flushinp(void)
MacroEvents moved to KeyModuleData UngetKeyEvents moved to KeyModuleData.
bool OptNews
(pseudo) used to change reader mode
char * LastFolder
Previously selected mailbox.
char ErrorBuf[1024]
Copy of the last error message.
bool ErrorBufMessage
true if the last message was an error
char * CurrentFolder
Currently selected mailbox.
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_message(...)
enum MailboxType nntp_path_probe(const char *path, const struct stat *st)
Is this an NNTP Mailbox?
enum MailboxType pop_path_probe(const char *path, const struct stat *st)
Is this a POP Mailbox?
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox?
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 exec_startup_shutdown_hook(enum CommandId id)
Execute any startup/shutdown hooks.
void exec_folder_hook(const char *path, const char *desc)
Perform a folder hook.
void imap_logout_all(void)
Close all open connections.
int log_dispatcher_t MuttLogger
@ LL_NOTIFY
Log of notifications.
static bool init_logging(struct CliShared *shared, struct ConfigSet *cs)
Initialise the Logging.
static void log_translation(void)
Log the translation being used.
static void init_nntp(struct Buffer *server, struct ConfigSet *cs)
Initialise the NNTP config.
static bool show_help(struct CliHelp *help)
Show the Help.
static int start_curses(void)
Start the Curses UI.
static bool dump_info(struct CliInfo *ci, struct ConfigSet *cs)
Show config info.
static void init_keys(struct NeoMutt *n)
Initialise the Keybindings.
static bool get_user_info(struct ConfigSet *cs)
Find the user's name, home and shell.
static int mutt_init(struct ConfigSet *cs, struct Buffer *dlevel, struct Buffer *dfile, bool skip_sys_rc, struct StringArray *user_files, struct StringArray *commands)
Initialise NeoMutt.
@ MODULE_ID_GUI
ModuleGui, Graphical code
@ MODULE_ID_NNTP
ModuleNntp, Nntp
struct Body * mutt_make_multipart(struct Body *b)
Create a multipart email.
void mutt_ch_cache_cleanup(void)
Clean up the cached iconv handles and charset strings.
void log_queue_empty(void)
Free the contents of the 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.
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.
enum MuttCursorState mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
@ MUTT_CURSOR_INVISIBLE
Hide the cursor.
@ MUTT_CURSOR_VISIBLE
Display a normal cursor.
void mutt_log_stop(void)
Close the log file.
void mutt_log_prep(void)
Prepare to log.
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.
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.
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.
@ MUTT_READONLY
Open in read-only mode.
@ MUTT_OPEN_NONE
No flags are set.
@ MUTT_MAILBOX_CHECK_IMMEDIATE
Don't postpone the actual checking.
void neomutt_cleanup(struct NeoMutt *n)
Clean up NeoMutt and Modules.
bool neomutt_init(struct NeoMutt *n, char **envp, const struct Module **modules)
Initialise NeoMutt.
void neomutt_gui_cleanup(struct NeoMutt *n)
Clean up the GUI Modules.
struct NeoMutt * neomutt_new(void)
Create the main NeoMutt object.
void neomutt_free(struct NeoMutt **ptr)
Free a NeoMutt.
bool neomutt_gui_init(struct NeoMutt *n)
Initialise the GUI Modules.
@ NT_GLOBAL_STARTUP
NeoMutt is initialised.
void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct)
Make fully qualified url from newsgroup name.
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.
struct CommandLine * command_line_new(void)
Create a new CommandLine.
void command_line_free(struct CommandLine **ptr)
Free a CommandLine.
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.
@ 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_FOREACH_SAFE(var, head, field, tvar)
#define TAILQ_EMPTY(head)
void rootwin_new(struct GuiModuleData *mod_data)
Create the default Windows.
void rootwin_cleanup(struct GuiModuleData *mod_data)
Free all the default Windows.
int mutt_write_mime_body(struct Body *b, FILE *fp, struct ConfigSubset *sub)
Write a MIME part.
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.
@ SEND_CONSUMED_STDIN
stdin has been read; don't read it twice
@ SEND_NO_FREE_HEADER
Used by the -E flag.
@ SEND_NONE
No flags are set.
@ SEND_BATCH
Send email in batch mode (without user interaction)
@ SEND_CLI_CRYPTO
Enable message security in modes that by default don't enable it.
@ SEND_DRAFT_FILE
Used by the -H flag.
@ SEND_POSTPONED
Recall a postponed email.
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.
void source_stack_cleanup(void)
Free memory from the stack used for the source command.
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
LOFF_T length
length (in bytes) of attachment
struct Body * next
next attachment in the list
size_t dsize
Length of data.
char * data
Pointer to data.
struct Buffer draft_file
-H Use this draft file
bool is_set
This struct has been used.
struct Buffer include_file
-i Use this include file
struct StringArray cc_list
-c Add a Cc:
struct StringArray attach
-a Attach a file
bool use_crypto
-C Use CLI crypto
bool edit_infile
-E Edit the draft/include
struct StringArray bcc_list
-b Add a Bcc:
struct StringArray addresses
Send to these addresses.
struct Buffer subject
-s Use this Subject:
struct StringArray commands
-e Run these commands
bool disable_system
-n Don't read the system config file
struct StringArray user_files
-F Use these user config files
struct Buffer mbox_type
-m Set the default Mailbox type
bool read_only
-R Open Mailbox read-only
bool start_any_mail
-z Check for Any Mail
bool start_nntp
-G Open an NNTP Mailbox
struct Buffer nntp_server
-g Open this NNTP Mailbox
struct Buffer folder
-f Open this Mailbox
bool start_postponed
-p Open Postponed emails
bool start_new_mail
-Z Check for New Mail
bool start_browser
-y Open the Mailbox Browser
struct CliSend send
Send Mode command line options.
struct CliShared shared
Shared command line options.
struct CliHelp help
Help Mode command line options.
struct CliInfo info
Info Mode command line options.
struct CliTui tui
Tui Mode command line options.
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.
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 AccountArray accounts
All Accounts.
struct Notify * notify_resize
Window resize notifications handler.
char ** env
Private copy of the environment variables.
struct Notify * notify
Notifications handler.
struct Connection * conn
Connection to NNTP Server.
Nntp private Module data.
struct NntpAccountData * current_news_srv
Current NNTP news server.
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.
#define buf_mktemp_draft(buf)
enum UrlScheme url_check_scheme(const char *str)
Check the protocol of a URL.
@ U_MAILTO
Url is mailto://.