NeoMutt  2019-12-07
Teaching an old dog new tricks
DOXYGEN
mutt.h File Reference

Many unsorted constants and some structs. More...

#include "config.h"
#include <stddef.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include "config/lib.h"
#include "hook.h"
#include "keymap.h"
#include "mutt_commands.h"
+ Include dependency graph for mutt.h:

Go to the source code of this file.

Macros

#define PATH_MAX   4096
 
#define MUTT_COMP_NO_FLAGS   0
 No flags are set. More...
 
#define MUTT_ALIAS   (1 << 0)
 Do alias "completion" by calling up the alias-menu. More...
 
#define MUTT_FILE   (1 << 1)
 Do file completion. More...
 
#define MUTT_EFILE   (1 << 2)
 Do file completion, plus incoming folders. More...
 
#define MUTT_CMD   (1 << 3)
 Do completion on previous word. More...
 
#define MUTT_PASS   (1 << 4)
 Password mode (no echo) More...
 
#define MUTT_CLEAR   (1 << 5)
 Clear input if printable character is pressed. More...
 
#define MUTT_COMMAND   (1 << 6)
 Do command completion. More...
 
#define MUTT_PATTERN   (1 << 7)
 Pattern mode - only used for history classes. More...
 
#define MUTT_LABEL   (1 << 8)
 Do label completion. More...
 
#define MUTT_NM_QUERY   (1 << 9)
 Notmuch query mode. More...
 
#define MUTT_NM_TAG   (1 << 10)
 Notmuch tag +/- mode. More...
 
#define MUTT_TOKEN_NO_FLAGS   0
 No flags are set. More...
 
#define MUTT_TOKEN_EQUAL   (1 << 0)
 Treat '=' as a special. More...
 
#define MUTT_TOKEN_CONDENSE   (1 << 1)
 ^(char) to control chars (macros) More...
 
#define MUTT_TOKEN_SPACE   (1 << 2)
 Don't treat whitespace as a term. More...
 
#define MUTT_TOKEN_QUOTE   (1 << 3)
 Don't interpret quotes. More...
 
#define MUTT_TOKEN_PATTERN   (1 << 4)
 ~%=!| are terms (for patterns) More...
 
#define MUTT_TOKEN_COMMENT   (1 << 5)
 Don't reap comments. More...
 
#define MUTT_TOKEN_SEMICOLON   (1 << 6)
 Don't treat ; as special. More...
 
#define MUTT_TOKEN_BACKTICK_VARS   (1 << 7)
 Expand variables within backticks. More...
 
#define MUTT_TOKEN_NOSHELL   (1 << 8)
 Don't expand environment variables. More...
 
#define MUTT_TOKEN_QUESTION   (1 << 9)
 Treat '?' as a special. More...
 
#define MUTT_SPAM   1
 
#define MUTT_NOSPAM   2
 
#define EXEC_SHELL   "/bin/sh"
 

Typedefs

typedef uint16_t CompletionFlags
 Flags for mutt_enter_string_full(), e.g. MUTT_ALIAS. More...
 
typedef uint16_t TokenFlags
 Flags for mutt_extract_token(), e.g. MUTT_TOKEN_EQUAL. More...
 

Enumerations

enum  MessageType {
  MUTT_ALL = 1, MUTT_NONE, MUTT_NEW, MUTT_OLD,
  MUTT_REPLIED, MUTT_READ, MUTT_UNREAD, MUTT_DELETE,
  MUTT_UNDELETE, MUTT_PURGE, MUTT_DELETED, MUTT_FLAG,
  MUTT_TAG, MUTT_UNTAG, MUTT_LIMIT, MUTT_EXPIRED,
  MUTT_SUPERSEDED, MUTT_TRASH, MUTT_MT_MAX
}
 To set flags or match patterns. More...
 

Functions

int mutt_init (bool skip_sys_rc, struct ListHead *commands)
 Initialise NeoMutt. More...
 
struct ConfigSetinit_config (size_t size)
 Initialise the config system. More...
 
char * mutt_compile_help (char *buf, size_t buflen, enum MenuType menu, const struct Mapping *items)
 Create the text for the help menu. More...
 
int mutt_extract_token (struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
 Extract one token from a string. More...
 
void mutt_opts_free (void)
 clean up before quitting More...
 
enum QuadOption query_quadoption (enum QuadOption opt, const char *prompt)
 Ask the user a quad-question. More...
 
int mutt_label_complete (char *buf, size_t buflen, int numtabs)
 Complete a label name. More...
 
int mutt_command_complete (char *buf, size_t buflen, int pos, int numtabs)
 Complete a command name. More...
 
int mutt_var_value_complete (char *buf, size_t buflen, int pos)
 Complete a variable/value. More...
 
bool mutt_nm_query_complete (char *buf, size_t buflen, int pos, int numtabs)
 Complete to the nearest notmuch tag. More...
 
bool mutt_nm_tag_complete (char *buf, size_t buflen, int numtabs)
 Complete to the nearest notmuch tag. More...
 
HookFlags mutt_get_hook_type (const char *name)
 Find a hook by name. More...
 
enum CommandResult mutt_parse_rc_line (char *line, struct Buffer *token, struct Buffer *err)
 Parse a line of user config. More...
 
int mutt_query_variables (struct ListHead *queries)
 Implement the -Q command line flag. More...
 
void reset_value (const char *name)
 

Detailed Description

Many unsorted constants and some structs.

Authors
  • Michael R. Elkins
  • g10 Code GmbH

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file mutt.h.

Macro Definition Documentation

◆ PATH_MAX

#define PATH_MAX   4096

Definition at line 50 of file mutt.h.

◆ MUTT_COMP_NO_FLAGS

#define MUTT_COMP_NO_FLAGS   0

No flags are set.

Definition at line 62 of file mutt.h.

◆ MUTT_ALIAS

#define MUTT_ALIAS   (1 << 0)

Do alias "completion" by calling up the alias-menu.

Definition at line 63 of file mutt.h.

◆ MUTT_FILE

#define MUTT_FILE   (1 << 1)

Do file completion.

Definition at line 64 of file mutt.h.

◆ MUTT_EFILE

#define MUTT_EFILE   (1 << 2)

Do file completion, plus incoming folders.

Definition at line 65 of file mutt.h.

◆ MUTT_CMD

#define MUTT_CMD   (1 << 3)

Do completion on previous word.

Definition at line 66 of file mutt.h.

◆ MUTT_PASS

#define MUTT_PASS   (1 << 4)

Password mode (no echo)

Definition at line 67 of file mutt.h.

◆ MUTT_CLEAR

#define MUTT_CLEAR   (1 << 5)

Clear input if printable character is pressed.

Definition at line 68 of file mutt.h.

◆ MUTT_COMMAND

#define MUTT_COMMAND   (1 << 6)

Do command completion.

Definition at line 69 of file mutt.h.

◆ MUTT_PATTERN

#define MUTT_PATTERN   (1 << 7)

Pattern mode - only used for history classes.

Definition at line 70 of file mutt.h.

◆ MUTT_LABEL

#define MUTT_LABEL   (1 << 8)

Do label completion.

Definition at line 71 of file mutt.h.

◆ MUTT_NM_QUERY

#define MUTT_NM_QUERY   (1 << 9)

Notmuch query mode.

Definition at line 72 of file mutt.h.

◆ MUTT_NM_TAG

#define MUTT_NM_TAG   (1 << 10)

Notmuch tag +/- mode.

Definition at line 73 of file mutt.h.

◆ MUTT_TOKEN_NO_FLAGS

#define MUTT_TOKEN_NO_FLAGS   0

No flags are set.

Definition at line 76 of file mutt.h.

◆ MUTT_TOKEN_EQUAL

#define MUTT_TOKEN_EQUAL   (1 << 0)

Treat '=' as a special.

Definition at line 77 of file mutt.h.

◆ MUTT_TOKEN_CONDENSE

#define MUTT_TOKEN_CONDENSE   (1 << 1)

^(char) to control chars (macros)

Definition at line 78 of file mutt.h.

◆ MUTT_TOKEN_SPACE

#define MUTT_TOKEN_SPACE   (1 << 2)

Don't treat whitespace as a term.

Definition at line 79 of file mutt.h.

◆ MUTT_TOKEN_QUOTE

#define MUTT_TOKEN_QUOTE   (1 << 3)

Don't interpret quotes.

Definition at line 80 of file mutt.h.

◆ MUTT_TOKEN_PATTERN

#define MUTT_TOKEN_PATTERN   (1 << 4)

~%=!| are terms (for patterns)

Definition at line 81 of file mutt.h.

◆ MUTT_TOKEN_COMMENT

#define MUTT_TOKEN_COMMENT   (1 << 5)

Don't reap comments.

Definition at line 82 of file mutt.h.

◆ MUTT_TOKEN_SEMICOLON

#define MUTT_TOKEN_SEMICOLON   (1 << 6)

Don't treat ; as special.

Definition at line 83 of file mutt.h.

◆ MUTT_TOKEN_BACKTICK_VARS

#define MUTT_TOKEN_BACKTICK_VARS   (1 << 7)

Expand variables within backticks.

Definition at line 84 of file mutt.h.

◆ MUTT_TOKEN_NOSHELL

#define MUTT_TOKEN_NOSHELL   (1 << 8)

Don't expand environment variables.

Definition at line 85 of file mutt.h.

◆ MUTT_TOKEN_QUESTION

#define MUTT_TOKEN_QUESTION   (1 << 9)

Treat '?' as a special.

Definition at line 86 of file mutt.h.

◆ MUTT_SPAM

#define MUTT_SPAM   1

Definition at line 118 of file mutt.h.

◆ MUTT_NOSPAM

#define MUTT_NOSPAM   2

Definition at line 119 of file mutt.h.

◆ EXEC_SHELL

#define EXEC_SHELL   "/bin/sh"

Definition at line 124 of file mutt.h.

Typedef Documentation

◆ CompletionFlags

typedef uint16_t CompletionFlags

Flags for mutt_enter_string_full(), e.g. MUTT_ALIAS.

Definition at line 61 of file mutt.h.

◆ TokenFlags

typedef uint16_t TokenFlags

Flags for mutt_extract_token(), e.g. MUTT_TOKEN_EQUAL.

Definition at line 75 of file mutt.h.

Enumeration Type Documentation

◆ MessageType

To set flags or match patterns.

See also
mutt_set_flag(), mutt_pattern_func()
Enumerator
MUTT_ALL 

All messages.

MUTT_NONE 

No messages.

MUTT_NEW 

New messages.

MUTT_OLD 

Old messages.

MUTT_REPLIED 

Messages that have been replied to.

MUTT_READ 

Messages that have been read.

MUTT_UNREAD 

Unread messages.

MUTT_DELETE 

Messages to be deleted.

MUTT_UNDELETE 

Messages to be un-deleted.

MUTT_PURGE 

Messages to be purged (bypass trash)

MUTT_DELETED 

Deleted messages.

MUTT_FLAG 

Flagged messages.

MUTT_TAG 

Tagged messages.

MUTT_UNTAG 

Messages to be un-tagged.

MUTT_LIMIT 

Messages in limited view.

MUTT_EXPIRED 

Expired messages.

MUTT_SUPERSEDED 

Superseded messages.

MUTT_TRASH 

Trashed messages.

MUTT_MT_MAX 

Definition at line 93 of file mutt.h.

94 {
95  MUTT_ALL = 1,
96  MUTT_NONE,
97  MUTT_NEW,
98  MUTT_OLD,
99  MUTT_REPLIED,
100  MUTT_READ,
101  MUTT_UNREAD,
102  MUTT_DELETE,
103  MUTT_UNDELETE,
104  MUTT_PURGE,
105  MUTT_DELETED,
106  MUTT_FLAG,
107  MUTT_TAG,
108  MUTT_UNTAG,
109  MUTT_LIMIT,
110  MUTT_EXPIRED,
112  MUTT_TRASH,
113 
114  MUTT_MT_MAX,
115 };
Deleted messages.
Definition: mutt.h:105
Messages in limited view.
Definition: mutt.h:109
Messages to be un-deleted.
Definition: mutt.h:103
Flagged messages.
Definition: mutt.h:106
No messages.
Definition: mutt.h:96
Messages to be purged (bypass trash)
Definition: mutt.h:104
Messages that have been replied to.
Definition: mutt.h:99
All messages.
Definition: mutt.h:95
Old messages.
Definition: mutt.h:98
Messages to be deleted.
Definition: mutt.h:102
Superseded messages.
Definition: mutt.h:111
Tagged messages.
Definition: mutt.h:107
New messages.
Definition: mutt.h:97
Messages that have been read.
Definition: mutt.h:100
Expired messages.
Definition: mutt.h:110
Unread messages.
Definition: mutt.h:101
Messages to be un-tagged.
Definition: mutt.h:108
Trashed messages.
Definition: mutt.h:112

Function Documentation

◆ mutt_init()

int mutt_init ( bool  skip_sys_rc,
struct ListHead *  commands 
)

Initialise NeoMutt.

Parameters
skip_sys_rcIf true, don't read the system config file
commandsList of config commands to execute
Return values
0Success
1Error

Definition at line 2996 of file init.c.

2997 {
2998  char buf[1024];
2999  int need_pause = 0;
3000  int rc = 1;
3001  struct Buffer err = mutt_buffer_make(256);
3002 
3004  /* reverse alias keys need to be strdup'ed because of idna conversions */
3009 
3010  mutt_menu_init();
3011 
3012  snprintf(AttachmentMarker, sizeof(AttachmentMarker), "\033]9;%" PRIu64 "\a", // Escape
3013  mutt_rand64());
3014 
3015  snprintf(ProtectedHeaderMarker, sizeof(ProtectedHeaderMarker), "\033]8;%lld\a", // Escape
3016  (long long) mutt_date_epoch());
3017 
3018  /* "$spoolfile" precedence: config file, environment */
3019  const char *p = mutt_str_getenv("MAIL");
3020  if (!p)
3021  p = mutt_str_getenv("MAILDIR");
3022  if (!p)
3023  {
3024 #ifdef HOMESPOOL
3025  mutt_path_concat(buf, NONULL(HomeDir), MAILPATH, sizeof(buf));
3026 #else
3027  mutt_path_concat(buf, MAILPATH, NONULL(Username), sizeof(buf));
3028 #endif
3029  p = buf;
3030  }
3031  cs_str_initial_set(Config, "spoolfile", p, NULL);
3032  cs_str_reset(Config, "spoolfile", NULL);
3033 
3034  p = mutt_str_getenv("REPLYTO");
3035  if (p)
3036  {
3037  struct Buffer tmp, token;
3038 
3039  snprintf(buf, sizeof(buf), "Reply-To: %s", p);
3040 
3041  mutt_buffer_init(&tmp);
3042  tmp.data = buf;
3043  tmp.dptr = buf;
3044  tmp.dsize = mutt_str_strlen(buf);
3045 
3046  mutt_buffer_init(&token);
3047  parse_my_hdr(&token, &tmp, 0, &err); /* adds to UserHeader */
3048  FREE(&token.data);
3049  }
3050 
3051  p = mutt_str_getenv("EMAIL");
3052  if (p)
3053  {
3054  cs_str_initial_set(Config, "from", p, NULL);
3055  cs_str_reset(Config, "from", NULL);
3056  }
3057 
3058  /* "$mailcap_path" precedence: config file, environment, code */
3059  const char *env_mc = mutt_str_getenv("MAILCAPS");
3060  if (env_mc)
3061  cs_str_string_set(Config, "mailcap_path", env_mc, NULL);
3062 
3063  /* "$tmpdir" precedence: config file, environment, code */
3064  const char *env_tmp = mutt_str_getenv("TMPDIR");
3065  if (env_tmp)
3066  cs_str_string_set(Config, "tmpdir", env_tmp, NULL);
3067 
3068  /* "$visual", "$editor" precedence: config file, environment, code */
3069  const char *env_ed = mutt_str_getenv("VISUAL");
3070  if (!env_ed)
3071  env_ed = mutt_str_getenv("EDITOR");
3072  if (env_ed)
3073  {
3074  cs_str_string_set(Config, "editor", env_ed, NULL);
3075  cs_str_string_set(Config, "visual", env_ed, NULL);
3076  }
3077 
3079  cs_str_initial_set(Config, "charset", C_Charset, NULL);
3081 
3082  Matches = mutt_mem_calloc(MatchesListsize, sizeof(char *));
3083 
3085 
3086 #ifdef HAVE_GETSID
3087  /* Unset suspend by default if we're the session leader */
3088  if (getsid(0) == getpid())
3089  C_Suspend = false;
3090 #endif
3091 
3092  /* RFC2368, "4. Unsafe headers"
3093  * The creator of a mailto URL can't expect the resolver of a URL to
3094  * understand more than the "subject" and "body" headers. Clients that
3095  * resolve mailto URLs into mail messages should be able to correctly
3096  * create RFC822-compliant mail messages using the "subject" and "body"
3097  * headers. */
3098  add_to_stailq(&MailToAllow, "body");
3099  add_to_stailq(&MailToAllow, "subject");
3100  /* Cc, In-Reply-To, and References help with not breaking threading on
3101  * mailing lists, see https://github.com/neomutt/neomutt/issues/115 */
3102  add_to_stailq(&MailToAllow, "cc");
3103  add_to_stailq(&MailToAllow, "in-reply-to");
3104  add_to_stailq(&MailToAllow, "references");
3105 
3106  if (STAILQ_EMPTY(&Muttrc))
3107  {
3108  const char *xdg_cfg_home = mutt_str_getenv("XDG_CONFIG_HOME");
3109 
3110  if (!xdg_cfg_home && HomeDir)
3111  {
3112  snprintf(buf, sizeof(buf), "%s/.config", HomeDir);
3113  xdg_cfg_home = buf;
3114  }
3115 
3116  char *config = find_cfg(HomeDir, xdg_cfg_home);
3117  if (config)
3118  {
3119  mutt_list_insert_tail(&Muttrc, config);
3120  }
3121  }
3122  else
3123  {
3124  struct ListNode *np = NULL;
3125  STAILQ_FOREACH(np, &Muttrc, entries)
3126  {
3127  mutt_str_strfcpy(buf, np->data, sizeof(buf));
3128  FREE(&np->data);
3129  mutt_expand_path(buf, sizeof(buf));
3130  np->data = mutt_str_strdup(buf);
3131  if (access(np->data, F_OK))
3132  {
3133  mutt_perror(np->data);
3134  goto done; // TEST10: neomutt -F missing
3135  }
3136  }
3137  }
3138 
3139  if (!STAILQ_EMPTY(&Muttrc))
3140  {
3141  cs_str_string_set(Config, "alias_file", STAILQ_FIRST(&Muttrc)->data, NULL);
3142  }
3143 
3144  /* Process the global rc file if it exists and the user hasn't explicitly
3145  * requested not to via "-n". */
3146  if (!skip_sys_rc)
3147  {
3148  do
3149  {
3150  if (mutt_set_xdg_path(XDG_CONFIG_DIRS, buf, sizeof(buf)))
3151  break;
3152 
3153  snprintf(buf, sizeof(buf), "%s/neomuttrc", SYSCONFDIR);
3154  if (access(buf, F_OK) == 0)
3155  break;
3156 
3157  snprintf(buf, sizeof(buf), "%s/Muttrc", SYSCONFDIR);
3158  if (access(buf, F_OK) == 0)
3159  break;
3160 
3161  snprintf(buf, sizeof(buf), "%s/neomuttrc", PKGDATADIR);
3162  if (access(buf, F_OK) == 0)
3163  break;
3164 
3165  snprintf(buf, sizeof(buf), "%s/Muttrc", PKGDATADIR);
3166  } while (false);
3167 
3168  if (access(buf, F_OK) == 0)
3169  {
3170  if (source_rc(buf, &err) != 0)
3171  {
3172  mutt_error("%s", err.data);
3173  need_pause = 1; // TEST11: neomutt (error in /etc/neomuttrc)
3174  }
3175  }
3176  }
3177 
3178  /* Read the user's initialization file. */
3179  struct ListNode *np = NULL;
3180  STAILQ_FOREACH(np, &Muttrc, entries)
3181  {
3182  if (np->data)
3183  {
3184  if (source_rc(np->data, &err) != 0)
3185  {
3186  mutt_error("%s", err.data);
3187  need_pause = 1; // TEST12: neomutt (error in ~/.neomuttrc)
3188  }
3189  }
3190  }
3191 
3192  if (execute_commands(commands) != 0)
3193  need_pause = 1; // TEST13: neomutt -e broken
3194 
3195  if (!get_hostname())
3196  goto done;
3197 
3198  if (!C_Realname)
3199  {
3200  struct passwd *pw = getpwuid(getuid());
3201  if (pw)
3202  {
3203  char name[256];
3204  C_Realname = mutt_str_strdup(mutt_gecos_name(name, sizeof(name), pw));
3205  }
3206  }
3207  cs_str_initial_set(Config, "realname", C_Realname, NULL);
3208 
3209  if (need_pause && !OptNoCurses)
3210  {
3212  if (mutt_any_key_to_continue(NULL) == 'q')
3213  goto done; // TEST14: neomutt -e broken (press 'q')
3214  }
3215 
3216  mutt_file_mkdir(C_Tmpdir, S_IRWXU);
3217 
3218  mutt_hist_init();
3220 
3221 #ifdef USE_NOTMUCH
3222  if (C_VirtualSpoolfile)
3223  {
3224  /* Find the first virtual folder and open it */
3225  struct MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_NOTMUCH);
3226  struct MailboxNode *mp = STAILQ_FIRST(&ml);
3227  if (mp)
3228  cs_str_string_set(Config, "spoolfile", mailbox_path(mp->mailbox), NULL);
3230  }
3231 #endif
3232  rc = 0;
3233 
3234 done:
3235  FREE(&err.data);
3236  return rc;
3237 }
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:411
WHERE char * Username
User&#39;s login name.
Definition: globals.h:53
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:194
char * mutt_path_concat(char *d, const char *dir, const char *fname, size_t l)
Join a directory name and a filename.
Definition: path.c:329
#define NONULL(x)
Definition: string2.h:37
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
#define mutt_perror(...)
Definition: logging.h:85
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:38
int cs_str_string_set(const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Definition: set.c:627
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:134
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.
Definition: logging.c:450
WHERE char AttachmentMarker[256]
Unique ANSI string to mark PGP messages in an email.
Definition: globals.h:47
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:83
struct ListHead MailToAllow
List of permitted fields in a mailto: uri.
Definition: email_globals.c:47
String manipulation buffer.
Definition: buffer.h:33
static int execute_commands(struct ListHead *p)
Execute a set of NeoMutt commands.
Definition: init.c:302
static int source_rc(const char *rcfile_path, struct Buffer *err)
Read an initialization file.
Definition: init.c:779
WHERE struct Hash * TagFormats
Hash table of tag-formats (tag -> format string)
Definition: globals.h:61
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:40
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:46
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
Index panel (list of emails)
Definition: keymap.h:77
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
Definition: charset.c:997
static enum CommandResult parse_my_hdr(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;my_hdr&#39; command - Implements command_t.
Definition: init.c:1435
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
Definition: logging.c:357
static char * find_cfg(const char *home, const char *xdg_cfg_home)
Find a config file.
Definition: init.c:337
Container for Accounts, Notifications.
Definition: neomutt.h:35
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1048
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.
Definition: set.c:487
#define MUTT_HASH_STRCASECMP
use strcasecmp() to compare keys
Definition: hash.h:75
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:134
void mutt_hist_read_file(void)
Read the History from a file.
Definition: history.c:584
int mutt_file_mkdir(const char *path, mode_t mode)
Recursively create directories.
Definition: file.c:873
const char * name
Definition: pgpmicalg.c:46
struct MailboxList neomutt_mailboxlist_get_all(struct NeoMutt *n, enum MailboxType magic)
Get a List of all Mailboxes.
Definition: neomutt.c:156
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:50
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
#define MUTT_HASH_ALLOW_DUPS
allow duplicate keys to be inserted
Definition: hash.h:77
static int MatchesListsize
Definition: init.c:94
void mutt_grouplist_init(void)
Initialize the GroupList singleton.
Definition: group.c:45
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
struct Hash * mutt_hash_new(size_t nelem, HashFlags flags)
Create a new Hash table (with string keys)
Definition: hash.c:275
char * mutt_ch_get_langinfo_charset(void)
Get the user&#39;s choice of character set.
Definition: charset.c:456
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
void mutt_hist_init(void)
Create a set of empty History ring buffers.
Definition: history.c:462
uint64_t mutt_rand64(void)
Create a 64-bit random number.
Definition: muttlib.c:556
int mutt_set_xdg_path(enum XdgType type, char *buf, size_t bufsize)
Find an XDG path or its fallback.
Definition: muttlib.c:1617
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:53
WHERE char ProtectedHeaderMarker[256]
Unique ANSI string to mark protected headers in an email.
Definition: globals.h:48
int cs_str_reset(const struct ConfigSet *cs, const char *name, struct Buffer *err)
Reset a config item to its initial value.
Definition: set.c:423
WHERE struct Hash * ReverseAliases
Hash table of aliases (email address -> alias)
Definition: globals.h:60
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:577
char * data
String.
Definition: list.h:35
WHERE bool C_Suspend
Config: Allow the user to suspend NeoMutt using &#39;^Z&#39;.
Definition: globals.h:264
char * mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw)
Lookup a user&#39;s real name in /etc/passwd.
Definition: muttlib.c:382
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define mutt_error(...)
Definition: logging.h:84
char * C_Tmpdir
Config: Directory for temporary files.
Definition: file.c:55
static const char ** Matches
Definition: init.c:92
#define FREE(x)
Definition: memory.h:40
#define STAILQ_EMPTY(head)
Definition: queue.h:346
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:54
List of Mailboxes.
Definition: mailbox.h:156
WHERE char * C_Realname
Config: Real name of the user.
Definition: globals.h:139
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
#define MUTT_HASH_STRDUP_KEYS
make a copy of the keys
Definition: hash.h:76
A List node for strings.
Definition: list.h:33
static bool get_hostname(void)
Find the Fully-Qualified Domain Name.
Definition: init.c:410
XDG system dir: /etc/xdg.
Definition: protos.h:50
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define MUTT_HASH_NO_FLAGS
No flags are set.
Definition: hash.h:74
static void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: init.c:118
WHERE bool C_VirtualSpoolfile
Config: (notmuch) Use the first virtual mailbox as a spool file.
Definition: globals.h:295
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:158
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_config()

struct ConfigSet* init_config ( size_t  size)

Initialise the config system.

Return values
ptrNew Config Set

Definition at line 3797 of file init.c.

3798 {
3799  struct ConfigSet *cs = cs_new(size);
3800 
3801  address_init(cs);
3802  bool_init(cs);
3803  enum_init(cs);
3804  long_init(cs);
3805  mbtable_init(cs);
3806  number_init(cs);
3807  quad_init(cs);
3808  regex_init(cs);
3809  slist_init(cs);
3810  sort_init(cs);
3811  string_init(cs);
3812 
3813  if (!cs_register_variables(cs, MuttVars, 0))
3814  {
3815  mutt_error("cs_register_variables() failed");
3816  cs_free(&cs);
3817  return NULL;
3818  }
3819 
3820  return cs;
3821 }
Container for lots of config items.
Definition: set.h:187
void quad_init(struct ConfigSet *cs)
Register the Quad-option config type.
Definition: quad.c:191
void bool_init(struct ConfigSet *cs)
Register the Bool config type.
Definition: bool.c:189
void number_init(struct ConfigSet *cs)
Register the Number config type.
Definition: number.c:192
void sort_init(struct ConfigSet *cs)
Register the Sort config type.
Definition: sort.c:381
void enum_init(struct ConfigSet *cs)
Register the Enumeration config type.
Definition: enum.c:218
void mbtable_init(struct ConfigSet *cs)
Register the MbTable config type.
Definition: mbtable.c:293
void slist_init(struct ConfigSet *cs)
Register the Slist config type.
Definition: slist.c:267
void address_init(struct ConfigSet *cs)
Register the Address config type.
Definition: address.c:249
void string_init(struct ConfigSet *cs)
Register the String config type.
Definition: string.c:240
void cs_free(struct ConfigSet **ptr)
Free a Config Set.
Definition: set.c:198
struct ConfigSet * cs_new(size_t size)
Create a new Config Set.
Definition: set.c:171
void long_init(struct ConfigSet *cs)
Register the Long config type.
Definition: long.c:173
struct ConfigDef MuttVars[]
Definition: init.h:135
#define mutt_error(...)
Definition: logging.h:84
void regex_init(struct ConfigSet *cs)
Register the Regex config type.
Definition: regex.c:315
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[], int flags)
Register a set of config items.
Definition: set.c:289
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_compile_help()

char* mutt_compile_help ( char *  buf,
size_t  buflen,
enum MenuType  menu,
const struct Mapping items 
)

Create the text for the help menu.

Parameters
bufBuffer for the result
buflenLength of buffer
menuCurrent Menu, e.g. MENU_PAGER
itemsMap of functions to display in the help bar
Return values
ptrBuffer containing result

Definition at line 115 of file help.c.

117 {
118  char *pbuf = buf;
119 
120  for (int i = 0; items[i].name && buflen > 2; i++)
121  {
122  if (i)
123  {
124  *pbuf++ = ' ';
125  *pbuf++ = ' ';
126  buflen -= 2;
127  }
128  mutt_make_help(pbuf, buflen, _(items[i].name), menu, items[i].value);
129  const size_t len = mutt_str_strlen(pbuf);
130  pbuf += len;
131  buflen -= len;
132  }
133  return buf;
134 }
#define _(a)
Definition: message.h:28
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
const char * name
Definition: pgpmicalg.c:46
void mutt_make_help(char *buf, size_t buflen, const char *txt, enum MenuType menu, int op)
Create one entry for the help bar.
Definition: help.c:92
const char * name
Definition: mapping.h:31
static unsigned char * pbuf
Cache PGP data packet.
Definition: pgppacket.c:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_extract_token()

int mutt_extract_token ( struct Buffer dest,
struct Buffer tok,
TokenFlags  flags 
)

Extract one token from a string.

Parameters
destBuffer for the result
tokBuffer containing tokens
flagsFlags, see TokenFlags
Return values
0Success
-1Error

Definition at line 2674 of file init.c.

2675 {
2676  if (!dest || !tok)
2677  return -1;
2678 
2679  char ch;
2680  char qc = '\0'; /* quote char */
2681  char *pc = NULL;
2682 
2683  mutt_buffer_reset(dest);
2684 
2685  SKIPWS(tok->dptr);
2686  while ((ch = *tok->dptr))
2687  {
2688  if (qc == '\0')
2689  {
2690  if ((IS_SPACE(ch) && !(flags & MUTT_TOKEN_SPACE)) ||
2691  ((ch == '#') && !(flags & MUTT_TOKEN_COMMENT)) ||
2692  ((ch == '=') && (flags & MUTT_TOKEN_EQUAL)) ||
2693  ((ch == '?') && (flags & MUTT_TOKEN_QUESTION)) ||
2694  ((ch == ';') && !(flags & MUTT_TOKEN_SEMICOLON)) ||
2695  ((flags & MUTT_TOKEN_PATTERN) && strchr("~%=!|", ch)))
2696  {
2697  break;
2698  }
2699  }
2700 
2701  tok->dptr++;
2702 
2703  if (ch == qc)
2704  qc = 0; /* end of quote */
2705  else if (!qc && ((ch == '\'') || (ch == '"')) && !(flags & MUTT_TOKEN_QUOTE))
2706  qc = ch;
2707  else if ((ch == '\\') && (qc != '\''))
2708  {
2709  if (tok->dptr[0] == '\0')
2710  return -1; /* premature end of token */
2711  switch (ch = *tok->dptr++)
2712  {
2713  case 'c':
2714  case 'C':
2715  if (tok->dptr[0] == '\0')
2716  return -1; /* premature end of token */
2717  mutt_buffer_addch(dest, (toupper((unsigned char) tok->dptr[0]) - '@') & 0x7f);
2718  tok->dptr++;
2719  break;
2720  case 'e':
2721  mutt_buffer_addch(dest, '\033'); // Escape
2722  break;
2723  case 'f':
2724  mutt_buffer_addch(dest, '\f');
2725  break;
2726  case 'n':
2727  mutt_buffer_addch(dest, '\n');
2728  break;
2729  case 'r':
2730  mutt_buffer_addch(dest, '\r');
2731  break;
2732  case 't':
2733  mutt_buffer_addch(dest, '\t');
2734  break;
2735  default:
2736  if (isdigit((unsigned char) ch) && isdigit((unsigned char) tok->dptr[0]) &&
2737  isdigit((unsigned char) tok->dptr[1]))
2738  {
2739  mutt_buffer_addch(dest, (ch << 6) + (tok->dptr[0] << 3) + tok->dptr[1] - 3504);
2740  tok->dptr += 2;
2741  }
2742  else
2743  mutt_buffer_addch(dest, ch);
2744  }
2745  }
2746  else if ((ch == '^') && (flags & MUTT_TOKEN_CONDENSE))
2747  {
2748  if (tok->dptr[0] == '\0')
2749  return -1; /* premature end of token */
2750  ch = *tok->dptr++;
2751  if (ch == '^')
2752  mutt_buffer_addch(dest, ch);
2753  else if (ch == '[')
2754  mutt_buffer_addch(dest, '\033'); // Escape
2755  else if (isalpha((unsigned char) ch))
2756  mutt_buffer_addch(dest, toupper((unsigned char) ch) - '@');
2757  else
2758  {
2759  mutt_buffer_addch(dest, '^');
2760  mutt_buffer_addch(dest, ch);
2761  }
2762  }
2763  else if ((ch == '`') && (!qc || (qc == '"')))
2764  {
2765  FILE *fp = NULL;
2766  pid_t pid;
2767  int line = 0;
2768 
2769  pc = tok->dptr;
2770  do
2771  {
2772  pc = strpbrk(pc, "\\`");
2773  if (pc)
2774  {
2775  /* skip any quoted chars */
2776  if (*pc == '\\')
2777  pc += 2;
2778  }
2779  } while (pc && (pc[0] != '`'));
2780  if (!pc)
2781  {
2782  mutt_debug(LL_DEBUG1, "mismatched backticks\n");
2783  return -1;
2784  }
2785  struct Buffer cmd;
2786  mutt_buffer_init(&cmd);
2787  *pc = '\0';
2788  if (flags & MUTT_TOKEN_BACKTICK_VARS)
2789  {
2790  /* recursively extract tokens to interpolate variables */
2791  mutt_extract_token(&cmd, tok,
2792  MUTT_TOKEN_QUOTE | MUTT_TOKEN_SPACE | MUTT_TOKEN_COMMENT |
2793  MUTT_TOKEN_SEMICOLON | MUTT_TOKEN_NOSHELL);
2794  }
2795  else
2796  {
2797  cmd.data = mutt_str_strdup(tok->dptr);
2798  }
2799  *pc = '`';
2800  pid = mutt_create_filter(cmd.data, NULL, &fp, NULL);
2801  if (pid < 0)
2802  {
2803  mutt_debug(LL_DEBUG1, "unable to fork command: %s\n", cmd.data);
2804  FREE(&cmd.data);
2805  return -1;
2806  }
2807  FREE(&cmd.data);
2808 
2809  tok->dptr = pc + 1;
2810 
2811  /* read line */
2812  struct Buffer expn = mutt_buffer_make(0);
2813  expn.data = mutt_file_read_line(NULL, &expn.dsize, fp, &line, 0);
2814  mutt_file_fclose(&fp);
2815  mutt_wait_filter(pid);
2816 
2817  /* if we got output, make a new string consisting of the shell output
2818  * plus whatever else was left on the original line */
2819  /* BUT: If this is inside a quoted string, directly add output to
2820  * the token */
2821  if (expn.data)
2822  {
2823  if (qc)
2824  {
2825  mutt_buffer_addstr(dest, expn.data);
2826  }
2827  else
2828  {
2829  struct Buffer *copy = mutt_buffer_pool_get();
2830  mutt_buffer_fix_dptr(&expn);
2831  mutt_buffer_copy(copy, &expn);
2832  mutt_buffer_addstr(copy, tok->dptr);
2833  mutt_buffer_copy(tok, copy);
2834  tok->dptr = tok->data;
2835  mutt_buffer_pool_release(&copy);
2836  }
2837  FREE(&expn.data);
2838  }
2839  }
2840  else if ((ch == '$') && (!qc || (qc == '"')) &&
2841  ((tok->dptr[0] == '{') || isalpha((unsigned char) tok->dptr[0])))
2842  {
2843  const char *env = NULL;
2844  char *var = NULL;
2845 
2846  if (tok->dptr[0] == '{')
2847  {
2848  pc = strchr(tok->dptr, '}');
2849  if (pc)
2850  {
2851  var = mutt_str_substr_dup(tok->dptr + 1, pc);
2852  tok->dptr = pc + 1;
2853 
2854  if ((flags & MUTT_TOKEN_NOSHELL))
2855  {
2856  mutt_buffer_addch(dest, ch);
2857  mutt_buffer_addch(dest, '{');
2858  mutt_buffer_addstr(dest, var);
2859  mutt_buffer_addch(dest, '}');
2860  FREE(&var);
2861  }
2862  }
2863  }
2864  else
2865  {
2866  for (pc = tok->dptr; isalnum((unsigned char) *pc) || (pc[0] == '_'); pc++)
2867  ;
2868  var = mutt_str_substr_dup(tok->dptr, pc);
2869  tok->dptr = pc;
2870  }
2871  if (var)
2872  {
2873  struct Buffer result;
2874  mutt_buffer_init(&result);
2875  int rc = cs_str_string_get(Config, var, &result);
2876 
2877  if (CSR_RESULT(rc) == CSR_SUCCESS)
2878  {
2879  mutt_buffer_addstr(dest, result.data);
2880  FREE(&result.data);
2881  }
2882  else if ((env = myvar_get(var)))
2883  {
2884  mutt_buffer_addstr(dest, env);
2885  }
2886  else if (!(flags & MUTT_TOKEN_NOSHELL) && (env = mutt_str_getenv(var)))
2887  {
2888  mutt_buffer_addstr(dest, env);
2889  }
2890  else
2891  {
2892  mutt_buffer_addch(dest, ch);
2893  mutt_buffer_addstr(dest, var);
2894  }
2895  FREE(&var);
2896  }
2897  }
2898  else
2899  mutt_buffer_addch(dest, ch);
2900  }
2901  mutt_buffer_addch(dest, 0); /* terminate the string */
2902  SKIPWS(tok->dptr);
2903  return 0;
2904 }
pid_t mutt_create_filter(const char *s, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
Definition: filter.c:209
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define CSR_RESULT(x)
Definition: set.h:62
size_t mutt_buffer_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer&#39;s contents to another Buffer.
Definition: buffer.c:445
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
#define MUTT_TOKEN_COMMENT
Don&#39;t reap comments.
Definition: mutt.h:82
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:40
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, int flags)
Read a line from a file.
Definition: file.c:664
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1048
size_t dsize
Length of data.
Definition: buffer.h:37
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
int cs_str_string_get(const struct ConfigSet *cs, const char *name, struct Buffer *result)
Get a config item as a string.
Definition: set.c:698
#define SKIPWS(ch)
Definition: string2.h:47
#define MUTT_TOKEN_NOSHELL
Don&#39;t expand environment variables.
Definition: mutt.h:85
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
void mutt_buffer_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition: buffer.c:181
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:46
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:80
#define MUTT_TOKEN_CONDENSE
^(char) to control chars (macros)
Definition: mutt.h:78
const char * line
Definition: common.c:36
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2674
char * dptr
Current read/write position.
Definition: buffer.h:36
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:79
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:240
const char * myvar_get(const char *var)
Get the value of a "my_" variable.
Definition: myvar.c:73
#define MUTT_TOKEN_SEMICOLON
Don&#39;t treat ; as special.
Definition: mutt.h:83
#define IS_SPACE(ch)
Definition: string2.h:38
Log at debug level 1.
Definition: logging.h:40
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:84
#define FREE(x)
Definition: memory.h:40
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:77
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:220
char * mutt_str_substr_dup(const char *begin, const char *end)
Duplicate a sub-string.
Definition: string.c:579
#define MUTT_TOKEN_PATTERN
~%=!| are terms (for patterns)
Definition: mutt.h:81
#define MUTT_TOKEN_QUESTION
Treat &#39;?&#39; as a special.
Definition: mutt.h:86
+ Here is the call graph for this function:

◆ mutt_opts_free()

void mutt_opts_free ( void  )

clean up before quitting

Definition at line 2909 of file init.c.

2910 {
2912 
2913  FREE(&Matches);
2914 
2915  mutt_aliaslist_free(&Aliases);
2916 
2917  mutt_regexlist_free(&Alternates);
2921  mutt_regexlist_free(&UnAlternates);
2924 
2929 
2930  /* Lists of strings */
2931  mutt_list_free(&AlternativeOrderList);
2932  mutt_list_free(&AutoViewList);
2933  mutt_list_free(&HeaderOrderList);
2936  mutt_list_free(&MimeLookupList);
2937  mutt_list_free(&Muttrc);
2939 #ifdef USE_SIDEBAR
2940  mutt_list_free(&SidebarWhitelist);
2941 #endif
2943  mutt_list_free(&UserHeader);
2944 
2945  /* Lists of AttachMatch */
2950 
2952 
2953  FREE(&CurrentFolder);
2954  FREE(&HomeDir);
2955  FREE(&LastFolder);
2956  FREE(&ShortHostname);
2957  FREE(&Username);
2958 
2961 
2963 
2964  mutt_hist_free();
2965  mutt_keys_free();
2966 
2968 }
WHERE char * Username
User&#39;s login name.
Definition: globals.h:53
void mutt_aliaslist_free(struct AliasList *a_list)
Free a List of Aliases.
Definition: alias.c:758
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:38
struct ListHead InlineAllow
List of inline types to counted.
Definition: mutt_parse.c:41
static struct ListHead MuttrcStack
Definition: init.c:79
struct ReplaceList SpamList
List of regexes and patterns to match spam emails.
Definition: email_globals.c:44
void mutt_list_free_type(struct ListHead *h, list_free_t fn)
Free a List of type.
Definition: list.c:145
struct ListHead MailToAllow
List of permitted fields in a mailto: uri.
Definition: email_globals.c:47
WHERE struct Hash * TagFormats
Hash table of tag-formats (tag -> format string)
Definition: globals.h:61
void mutt_delete_hooks(HookFlags type)
Delete matching hooks.
Definition: hook.c:302
WHERE char * LastFolder
Previously selected mailbox.
Definition: globals.h:56
struct ListHead UnIgnore
List of header patterns to unignore (see)
Definition: email_globals.c:46
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:447
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:50
WHERE char * CurrentFolder
Currently selected mailbox.
Definition: globals.h:55
struct ListHead InlineExclude
List of inline types to ignore.
Definition: mutt_parse.c:42
void mutt_keys_free(void)
Free the key maps.
Definition: keymap.c:1601
static void mutt_attachmatch_free(struct AttachMatch **ptr)
Free an AttachMatch - Implements list_free_t.
Definition: init.c:2317
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: email_globals.c:50
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: email_globals.c:52
Definition: color.h:130
WHERE struct Hash * ReverseAliases
Hash table of aliases (email address -> alias)
Definition: globals.h:60
void mutt_colors_free(struct Colors **ptr)
Free all the colours.
Definition: color.c:355
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: mutt_parse.c:40
static const char ** Matches
Definition: init.c:92
WHERE char * ShortHostname
Short version of the hostname.
Definition: globals.h:51
#define FREE(x)
Definition: memory.h:40
#define MUTT_HOOK_NO_FLAGS
No flags are set.
Definition: hook.h:44
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: email_globals.c:51
void mutt_grouplist_free(void)
Free GroupList singleton resource.
Definition: group.c:55
void mutt_hash_free(struct Hash **ptr)
Free a hash table.
Definition: hash.c:471
struct ListHead AttachAllow
List of attachment types to be counted.
Definition: mutt_parse.c:39
struct RegexList NoSpamList
List of regexes to whitelist non-spam emails.
Definition: email_globals.c:43
void mutt_hist_free(void)
Free all the history lists.
Definition: history.c:439
struct ListHead Ignore
List of header patterns to ignore.
Definition: email_globals.c:45
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition: regex.c:170
void(* list_free_t)(void **ptr)
typedef list_free_t - Prototype for a function to free List data
Definition: list.h:44
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: email_globals.c:49
struct ReplaceList SubjectRegexList
List of regexes to tidy the view of the email&#39;s subject.
Definition: email_globals.c:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ query_quadoption()

enum QuadOption query_quadoption ( enum QuadOption  opt,
const char *  prompt 
)

Ask the user a quad-question.

Parameters
optOption to use
promptMessage to show to the user
Return values
QuadOptionResult, e.g. MUTT_NO

Definition at line 3359 of file init.c.

3360 {
3361  switch (opt)
3362  {
3363  case MUTT_YES:
3364  case MUTT_NO:
3365  return opt;
3366 
3367  default:
3368  opt = mutt_yesorno(prompt, (opt == MUTT_ASKYES) ? MUTT_YES : MUTT_NO);
3370  return opt;
3371  }
3372 
3373  /* not reached */
3374 }
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
Ask the user, defaulting to &#39;Yes&#39;.
Definition: quad.h:41
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:375
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:95
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_label_complete()

int mutt_label_complete ( char *  buf,
size_t  buflen,
int  numtabs 
)

Complete a label name.

Parameters
bufBuffer for the result
buflenLength of the buffer
numtabsNumber of times the user has hit 'tab'
Return values
1Success, a match
0Error, no match

Definition at line 3555 of file init.c.

3556 {
3557  char *pt = buf;
3558  int spaces; /* keep track of the number of leading spaces on the line */
3559 
3560  if (!Context || !Context->mailbox->label_hash)
3561  return 0;
3562 
3563  SKIPWS(buf);
3564  spaces = buf - pt;
3565 
3566  /* first TAB. Collect all the matches */
3567  if (numtabs == 1)
3568  {
3569  struct HashElem *entry = NULL;
3570  struct HashWalkState state = { 0 };
3571 
3572  NumMatched = 0;
3573  mutt_str_strfcpy(UserTyped, buf, sizeof(UserTyped));
3574  memset(Matches, 0, MatchesListsize);
3575  memset(Completed, 0, sizeof(Completed));
3576  while ((entry = mutt_hash_walk(Context->mailbox->label_hash, &state)))
3577  candidate(UserTyped, entry->key.strkey, Completed, sizeof(Completed));
3579  qsort(Matches, NumMatched, sizeof(char *), (sort_t) mutt_str_strcasecmp);
3581 
3582  /* All matches are stored. Longest non-ambiguous string is ""
3583  * i.e. don't change 'buf'. Fake successful return this time */
3584  if (UserTyped[0] == '\0')
3585  return 1;
3586  }
3587 
3588  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3589  return 0;
3590 
3591  /* NumMatched will _always_ be at least 1 since the initial
3592  * user-typed string is always stored */
3593  if ((numtabs == 1) && (NumMatched == 2))
3594  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3595  else if ((numtabs > 1) && (NumMatched > 2))
3596  {
3597  /* cycle through all the matches */
3598  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3599  }
3600 
3601  /* return the completed label */
3602  strncpy(buf, Completed, buflen - spaces);
3603 
3604  return 1;
3605 }
The "current" mailbox.
Definition: context.h:36
union HashKey key
Definition: hash.h:45
static int NumMatched
Definition: init.c:90
Cursor to iterate through a Hash Table.
Definition: hash.h:96
struct Mailbox * mailbox
Definition: context.h:50
#define SKIPWS(ch)
Definition: string2.h:47
static char Completed[256]
Definition: init.c:91
int(* sort_t)(const void *a, const void *b)
typedef sort_t - Prototype for a function to compare two emails
Definition: sort.h:48
static int MatchesListsize
Definition: init.c:94
static void matches_ensure_morespace(int current)
Allocate more space for auto-completion.
Definition: init.c:176
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
struct HashElem * mutt_hash_walk(const struct Hash *table, struct HashWalkState *state)
Iterate through all the HashElem&#39;s in a Hash table.
Definition: hash.c:503
static char UserTyped[1024]
Definition: init.c:88
const char * strkey
Definition: hash.h:35
static const char ** Matches
Definition: init.c:92
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
The item stored in a Hash Table.
Definition: hash.h:42
struct Hash * label_hash
Hash table for x-labels.
Definition: mailbox.h:140
static void candidate(char *user, const char *src, char *dest, size_t dlen)
helper function for completion
Definition: init.c:199
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_command_complete()

int mutt_command_complete ( char *  buf,
size_t  buflen,
int  pos,
int  numtabs 
)

Complete a command name.

Parameters
bufBuffer for the result
buflenLength of the buffer
posCursor position in the buffer
numtabsNumber of times the user has hit 'tab'
Return values
1Success, a match
0Error, no match

Definition at line 3385 of file init.c.

3386 {
3387  char *pt = buf;
3388  int num;
3389  int spaces; /* keep track of the number of leading spaces on the line */
3390  struct MyVar *myv = NULL;
3391 
3392  SKIPWS(buf);
3393  spaces = buf - pt;
3394 
3395  pt = buf + pos - spaces;
3396  while ((pt > buf) && !isspace((unsigned char) *pt))
3397  pt--;
3398 
3399  if (pt == buf) /* complete cmd */
3400  {
3401  /* first TAB. Collect all the matches */
3402  if (numtabs == 1)
3403  {
3404  NumMatched = 0;
3405  mutt_str_strfcpy(UserTyped, pt, sizeof(UserTyped));
3406  memset(Matches, 0, MatchesListsize);
3407  memset(Completed, 0, sizeof(Completed));
3408  for (num = 0; Commands[num].name; num++)
3412 
3413  /* All matches are stored. Longest non-ambiguous string is ""
3414  * i.e. don't change 'buf'. Fake successful return this time */
3415  if (UserTyped[0] == '\0')
3416  return 1;
3417  }
3418 
3419  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3420  return 0;
3421 
3422  /* NumMatched will _always_ be at least 1 since the initial
3423  * user-typed string is always stored */
3424  if ((numtabs == 1) && (NumMatched == 2))
3425  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3426  else if ((numtabs > 1) && (NumMatched > 2))
3427  {
3428  /* cycle through all the matches */
3429  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3430  }
3431 
3432  /* return the completed command */
3433  strncpy(buf, Completed, buflen - spaces);
3434  }
3435  else if (mutt_str_startswith(buf, "set", CASE_MATCH) ||
3436  mutt_str_startswith(buf, "unset", CASE_MATCH) ||
3437  mutt_str_startswith(buf, "reset", CASE_MATCH) ||
3438  mutt_str_startswith(buf, "toggle", CASE_MATCH))
3439  { /* complete variables */
3440  static const char *const prefixes[] = { "no", "inv", "?", "&", 0 };
3441 
3442  pt++;
3443  /* loop through all the possible prefixes (no, inv, ...) */
3444  if (mutt_str_startswith(buf, "set", CASE_MATCH))
3445  {
3446  for (num = 0; prefixes[num]; num++)
3447  {
3448  if (mutt_str_startswith(pt, prefixes[num], CASE_MATCH))
3449  {
3450  pt += mutt_str_strlen(prefixes[num]);
3451  break;
3452  }
3453  }
3454  }
3455 
3456  /* first TAB. Collect all the matches */
3457  if (numtabs == 1)
3458  {
3459  NumMatched = 0;
3460  mutt_str_strfcpy(UserTyped, pt, sizeof(UserTyped));
3461  memset(Matches, 0, MatchesListsize);
3462  memset(Completed, 0, sizeof(Completed));
3463  for (num = 0; MuttVars[num].name; num++)
3464  candidate(UserTyped, MuttVars[num].name, Completed, sizeof(Completed));
3465  TAILQ_FOREACH(myv, &MyVars, entries)
3466  {
3467  candidate(UserTyped, myv->name, Completed, sizeof(Completed));
3468  }
3471 
3472  /* All matches are stored. Longest non-ambiguous string is ""
3473  * i.e. don't change 'buf'. Fake successful return this time */
3474  if (UserTyped[0] == '\0')
3475  return 1;
3476  }
3477 
3478  if ((Completed[0] == 0) && UserTyped[0])
3479  return 0;
3480 
3481  /* NumMatched will _always_ be at least 1 since the initial
3482  * user-typed string is always stored */
3483  if ((numtabs == 1) && (NumMatched == 2))
3484  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3485  else if ((numtabs > 1) && (NumMatched > 2))
3486  {
3487  /* cycle through all the matches */
3488  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3489  }
3490 
3491  strncpy(pt, Completed, buf + buflen - pt - spaces);
3492  }
3493  else if (mutt_str_startswith(buf, "exec", CASE_MATCH))
3494  {
3495  const struct Binding *menu = km_get_table(CurrentMenu);
3496 
3497  if (!menu && (CurrentMenu != MENU_PAGER))
3498  menu = OpGeneric;
3499 
3500  pt++;
3501  /* first TAB. Collect all the matches */
3502  if (numtabs == 1)
3503  {
3504  NumMatched = 0;
3505  mutt_str_strfcpy(UserTyped, pt, sizeof(UserTyped));
3506  memset(Matches, 0, MatchesListsize);
3507  memset(Completed, 0, sizeof(Completed));
3508  for (num = 0; menu[num].name; num++)
3509  candidate(UserTyped, menu[num].name, Completed, sizeof(Completed));
3510  /* try the generic menu */
3511  if ((Completed[0] == '\0') && (CurrentMenu != MENU_PAGER))
3512  {
3513  menu = OpGeneric;
3514  for (num = 0; menu[num].name; num++)
3515  candidate(UserTyped, menu[num].name, Completed, sizeof(Completed));
3516  }
3519 
3520  /* All matches are stored. Longest non-ambiguous string is ""
3521  * i.e. don't change 'buf'. Fake successful return this time */
3522  if (UserTyped[0] == '\0')
3523  return 1;
3524  }
3525 
3526  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3527  return 0;
3528 
3529  /* NumMatched will _always_ be at least 1 since the initial
3530  * user-typed string is always stored */
3531  if ((numtabs == 1) && (NumMatched == 2))
3532  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3533  else if ((numtabs > 1) && (NumMatched > 2))
3534  {
3535  /* cycle through all the matches */
3536  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3537  }
3538 
3539  strncpy(pt, Completed, buf + buflen - pt - spaces);
3540  }
3541  else
3542  return 0;
3543 
3544  return 1;
3545 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
static int NumMatched
Definition: init.c:90
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:83
const char * name
Name of the command.
Definition: mutt_commands.h:56
Match case when comparing strings.
Definition: string2.h:67
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
char * name
Name of user variable.
Definition: myvar.h:33
const struct Command Commands[]
Definition: init.h:5002
Pager pager (email viewer)
Definition: keymap.h:78
const char * name
Definition: pgpmicalg.c:46
A user-set variable.
Definition: myvar.h:31
struct MyVarList MyVars
List of all the user&#39;s custom config variables.
Definition: myvar.c:34
const char * name
name of the function
Definition: keymap.h:116
#define SKIPWS(ch)
Definition: string2.h:47
static char Completed[256]
Definition: init.c:91
const char * name
User-visible name.
Definition: set.h:155
static int MatchesListsize
Definition: init.c:94
static void matches_ensure_morespace(int current)
Allocate more space for auto-completion.
Definition: init.c:176
const struct Binding OpGeneric[]
Key bindings for the generic menu.
Definition: functions.h:54
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
static char UserTyped[1024]
Definition: init.c:88
struct ConfigDef MuttVars[]
Definition: init.h:135
static const char ** Matches
Definition: init.c:92
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu&#39;s keybindings.
Definition: keymap.c:1223
Mapping between a user key and a function.
Definition: keymap.h:114
static void candidate(char *user, const char *src, char *dest, size_t dlen)
helper function for completion
Definition: init.c:199
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_var_value_complete()

int mutt_var_value_complete ( char *  buf,
size_t  buflen,
int  pos 
)

Complete a variable/value.

Parameters
bufBuffer for the result
buflenLength of the buffer
posCursor position in the buffer

Definition at line 3729 of file init.c.

3730 {
3731  char *pt = buf;
3732 
3733  if (buf[0] == '\0')
3734  return 0;
3735 
3736  SKIPWS(buf);
3737  const int spaces = buf - pt;
3738 
3739  pt = buf + pos - spaces;
3740  while ((pt > buf) && !isspace((unsigned char) *pt))
3741  pt--;
3742  pt++; /* move past the space */
3743  if (*pt == '=') /* abort if no var before the '=' */
3744  return 0;
3745 
3746  if (mutt_str_startswith(buf, "set", CASE_MATCH))
3747  {
3748  const char *myvarval = NULL;
3749  char var[256];
3750  mutt_str_strfcpy(var, pt, sizeof(var));
3751  /* ignore the trailing '=' when comparing */
3752  int vlen = mutt_str_strlen(var);
3753  if (vlen == 0)
3754  return 0;
3755 
3756  var[vlen - 1] = '\0';
3757 
3758  struct HashElem *he = cs_get_elem(Config, var);
3759  if (!he)
3760  {
3761  myvarval = myvar_get(var);
3762  if (myvarval)
3763  {
3764  struct Buffer pretty = mutt_buffer_make(256);
3765  pretty_var(myvarval, &pretty);
3766  snprintf(pt, buflen - (pt - buf), "%s=%s", var, pretty.data);
3767  mutt_buffer_dealloc(&pretty);
3768  return 1;
3769  }
3770  return 0; /* no such variable. */
3771  }
3772  else
3773  {
3774  struct Buffer value = mutt_buffer_make(256);
3775  struct Buffer pretty = mutt_buffer_make(256);
3776  int rc = cs_he_string_get(Config, he, &value);
3777  if (CSR_RESULT(rc) == CSR_SUCCESS)
3778  {
3779  pretty_var(value.data, &pretty);
3780  snprintf(pt, buflen - (pt - buf), "%s=%s", var, pretty.data);
3781  mutt_buffer_dealloc(&value);
3782  mutt_buffer_dealloc(&pretty);
3783  return 0;
3784  }
3785  mutt_buffer_dealloc(&value);
3786  mutt_buffer_dealloc(&pretty);
3787  return 1;
3788  }
3789  }
3790  return 0;
3791 }
#define CSR_RESULT(x)
Definition: set.h:62
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:40
Match case when comparing strings.
Definition: string2.h:67
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
#define SKIPWS(ch)
Definition: string2.h:47
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
Definition: set.c:216
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:46
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
const char * myvar_get(const char *var)
Get the value of a "my_" variable.
Definition: myvar.c:73
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
int cs_he_string_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: set.c:650
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
Definition: dump.c:80
The item stored in a Hash Table.
Definition: hash.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_nm_query_complete()

bool mutt_nm_query_complete ( char *  buf,
size_t  buflen,
int  pos,
int  numtabs 
)

Complete to the nearest notmuch tag.

Parameters
bufBuffer for the result
buflenLength of the buffer
posCursor position in the buffer
numtabsNumber of times the user has hit 'tab'
Return values
trueSuccess, a match
falseError, no match

Complete the nearest "tag:"-prefixed string previous to pos.

Definition at line 3619 of file init.c.

3620 {
3621  char *pt = buf;
3622  int spaces;
3623 
3624  SKIPWS(buf);
3625  spaces = buf - pt;
3626 
3627  pt = (char *) mutt_str_rstrnstr((char *) buf, pos, "tag:");
3628  if (pt)
3629  {
3630  pt += 4;
3631  if (numtabs == 1)
3632  {
3633  /* First TAB. Collect all the matches */
3635 
3636  /* All matches are stored. Longest non-ambiguous string is ""
3637  * i.e. don't change 'buf'. Fake successful return this time. */
3638  if (UserTyped[0] == '\0')
3639  return true;
3640  }
3641 
3642  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3643  return false;
3644 
3645  /* NumMatched will _always_ be at least 1 since the initial
3646  * user-typed string is always stored */
3647  if ((numtabs == 1) && (NumMatched == 2))
3648  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3649  else if ((numtabs > 1) && (NumMatched > 2))
3650  {
3651  /* cycle through all the matches */
3652  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3653  }
3654 
3655  /* return the completed query */
3656  strncpy(pt, Completed, buf + buflen - pt - spaces);
3657  }
3658  else
3659  return false;
3660 
3661  return true;
3662 }
static int NumMatched
Definition: init.c:90
#define SKIPWS(ch)
Definition: string2.h:47
static char Completed[256]
Definition: init.c:91
static int complete_all_nm_tags(const char *pt)
Pass a list of Notmuch tags to the completion code.
Definition: init.c:245
static char UserTyped[1024]
Definition: init.c:88
static const char ** Matches
Definition: init.c:92
const char * mutt_str_rstrnstr(const char *haystack, size_t haystack_length, const char *needle)
Find last instance of a substring.
Definition: string.c:938
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_nm_tag_complete()

bool mutt_nm_tag_complete ( char *  buf,
size_t  buflen,
int  numtabs 
)

Complete to the nearest notmuch tag.

Parameters
bufBuffer for the result
buflenLength of the buffer
numtabsNumber of times the user has hit 'tab'
Return values
trueSuccess, a match
falseError, no match

Complete the nearest "+" or "-" -prefixed string previous to pos.

Definition at line 3676 of file init.c.

3677 {
3678  if (!buf)
3679  return false;
3680 
3681  char *pt = buf;
3682 
3683  /* Only examine the last token */
3684  char *last_space = strrchr(buf, ' ');
3685  if (last_space)
3686  pt = (last_space + 1);
3687 
3688  /* Skip the +/- */
3689  if ((pt[0] == '+') || (pt[0] == '-'))
3690  pt++;
3691 
3692  if (numtabs == 1)
3693  {
3694  /* First TAB. Collect all the matches */
3696 
3697  /* All matches are stored. Longest non-ambiguous string is ""
3698  * i.e. don't change 'buf'. Fake successful return this time. */
3699  if (UserTyped[0] == '\0')
3700  return true;
3701  }
3702 
3703  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3704  return false;
3705 
3706  /* NumMatched will _always_ be at least 1 since the initial
3707  * user-typed string is always stored */
3708  if ((numtabs == 1) && (NumMatched == 2))
3709  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3710  else if ((numtabs > 1) && (NumMatched > 2))
3711  {
3712  /* cycle through all the matches */
3713  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3714  }
3715 
3716  /* return the completed query */
3717  strncpy(pt, Completed, buf + buflen - pt);
3718 
3719  return true;
3720 }
static int NumMatched
Definition: init.c:90
static char Completed[256]
Definition: init.c:91
static int complete_all_nm_tags(const char *pt)
Pass a list of Notmuch tags to the completion code.
Definition: init.c:245
static char UserTyped[1024]
Definition: init.c:88
static const char ** Matches
Definition: init.c:92
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_get_hook_type()

HookFlags mutt_get_hook_type ( const char *  name)

Find a hook by name.

Parameters
nameName to find
Return values
numHook ID, e.g. MUTT_FOLDER_HOOK
MUTT_HOOK_NO_FLAGSError, no matching hook

Definition at line 2976 of file init.c.

2977 {
2978  for (const struct Command *c = Commands; c->name; c++)
2979  {
2980  if (((c->func == mutt_parse_hook) || (c->func == mutt_parse_idxfmt_hook)) &&
2981  (mutt_str_strcasecmp(c->name, name) == 0))
2982  {
2983  return c->data;
2984  }
2985  }
2986  return MUTT_HOOK_NO_FLAGS;
2987 }
A user-callable command.
Definition: mutt_commands.h:54
const char * name
Name of the command.
Definition: mutt_commands.h:56
const struct Command Commands[]
Definition: init.h:5002
enum CommandResult mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;hook&#39; family of commands - Implements command_t.
Definition: hook.c:85
const char * name
Definition: pgpmicalg.c:46
enum CommandResult mutt_parse_idxfmt_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;index-format-hook&#39; command - Implements command_t.
Definition: hook.c:349
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
#define MUTT_HOOK_NO_FLAGS
No flags are set.
Definition: hook.h:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_parse_rc_line()

enum CommandResult mutt_parse_rc_line ( char *  line,
struct Buffer token,
struct Buffer err 
)

Parse a line of user config.

Parameters
lineconfig line to read
tokenscratch buffer to be used by parser
errwhere to write error messages
Return values
CommandResultResult e.g. MUTT_CMD_SUCCESS

Caller should free token->data when finished. the reason for this variable is to avoid having to allocate and deallocate a lot of memory if we are parsing many lines. the caller can pass in the memory to use, which avoids having to create new space for every call to this function.

Definition at line 3251 of file init.c.

3253 {
3254  if (!line || !*line)
3255  return 0;
3256 
3257  int i;
3258  enum CommandResult rc = MUTT_CMD_SUCCESS;
3259 
3260  struct Buffer expn = mutt_buffer_make(128);
3261  mutt_buffer_addstr(&expn, line);
3262  expn.dptr = expn.data;
3263 
3264  *err->data = 0;
3265 
3266  SKIPWS(expn.dptr);
3267  while (*expn.dptr != '\0')
3268  {
3269  if (*expn.dptr == '#')
3270  break; /* rest of line is a comment */
3271  if (*expn.dptr == ';')
3272  {
3273  expn.dptr++;
3274  continue;
3275  }
3276  mutt_extract_token(token, &expn, MUTT_TOKEN_NO_FLAGS);
3277  for (i = 0; Commands[i].name; i++)
3278  {
3279  if (mutt_str_strcmp(token->data, Commands[i].name) == 0)
3280  {
3281  rc = Commands[i].func(token, &expn, Commands[i].data, err);
3282  if (rc != MUTT_CMD_SUCCESS)
3283  { /* -1 Error, +1 Finish */
3284  goto finish; /* Propagate return code */
3285  }
3287  break; /* Continue with next command */
3288  }
3289  }
3290  if (!Commands[i].name)
3291  {
3292  mutt_buffer_printf(err, _("%s: unknown command"), NONULL(token->data));
3293  rc = MUTT_CMD_ERROR;
3294  break; /* Ignore the rest of the line */
3295  }
3296  }
3297 finish:
3298  mutt_buffer_dealloc(&expn);
3299  return rc;
3300 }
#define NONULL(x)
Definition: string2.h:37
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
command_t func
Function to parse the command.
Definition: mutt_commands.h:57
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
const char * name
Name of the command.
Definition: mutt_commands.h:56
A Command has been executed.
Definition: notify_type.h:40
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
Container for Accounts, Notifications.
Definition: neomutt.h:35
const struct Command Commands[]
Definition: init.h:5002
const char * name
Definition: pgpmicalg.c:46
#define SKIPWS(ch)
Definition: string2.h:47
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
const char * line
Definition: common.c:36
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2674
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
struct Notify * notify
Notifications handler.
Definition: neomutt.h:37
Success: Command worked.
Definition: mutt_commands.h:37
bool notify_send(struct Notify *notify, int type, int subtype, intptr_t data)
Send out a notification message.
Definition: notify.c:145
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_query_variables()

int mutt_query_variables ( struct ListHead *  queries)

Implement the -Q command line flag.

Parameters
queriesList of query strings
Return values
0Success, all queries exist
1Error

Definition at line 3308 of file init.c.

3309 {
3310  struct Buffer value = mutt_buffer_make(256);
3311  struct Buffer tmp = mutt_buffer_make(256);
3312  int rc = 0;
3313 
3314  struct ListNode *np = NULL;
3315  STAILQ_FOREACH(np, queries, entries)
3316  {
3317  mutt_buffer_reset(&value);
3318 
3319  struct HashElem *he = cs_get_elem(Config, np->data);
3320  if (!he)
3321  {
3322  rc = 1;
3323  continue;
3324  }
3325 
3326  int rv = cs_he_string_get(Config, he, &value);
3327  if (CSR_RESULT(rv) != CSR_SUCCESS)
3328  {
3329  rc = 1;
3330  continue;
3331  }
3332 
3333  int type = DTYPE(he->type);
3334  if (IS_PATH(he) && !(he->type & DT_MAILBOX))
3335  mutt_pretty_mailbox(value.data, value.dsize);
3336 
3337  if ((type != DT_BOOL) && (type != DT_NUMBER) && (type != DT_LONG) && (type != DT_QUAD))
3338  {
3339  mutt_buffer_reset(&tmp);
3340  pretty_var(value.data, &tmp);
3341  mutt_buffer_strcpy(&value, tmp.data);
3342  }
3343 
3344  dump_config_neo(Config, he, &value, NULL, CS_DUMP_NO_FLAGS, stdout);
3345  }
3346 
3347  mutt_buffer_dealloc(&value);
3348  mutt_buffer_dealloc(&tmp);
3349 
3350  return rc; // TEST16: neomutt -Q charset
3351 }
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
#define DT_LONG
a number (long)
Definition: types.h:33
#define IS_PATH(x)
Definition: types.h:55
#define CSR_RESULT(x)
Definition: set.h:62
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:40
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:36
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:43
size_t dsize
Length of data.
Definition: buffer.h:37
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.
Definition: dump.c:150
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
Definition: set.c:216
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:46
#define DT_MAILBOX
Don&#39;t perform path expansions.
Definition: types.h:47
#define CS_DUMP_NO_FLAGS
No flags are set.
Definition: dump.h:35
char * data
Pointer to data.
Definition: buffer.h:35
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:628
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
int cs_he_string_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: set.c:650
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
Definition: dump.c:80
char * data
String.
Definition: list.h:35
int type
Definition: hash.h:44
The item stored in a Hash Table.
Definition: hash.h:42
A List node for strings.
Definition: list.h:33
#define DT_NUMBER
a number
Definition: types.h:35
#define DT_BOOL
boolean option
Definition: types.h:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_value()

void reset_value ( const char *  name)