NeoMutt  2019-12-07-60-g0cfa53
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 (struct ConfigSet *cs, 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 ( struct ConfigSet cs,
bool  skip_sys_rc,
struct ListHead *  commands 
)

Initialise NeoMutt.

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

Definition at line 2997 of file init.c.

2998 {
2999  char buf[1024];
3000  int need_pause = 0;
3001  int rc = 1;
3002  struct Buffer err = mutt_buffer_make(256);
3003 
3005  /* reverse alias keys need to be strdup'ed because of idna conversions */
3010 
3011  mutt_menu_init();
3012 
3013  snprintf(AttachmentMarker, sizeof(AttachmentMarker), "\033]9;%" PRIu64 "\a", // Escape
3014  mutt_rand64());
3015 
3016  snprintf(ProtectedHeaderMarker, sizeof(ProtectedHeaderMarker), "\033]8;%lld\a", // Escape
3017  (long long) mutt_date_epoch());
3018 
3019  /* "$spoolfile" precedence: config file, environment */
3020  const char *p = mutt_str_getenv("MAIL");
3021  if (!p)
3022  p = mutt_str_getenv("MAILDIR");
3023  if (!p)
3024  {
3025 #ifdef HOMESPOOL
3026  mutt_path_concat(buf, NONULL(HomeDir), MAILPATH, sizeof(buf));
3027 #else
3028  mutt_path_concat(buf, MAILPATH, NONULL(Username), sizeof(buf));
3029 #endif
3030  p = buf;
3031  }
3032  cs_str_initial_set(cs, "spoolfile", p, NULL);
3033  cs_str_reset(cs, "spoolfile", NULL);
3034 
3035  p = mutt_str_getenv("REPLYTO");
3036  if (p)
3037  {
3038  struct Buffer tmp, token;
3039 
3040  snprintf(buf, sizeof(buf), "Reply-To: %s", p);
3041 
3042  mutt_buffer_init(&tmp);
3043  tmp.data = buf;
3044  tmp.dptr = buf;
3045  tmp.dsize = mutt_str_strlen(buf);
3046 
3047  mutt_buffer_init(&token);
3048  parse_my_hdr(&token, &tmp, 0, &err); /* adds to UserHeader */
3049  FREE(&token.data);
3050  }
3051 
3052  p = mutt_str_getenv("EMAIL");
3053  if (p)
3054  {
3055  cs_str_initial_set(cs, "from", p, NULL);
3056  cs_str_reset(cs, "from", NULL);
3057  }
3058 
3059  /* "$mailcap_path" precedence: config file, environment, code */
3060  const char *env_mc = mutt_str_getenv("MAILCAPS");
3061  if (env_mc)
3062  cs_str_string_set(cs, "mailcap_path", env_mc, NULL);
3063 
3064  /* "$tmpdir" precedence: config file, environment, code */
3065  const char *env_tmp = mutt_str_getenv("TMPDIR");
3066  if (env_tmp)
3067  cs_str_string_set(cs, "tmpdir", env_tmp, NULL);
3068 
3069  /* "$visual", "$editor" precedence: config file, environment, code */
3070  const char *env_ed = mutt_str_getenv("VISUAL");
3071  if (!env_ed)
3072  env_ed = mutt_str_getenv("EDITOR");
3073  if (env_ed)
3074  {
3075  cs_str_string_set(cs, "editor", env_ed, NULL);
3076  cs_str_string_set(cs, "visual", env_ed, NULL);
3077  }
3078 
3080  cs_str_initial_set(cs, "charset", C_Charset, NULL);
3082 
3083  Matches = mutt_mem_calloc(MatchesListsize, sizeof(char *));
3084 
3086 
3087 #ifdef HAVE_GETSID
3088  /* Unset suspend by default if we're the session leader */
3089  if (getsid(0) == getpid())
3090  C_Suspend = false;
3091 #endif
3092 
3093  /* RFC2368, "4. Unsafe headers"
3094  * The creator of a mailto URL can't expect the resolver of a URL to
3095  * understand more than the "subject" and "body" headers. Clients that
3096  * resolve mailto URLs into mail messages should be able to correctly
3097  * create RFC822-compliant mail messages using the "subject" and "body"
3098  * headers. */
3099  add_to_stailq(&MailToAllow, "body");
3100  add_to_stailq(&MailToAllow, "subject");
3101  /* Cc, In-Reply-To, and References help with not breaking threading on
3102  * mailing lists, see https://github.com/neomutt/neomutt/issues/115 */
3103  add_to_stailq(&MailToAllow, "cc");
3104  add_to_stailq(&MailToAllow, "in-reply-to");
3105  add_to_stailq(&MailToAllow, "references");
3106 
3107  if (STAILQ_EMPTY(&Muttrc))
3108  {
3109  const char *xdg_cfg_home = mutt_str_getenv("XDG_CONFIG_HOME");
3110 
3111  if (!xdg_cfg_home && HomeDir)
3112  {
3113  snprintf(buf, sizeof(buf), "%s/.config", HomeDir);
3114  xdg_cfg_home = buf;
3115  }
3116 
3117  char *config = find_cfg(HomeDir, xdg_cfg_home);
3118  if (config)
3119  {
3120  mutt_list_insert_tail(&Muttrc, config);
3121  }
3122  }
3123  else
3124  {
3125  struct ListNode *np = NULL;
3126  STAILQ_FOREACH(np, &Muttrc, entries)
3127  {
3128  mutt_str_strfcpy(buf, np->data, sizeof(buf));
3129  FREE(&np->data);
3130  mutt_expand_path(buf, sizeof(buf));
3131  np->data = mutt_str_strdup(buf);
3132  if (access(np->data, F_OK))
3133  {
3134  mutt_perror(np->data);
3135  goto done; // TEST10: neomutt -F missing
3136  }
3137  }
3138  }
3139 
3140  if (!STAILQ_EMPTY(&Muttrc))
3141  {
3142  cs_str_string_set(cs, "alias_file", STAILQ_FIRST(&Muttrc)->data, NULL);
3143  }
3144 
3145  /* Process the global rc file if it exists and the user hasn't explicitly
3146  * requested not to via "-n". */
3147  if (!skip_sys_rc)
3148  {
3149  do
3150  {
3151  if (mutt_set_xdg_path(XDG_CONFIG_DIRS, buf, sizeof(buf)))
3152  break;
3153 
3154  snprintf(buf, sizeof(buf), "%s/neomuttrc", SYSCONFDIR);
3155  if (access(buf, F_OK) == 0)
3156  break;
3157 
3158  snprintf(buf, sizeof(buf), "%s/Muttrc", SYSCONFDIR);
3159  if (access(buf, F_OK) == 0)
3160  break;
3161 
3162  snprintf(buf, sizeof(buf), "%s/neomuttrc", PKGDATADIR);
3163  if (access(buf, F_OK) == 0)
3164  break;
3165 
3166  snprintf(buf, sizeof(buf), "%s/Muttrc", PKGDATADIR);
3167  } while (false);
3168 
3169  if (access(buf, F_OK) == 0)
3170  {
3171  if (source_rc(buf, &err) != 0)
3172  {
3173  mutt_error("%s", err.data);
3174  need_pause = 1; // TEST11: neomutt (error in /etc/neomuttrc)
3175  }
3176  }
3177  }
3178 
3179  /* Read the user's initialization file. */
3180  struct ListNode *np = NULL;
3181  STAILQ_FOREACH(np, &Muttrc, entries)
3182  {
3183  if (np->data)
3184  {
3185  if (source_rc(np->data, &err) != 0)
3186  {
3187  mutt_error("%s", err.data);
3188  need_pause = 1; // TEST12: neomutt (error in ~/.neomuttrc)
3189  }
3190  }
3191  }
3192 
3193  if (execute_commands(commands) != 0)
3194  need_pause = 1; // TEST13: neomutt -e broken
3195 
3196  if (!get_hostname(cs))
3197  goto done;
3198 
3199  if (!C_Realname)
3200  {
3201  struct passwd *pw = getpwuid(getuid());
3202  if (pw)
3203  {
3204  char name[256];
3205  C_Realname = mutt_str_strdup(mutt_gecos_name(name, sizeof(name), pw));
3206  }
3207  }
3208  cs_str_initial_set(cs, "realname", C_Realname, NULL);
3209 
3210  if (need_pause && !OptNoCurses)
3211  {
3213  if (mutt_any_key_to_continue(NULL) == 'q')
3214  goto done; // TEST14: neomutt -e broken (press 'q')
3215  }
3216 
3217  mutt_file_mkdir(C_Tmpdir, S_IRWXU);
3218 
3219  mutt_hist_init();
3221 
3222 #ifdef USE_NOTMUCH
3223  if (C_VirtualSpoolfile)
3224  {
3225  /* Find the first virtual folder and open it */
3226  struct MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_NOTMUCH);
3227  struct MailboxNode *mp = STAILQ_FIRST(&ml);
3228  if (mp)
3229  cs_str_string_set(cs, "spoolfile", mailbox_path(mp->mailbox), NULL);
3231  }
3232 #endif
3233  rc = 0;
3234 
3235 done:
3236  FREE(&err.data);
3237  return rc;
3238 }
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:52
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:191
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:591
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:135
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:46
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:82
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:60
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:453
#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:133
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:157
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:49
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
static bool get_hostname(struct ConfigSet *cs)
Find the Fully-Qualified Domain Name.
Definition: init.c:410
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:349
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:555
int mutt_set_xdg_path(enum XdgType type, char *buf, size_t bufsize)
Find an XDG path or its fallback.
Definition: muttlib.c:1616
&#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:47
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:390
WHERE struct Hash * ReverseAliases
Hash table of aliases (email address -> alias)
Definition: globals.h:59
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:578
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:256
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:381
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:345
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:54
List of Mailboxes.
Definition: mailbox.h:144
WHERE char * C_Realname
Config: Real name of the user.
Definition: globals.h:138
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
XDG system dir: /etc/xdg.
Definition: protos.h:50
#define STAILQ_FIRST(head)
Definition: queue.h:347
#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:287
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:146
+ 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.

Parameters
sizeSize for Config Hash Table
Return values
ptrNew Config Set

Definition at line 3799 of file init.c.

3800 {
3801  struct ConfigSet *cs = cs_new(size);
3802 
3803  address_init(cs);
3804  bool_init(cs);
3805  enum_init(cs);
3806  long_init(cs);
3807  mbtable_init(cs);
3808  number_init(cs);
3809  quad_init(cs);
3810  regex_init(cs);
3811  slist_init(cs);
3812  sort_init(cs);
3813  string_init(cs);
3814 
3815  if (!cs_register_variables(cs, MuttVars, 0))
3816  {
3817  mutt_error("cs_register_variables() failed");
3818  cs_free(&cs);
3819  return NULL;
3820  }
3821 
3822  return cs;
3823 }
Container for lots of config items.
Definition: set.h:168
void quad_init(struct ConfigSet *cs)
Register the Quad-option config type.
Definition: quad.c:192
void bool_init(struct ConfigSet *cs)
Register the Bool config type.
Definition: bool.c:190
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:168
struct ConfigSet * cs_new(size_t size)
Create a new Config Set.
Definition: set.c:154
void long_init(struct ConfigSet *cs)
Register the Long config type.
Definition: long.c:173
struct ConfigDef MuttVars[]
Definition: init.h:134
#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:275
+ 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_subset_str_string_get(NeoMutt->sub, 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:53
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
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
Container for Accounts, Notifications.
Definition: neomutt.h:35
int cs_subset_str_string_get(const struct ConfigSubset *sub, const char *name, struct Buffer *result)
Get a config item as a string.
Definition: subset.c:308
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
#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:37
#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 ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
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:52
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:60
void mutt_delete_hooks(HookFlags type)
Delete matching hooks.
Definition: hook.c:302
WHERE char * LastFolder
Previously selected mailbox.
Definition: globals.h:55
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:49
WHERE char * CurrentFolder
Currently selected mailbox.
Definition: globals.h:54
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:1599
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:59
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:50
#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 3360 of file init.c.

3361 {
3362  switch (opt)
3363  {
3364  case MUTT_YES:
3365  case MUTT_NO:
3366  return opt;
3367 
3368  default:
3369  opt = mutt_yesorno(prompt, (opt == MUTT_ASKYES) ? MUTT_YES : MUTT_NO);
3371  return opt;
3372  }
3373 
3374  /* not reached */
3375 }
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:40
Ask the user, defaulting to &#39;Yes&#39;.
Definition: quad.h:42
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:376
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:113
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:39
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:47
+ 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 3556 of file init.c.

3557 {
3558  char *pt = buf;
3559  int spaces; /* keep track of the number of leading spaces on the line */
3560 
3561  if (!Context || !Context->mailbox->label_hash)
3562  return 0;
3563 
3564  SKIPWS(buf);
3565  spaces = buf - pt;
3566 
3567  /* first TAB. Collect all the matches */
3568  if (numtabs == 1)
3569  {
3570  struct HashElem *entry = NULL;
3571  struct HashWalkState state = { 0 };
3572 
3573  NumMatched = 0;
3574  mutt_str_strfcpy(UserTyped, buf, sizeof(UserTyped));
3575  memset(Matches, 0, MatchesListsize);
3576  memset(Completed, 0, sizeof(Completed));
3577  while ((entry = mutt_hash_walk(Context->mailbox->label_hash, &state)))
3578  candidate(UserTyped, entry->key.strkey, Completed, sizeof(Completed));
3580  qsort(Matches, NumMatched, sizeof(char *), (sort_t) mutt_str_strcasecmp);
3582 
3583  /* All matches are stored. Longest non-ambiguous string is ""
3584  * i.e. don't change 'buf'. Fake successful return this time */
3585  if (UserTyped[0] == '\0')
3586  return 1;
3587  }
3588 
3589  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3590  return 0;
3591 
3592  /* NumMatched will _always_ be at least 1 since the initial
3593  * user-typed string is always stored */
3594  if ((numtabs == 1) && (NumMatched == 2))
3595  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3596  else if ((numtabs > 1) && (NumMatched > 2))
3597  {
3598  /* cycle through all the matches */
3599  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3600  }
3601 
3602  /* return the completed label */
3603  strncpy(buf, Completed, buflen - spaces);
3604 
3605  return 1;
3606 }
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:128
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 3386 of file init.c.

3387 {
3388  char *pt = buf;
3389  int num;
3390  int spaces; /* keep track of the number of leading spaces on the line */
3391  struct MyVar *myv = NULL;
3392 
3393  SKIPWS(buf);
3394  spaces = buf - pt;
3395 
3396  pt = buf + pos - spaces;
3397  while ((pt > buf) && !isspace((unsigned char) *pt))
3398  pt--;
3399 
3400  if (pt == buf) /* complete cmd */
3401  {
3402  /* first TAB. Collect all the matches */
3403  if (numtabs == 1)
3404  {
3405  NumMatched = 0;
3406  mutt_str_strfcpy(UserTyped, pt, sizeof(UserTyped));
3407  memset(Matches, 0, MatchesListsize);
3408  memset(Completed, 0, sizeof(Completed));
3409  for (num = 0; Commands[num].name; num++)
3413 
3414  /* All matches are stored. Longest non-ambiguous string is ""
3415  * i.e. don't change 'buf'. Fake successful return this time */
3416  if (UserTyped[0] == '\0')
3417  return 1;
3418  }
3419 
3420  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3421  return 0;
3422 
3423  /* NumMatched will _always_ be at least 1 since the initial
3424  * user-typed string is always stored */
3425  if ((numtabs == 1) && (NumMatched == 2))
3426  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3427  else if ((numtabs > 1) && (NumMatched > 2))
3428  {
3429  /* cycle through all the matches */
3430  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3431  }
3432 
3433  /* return the completed command */
3434  strncpy(buf, Completed, buflen - spaces);
3435  }
3436  else if (mutt_str_startswith(buf, "set", CASE_MATCH) ||
3437  mutt_str_startswith(buf, "unset", CASE_MATCH) ||
3438  mutt_str_startswith(buf, "reset", CASE_MATCH) ||
3439  mutt_str_startswith(buf, "toggle", CASE_MATCH))
3440  { /* complete variables */
3441  static const char *const prefixes[] = { "no", "inv", "?", "&", 0 };
3442 
3443  pt++;
3444  /* loop through all the possible prefixes (no, inv, ...) */
3445  if (mutt_str_startswith(buf, "set", CASE_MATCH))
3446  {
3447  for (num = 0; prefixes[num]; num++)
3448  {
3449  if (mutt_str_startswith(pt, prefixes[num], CASE_MATCH))
3450  {
3451  pt += mutt_str_strlen(prefixes[num]);
3452  break;
3453  }
3454  }
3455  }
3456 
3457  /* first TAB. Collect all the matches */
3458  if (numtabs == 1)
3459  {
3460  NumMatched = 0;
3461  mutt_str_strfcpy(UserTyped, pt, sizeof(UserTyped));
3462  memset(Matches, 0, MatchesListsize);
3463  memset(Completed, 0, sizeof(Completed));
3464  for (num = 0; MuttVars[num].name; num++)
3465  candidate(UserTyped, MuttVars[num].name, Completed, sizeof(Completed));
3466  TAILQ_FOREACH(myv, &MyVars, entries)
3467  {
3468  candidate(UserTyped, myv->name, Completed, sizeof(Completed));
3469  }
3472 
3473  /* All matches are stored. Longest non-ambiguous string is ""
3474  * i.e. don't change 'buf'. Fake successful return this time */
3475  if (UserTyped[0] == '\0')
3476  return 1;
3477  }
3478 
3479  if ((Completed[0] == 0) && UserTyped[0])
3480  return 0;
3481 
3482  /* NumMatched will _always_ be at least 1 since the initial
3483  * user-typed string is always stored */
3484  if ((numtabs == 1) && (NumMatched == 2))
3485  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3486  else if ((numtabs > 1) && (NumMatched > 2))
3487  {
3488  /* cycle through all the matches */
3489  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3490  }
3491 
3492  strncpy(pt, Completed, buf + buflen - pt - spaces);
3493  }
3494  else if (mutt_str_startswith(buf, "exec", CASE_MATCH))
3495  {
3496  const struct Binding *menu = km_get_table(CurrentMenu);
3497 
3498  if (!menu && (CurrentMenu != MENU_PAGER))
3499  menu = OpGeneric;
3500 
3501  pt++;
3502  /* first TAB. Collect all the matches */
3503  if (numtabs == 1)
3504  {
3505  NumMatched = 0;
3506  mutt_str_strfcpy(UserTyped, pt, sizeof(UserTyped));
3507  memset(Matches, 0, MatchesListsize);
3508  memset(Completed, 0, sizeof(Completed));
3509  for (num = 0; menu[num].name; num++)
3510  candidate(UserTyped, menu[num].name, Completed, sizeof(Completed));
3511  /* try the generic menu */
3512  if ((Completed[0] == '\0') && (CurrentMenu != MENU_PAGER))
3513  {
3514  menu = OpGeneric;
3515  for (num = 0; menu[num].name; num++)
3516  candidate(UserTyped, menu[num].name, Completed, sizeof(Completed));
3517  }
3520 
3521  /* All matches are stored. Longest non-ambiguous string is ""
3522  * i.e. don't change 'buf'. Fake successful return this time */
3523  if (UserTyped[0] == '\0')
3524  return 1;
3525  }
3526 
3527  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3528  return 0;
3529 
3530  /* NumMatched will _always_ be at least 1 since the initial
3531  * user-typed string is always stored */
3532  if ((numtabs == 1) && (NumMatched == 2))
3533  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3534  else if ((numtabs > 1) && (NumMatched > 2))
3535  {
3536  /* cycle through all the matches */
3537  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3538  }
3539 
3540  strncpy(pt, Completed, buf + buflen - pt - spaces);
3541  }
3542  else
3543  return 0;
3544 
3545  return 1;
3546 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
static int NumMatched
Definition: init.c:90
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:82
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:5001
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:136
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:134
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:1221
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 3730 of file init.c.

3731 {
3732  char *pt = buf;
3733 
3734  if (buf[0] == '\0')
3735  return 0;
3736 
3737  SKIPWS(buf);
3738  const int spaces = buf - pt;
3739 
3740  pt = buf + pos - spaces;
3741  while ((pt > buf) && !isspace((unsigned char) *pt))
3742  pt--;
3743  pt++; /* move past the space */
3744  if (*pt == '=') /* abort if no var before the '=' */
3745  return 0;
3746 
3747  if (mutt_str_startswith(buf, "set", CASE_MATCH))
3748  {
3749  const char *myvarval = NULL;
3750  char var[256];
3751  mutt_str_strfcpy(var, pt, sizeof(var));
3752  /* ignore the trailing '=' when comparing */
3753  int vlen = mutt_str_strlen(var);
3754  if (vlen == 0)
3755  return 0;
3756 
3757  var[vlen - 1] = '\0';
3758 
3759  struct HashElem *he = cs_subset_lookup(NeoMutt->sub, var);
3760  if (!he)
3761  {
3762  myvarval = myvar_get(var);
3763  if (myvarval)
3764  {
3765  struct Buffer pretty = mutt_buffer_make(256);
3766  pretty_var(myvarval, &pretty);
3767  snprintf(pt, buflen - (pt - buf), "%s=%s", var, pretty.data);
3768  mutt_buffer_dealloc(&pretty);
3769  return 1;
3770  }
3771  return 0; /* no such variable. */
3772  }
3773  else
3774  {
3775  struct Buffer value = mutt_buffer_make(256);
3776  struct Buffer pretty = mutt_buffer_make(256);
3777  int rc = cs_subset_he_string_get(NeoMutt->sub, he, &value);
3778  if (CSR_RESULT(rc) == CSR_SUCCESS)
3779  {
3780  pretty_var(value.data, &pretty);
3781  snprintf(pt, buflen - (pt - buf), "%s=%s", var, pretty.data);
3782  mutt_buffer_dealloc(&value);
3783  mutt_buffer_dealloc(&pretty);
3784  return 0;
3785  }
3786  mutt_buffer_dealloc(&value);
3787  mutt_buffer_dealloc(&pretty);
3788  return 1;
3789  }
3790  }
3791  return 0;
3792 }
#define CSR_RESULT(x)
Definition: set.h:53
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
int cs_subset_he_string_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: subset.c:292
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
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:119
Container for Accounts, Notifications.
Definition: neomutt.h:35
#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
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:37
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
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
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
+ 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 3620 of file init.c.

3621 {
3622  char *pt = buf;
3623  int spaces;
3624 
3625  SKIPWS(buf);
3626  spaces = buf - pt;
3627 
3628  pt = (char *) mutt_str_rstrnstr((char *) buf, pos, "tag:");
3629  if (pt)
3630  {
3631  pt += 4;
3632  if (numtabs == 1)
3633  {
3634  /* First TAB. Collect all the matches */
3636 
3637  /* All matches are stored. Longest non-ambiguous string is ""
3638  * i.e. don't change 'buf'. Fake successful return this time. */
3639  if (UserTyped[0] == '\0')
3640  return true;
3641  }
3642 
3643  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3644  return false;
3645 
3646  /* NumMatched will _always_ be at least 1 since the initial
3647  * user-typed string is always stored */
3648  if ((numtabs == 1) && (NumMatched == 2))
3649  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3650  else if ((numtabs > 1) && (NumMatched > 2))
3651  {
3652  /* cycle through all the matches */
3653  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3654  }
3655 
3656  /* return the completed query */
3657  strncpy(pt, Completed, buf + buflen - pt - spaces);
3658  }
3659  else
3660  return false;
3661 
3662  return true;
3663 }
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 3677 of file init.c.

3678 {
3679  if (!buf)
3680  return false;
3681 
3682  char *pt = buf;
3683 
3684  /* Only examine the last token */
3685  char *last_space = strrchr(buf, ' ');
3686  if (last_space)
3687  pt = (last_space + 1);
3688 
3689  /* Skip the +/- */
3690  if ((pt[0] == '+') || (pt[0] == '-'))
3691  pt++;
3692 
3693  if (numtabs == 1)
3694  {
3695  /* First TAB. Collect all the matches */
3697 
3698  /* All matches are stored. Longest non-ambiguous string is ""
3699  * i.e. don't change 'buf'. Fake successful return this time. */
3700  if (UserTyped[0] == '\0')
3701  return true;
3702  }
3703 
3704  if ((Completed[0] == '\0') && (UserTyped[0] != '\0'))
3705  return false;
3706 
3707  /* NumMatched will _always_ be at least 1 since the initial
3708  * user-typed string is always stored */
3709  if ((numtabs == 1) && (NumMatched == 2))
3710  snprintf(Completed, sizeof(Completed), "%s", Matches[0]);
3711  else if ((numtabs > 1) && (NumMatched > 2))
3712  {
3713  /* cycle through all the matches */
3714  snprintf(Completed, sizeof(Completed), "%s", Matches[(numtabs - 2) % NumMatched]);
3715  }
3716 
3717  /* return the completed query */
3718  strncpy(pt, Completed, buf + buflen - pt);
3719 
3720  return true;
3721 }
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:5001
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 3252 of file init.c.

3254 {
3255  if (!line || !*line)
3256  return 0;
3257 
3258  int i;
3259  enum CommandResult rc = MUTT_CMD_SUCCESS;
3260 
3261  struct Buffer expn = mutt_buffer_make(128);
3262  mutt_buffer_addstr(&expn, line);
3263  expn.dptr = expn.data;
3264 
3265  *err->data = 0;
3266 
3267  SKIPWS(expn.dptr);
3268  while (*expn.dptr != '\0')
3269  {
3270  if (*expn.dptr == '#')
3271  break; /* rest of line is a comment */
3272  if (*expn.dptr == ';')
3273  {
3274  expn.dptr++;
3275  continue;
3276  }
3277  mutt_extract_token(token, &expn, MUTT_TOKEN_NO_FLAGS);
3278  for (i = 0; Commands[i].name; i++)
3279  {
3280  if (mutt_str_strcmp(token->data, Commands[i].name) == 0)
3281  {
3282  rc = Commands[i].func(token, &expn, Commands[i].data, err);
3283  if (rc != MUTT_CMD_SUCCESS)
3284  { /* -1 Error, +1 Finish */
3285  goto finish; /* Propagate return code */
3286  }
3287  notify_send(NeoMutt->notify, NT_COMMAND, i, (void *) &Commands[i]);
3288  break; /* Continue with next command */
3289  }
3290  }
3291  if (!Commands[i].name)
3292  {
3293  mutt_buffer_printf(err, _("%s: unknown command"), NONULL(token->data));
3294  rc = MUTT_CMD_ERROR;
3295  break; /* Ignore the rest of the line */
3296  }
3297  }
3298 finish:
3299  mutt_buffer_dealloc(&expn);
3300  return rc;
3301 }
#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:33
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:5001
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
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:138
Success: Command worked.
Definition: mutt_commands.h:37
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 3309 of file init.c.

3310 {
3311  struct Buffer value = mutt_buffer_make(256);
3312  struct Buffer tmp = mutt_buffer_make(256);
3313  int rc = 0;
3314 
3315  struct ListNode *np = NULL;
3316  STAILQ_FOREACH(np, queries, entries)
3317  {
3318  mutt_buffer_reset(&value);
3319 
3320  struct HashElem *he = cs_subset_lookup(NeoMutt->sub, np->data);
3321  if (!he)
3322  {
3323  rc = 1;
3324  continue;
3325  }
3326 
3327  int rv = cs_subset_he_string_get(NeoMutt->sub, he, &value);
3328  if (CSR_RESULT(rv) != CSR_SUCCESS)
3329  {
3330  rc = 1;
3331  continue;
3332  }
3333 
3334  int type = DTYPE(he->type);
3335  if (IS_PATH(he) && !(he->type & DT_MAILBOX))
3336  mutt_pretty_mailbox(value.data, value.dsize);
3337 
3338  if ((type != DT_BOOL) && (type != DT_NUMBER) && (type != DT_LONG) && (type != DT_QUAD))
3339  {
3340  mutt_buffer_reset(&tmp);
3341  pretty_var(value.data, &tmp);
3342  mutt_buffer_strcpy(&value, tmp.data);
3343  }
3344 
3345  dump_config_neo(NeoMutt->sub->cs, he, &value, NULL, CS_DUMP_NO_FLAGS, stdout);
3346  }
3347 
3348  mutt_buffer_dealloc(&value);
3349  mutt_buffer_dealloc(&tmp);
3350 
3351  return rc; // TEST16: neomutt -Q charset
3352 }
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:53
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
int cs_subset_he_string_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: subset.c:292
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:119
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:36
Container for Accounts, Notifications.
Definition: neomutt.h:35
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:43
size_t dsize
Length of data.
Definition: buffer.h:37
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:49
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
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:37
#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:627
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
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
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
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)