39#include <sys/utsname.h>
109static char *
find_cfg(
const char *home,
const char *xdg_cfg_home)
111 const char *names[] = {
117 const char *locations[][2] = {
118 { xdg_cfg_home,
"neomutt/" },
119 { xdg_cfg_home,
"mutt/" },
120 { home,
".neomutt/" },
126 for (
int i = 0; locations[i][0] || locations[i][1]; i++)
128 if (!locations[i][0])
131 for (
int j = 0; names[j]; j++)
133 char buf[256] = { 0 };
135 snprintf(buf,
sizeof(buf),
"%s/%s%s", locations[i][0], locations[i][1], names[j]);
136 if (access(buf, F_OK) == 0)
152 char *mailname = NULL;
153 static const char *mn_files[] = {
"/etc/mailname",
"/etc/mail/mailname" };
164 if (mailname && *mailname)
185 const char *short_host = NULL;
186 struct utsname utsname = { 0 };
191 short_host = c_hostname;
198 if ((uname(&utsname)) == -1)
200 mutt_perror(
_(
"unable to determine nodename via uname()"));
204 short_host = utsname.nodename;
208 char *dot = strchr(short_host,
'.');
319 bool skip_sys_rc,
struct ListHead *commands)
321 bool need_pause =
false;
343#ifdef NEOMUTT_DIRECT_COLORS
354 if (COLORS == 16777216)
359 if (env_colorterm && (
mutt_str_equal(env_colorterm,
"truecolor") ||
438 if (getsid(0) == getpid())
484 if (access(np->
data, F_OK))
551 char name[256] = { 0 };
555 struct passwd *pw = getpwuid(getuid());
586 mutt_error(
_(
"Can't create %s: %s"), c_tmp_dir, strerror(errno));
595 if (c_virtual_spool_file)
void alias_cleanup(void)
Clean up the Alias globals.
void alias_init(void)
Set up the Alias globals.
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.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another 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.
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.
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 commands_init(void)
Initialize commands array and register default commands.
void source_stack_cleanup(void)
Free memory from the stack used for the source command.
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 feature commands.
Compressed mbox local mailbox type.
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
void dump_config_neo(struct ConfigSet *cs, struct HashElem *he, struct Buffer *value, struct Buffer *initial, ConfigDumpFlags flags, FILE *fp)
Dump the config in the style of NeoMutt.
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using '~' or '='.
#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.
const char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
char * HomeDir
User's home directory.
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.
int cs_str_reset(const struct ConfigSet *cs, const char *name, struct Buffer *err)
Reset a config item to its initial value.
int cs_str_string_set(const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
#define CSR_SUCCESS
Action completed successfully.
void commands_cleanup(void)
Free Commands array.
Convenience wrapper for the core headers.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
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.
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line 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.
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 * 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.
char * Username
User's login name.
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() -.
#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 -.
#define mutt_debug(LEVEL,...)
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_delete_hooks(HookFlags type)
Delete matching hooks.
void hooks_init(void)
Setup feature commands.
Parse and execute user-defined hooks.
#define MUTT_HOOK_NO_FLAGS
No flags are set.
void imap_init(void)
Setup feature commands.
static char * find_cfg(const char *home, const char *xdg_cfg_home)
Find a config file.
static char * getmailname(void)
Try to retrieve the FQDN from mailname files.
static int execute_commands(struct ListHead *p)
Execute a set of NeoMutt commands.
int mutt_query_variables(struct ListHead *queries, bool show_docs)
Implement the -Q command line flag.
int mutt_init(struct ConfigSet *cs, const char *dlevel, const char *dfile, bool skip_sys_rc, struct ListHead *commands)
Initialise NeoMutt.
static bool get_hostname(struct ConfigSet *cs)
Find the Fully-Qualified Domain Name.
void mutt_opts_cleanup(void)
Clean up before quitting.
void mutt_keys_cleanup(void)
Free the key maps.
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.
@ LL_DEBUG1
Log at debug level 1.
#define mutt_array_size(x)
char * mutt_ch_get_langinfo_charset(void)
Get the user's choice of character set.
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
Convenience wrapper for the library headers.
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
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.
int mutt_log_start(void)
Enable file logging.
void mutt_lua_init(void)
Setup feature commands.
Integrated Lua scripting.
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.
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.
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.
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.
Prototypes for many functions.
@ XDG_CONFIG_DIRS
XDG system dir: /etc/xdg.
#define STAILQ_HEAD_INITIALIZER(head)
#define STAILQ_FIRST(head)
#define STAILQ_FOREACH(var, head, field)
#define STAILQ_EMPTY(head)
enum CommandResult parse_rc_line(const char *line, struct Buffer *err)
Parse a line of user config.
String manipulation buffer.
size_t dsize
Length of data.
char * data
Pointer to data.
Container for lots of config items.
struct ConfigSet * cs
Parent ConfigSet.
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.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
int cs_subset_he_string_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
#define D_INTERNAL_DEPRECATED
Config item shouldn't be used any more.
@ DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
@ DT_PATH
a path to a file/directory