NeoMutt  2018-07-16 +1783-b00bd9
Teaching an old dog new tricks
DOXYGEN
init.c File Reference

Config/command parsing. More...

#include "config.h"
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <pwd.h>
#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <wchar.h>
#include "mutt/mutt.h"
#include "address/lib.h"
#include "email/lib.h"
#include "mutt.h"
#include "init.h"
#include "account.h"
#include "alias.h"
#include "context.h"
#include "filter.h"
#include "hcache/hcache.h"
#include "keymap.h"
#include "monitor.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mutt_window.h"
#include "mx.h"
#include "myvar.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "protos.h"
#include "sidebar.h"
#include "version.h"
#include "notmuch/mutt_notmuch.h"
#include "imap/imap.h"
#include <libintl.h>
+ Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define MAX_ERRS   128
 
#define NUM_VARS   mutt_array_size(MuttVars)
 
#define NUM_COMMANDS   mutt_array_size(Commands)
 

Enumerations

enum  GroupState { GS_NONE, GS_RX, GS_ADDR }
 Type of email address group. More...
 

Functions

static void add_to_stailq (struct ListHead *head, const char *str)
 Add a string to a list. More...
 
static void alternates_clean (void)
 Clear the recipient valid flag of all emails. More...
 
static void attachments_clean (void)
 always wise to do what someone else did before More...
 
static void matches_ensure_morespace (int current)
 Allocate more space for auto-completion. More...
 
static void candidate (char *try, const char *src, char *dest, size_t dlen)
 helper function for completion More...
 
static void clear_subject_mods (void)
 Clear out all modified email subjects. More...
 
static int complete_all_nm_tags (const char *pt)
 Pass a list of Notmuch tags to the completion code. More...
 
static int execute_commands (struct ListHead *p)
 Execute a set of NeoMutt commands. More...
 
static char * find_cfg (const char *home, const char *xdg_cfg_home)
 Find a config file. More...
 
static char * getmailname (void)
 Try to retrieve the FQDN from mailname files. More...
 
static bool get_hostname (void)
 Find the Fully-Qualified Domain Name. More...
 
static enum CommandResult parse_attach_list (struct Buffer *buf, struct Buffer *s, struct ListHead *head, struct Buffer *err)
 Parse the "attachments" command. More...
 
static int parse_grouplist (struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse a group context. More...
 
static enum CommandResult parse_replace_list (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse a string replacement rule - Implements command_t. More...
 
static enum CommandResult parse_unattach_list (struct Buffer *buf, struct Buffer *s, struct ListHead *head, struct Buffer *err)
 Parse the "unattachments" command. More...
 
static enum CommandResult parse_unreplace_list (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Remove a string replacement rule - Implements command_t. More...
 
static int print_attach_list (struct ListHead *h, const char op, const char *name)
 Print a list of attachments. More...
 
static void remove_from_stailq (struct ListHead *head, const char *str)
 Remove an item, matching a string, from a List. More...
 
static int source_rc (const char *rcfile_path, struct Buffer *err)
 Read an initialization file. More...
 
static enum CommandResult parse_alias (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'alias' command - Implements command_t. More...
 
static enum CommandResult parse_alternates (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'alternates' command - Implements command_t. More...
 
static enum CommandResult parse_attachments (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'attachments' command - Implements command_t. More...
 
static enum CommandResult parse_echo (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'echo' command - Implements command_t. More...
 
static enum CommandResult parse_finish (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'finish' command - Implements command_t. More...
 
static enum CommandResult parse_group (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'group' and 'ungroup' commands - Implements command_t. More...
 
static bool is_function (const char *name)
 Is the argument a neomutt function? More...
 
static enum CommandResult parse_ifdef (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'ifdef' and 'ifndef' commands - Implements command_t. More...
 
static enum CommandResult parse_ignore (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'ignore' command - Implements command_t. More...
 
static enum CommandResult parse_lists (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'lists' command - Implements command_t. More...
 
static enum CommandResult parse_mailboxes (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'mailboxes' command - Implements command_t. More...
 
static enum CommandResult parse_my_hdr (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'my_hdr' command - Implements command_t. More...
 
static enum CommandResult parse_path_list (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'sidebar_whitelist' command - Implements command_t. More...
 
static enum CommandResult parse_path_unlist (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unsidebar_whitelist' command - Implements command_t. More...
 
static enum CommandResult parse_set (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'set' family of commands - Implements command_t. More...
 
static enum CommandResult parse_setenv (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'setenv' and 'unsetenv' commands - Implements command_t. More...
 
static enum CommandResult parse_source (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'source' command - Implements command_t. More...
 
static enum CommandResult parse_spam_list (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'spam' and 'nospam' commands - Implements command_t. More...
 
static enum CommandResult parse_stailq (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse a list command - Implements command_t. More...
 
static enum CommandResult parse_subjectrx_list (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'subjectrx' command - Implements command_t. More...
 
static enum CommandResult parse_subscribe (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'subscribe' command - Implements command_t. More...
 
static enum CommandResult parse_subscribe_to (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'subscribe-to' command - Implements command_t. More...
 
static enum CommandResult parse_tag_formats (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'tag-formats' command - Implements command_t. More...
 
static enum CommandResult parse_tag_transforms (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'tag-transforms' command - Implements command_t. More...
 
static enum CommandResult parse_unalias (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unalias' command - Implements command_t. More...
 
static enum CommandResult parse_unalternates (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unalternates' command - Implements command_t. More...
 
static enum CommandResult parse_unattachments (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unattachments' command - Implements command_t. More...
 
static enum CommandResult parse_unignore (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unignore' command - Implements command_t. More...
 
static enum CommandResult parse_unlists (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unlists' command - Implements command_t. More...
 
static enum CommandResult parse_unmailboxes (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unmailboxes' command - Implements command_t. More...
 
static enum CommandResult parse_unmy_hdr (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unmy_hdr' command - Implements command_t. More...
 
static enum CommandResult parse_unstailq (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse an unlist command - Implements command_t. More...
 
static enum CommandResult parse_unsubjectrx_list (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unsubjectrx' command - Implements command_t. More...
 
static enum CommandResult parse_unsubscribe (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unsubscribe' command - Implements command_t. More...
 
static enum CommandResult parse_unsubscribe_from (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unsubscribe-from' command - Implements command_t. More...
 
const struct Commandmutt_command_get (const char *s)
 Get a Command by its name. More...
 
int mutt_dump_variables (bool hide_sensitive)
 Print a list of all variables with their values. More...
 
int mutt_extract_token (struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
 Extract one token from a string. More...
 
void mutt_free_attachmatch (struct AttachMatch **am)
 Free an AttachMatch - Implements list_free_t. More...
 
void mutt_free_opts (void)
 clean up before quitting More...
 
HookFlags mutt_get_hook_type (const char *name)
 Find a hook by name. More...
 
int mutt_init (bool skip_sys_rc, struct ListHead *commands)
 Initialise NeoMutt. 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...
 
enum QuadOption query_quadoption (enum QuadOption opt, const char *prompt)
 Ask the user a quad-question. More...
 
int mutt_command_complete (char *buf, size_t buflen, int pos, int numtabs)
 Complete a command name. More...
 
int mutt_label_complete (char *buf, size_t buflen, int numtabs)
 Complete a label name. 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...
 
int mutt_var_value_complete (char *buf, size_t buflen, int pos)
 Complete a variable/value. More...
 
struct ConfigSetinit_config (size_t size)
 Initialise the config system. More...
 
int charset_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Validate the "charset" config variable - Implements cs_validator() More...
 
int hcache_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Validate the "header_cache_backend" config variable - Implements cs_validator() More...
 
int pager_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Check for config variables that can't be set from the pager - Implements cs_validator() More...
 
int multipart_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Validate the "show_multipart_alternative" config variable - Implements cs_validator() More...
 
int reply_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Validate the "reply_regex" config variable - Implements cs_validator() More...
 

Variables

static struct ListHead MuttrcStack = STAILQ_HEAD_INITIALIZER(MuttrcStack)
 
static char UserTyped [1024] = { 0 }
 
static int NumMatched = 0
 
static char Completed [256] = { 0 }
 
static const char ** Matches
 
static int MatchesListsize = MAX(NUM_VARS, NUM_COMMANDS) + 10
 
static char ** nm_tags
 

Detailed Description

Config/command parsing.

Authors
  • Michael R. Elkins

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 init.c.

Macro Definition Documentation

#define MAX_ERRS   128

Definition at line 80 of file init.c.

#define NUM_VARS   mutt_array_size(MuttVars)

Definition at line 82 of file init.c.

#define NUM_COMMANDS   mutt_array_size(Commands)

Definition at line 83 of file init.c.

Enumeration Type Documentation

enum GroupState

Type of email address group.

Enumerator
GS_NONE 

Group is missing an argument.

GS_RX 

Entry is a regular expression.

GS_ADDR 

Entry is an address.

Definition at line 103 of file init.c.

104 {
105  GS_NONE,
106  GS_RX,
107  GS_ADDR,
108 };
Group is missing an argument.
Definition: init.c:105
Entry is an address.
Definition: init.c:107
Entry is a regular expression.
Definition: init.c:106

Function Documentation

static void add_to_stailq ( struct ListHead *  head,
const char *  str 
)
static

Add a string to a list.

Parameters
headString list
strString to add
Note
Duplicate or empty strings will not be added

Definition at line 117 of file init.c.

118 {
119  /* don't add a NULL or empty string to the list */
120  if (!str || (*str == '\0'))
121  return;
122 
123  /* check to make sure the item is not already on this list */
124  struct ListNode *np = NULL;
125  STAILQ_FOREACH(np, head, entries)
126  {
127  if (mutt_str_strcasecmp(str, np->data) == 0)
128  {
129  return;
130  }
131  }
133 }
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:61
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
char * data
Definition: list.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
A List node for strings.
Definition: list.h:33

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void alternates_clean ( void  )
static

Clear the recipient valid flag of all emails.

Definition at line 138 of file init.c.

139 {
140  if (!Context)
141  return;
142 
143  for (int i = 0; i < Context->mailbox->msg_count; i++)
144  Context->mailbox->emails[i]->recip_valid = false;
145 }
struct Email ** emails
Definition: mailbox.h:99
The "current" mailbox.
Definition: context.h:38
int msg_count
total number of messages
Definition: mailbox.h:92
struct Mailbox * mailbox
Definition: context.h:52
bool recip_valid
is_recipient is valid
Definition: email.h:58

+ Here is the caller graph for this function:

static void attachments_clean ( void  )
static

always wise to do what someone else did before

Definition at line 150 of file init.c.

151 {
152  if (!Context)
153  return;
154 
155  for (int i = 0; i < Context->mailbox->msg_count; i++)
156  Context->mailbox->emails[i]->attach_valid = false;
157 }
struct Email ** emails
Definition: mailbox.h:99
The "current" mailbox.
Definition: context.h:38
int msg_count
total number of messages
Definition: mailbox.h:92
struct Mailbox * mailbox
Definition: context.h:52
bool attach_valid
Definition: email.h:73

+ Here is the caller graph for this function:

static void matches_ensure_morespace ( int  current)
static

Allocate more space for auto-completion.

Parameters
currentCurrent allocation

Definition at line 163 of file init.c.

164 {
165  if (current <= (MatchesListsize - 2))
166  return;
167 
168  int base_space = MAX(NUM_VARS, NUM_COMMANDS) + 1;
169  int extra_space = MatchesListsize - base_space;
170  extra_space *= 2;
171  const int space = base_space + extra_space;
172  mutt_mem_realloc(&Matches, space * sizeof(char *));
173  memset(&Matches[current + 1], 0, space - current);
174  MatchesListsize = space;
175 }
#define MAX(a, b)
Definition: memory.h:30
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:121
static int MatchesListsize
Definition: init.c:93
#define NUM_VARS
Definition: init.c:82
static const char ** Matches
Definition: init.c:91
#define NUM_COMMANDS
Definition: init.c:83

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void candidate ( char *  try,
const char *  src,
char *  dest,
size_t  dlen 
)
static

helper function for completion

Parameters
tryUser entered data for completion
srcCandidate for completion
destCompletion result gets here
dlenLength of dest buffer

Changes the dest buffer if necessary/possible to aid completion.

Definition at line 186 of file init.c.

187 {
188  if (!dest || !try || !src)
189  return;
190 
191  if (strstr(src, try) != src)
192  return;
193 
195  Matches[NumMatched++] = src;
196  if (dest[0] == '\0')
197  mutt_str_strfcpy(dest, src, dlen);
198  else
199  {
200  int l;
201  for (l = 0; src[l] && src[l] == dest[l]; l++)
202  ;
203  dest[l] = '\0';
204  }
205 }
static int NumMatched
Definition: init.c:89
static void matches_ensure_morespace(int current)
Allocate more space for auto-completion.
Definition: init.c:163
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:753
static const char ** Matches
Definition: init.c:91

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void clear_subject_mods ( void  )
static

Clear out all modified email subjects.

Definition at line 210 of file init.c.

211 {
212  if (!Context)
213  return;
214 
215  for (int i = 0; i < Context->mailbox->msg_count; i++)
217 }
struct Email ** emails
Definition: mailbox.h:99
The "current" mailbox.
Definition: context.h:38
int msg_count
total number of messages
Definition: mailbox.h:92
char * disp_subj
display subject (modified copy of subject)
Definition: envelope.h:52
struct Mailbox * mailbox
Definition: context.h:52
struct Envelope * env
envelope information
Definition: email.h:92
#define FREE(x)
Definition: memory.h:40

+ Here is the caller graph for this function:

static int complete_all_nm_tags ( const char *  pt)
static

Pass a list of Notmuch tags to the completion code.

Parameters
ptList of all Notmuch tags
Return values
0Success
-1Error

Definition at line 226 of file init.c.

227 {
228  int tag_count_1 = 0;
229  int tag_count_2 = 0;
230 
231  NumMatched = 0;
232  mutt_str_strfcpy(UserTyped, pt, sizeof(UserTyped));
233  memset(Matches, 0, MatchesListsize);
234  memset(Completed, 0, sizeof(Completed));
235 
237 
238  /* Work out how many tags there are. */
239  if (nm_get_all_tags(Context->mailbox, NULL, &tag_count_1) || (tag_count_1 == 0))
240  goto done;
241 
242  /* Free the old list, if any. */
243  if (nm_tags)
244  {
245  for (int i = 0; nm_tags[i]; i++)
246  FREE(&nm_tags[i]);
247  FREE(&nm_tags);
248  }
249  /* Allocate a new list, with sentinel. */
250  nm_tags = mutt_mem_malloc((tag_count_1 + 1) * sizeof(char *));
251  nm_tags[tag_count_1] = NULL;
252 
253  /* Get all the tags. */
254  if (nm_get_all_tags(Context->mailbox, nm_tags, &tag_count_2) || (tag_count_1 != tag_count_2))
255  {
256  FREE(&nm_tags);
257  nm_tags = NULL;
259  return -1;
260  }
261 
262  /* Put them into the completion machinery. */
263  for (int num = 0; num < tag_count_1; num++)
264  {
265  candidate(UserTyped, nm_tags[num], Completed, sizeof(Completed));
266  }
267 
270 
271 done:
273  return 0;
274 }
The "current" mailbox.
Definition: context.h:38
static int NumMatched
Definition: init.c:89
static char ** nm_tags
Definition: init.c:97
static void candidate(char *try, const char *src, char *dest, size_t dlen)
helper function for completion
Definition: init.c:186
struct Mailbox * mailbox
Definition: context.h:52
static char Completed[256]
Definition: init.c:90
void nm_db_longrun_done(struct Mailbox *m)
Finish a long transaction.
Definition: nm_db.c:307
static int MatchesListsize
Definition: init.c:93
static void matches_ensure_morespace(int current)
Allocate more space for auto-completion.
Definition: init.c:163
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:97
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:753
int nm_get_all_tags(struct Mailbox *m, char **tag_list, int *tag_count)
Fill a list with all notmuch tags.
static char UserTyped[1024]
Definition: init.c:87
static const char ** Matches
Definition: init.c:91
#define FREE(x)
Definition: memory.h:40
void nm_db_longrun_init(struct Mailbox *m, bool writable)
Start a long transaction.
Definition: nm_db.c:292

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int execute_commands ( struct ListHead *  p)
static

Execute a set of NeoMutt commands.

Parameters
pList of command strings
Return values
0Success, all the commands succeeded
-1Error

Definition at line 283 of file init.c.

284 {
285  int rc = 0;
286  struct Buffer *err = mutt_buffer_pool_get();
287  struct Buffer *token = mutt_buffer_pool_get();
288 
289  struct ListNode *np = NULL;
290  STAILQ_FOREACH(np, p, entries)
291  {
292  if (mutt_parse_rc_line(np->data, token, err) == MUTT_CMD_ERROR)
293  {
294  mutt_error(_("Error in command line: %s"), mutt_b2s(err));
295  mutt_buffer_pool_release(&token);
297 
298  return -1;
299  }
300  }
301  mutt_buffer_pool_release(&token);
303 
304  return rc;
305 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
#define mutt_b2s(buf)
Definition: buffer.h:42
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
char * data
Definition: list.h:35
#define mutt_error(...)
Definition: logging.h:83
A List node for strings.
Definition: list.h:33
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: buffer.c:409
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: buffer.c:398
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3257

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static char* find_cfg ( const char *  home,
const char *  xdg_cfg_home 
)
static

Find a config file.

Parameters
homeUser's home directory
xdg_cfg_homeXDG home directory
Return values
ptrSuccess, first matching directory
NULLError, no matching directories

Definition at line 314 of file init.c.

315 {
316  const char *names[] = {
317  "neomuttrc",
318  "muttrc",
319  NULL,
320  };
321 
322  const char *locations[][2] = {
323  { xdg_cfg_home, "neomutt/" },
324  { xdg_cfg_home, "mutt/" },
325  { home, ".neomutt/" },
326  { home, ".mutt/" },
327  { home, "." },
328  { NULL, NULL },
329  };
330 
331  for (int i = 0; locations[i][0] || locations[i][1]; i++)
332  {
333  if (!locations[i][0])
334  continue;
335 
336  for (int j = 0; names[j]; j++)
337  {
338  char buf[256];
339 
340  snprintf(buf, sizeof(buf), "%s/%s%s", locations[i][0], locations[i][1], names[j]);
341  if (access(buf, F_OK) == 0)
342  return mutt_str_strdup(buf);
343  }
344  }
345 
346  return NULL;
347 }
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static char* getmailname ( void  )
static

Try to retrieve the FQDN from mailname files.

Return values
ptrHeap allocated string with the FQDN
NULLif no valid mailname file could be read

Definition at line 355 of file init.c.

356 {
357  char *mailname = NULL;
358  static const char *mn_files[] = { "/etc/mailname", "/etc/mail/mailname" };
359 
360  for (size_t i = 0; i < mutt_array_size(mn_files); i++)
361  {
362  FILE *fp = mutt_file_fopen(mn_files[i], "r");
363  if (!fp)
364  continue;
365 
366  size_t len = 0;
367  mailname = mutt_file_read_line(NULL, &len, fp, NULL, 0);
368  mutt_file_fclose(&fp);
369  if (mailname && *mailname)
370  break;
371 
372  FREE(&mailname);
373  }
374 
375  return mailname;
376 }
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:657
#define mutt_array_size(x)
Definition: memory.h:33
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
#define FREE(x)
Definition: memory.h:40
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:578

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool get_hostname ( void  )
static

Find the Fully-Qualified Domain Name.

Return values
trueSuccess
falseError, failed to find any name

Use several methods to try to find the Fully-Qualified domain name of this host. If the user has already configured a hostname, this function will use it.

Definition at line 387 of file init.c.

388 {
389  char *str = NULL;
390  struct utsname utsname;
391 
392  if (C_Hostname)
393  {
394  str = C_Hostname;
395  }
396  else
397  {
398  /* The call to uname() shouldn't fail, but if it does, the system is horribly
399  * broken, and the system's networking configuration is in an unreliable
400  * state. We should bail. */
401  if ((uname(&utsname)) == -1)
402  {
403  mutt_perror(_("unable to determine nodename via uname()"));
404  return false; // TEST09: can't test
405  }
406 
407  str = utsname.nodename;
408  }
409 
410  /* some systems report the FQDN instead of just the hostname */
411  char *dot = strchr(str, '.');
412  if (dot)
414  else
416 
417  if (!C_Hostname)
418  {
419  /* now get FQDN. Use configured domain first, DNS next, then uname */
420 #ifdef DOMAIN
421  /* we have a compile-time domain name, use that for C_Hostname */
422  C_Hostname =
424  sprintf((char *) C_Hostname, "%s.%s", NONULL(ShortHostname), DOMAIN);
425 #else
427  if (!C_Hostname)
428  {
429  char buffer[1024];
430  if (getdnsdomainname(buffer, sizeof(buffer)) == 0)
431  {
434  sprintf((char *) C_Hostname, "%s.%s", NONULL(ShortHostname), buffer);
435  }
436  else
437  {
438  /* DNS failed, use the nodename. Whether or not the nodename had a '.'
439  * in it, we can use the nodename as the FQDN. On hosts where DNS is
440  * not being used, e.g. small network that relies on hosts files, a
441  * short host name is all that is required for SMTP to work correctly.
442  * It could be wrong, but we've done the best we can, at this point the
443  * onus is on the user to provide the correct hostname if the nodename
444  * won't work in their network. */
445  C_Hostname = mutt_str_strdup(utsname.nodename);
446  }
447  }
448 #endif
449  }
450  if (C_Hostname)
451  cs_str_initial_set(Config, "hostname", C_Hostname, NULL);
452 
453  return true;
454 }
#define NONULL(x)
Definition: string2.h:36
#define mutt_perror(...)
Definition: logging.h:84
static char * getmailname(void)
Try to retrieve the FQDN from mailname files.
Definition: init.c:355
#define _(a)
Definition: message.h:28
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:39
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:669
int getdnsdomainname(char *buf, size_t buflen)
Lookup the host&#39;s name using DNS.
Definition: getdomain.c:44
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:500
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:97
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
WHERE char * ShortHostname
Short version of the hostname.
Definition: globals.h:49
WHERE char * C_Hostname
Config: Fully-qualified domain name of this machine.
Definition: globals.h:106
char * mutt_str_substr_dup(const char *begin, const char *end)
Duplicate a sub-string.
Definition: string.c:582

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static enum CommandResult parse_attach_list ( struct Buffer buf,
struct Buffer s,
struct ListHead *  head,
struct Buffer err 
)
static

Parse the "attachments" command.

Parameters
bufBuffer for temporary storage
sBuffer containing the attachments command
headList of AttachMatch to add to
errBuffer for error messages
Return values
CommandResultResult e.g. MUTT_CMD_SUCCESS

Definition at line 464 of file init.c.

466 {
467  struct AttachMatch *a = NULL;
468  char *p = NULL;
469  char *tmpminor = NULL;
470  size_t len;
471  int ret;
472 
473  do
474  {
476 
477  if (!buf->data || (*buf->data == '\0'))
478  continue;
479 
480  a = mutt_mem_malloc(sizeof(struct AttachMatch));
481 
482  /* some cheap hacks that I expect to remove */
483  if (mutt_str_strcasecmp(buf->data, "any") == 0)
484  a->major = mutt_str_strdup("*/.*");
485  else if (mutt_str_strcasecmp(buf->data, "none") == 0)
486  a->major = mutt_str_strdup("cheap_hack/this_should_never_match");
487  else
488  a->major = mutt_str_strdup(buf->data);
489 
490  p = strchr(a->major, '/');
491  if (p)
492  {
493  *p = '\0';
494  p++;
495  a->minor = p;
496  }
497  else
498  {
499  a->minor = "unknown";
500  }
501 
502  len = strlen(a->minor);
503  tmpminor = mutt_mem_malloc(len + 3);
504  strcpy(&tmpminor[1], a->minor);
505  tmpminor[0] = '^';
506  tmpminor[len + 1] = '$';
507  tmpminor[len + 2] = '\0';
508 
510  ret = REG_COMP(&a->minor_regex, tmpminor, REG_ICASE);
511 
512  FREE(&tmpminor);
513 
514  if (ret != 0)
515  {
516  regerror(ret, &a->minor_regex, err->data, err->dsize);
517  FREE(&a->major);
518  FREE(&a);
519  return MUTT_CMD_ERROR;
520  }
521 
522  mutt_debug(LL_DEBUG3, "added %s/%s [%d]\n", a->major, a->minor, a->major_int);
523 
524  mutt_list_insert_tail(head, (char *) a);
525  } while (MoreArgs(s));
526 
528  return MUTT_CMD_SUCCESS;
529 }
int major_int
Definition: mutt.h:131
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
size_t dsize
length of data
Definition: buffer.h:37
#define MoreArgs(buf)
Definition: buffer.h:44
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition: regex3.h:52
const char * major
Definition: mutt.h:130
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:61
static void attachments_clean(void)
always wise to do what someone else did before
Definition: init.c:150
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:97
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
regex_t minor_regex
Definition: mutt.h:133
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
int mutt_check_mime_type(const char *s)
Check a MIME type string.
Definition: parse.c:287
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:80
An attachment matching a regex.
Definition: mutt.h:128
const char * minor
Definition: mutt.h:132
Log at debug level 3.
Definition: logging.h:58
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int parse_grouplist ( struct GroupList *  ctx,
struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse a group context.

Parameters
ctxGroupList to add to
bufTemporary Buffer space
sBuffer containing string to be parsed
dataFlags associated with the command
errBuffer for error messages
Return values
0Success
-1Error

Definition at line 541 of file init.c.

543 {
544  while (mutt_str_strcasecmp(buf->data, "-group") == 0)
545  {
546  if (!MoreArgs(s))
547  {
548  mutt_buffer_strcpy(err, _("-group: no group name"));
549  goto bail;
550  }
551 
553 
555 
556  if (!MoreArgs(s))
557  {
558  mutt_buffer_strcpy(err, _("out of arguments"));
559  goto bail;
560  }
561 
563  }
564 
565  return 0;
566 
567 bail:
568  return -1;
569 }
#define _(a)
Definition: message.h:28
#define MoreArgs(buf)
Definition: buffer.h:44
void mutt_grouplist_add(struct GroupList *head, struct Group *group)
Add a Group to a GroupList.
Definition: group.c:134
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:322
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
struct Group * mutt_pattern_group(const char *pat)
Match a pattern to a Group.
Definition: group.c:64
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static enum CommandResult parse_replace_list ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse a string replacement rule - Implements command_t.

Definition at line 574 of file init.c.

576 {
577  struct ReplaceList *list = (struct ReplaceList *) data;
578  struct Buffer templ = { 0 };
579 
580  /* First token is a regex. */
581  if (!MoreArgs(s))
582  {
583  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
584  return MUTT_CMD_WARNING;
585  }
587 
588  /* Second token is a replacement template */
589  if (!MoreArgs(s))
590  {
591  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
592  return MUTT_CMD_WARNING;
593  }
595 
596  if (mutt_replacelist_add(list, buf->data, templ.data, err) != 0)
597  {
598  FREE(&templ.data);
599  return MUTT_CMD_ERROR;
600  }
601  FREE(&templ.data);
602 
603  return MUTT_CMD_SUCCESS;
604 }
int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, const char *templ, struct Buffer *err)
Add a pattern and a template to a list.
Definition: regex.c:263
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
#define FREE(x)
Definition: memory.h:40
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static enum CommandResult parse_unattach_list ( struct Buffer buf,
struct Buffer s,
struct ListHead *  head,
struct Buffer err 
)
static

Parse the "unattachments" command.

Parameters
bufBuffer for temporary storage
sBuffer containing the unattachments command
headList of AttachMatch to remove from
errBuffer for error messages
Return values
MUTT_CMD_SUCCESSAlways

Definition at line 614 of file init.c.

616 {
617  struct AttachMatch *a = NULL;
618  char *tmp = NULL;
619  char *minor = NULL;
620 
621  do
622  {
624  FREE(&tmp);
625 
626  if (mutt_str_strcasecmp(buf->data, "any") == 0)
627  tmp = mutt_str_strdup("*/.*");
628  else if (mutt_str_strcasecmp(buf->data, "none") == 0)
629  tmp = mutt_str_strdup("cheap_hack/this_should_never_match");
630  else
631  tmp = mutt_str_strdup(buf->data);
632 
633  minor = strchr(tmp, '/');
634  if (minor)
635  {
636  *minor = '\0';
637  minor++;
638  }
639  else
640  {
641  minor = "unknown";
642  }
643  const int major = mutt_check_mime_type(tmp);
644 
645  struct ListNode *np, *tmp2;
646  STAILQ_FOREACH_SAFE(np, head, entries, tmp2)
647  {
648  a = (struct AttachMatch *) np->data;
649  mutt_debug(LL_DEBUG3, "check %s/%s [%d] : %s/%s [%d]\n", a->major,
650  a->minor, a->major_int, tmp, minor, major);
651  if ((a->major_int == major) && (mutt_str_strcasecmp(minor, a->minor) == 0))
652  {
653  mutt_debug(LL_DEBUG3, "removed %s/%s [%d]\n", a->major, a->minor, a->major_int);
654  regfree(&a->minor_regex);
655  FREE(&a->major);
656  STAILQ_REMOVE(head, np, ListNode, entries);
657  FREE(&np->data);
658  FREE(&np);
659  }
660  }
661 
662  } while (MoreArgs(s));
663 
664  FREE(&tmp);
666  return MUTT_CMD_SUCCESS;
667 }
int major_int
Definition: mutt.h:131
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:400
#define MoreArgs(buf)
Definition: buffer.h:44
const char * major
Definition: mutt.h:130
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:360
static void attachments_clean(void)
always wise to do what someone else did before
Definition: init.c:150
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
char * data
Definition: list.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
regex_t minor_regex
Definition: mutt.h:133
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
int mutt_check_mime_type(const char *s)
Check a MIME type string.
Definition: parse.c:287
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:80
An attachment matching a regex.
Definition: mutt.h:128
A List node for strings.
Definition: list.h:33
const char * minor
Definition: mutt.h:132
Log at debug level 3.
Definition: logging.h:58
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static enum CommandResult parse_unreplace_list ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Remove a string replacement rule - Implements command_t.

Definition at line 672 of file init.c.

674 {
675  struct ReplaceList *list = (struct ReplaceList *) data;
676 
677  /* First token is a regex. */
678  if (!MoreArgs(s))
679  {
680  mutt_buffer_printf(err, _("%s: too few arguments"), "unsubjectrx");
681  return MUTT_CMD_WARNING;
682  }
683 
685 
686  /* "*" is a special case. */
687  if (mutt_str_strcmp(buf->data, "*") == 0)
688  {
689  mutt_replacelist_free(list);
690  return MUTT_CMD_SUCCESS;
691  }
692 
693  mutt_replacelist_remove(list, buf->data);
694  return MUTT_CMD_SUCCESS;
695 }
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:446
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
int mutt_replacelist_remove(struct ReplaceList *rl, const char *pat)
Remove a pattern from a list.
Definition: regex.c:563
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int print_attach_list ( struct ListHead *  h,
const char  op,
const char *  name 
)
static

Print a list of attachments.

Parameters
hList of attachments
opOperation, e.g. '+', '-'
nameAttached/Inline, 'A', 'I'
Return values
0Always

Definition at line 704 of file init.c.

705 {
706  struct ListNode *np = NULL;
707  STAILQ_FOREACH(np, h, entries)
708  {
709  printf("attachments %c%s %s/%s\n", op, name,
710  ((struct AttachMatch *) np->data)->major,
711  ((struct AttachMatch *) np->data)->minor);
712  }
713 
714  return 0;
715 }
const char * name
Definition: pgpmicalg.c:45
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
char * data
Definition: list.h:35
An attachment matching a regex.
Definition: mutt.h:128
A List node for strings.
Definition: list.h:33

+ Here is the caller graph for this function:

static void remove_from_stailq ( struct ListHead *  head,
const char *  str 
)
static

Remove an item, matching a string, from a List.

Parameters
headHead of the List
strString to match
Note
The string comparison is case-insensitive

Definition at line 724 of file init.c.

725 {
726  if (mutt_str_strcmp("*", str) == 0)
727  mutt_list_free(head); /* "unCMD *" means delete all current entries */
728  else
729  {
730  struct ListNode *np, *tmp;
731  STAILQ_FOREACH_SAFE(np, head, entries, tmp)
732  {
733  if (mutt_str_strcasecmp(str, np->data) == 0)
734  {
735  STAILQ_REMOVE(head, np, ListNode, entries);
736  FREE(&np->data);
737  FREE(&np);
738  break;
739  }
740  }
741  }
742 }
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:400
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:117
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:360
char * data
Definition: list.h:35
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
#define FREE(x)
Definition: memory.h:40
A List node for strings.
Definition: list.h:33
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int source_rc ( const char *  rcfile_path,
struct Buffer err 
)
static

Read an initialization file.

Parameters
rcfile_pathPath to initialization file
errBuffer for error messages
Return values
<0if neomutt should pause to let the user know

Definition at line 750 of file init.c.

751 {
752  int line = 0, rc = 0, warnings = 0;
753  enum CommandResult line_rc;
754  struct Buffer token;
755  char *linebuf = NULL;
756  char *currentline = NULL;
757  char rcfile[PATH_MAX];
758  size_t buflen;
759 
760  pid_t pid;
761 
762  mutt_str_strfcpy(rcfile, rcfile_path, sizeof(rcfile));
763 
764  size_t rcfilelen = mutt_str_strlen(rcfile);
765  if (rcfilelen == 0)
766  return -1;
767 
768  bool ispipe = rcfile[rcfilelen - 1] == '|';
769 
770  if (!ispipe)
771  {
772  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
773  if (!mutt_path_to_absolute(rcfile, np ? NONULL(np->data) : ""))
774  {
775  mutt_error(_("Error: Can't build path of '%s'"), rcfile_path);
776  return -1;
777  }
778 
779  STAILQ_FOREACH(np, &MuttrcStack, entries)
780  {
781  if (mutt_str_strcmp(np->data, rcfile) == 0)
782  {
783  break;
784  }
785  }
786  if (!np)
787  {
789  }
790  else
791  {
792  mutt_error(_("Error: Cyclic sourcing of configuration file '%s'"), rcfile);
793  return -1;
794  }
795  }
796 
797  mutt_debug(LL_DEBUG2, "Reading configuration file '%s'\n", rcfile);
798 
799  FILE *fp = mutt_open_read(rcfile, &pid);
800  if (!fp)
801  {
802  mutt_buffer_printf(err, "%s: %s", rcfile, strerror(errno));
803  return -1;
804  }
805 
806  mutt_buffer_init(&token);
807  while ((linebuf = mutt_file_read_line(linebuf, &buflen, fp, &line, MUTT_CONT)))
808  {
809  const int conv = C_ConfigCharset && (*C_ConfigCharset) && C_Charset;
810  if (conv)
811  {
812  currentline = mutt_str_strdup(linebuf);
813  if (!currentline)
814  continue;
815  mutt_ch_convert_string(&currentline, C_ConfigCharset, C_Charset, 0);
816  }
817  else
818  currentline = linebuf;
819  mutt_buffer_reset(err);
820  line_rc = mutt_parse_rc_line(currentline, &token, err);
821  if (line_rc == MUTT_CMD_ERROR)
822  {
823  mutt_error(_("Error in %s, line %d: %s"), rcfile, line, err->data);
824  if (--rc < -MAX_ERRS)
825  {
826  if (conv)
827  FREE(&currentline);
828  break;
829  }
830  }
831  else if (line_rc == MUTT_CMD_WARNING)
832  {
833  /* Warning */
834  mutt_warning(_("Warning in %s, line %d: %s"), rcfile, line, err->data);
835  warnings++;
836  }
837  else if (line_rc == MUTT_CMD_FINISH)
838  {
839  break; /* Found "finish" command */
840  }
841  else
842  {
843  if (rc < 0)
844  rc = -1;
845  }
846  if (conv)
847  FREE(&currentline);
848  }
849  FREE(&token.data);
850  FREE(&linebuf);
851  mutt_file_fclose(&fp);
852  if (pid != -1)
853  mutt_wait_filter(pid);
854  if (rc)
855  {
856  /* the neomuttrc source keyword */
857  mutt_buffer_reset(err);
858  mutt_buffer_printf(err, (rc >= -MAX_ERRS) ? _("source: errors in %s") : _("source: reading aborted due to too many errors in %s"),
859  rcfile);
860  rc = -1;
861  }
862  else
863  {
864  /* Don't alias errors with warnings */
865  if (warnings > 0)
866  {
867  mutt_buffer_printf(err, ngettext("source: %d warning in %s", "source: %d warnings in %s", warnings),
868  warnings, rcfile);
869  rc = -2;
870  }
871  }
872 
873  if (!ispipe && !STAILQ_EMPTY(&MuttrcStack))
874  {
875  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
876  STAILQ_REMOVE_HEAD(&MuttrcStack, entries);
877  FREE(&np->data);
878  FREE(&np);
879  }
880 
881  return rc;
882 }
#define mutt_warning(...)
Definition: logging.h:81
#define NONULL(x)
Definition: string2.h:36
int mutt_ch_convert_string(char **ps, const char *from, const char *to, int flags)
Convert a string between encodings.
Definition: charset.c:723
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:83
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:31
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
static struct ListHead MuttrcStack
Definition: init.c:78
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
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:657
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:669
#define STAILQ_REMOVE_HEAD(head, field)
Definition: queue.h:420
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MUTT_CONT
-continuation
Definition: file.h:37
#define MAX_ERRS
Definition: init.c:80
WHERE char * C_ConfigCharset
Config: Character set that the config files are in.
Definition: globals.h:99
Log at debug level 2.
Definition: logging.h:57
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
const char * line
Definition: common.c:35
#define PATH_MAX
Definition: mutt.h:49
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:753
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
Definition: path.c:430
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition: list.c:44
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
char * data
Definition: list.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
Finish: Stop processing this file.
Definition: mutt_commands.h:36
#define mutt_error(...)
Definition: logging.h:83
#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
#define mutt_debug(LEVEL,...)
Definition: logging.h:80
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:68
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:227
A List node for strings.
Definition: list.h:33
FILE * mutt_open_read(const char *path, pid_t *thepid)
Run a command to read from.
Definition: muttlib.c:1359
#define STAILQ_FIRST(head)
Definition: queue.h:348
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3257

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static enum CommandResult parse_alias ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'alias' command - Implements command_t.

Definition at line 887 of file init.c.

889 {
890  struct Alias *tmp = NULL;
891  char *estr = NULL;
892  struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
893 
894  if (!MoreArgs(s))
895  {
896  mutt_buffer_strcpy(err, _("alias: no address"));
897  return MUTT_CMD_WARNING;
898  }
899 
901 
902  if (parse_grouplist(&gc, buf, s, data, err) == -1)
903  return MUTT_CMD_ERROR;
904 
905  /* check to see if an alias with this name already exists */
906  TAILQ_FOREACH(tmp, &Aliases, entries)
907  {
908  if (mutt_str_strcasecmp(tmp->name, buf->data) == 0)
909  break;
910  }
911 
912  if (!tmp)
913  {
914  /* create a new alias */
915  tmp = mutt_mem_calloc(1, sizeof(struct Alias));
916  tmp->name = mutt_str_strdup(buf->data);
917  TAILQ_INSERT_TAIL(&Aliases, tmp, entries);
918  /* give the main addressbook code a chance */
919  if (CurrentMenu == MENU_ALIAS)
920  OptMenuCaller = true;
921  }
922  else
923  {
925  /* override the previous value */
926  mutt_addr_free(&tmp->addr);
927  if (CurrentMenu == MENU_ALIAS)
929  }
930 
932  mutt_debug(5, "Second token is '%s'\n", buf->data);
933 
934  tmp->addr = mutt_addr_parse_list2(tmp->addr, buf->data);
935 
936  if (mutt_addrlist_to_intl(tmp->addr, &estr))
937  {
938  mutt_buffer_printf(err, _("Warning: Bad IDN '%s' in alias '%s'"), estr, tmp->name);
939  FREE(&estr);
940  goto bail;
941  }
942 
945 
946  if (C_DebugLevel > LL_DEBUG4)
947  {
948  /* A group is terminated with an empty address, so check a->mailbox */
949  for (struct Address *a = tmp->addr; a && a->mailbox; a = a->next)
950  {
951  if (a->group)
952  mutt_debug(5, " Group %s\n", a->mailbox);
953  else
954  mutt_debug(5, " %s\n", a->mailbox);
955  }
956  }
958  return MUTT_CMD_SUCCESS;
959 
960 bail:
962  return MUTT_CMD_ERROR;
963 }
void mutt_alias_delete_reverse(struct Alias *t)
Remove an email address lookup for an Alias.
Definition: alias.c:571
A shortcut for an email address.
Definition: alias.h:36
Log at debug level 4.
Definition: logging.h:59
char * name
Definition: alias.h:38
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
struct Address * mutt_addr_parse_list2(struct Address *p, const char *s)
Parse a list of email addresses.
Definition: address.c:641
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
void mutt_grouplist_add_addrlist(struct GroupList *head, struct Address *a)
Add Address list to a GroupList.
Definition: group.c:238
WHERE bool OptMenuCaller
(pseudo) tell menu to give caller a take
Definition: options.h:37
#define _(a)
Definition: message.h:28
An email address.
Definition: address.h:32
char * mailbox
mailbox and host address
Definition: address.h:35
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MoreArgs(buf)
Definition: buffer.h:44
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:79
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:322
short C_DebugLevel
Config: Logging level for debug logs.
Definition: mutt_logging.c:48
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:78
int mutt_addrlist_to_intl(struct Address *a, char **err)
Convert an Address list to Punycode.
Definition: address.c:1249
char * data
pointer to data
Definition: buffer.h:35
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:803
Select an email address by its alias.
Definition: keymap.h:70
#define MUTT_TOKEN_SEMICOLON
Don&#39;t treat ; as special.
Definition: mutt.h:82
Success: Command worked.
Definition: mutt_commands.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
void mutt_alias_add_reverse(struct Alias *t)
Add an email address lookup for an Alias.
Definition: alias.c:550
#define FREE(x)
Definition: memory.h:40
struct Address * addr
Definition: alias.h:39
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
void mutt_addr_free(struct Address **p)
Free a list of Addresses.
Definition: address.c:451
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:86
#define mutt_debug(LEVEL,...)
Definition: logging.h:80
static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:541
void mutt_grouplist_destroy(struct GroupList *head)
Free a GroupList.
Definition: group.c:154
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_alternates ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'alternates' command - Implements command_t.

Definition at line 968 of file init.c.

970 {
971  struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
972 
974 
975  do
976  {
978 
979  if (parse_grouplist(&gc, buf, s, data, err) == -1)
980  goto bail;
981 
982  mutt_regexlist_remove(&UnAlternates, buf->data);
983 
984  if (mutt_regexlist_add(&Alternates, buf->data, REG_ICASE, err) != 0)
985  goto bail;
986 
987  if (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0)
988  goto bail;
989  } while (MoreArgs(s));
990 
992  return MUTT_CMD_SUCCESS;
993 
994 bail:
996  return MUTT_CMD_ERROR;
997 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:227
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
static void alternates_clean(void)
Clear the recipient valid flag of all emails.
Definition: init.c:138
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:285
static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:541
void mutt_grouplist_destroy(struct GroupList *head)
Free a GroupList.
Definition: group.c:154
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_attachments ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'attachments' command - Implements command_t.

Definition at line 1002 of file init.c.

1004 {
1005  char op, *category = NULL;
1006  struct ListHead *head = NULL;
1007 
1009  if (!buf->data || (*buf->data == '\0'))
1010  {
1011  mutt_buffer_strcpy(err, _("attachments: no disposition"));
1012  return MUTT_CMD_WARNING;
1013  }
1014 
1015  category = buf->data;
1016  op = *category++;
1017 
1018  if (op == '?')
1019  {
1020  mutt_endwin();
1021  fflush(stdout);
1022  printf("\n%s\n\n", _("Current attachments settings:"));
1023  print_attach_list(&AttachAllow, '+', "A");
1024  print_attach_list(&AttachExclude, '-', "A");
1025  print_attach_list(&InlineAllow, '+', "I");
1026  print_attach_list(&InlineExclude, '-', "I");
1028  return MUTT_CMD_SUCCESS;
1029  }
1030 
1031  if ((op != '+') && (op != '-'))
1032  {
1033  op = '+';
1034  category--;
1035  }
1036  if (mutt_str_startswith("attachment", category, CASE_IGNORE))
1037  {
1038  if (op == '+')
1039  head = &AttachAllow;
1040  else
1041  head = &AttachExclude;
1042  }
1043  else if (mutt_str_startswith("inline", category, CASE_IGNORE))
1044  {
1045  if (op == '+')
1046  head = &InlineAllow;
1047  else
1048  head = &InlineExclude;
1049  }
1050  else
1051  {
1052  mutt_buffer_strcpy(err, _("attachments: invalid disposition"));
1053  return MUTT_CMD_ERROR;
1054  }
1055 
1056  return parse_attach_list(buf, s, head, err);
1057 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define _(a)
Definition: message.h:28
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:322
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Ignore case when comparing strings.
Definition: string2.h:67
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 mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:532
Success: Command worked.
Definition: mutt_commands.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
static enum CommandResult parse_attach_list(struct Buffer *buf, struct Buffer *s, struct ListHead *head, struct Buffer *err)
Parse the "attachments" command.
Definition: init.c:464
static int print_attach_list(struct ListHead *h, const char op, const char *name)
Print a list of attachments.
Definition: init.c:704
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_echo ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'echo' command - Implements command_t.

Definition at line 1062 of file init.c.

1064 {
1065  if (!MoreArgs(s))
1066  {
1067  mutt_buffer_printf(err, _("%s: too few arguments"), "echo");
1068  return MUTT_CMD_WARNING;
1069  }
1071  OptForceRefresh = true;
1072  mutt_message("%s", buf->data);
1073  OptForceRefresh = false;
1074  mutt_sleep(0);
1075 
1076  return MUTT_CMD_SUCCESS;
1077 }
#define mutt_message(...)
Definition: logging.h:82
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MoreArgs(buf)
Definition: buffer.h:44
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1498
WHERE bool OptForceRefresh
(pseudo) refresh even during macros
Definition: options.h:34
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_finish ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'finish' command - Implements command_t.

Return values
MUTT_CMD_FINISHStop processing the current file
MUTT_CMD_WARNINGFailed

If the 'finish' command is found, we should stop reading the current file.

Definition at line 1086 of file init.c.

1088 {
1089  if (MoreArgs(s))
1090  {
1091  mutt_buffer_printf(err, _("%s: too many arguments"), "finish");
1092  return MUTT_CMD_WARNING;
1093  }
1094 
1095  return MUTT_CMD_FINISH;
1096 }
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MoreArgs(buf)
Definition: buffer.h:44
Warning: Help given to the user.
Definition: mutt_commands.h:34
Finish: Stop processing this file.
Definition: mutt_commands.h:36

+ Here is the call graph for this function:

static enum CommandResult parse_group ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'group' and 'ungroup' commands - Implements command_t.

Definition at line 1101 of file init.c.

1103 {
1104  struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
1105  enum GroupState state = GS_NONE;
1106  struct Address *addr = NULL;
1107 
1108  do
1109  {
1111  if (parse_grouplist(&gc, buf, s, data, err) == -1)
1112  goto bail;
1113 
1114  if ((data == MUTT_UNGROUP) && (mutt_str_strcasecmp(buf->data, "*") == 0))
1115  {
1116  mutt_grouplist_clear(&gc);
1117  goto out;
1118  }
1119 
1120  if (mutt_str_strcasecmp(buf->data, "-rx") == 0)
1121  state = GS_RX;
1122  else if (mutt_str_strcasecmp(buf->data, "-addr") == 0)
1123  state = GS_ADDR;
1124  else
1125  {
1126  switch (state)
1127  {
1128  case GS_NONE:
1129  mutt_buffer_printf(err, _("%sgroup: missing -rx or -addr"),
1130  (data == MUTT_UNGROUP) ? "un" : "");
1131  goto warn;
1132 
1133  case GS_RX:
1134  if ((data == MUTT_GROUP) &&
1135  (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0))
1136  {
1137  goto bail;
1138  }
1139  else if ((data == MUTT_UNGROUP) &&
1140  (mutt_grouplist_remove_regex(&gc, buf->data) < 0))
1141  {
1142  goto bail;
1143  }
1144  break;
1145 
1146  case GS_ADDR:
1147  {
1148  char *estr = NULL;
1149  addr = mutt_addr_parse_list2(NULL, buf->data);
1150  if (!addr)
1151  goto bail;
1152  if (mutt_addrlist_to_intl(addr, &estr))
1153  {
1154  mutt_buffer_printf(err, _("%sgroup: warning: bad IDN '%s'"),
1155  (data == 1) ? "un" : "", estr);
1156  mutt_addr_free(&addr);
1157  FREE(&estr);
1158  goto bail;
1159  }
1160  if (data == MUTT_GROUP)
1161  mutt_grouplist_add_addrlist(&gc, addr);
1162  else if (data == MUTT_UNGROUP)
1163  mutt_grouplist_remove_addrlist(&gc, addr);
1164  mutt_addr_free(&addr);
1165  break;
1166  }
1167  }
1168  }
1169  } while (MoreArgs(s));
1170 
1171 out:
1173  return MUTT_CMD_SUCCESS;
1174 
1175 bail:
1177  return MUTT_CMD_ERROR;
1178 
1179 warn:
1181  return MUTT_CMD_WARNING;
1182 }
int mutt_grouplist_remove_regex(struct GroupList *head, const char *s)
Remove matching addresses from a GroupList.
Definition: group.c:310
struct Address * mutt_addr_parse_list2(struct Address *p, const char *s)
Parse a list of email addresses.
Definition: address.c:641
#define MUTT_UNGROUP
Definition: group.h:33
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
void mutt_grouplist_add_addrlist(struct GroupList *head, struct Address *a)
Add Address list to a GroupList.
Definition: group.c:238
void mutt_grouplist_clear(struct GroupList *head)
Clear a GroupList.
Definition: group.c:101
#define _(a)
Definition: message.h:28
An email address.
Definition: address.h:32
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
int mutt_addrlist_to_intl(struct Address *a, char **err)
Convert an Address list to Punycode.
Definition: address.c:1249
char * data
pointer to data
Definition: buffer.h:35
Group is missing an argument.
Definition: init.c:105
int mutt_grouplist_remove_addrlist(struct GroupList *head, struct Address *a)
Remove Address from a GroupList.
Definition: group.c:257
Success: Command worked.
Definition: mutt_commands.h:35
GroupState
Type of email address group.
Definition: init.c:103
Warning: Help given to the user.
Definition: mutt_commands.h:34
Entry is an address.
Definition: init.c:107
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
#define FREE(x)
Definition: memory.h:40
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
void mutt_addr_free(struct Address **p)
Free a list of Addresses.
Definition: address.c:451
Entry is a regular expression.
Definition: init.c:106
int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:285
static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:541
void mutt_grouplist_destroy(struct GroupList *head)
Free a GroupList.
Definition: group.c:154
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75
#define MUTT_GROUP
Definition: group.h:32

+ Here is the call graph for this function:

static bool is_function ( const char *  name)
static

Is the argument a neomutt function?

Parameters
nameCommand name to be searched for
Return values
trueFunction found
falseFunction not found

Definition at line 1190 of file init.c.

1191 {
1192  for (int i = 0; i < MENU_MAX; i++)
1193  {
1194  const struct Binding *b = km_get_table(Menus[i].value);
1195  if (!b)
1196  continue;
1197 
1198  for (int j = 0; b[j].name; j++)
1199  if (mutt_str_strcmp(name, b[j].name) == 0)
1200  return true;
1201  }
1202  return false;
1203 }
const char * name
Definition: pgpmicalg.c:45
const char * name
name of the function
Definition: keymap.h:104
const struct Mapping Menus[]
Menu name lookup table.
Definition: keymap.c:60
const struct Binding * km_get_table(int menu)
Lookup a menu&#39;s keybindings.
Definition: keymap.c:1204
Mapping between a user key and a function.
Definition: keymap.h:102
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static enum CommandResult parse_ifdef ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'ifdef' and 'ifndef' commands - Implements command_t.

The 'ifdef' command allows conditional elements in the config file. If a given variable, function, command or compile-time symbol exists, then read the rest of the line of config commands. e.g. ifdef sidebar source ~/.neomutt/sidebar.rc

If (data == 1) then it means use the 'ifndef' (if-not-defined) command. e.g. ifndef imap finish

Definition at line 1218 of file init.c.

1220 {
1221  struct Buffer token = { 0 };
1222 
1224 
1225  // is the item defined as:
1226  bool res = cs_get_elem(Config, buf->data) // a variable?
1227  || feature_enabled(buf->data) // a compiled-in feature?
1228  || is_function(buf->data) // a function?
1229  || mutt_command_get(buf->data) // a command?
1230  || myvar_get(buf->data) // a my_ variable?
1231  || mutt_str_getenv(buf->data); // an environment variable?
1232 
1233  if (!MoreArgs(s))
1234  {
1235  mutt_buffer_printf(err, _("%s: too few arguments"), (data ? "ifndef" : "ifdef"));
1236  return MUTT_CMD_WARNING;
1237  }
1239 
1240  /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
1241  if ((res && (data == 0)) || (!res && (data == 1)))
1242  {
1243  enum CommandResult rc = mutt_parse_rc_line(buf->data, &token, err);
1244  if (rc == MUTT_CMD_ERROR)
1245  {
1246  mutt_error(_("Error: %s"), err->data);
1247  FREE(&token.data);
1248  return MUTT_CMD_ERROR;
1249  }
1250  FREE(&token.data);
1251  return rc;
1252  }
1253  return MUTT_CMD_SUCCESS;
1254 }
static bool is_function(const char *name)
Is the argument a neomutt function?
Definition: init.c:1190
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:31
bool feature_enabled(const char *name)
Test if a compile-time feature is enabled.
Definition: version.c:472
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:39
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
const struct Command * mutt_command_get(const char *s)
Get a Command by its name.
Definition: init.c:2585
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1086
#define MoreArgs(buf)
Definition: buffer.h:44
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
Definition: set.c:188
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:78
char * data
pointer to data
Definition: buffer.h:35
const char * myvar_get(const char *var)
Get the value of a "my_" variable.
Definition: myvar.c:42
Success: Command worked.
Definition: mutt_commands.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
#define mutt_error(...)
Definition: logging.h:83
#define FREE(x)
Definition: memory.h:40
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3257
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_ignore ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'ignore' command - Implements command_t.

Definition at line 1259 of file init.c.

1261 {
1262  do
1263  {
1266  add_to_stailq(&Ignore, buf->data);
1267  } while (MoreArgs(s));
1268 
1269  return MUTT_CMD_SUCCESS;
1270 }
static void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: init.c:724
struct ListHead UnIgnore
List of header patterns to unignore (see)
Definition: email_globals.c:46
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
struct ListHead Ignore
List of header patterns to ignore.
Definition: email_globals.c:45
static void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: init.c:117
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_lists ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'lists' command - Implements command_t.

Definition at line 1275 of file init.c.

1277 {
1278  struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
1279 
1280  do
1281  {
1283 
1284  if (parse_grouplist(&gc, buf, s, data, err) == -1)
1285  goto bail;
1286 
1288 
1289  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
1290  goto bail;
1291 
1292  if (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0)
1293  goto bail;
1294  } while (MoreArgs(s));
1295 
1297  return MUTT_CMD_SUCCESS;
1298 
1299 bail:
1301  return MUTT_CMD_ERROR;
1302 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:227
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: email_globals.c:50
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: email_globals.c:51
int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:285
static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:541
void mutt_grouplist_destroy(struct GroupList *head)
Free a GroupList.
Definition: group.c:154
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_mailboxes ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'mailboxes' command - Implements command_t.

This is also used by 'virtual-mailboxes'.

Definition at line 1309 of file init.c.

1311 {
1312  while (MoreArgs(s))
1313  {
1314  struct Mailbox *m = mailbox_new();
1315 
1316  if (data & MUTT_NAMED)
1317  {
1319  if (buf->data && (*buf->data != '\0'))
1320  {
1321  m->desc = mutt_str_strdup(buf->data);
1322  }
1323  else
1324  {
1325  mailbox_free(&m);
1326  continue;
1327  }
1328  }
1329 
1331  if (mutt_buffer_is_empty(buf))
1332  {
1333  /* Skip empty tokens. */
1334  mailbox_free(&m);
1335  continue;
1336  }
1337 
1338  mutt_buffer_strcpy(m->pathbuf, buf->data);
1339  /* int rc = */ mx_path_canon2(m, C_Folder);
1340 
1341  bool new_account = false;
1342  struct Account *a = mx_ac_find(m);
1343  if (!a)
1344  {
1345  a = account_new();
1346  a->magic = m->magic;
1347  new_account = true;
1348  }
1349 
1350  if (!new_account)
1351  {
1352  struct Mailbox *old_m = mx_mbox_find(a, m->realpath);
1353  if (old_m)
1354  {
1355  if (old_m->flags == MB_HIDDEN)
1356  {
1357  old_m->flags = MB_NORMAL;
1358  mutt_sb_notify_mailbox(old_m, true);
1359  struct MailboxNode *mn = mutt_mem_calloc(1, sizeof(*mn));
1360  mn->mailbox = old_m;
1361  STAILQ_INSERT_TAIL(&AllMailboxes, mn, entries);
1362  }
1363  mailbox_free(&m);
1364  continue;
1365  }
1366  }
1367 
1368  if (mx_ac_add(a, m) < 0)
1369  {
1370  //error
1371  mailbox_free(&m);
1372  if (new_account)
1373  {
1374  FREE(&a);
1375  }
1376  continue;
1377  }
1378  if (new_account)
1379  {
1380  TAILQ_INSERT_TAIL(&AllAccounts, a, entries);
1381  }
1382 
1383  struct MailboxNode *mn = mutt_mem_calloc(1, sizeof(*mn));
1384  mn->mailbox = m;
1385  STAILQ_INSERT_TAIL(&AllMailboxes, mn, entries);
1386 
1387 #ifdef USE_SIDEBAR
1388  mutt_sb_notify_mailbox(m, true);
1389 #endif
1390 #ifdef USE_INOTIFY
1391  mutt_monitor_add(m);
1392 #endif
1393  }
1394  return MUTT_CMD_SUCCESS;
1395 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
int mx_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Wrapper for MxOps::ac_add.
Definition: mx.c:1551
int mx_path_canon2(struct Mailbox *m, const char *folder)
XXX canonicalise the path to realpath.
Definition: mx.c:1385
char * desc
Definition: mailbox.h:87
char * realpath
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:86
XXX.
Definition: account.h:36
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
XXX.
Definition: mx.c:1488
#define STAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:387
int mutt_monitor_add(struct Mailbox *m)
Add a watch for a mailbox.
Definition: monitor.c:461
struct Account * mx_ac_find(struct Mailbox *m)
XXX.
Definition: mx.c:1465
#define MoreArgs(buf)
Definition: buffer.h:44
struct AccountList AllAccounts
List of all Accounts.
Definition: account.c:33
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:105
enum MailboxType magic
mailbox type
Definition: mailbox.h:105
int flags
e.g.
Definition: mailbox.h:134
#define MB_HIDDEN
Definition: mailbox.h:47
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:322
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
Definition: globals.h:114
A mailbox.
Definition: mailbox.h:83
enum MailboxType magic
Definition: account.h:38
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
#define MUTT_NAMED
Definition: init.h:107
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:803
struct MailboxList AllMailboxes
List of all Mailboxes.
Definition: mailbox.c:86
struct Buffer * pathbuf
Definition: mailbox.h:85
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition: mailbox.c:92
Success: Command worked.
Definition: mutt_commands.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define FREE(x)
Definition: memory.h:40
List of Mailboxes.
Definition: mailbox.h:146
struct Account * account_new(void)
Create a new Account.
Definition: account.c:39
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:291
#define MB_NORMAL
Definition: mailbox.h:46
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75
struct Mailbox * mailbox
Definition: mailbox.h:148

+ Here is the call graph for this function:

static enum CommandResult parse_my_hdr ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'my_hdr' command - Implements command_t.

Definition at line 1400 of file init.c.

1402 {
1403  struct ListNode *n = NULL;
1404  size_t keylen;
1405 
1407  char *p = strpbrk(buf->data, ": \t");
1408  if (!p || (*p != ':'))
1409  {
1410  mutt_buffer_strcpy(err, _("invalid header field"));
1411  return MUTT_CMD_WARNING;
1412  }
1413  keylen = p - buf->data + 1;
1414 
1415  STAILQ_FOREACH(n, &UserHeader, entries)
1416  {
1417  /* see if there is already a field by this name */
1418  if (mutt_str_strncasecmp(buf->data, n->data, keylen) == 0)
1419  {
1420  break;
1421  }
1422  }
1423 
1424  if (!n)
1425  {
1426  /* not found, allocate memory for a new node and add it to the list */
1427  n = mutt_list_insert_tail(&UserHeader, NULL);
1428  }
1429  else
1430  {
1431  /* found, free the existing data */
1432  FREE(&n->data);
1433  }
1434 
1435  n->data = buf->data;
1436  mutt_buffer_init(buf);
1437 
1438  return MUTT_CMD_SUCCESS;
1439 }
#define _(a)
Definition: message.h:28
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:61
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:79
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:322
int mutt_str_strncasecmp(const char *a, const char *b, size_t l)
Compare two strings ignoring case (to a maximum), safely.
Definition: string.c:659
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:78
char * data
pointer to data
Definition: buffer.h:35
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
Success: Command worked.
Definition: mutt_commands.h:35
char * data
Definition: list.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:68
A List node for strings.
Definition: list.h:33

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static enum CommandResult parse_path_list ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'sidebar_whitelist' command - Implements command_t.

Definition at line 1445 of file init.c.

1447 {
1448  char path[PATH_MAX];
1449 
1450  do
1451  {
1453  mutt_str_strfcpy(path, buf->data, sizeof(path));
1454  mutt_expand_path(path, sizeof(path));
1455  add_to_stailq((struct ListHead *) data, path);
1456  } while (MoreArgs(s));
1457 
1458  return MUTT_CMD_SUCCESS;
1459 }
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:127
#define MoreArgs(buf)
Definition: buffer.h:44
#define PATH_MAX
Definition: mutt.h:49
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
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:753
Success: Command worked.
Definition: mutt_commands.h:35
char * data
Definition: list.h:35
static void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: init.c:117
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_path_unlist ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unsidebar_whitelist' command - Implements command_t.

Definition at line 1466 of file init.c.

1468 {
1469  char path[PATH_MAX];
1470 
1471  do
1472  {
1474  /* Check for deletion of entire list */
1475  if (mutt_str_strcmp(buf->data, "*") == 0)
1476  {
1477  mutt_list_free((struct ListHead *) data);
1478  break;
1479  }
1480  mutt_str_strfcpy(path, buf->data, sizeof(path));
1481  mutt_expand_path(path, sizeof(path));
1482  remove_from_stailq((struct ListHead *) data, path);
1483  } while (MoreArgs(s));
1484 
1485  return MUTT_CMD_SUCCESS;
1486 }
static void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: init.c:724
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:117
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:127
#define MoreArgs(buf)
Definition: buffer.h:44
#define PATH_MAX
Definition: mutt.h:49
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
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:753
Success: Command worked.
Definition: mutt_commands.h:35
char * data
Definition: list.h:35
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_set ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'set' family of commands - Implements command_t.

This is used by 'reset', 'set', 'toggle' and 'unset'.

Definition at line 1494 of file init.c.

1496 {
1497  /* The order must match `enum MuttSetCommand` */
1498  static const char *set_commands[] = { "set", "toggle", "unset", "reset" };
1499 
1500  int rc = 0;
1501 
1502  while (MoreArgs(s))
1503  {
1504  bool prefix = false;
1505  bool query = false;
1506  bool inv = (data == MUTT_SET_INV);
1507  bool reset = (data == MUTT_SET_RESET);
1508  bool unset = (data == MUTT_SET_UNSET);
1509 
1510  if (*s->dptr == '?')
1511  {
1512  prefix = true;
1513  query = true;
1514  s->dptr++;
1515  }
1516  else if (mutt_str_startswith(s->dptr, "no", CASE_MATCH))
1517  {
1518  prefix = true;
1519  unset = !unset;
1520  s->dptr += 2;
1521  }
1522  else if (mutt_str_startswith(s->dptr, "inv", CASE_MATCH))
1523  {
1524  prefix = true;
1525  inv = !inv;
1526  s->dptr += 3;
1527  }
1528  else if (*s->dptr == '&')
1529  {
1530  prefix = true;
1531  reset = true;
1532  s->dptr++;
1533  }
1534 
1535  if (prefix && (data != MUTT_SET_SET))
1536  {
1537  mutt_buffer_printf(err, "ERR22 can't use 'inv', 'no', '&' or '?' with the '%s' command",
1538  set_commands[data]);
1539  return MUTT_CMD_WARNING;
1540  }
1541 
1542  /* get the variable name */
1544 
1545  bool bq = false;
1546  bool equals = false;
1547 
1548  struct HashElem *he = NULL;
1549  bool my = mutt_str_startswith(buf->data, "my_", CASE_MATCH);
1550  if (!my)
1551  {
1552  he = cs_get_elem(Config, buf->data);
1553  if (!he)
1554  {
1555  if (reset && (mutt_str_strcmp(buf->data, "all") == 0))
1556  {
1557  struct HashElem **list = get_elem_list(Config);
1558  if (!list)
1559  return MUTT_CMD_ERROR;
1560 
1561  for (size_t i = 0; list[i]; i++)
1562  cs_he_reset(Config, list[i], NULL);
1563 
1564  FREE(&list);
1565  break;
1566  }
1567  else
1568  {
1569  mutt_buffer_printf(err, "ERR01 unknown variable: %s", buf->data);
1570  return MUTT_CMD_ERROR;
1571  }
1572  }
1573 
1574  bq = ((DTYPE(he->type) == DT_BOOL) || (DTYPE(he->type) == DT_QUAD));
1575  }
1576 
1577  if (*s->dptr == '?')
1578  {
1579  if (prefix)
1580  {
1581  mutt_buffer_printf(err,
1582  "ERR02 can't use a prefix when querying a variable");
1583  return MUTT_CMD_WARNING;
1584  }
1585 
1586  if (reset || unset || inv)
1587  {
1588  mutt_buffer_printf(err, "ERR03 can't query a variable with the '%s' command",
1589  set_commands[data]);
1590  return MUTT_CMD_WARNING;
1591  }
1592 
1593  query = true;
1594  s->dptr++;
1595  }
1596  else if (*s->dptr == '=')
1597  {
1598  if (prefix)
1599  {
1600  mutt_buffer_printf(err,
1601  "ERR04 can't use prefix when setting a variable");
1602  return MUTT_CMD_WARNING;
1603  }
1604 
1605  if (reset || unset || inv)
1606  {
1607  mutt_buffer_printf(err, "ERR05 can't set a variable with the '%s' command",
1608  set_commands[data]);
1609  return MUTT_CMD_WARNING;
1610  }
1611 
1612  equals = true;
1613  s->dptr++;
1614  }
1615 
1616  if (!bq && (inv || (unset && prefix)))
1617  {
1618  if (data == MUTT_SET_SET)
1619  {
1620  mutt_buffer_printf(err, "ERR06 prefixes 'no' and 'inv' may only be "
1621  "used with bool/quad variables");
1622  }
1623  else
1624  {
1625  mutt_buffer_printf(err, "ERR07 command '%s' can only be used with bool/quad variables",
1626  set_commands[data]);
1627  }
1628  return MUTT_CMD_WARNING;
1629  }
1630 
1631  if (reset)
1632  {
1633  // mutt_buffer_printf(err, "ACT24 reset variable %s", buf->data);
1634  if (he)
1635  {
1636  rc = cs_he_reset(Config, he, err);
1637  if (CSR_RESULT(rc) != CSR_SUCCESS)
1638  return MUTT_CMD_ERROR;
1639  }
1640  else
1641  {
1642  myvar_del(buf->data);
1643  }
1644  continue;
1645  }
1646 
1647  if ((data == MUTT_SET_SET) && !inv && !unset)
1648  {
1649  if (query)
1650  {
1651  // mutt_buffer_printf(err, "ACT08 query variable %s", buf->data);
1652  if (he)
1653  {
1654  mutt_buffer_addstr(err, buf->data);
1655  mutt_buffer_addch(err, '=');
1656  mutt_buffer_reset(buf);
1657  rc = cs_he_string_get(Config, he, buf);
1658  if (CSR_RESULT(rc) != CSR_SUCCESS)
1659  {
1660  mutt_buffer_addstr(err, buf->data);
1661  return MUTT_CMD_ERROR;
1662  }
1663  pretty_var(buf->data, err);
1664  }
1665  else
1666  {
1667  const char *val = myvar_get(buf->data);
1668  if (val)
1669  {
1670  mutt_buffer_addstr(err, buf->data);
1671  mutt_buffer_addch(err, '=');
1672  pretty_var(val, err);
1673  }
1674  else
1675  {
1676  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1677  return MUTT_CMD_ERROR;
1678  }
1679  }
1680  break;
1681  }
1682  else if (equals)
1683  {
1684  // mutt_buffer_printf(err, "ACT11 set variable %s to ", buf->data);
1685  const char *name = NULL;
1686  if (my)
1687  {
1688  name = mutt_str_strdup(buf->data);
1689  }
1691  if (my)
1692  {
1693  myvar_set(name, buf->data);
1694  FREE(&name);
1695  }
1696  else
1697  {
1698  if (DTYPE(he->type) == DT_PATH)
1699  {
1700  mutt_expand_path(buf->data, buf->dsize);
1701  char scratch[PATH_MAX];
1702  mutt_str_strfcpy(scratch, buf->data, sizeof(scratch));
1703  size_t scratchlen = mutt_str_strlen(scratch);
1704  if (!(he->type & DT_MAILBOX) && (scratchlen != 0))
1705  {
1706  if ((scratch[scratchlen - 1] != '|') && /* not a command */
1707  (url_check_scheme(scratch) == U_UNKNOWN)) /* probably a local file */
1708  {
1709  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
1710  if (mutt_path_to_absolute(scratch, np ? NONULL(np->data) : "./"))
1711  {
1712  mutt_buffer_reset(buf);
1713  mutt_buffer_addstr(buf, scratch);
1714  }
1715  else
1716  {
1717  mutt_error(_("Error: Can't build path of '%s'"), scratch);
1718  }
1719  }
1720  }
1721  }
1722  else if (DTYPE(he->type) == DT_COMMAND)
1723  {
1724  char scratch[PATH_MAX];
1725  mutt_str_strfcpy(scratch, buf->data, sizeof(scratch));
1726 
1727  if (mutt_str_strcmp(buf->data, "builtin") != 0)
1728  {
1729  mutt_expand_path(scratch, sizeof(scratch));
1730  }
1731  mutt_buffer_reset(buf);
1732  mutt_buffer_addstr(buf, scratch);
1733  }
1734 
1735  rc = cs_he_string_set(Config, he, buf->data, err);
1736  if (CSR_RESULT(rc) != CSR_SUCCESS)
1737  return MUTT_CMD_ERROR;
1738  }
1739  continue;
1740  }
1741  else
1742  {
1743  if (bq)
1744  {
1745  // mutt_buffer_printf(err, "ACT23 set variable %s to 'yes'", buf->data);
1746  rc = cs_he_native_set(Config, he, true, err);
1747  if (CSR_RESULT(rc) != CSR_SUCCESS)
1748  return MUTT_CMD_ERROR;
1749  continue;
1750  }
1751  else
1752  {
1753  // mutt_buffer_printf(err, "ACT10 query variable %s", buf->data);
1754  if (he)
1755  {
1756  mutt_buffer_addstr(err, buf->data);
1757  mutt_buffer_addch(err, '=');
1758  mutt_buffer_reset(buf);
1759  rc = cs_he_string_get(Config, he, buf);
1760  if (CSR_RESULT(rc) != CSR_SUCCESS)
1761  {
1762  mutt_buffer_addstr(err, buf->data);
1763  return MUTT_CMD_ERROR;
1764  }
1765  pretty_var(buf->data, err);
1766  }
1767  else
1768  {
1769  const char *val = myvar_get(buf->data);
1770  if (val)
1771  {
1772  mutt_buffer_addstr(err, buf->data);
1773  mutt_buffer_addch(err, '=');
1774  pretty_var(val, err);
1775  }
1776  else
1777  {
1778  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1779  return MUTT_CMD_ERROR;
1780  }
1781  }
1782  break;
1783  }
1784  }
1785  }
1786 
1787  if (my)
1788  {
1789  myvar_del(buf->data);
1790  }
1791  else if (bq)
1792  {
1793  if (inv)
1794  {
1795  // mutt_buffer_printf(err, "ACT25 TOGGLE bool/quad variable %s", buf->data);
1796  if (DTYPE(he->type) == DT_BOOL)
1797  bool_he_toggle(Config, he, err);
1798  else
1799  quad_he_toggle(Config, he, err);
1800  }
1801  else
1802  {
1803  // mutt_buffer_printf(err, "ACT26 UNSET bool/quad variable %s", buf->data);
1804  rc = cs_he_native_set(Config, he, false, err);
1805  if (CSR_RESULT(rc) != CSR_SUCCESS)
1806  return MUTT_CMD_ERROR;
1807  }
1808  continue;
1809  }
1810  else
1811  {
1812  rc = cs_he_string_set(Config, he, NULL, err);
1813  if (CSR_RESULT(rc) != CSR_SUCCESS)
1814  return MUTT_CMD_ERROR;
1815  }
1816  }
1817 
1818  return MUTT_CMD_SUCCESS;
1819 }
#define NONULL(x)
Definition: string2.h:36
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:83
#define CSR_RESULT(x)
Definition: set.h:62
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
static struct ListHead MuttrcStack
Definition: init.c:78
Url wasn&#39;t recognised.
Definition: url.h:34
#define _(a)
Definition: message.h:28
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:39
Match case when comparing strings.
Definition: string2.h:66
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:669
struct HashElem ** get_elem_list(struct ConfigSet *cs)
Create a sorted list of all config items.
Definition: dump.c:119
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
int bool_he_toggle(struct ConfigSet *cs, struct HashElem *he, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:209
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:38
enum UrlScheme url_check_scheme(const char *s)
Check the protocol of a URL.
Definition: url.c:133
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:44
size_t dsize
length of data
Definition: buffer.h:37
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:127
#define MoreArgs(buf)
Definition: buffer.h:44
const char * name
Definition: pgpmicalg.c:45
int cs_he_reset(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *err)
Reset a config item to its initial value.
Definition: set.c:389
default is to invert all vars
Definition: init.h:101
int cs_he_native_set(const struct ConfigSet *cs, struct HashElem *he, intptr_t value, struct Buffer *err)
Natively set the value of a HashElem config item.
Definition: set.c:739
default is to set all vars
Definition: init.h:100
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
Definition: set.c:188
void myvar_del(const char *var)
Unset the value of a "my_" variable.
Definition: myvar.c:83
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:264
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:46
void myvar_set(const char *var, const char *val)
Set the value of a "my_" variable.
Definition: myvar.c:60
#define DT_PATH
a pathname
Definition: types.h:37
#define PATH_MAX
Definition: mutt.h:49
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
#define DT_MAILBOX
DT_PATH: Don&#39;t perform path expansions.
Definition: types.h:48
char * dptr
current read/write position
Definition: buffer.h:36
char * data
pointer to data
Definition: buffer.h:35
#define DT_COMMAND
a command
Definition: types.h:31
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:753
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
Definition: path.c:430
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:279
default is to reset all vars to default
Definition: init.h:103
const char * myvar_get(const char *var)
Get the value of a "my_" variable.
Definition: myvar.c:42
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:668
void * data
Definition: hash.h:46
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
Definition: dump.c:81
default is to unset all vars
Definition: init.h:102
Success: Command worked.
Definition: mutt_commands.h:35
char * data
Definition: list.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
int quad_he_toggle(struct ConfigSet *cs, struct HashElem *he, struct Buffer *err)
Toggle the value of a quad.
Definition: quad.c:225
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define mutt_error(...)
Definition: logging.h:83
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:83
int type
Definition: hash.h:44
#define FREE(x)
Definition: memory.h:40
The item stored in a Hash Table.
Definition: hash.h:42
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:76
A List node for strings.
Definition: list.h:33
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define DT_BOOL
boolean option
Definition: types.h:30
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
int cs_he_string_set(const struct ConfigSet *cs, struct HashElem *he, const char *value, struct Buffer *err)
Set a config item by string.
Definition: set.c:590
#define MUTT_TOKEN_QUESTION
Treat &#39;?&#39; as a special.
Definition: mutt.h:85

+ Here is the call graph for this function:

static enum CommandResult parse_setenv ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'setenv' and 'unsetenv' commands - Implements command_t.

Definition at line 1824 of file init.c.

1826 {
1827  char **envp = mutt_envlist_getlist();
1828 
1829  bool query = false;
1830  bool unset = (data == MUTT_SET_UNSET);
1831 
1832  if (!MoreArgs(s))
1833  {
1834  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1835  return MUTT_CMD_WARNING;
1836  }
1837 
1838  if (*s->dptr == '?')
1839  {
1840  query = true;
1841  s->dptr++;
1842  }
1843 
1844  /* get variable name */
1846 
1847  if (query)
1848  {
1849  bool found = false;
1850  while (envp && *envp)
1851  {
1852  /* This will display all matches for "^QUERY" */
1853  if (mutt_str_startswith(*envp, buf->data, CASE_MATCH))
1854  {
1855  if (!found)
1856  {
1857  mutt_endwin();
1858  found = true;
1859  }
1860  puts(*envp);
1861  }
1862  envp++;
1863  }
1864 
1865  if (found)
1866  {
1868  return MUTT_CMD_SUCCESS;
1869  }
1870 
1871  mutt_buffer_printf(err, _("%s is unset"), buf->data);
1872  return MUTT_CMD_WARNING;
1873  }
1874 
1875  if (unset)
1876  {
1877  if (mutt_envlist_unset(buf->data))
1878  return MUTT_CMD_SUCCESS;
1879  return MUTT_CMD_ERROR;
1880  }
1881 
1882  /* set variable */
1883 
1884  if (*s->dptr == '=')
1885  {
1886  s->dptr++;
1887  SKIPWS(s->dptr);
1888  }
1889 
1890  if (!MoreArgs(s))
1891  {
1892  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1893  return MUTT_CMD_WARNING;
1894  }
1895 
1896  char *name = mutt_str_strdup(buf->data);
1898  mutt_envlist_set(name, buf->data, true);
1899  FREE(&name);
1900 
1901  return MUTT_CMD_SUCCESS;
1902 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define _(a)
Definition: message.h:28
Match case when comparing strings.
Definition: string2.h:66
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MoreArgs(buf)
Definition: buffer.h:44
const char * name
Definition: pgpmicalg.c:45
#define SKIPWS(ch)
Definition: string2.h:46
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
bool mutt_envlist_unset(const char *name)
Unset an environment variable.
Definition: envlist.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * dptr
current read/write position
Definition: buffer.h:36
char * data
pointer to data
Definition: buffer.h:35
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 mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:532
default is to unset all vars
Definition: init.h:102
Success: Command worked.
Definition: mutt_commands.h:35
char * data
Definition: list.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define FREE(x)
Definition: memory.h:40
bool mutt_envlist_set(const char *name, const char *value, bool overwrite)
Set an environment variable.
Definition: envlist.c:84
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:76
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75
char ** mutt_envlist_getlist(void)
Get the private environment.
Definition: envlist.c:167

+ Here is the call graph for this function:

static enum CommandResult parse_source ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'source' command - Implements command_t.

Definition at line 1907 of file init.c.

1909 {
1910  char path[PATH_MAX];
1911 
1912  do
1913  {
1914  if (mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS) != 0)
1915  {
1916  mutt_buffer_printf(err, _("source: error at %s"), s->dptr);
1917  return MUTT_CMD_ERROR;
1918  }
1919  mutt_str_strfcpy(path, buf->data, sizeof(path));
1920  mutt_expand_path(path, sizeof(path));
1921 
1922  if (source_rc(path, err) < 0)
1923  {
1924  mutt_buffer_printf(err, _("source: file %s could not be sourced"), path);
1925  return MUTT_CMD_ERROR;
1926  }
1927 
1928  } while (MoreArgs(s));
1929 
1930  return MUTT_CMD_SUCCESS;
1931 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
static int source_rc(const char *rcfile_path, struct Buffer *err)
Read an initialization file.
Definition: init.c:750
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:127
#define MoreArgs(buf)
Definition: buffer.h:44
#define PATH_MAX
Definition: mutt.h:49
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * dptr
current read/write position
Definition: buffer.h:36
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:753
Success: Command worked.
Definition: mutt_commands.h:35
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_spam_list ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'spam' and 'nospam' commands - Implements command_t.

Definition at line 1936 of file init.c.

1938 {
1939  struct Buffer templ;
1940 
1941  mutt_buffer_init(&templ);
1942 
1943  /* Insist on at least one parameter */
1944  if (!MoreArgs(s))
1945  {
1946  if (data == MUTT_SPAM)
1947  mutt_buffer_strcpy(err, _("spam: no matching pattern"));
1948  else
1949  mutt_buffer_strcpy(err, _("nospam: no matching pattern"));
1950  return MUTT_CMD_ERROR;
1951  }
1952 
1953  /* Extract the first token, a regex */
1955 
1956  /* data should be either MUTT_SPAM or MUTT_NOSPAM. MUTT_SPAM is for spam commands. */
1957  if (data == MUTT_SPAM)
1958  {
1959  /* If there's a second parameter, it's a template for the spam tag. */
1960  if (MoreArgs(s))
1961  {
1963 
1964  /* Add to the spam list. */
1965  if (mutt_replacelist_add(&SpamList, buf->data, templ.data, err) != 0)
1966  {
1967  FREE(&templ.data);
1968  return MUTT_CMD_ERROR;
1969  }
1970  FREE(&templ.data);
1971  }
1972  /* If not, try to remove from the nospam list. */
1973  else
1974  {
1976  }
1977 
1978  return MUTT_CMD_SUCCESS;
1979  }
1980  /* MUTT_NOSPAM is for nospam commands. */
1981  else if (data == MUTT_NOSPAM)
1982  {
1983  /* nospam only ever has one parameter. */
1984 
1985  /* "*" is a special case. */
1986  if (mutt_str_strcmp(buf->data, "*") == 0)
1987  {
1990  return MUTT_CMD_SUCCESS;
1991  }
1992 
1993  /* If it's on the spam list, just remove it. */
1994  if (mutt_replacelist_remove(&SpamList, buf->data) != 0)
1995  return MUTT_CMD_SUCCESS;
1996 
1997  /* Otherwise, add it to the nospam list. */
1998  if (mutt_regexlist_add(&NoSpamList, buf->data, REG_ICASE, err) != 0)
1999  return MUTT_CMD_ERROR;
2000 
2001  return MUTT_CMD_SUCCESS;
2002  }
2003 
2004  /* This should not happen. */
2005  mutt_buffer_strcpy(err, "This is no good at all.");
2006  return MUTT_CMD_ERROR;
2007 }
int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, const char *templ, struct Buffer *err)
Add a pattern and a template to a list.
Definition: regex.c:263
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:227
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define MUTT_NOSPAM
Definition: mutt.h:118
struct ReplaceList SpamList
List of regexes and patterns to match spam emails.
Definition: email_globals.c:44
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:446
#define MoreArgs(buf)
Definition: buffer.h:44
#define MUTT_SPAM
Definition: mutt.h:117
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:322
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
int mutt_replacelist_remove(struct ReplaceList *rl, const char *pat)
Remove a pattern from a list.
Definition: regex.c:563
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:68
struct RegexList NoSpamList
List of regexes to whitelist non-spam emails.
Definition: email_globals.c:43
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition: regex.c:169
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_stailq ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse a list command - Implements command_t.

This is used by 'alternative_order', 'auto_view' and several others.

Definition at line 2014 of file init.c.

2016 {
2017  do
2018  {
2020  add_to_stailq((struct ListHead *) data, buf->data);
2021  } while (MoreArgs(s));
2022 
2023  return MUTT_CMD_SUCCESS;
2024 }
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
static void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: init.c:117
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_subjectrx_list ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'subjectrx' command - Implements command_t.

Definition at line 2029 of file init.c.

2031 {
2032  enum CommandResult rc;
2033 
2034  rc = parse_replace_list(buf, s, data, err);
2035  if (rc == MUTT_CMD_SUCCESS)
2037  return rc;
2038 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:31
static enum CommandResult parse_replace_list(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a string replacement rule - Implements command_t.
Definition: init.c:574
static void clear_subject_mods(void)
Clear out all modified email subjects.
Definition: init.c:210
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35

+ Here is the call graph for this function:

static enum CommandResult parse_subscribe ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'subscribe' command - Implements command_t.

Definition at line 2043 of file init.c.

2045 {
2046  struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
2047 
2048  do
2049  {
2051 
2052  if (parse_grouplist(&gc, buf, s, data, err) == -1)
2053  goto bail;
2054 
2057 
2058  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
2059  goto bail;
2060  if (mutt_regexlist_add(&SubscribedLists, buf->data, REG_ICASE, err) != 0)
2061  goto bail;
2062  if (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0)
2063  goto bail;
2064  } while (MoreArgs(s));
2065 
2067  return MUTT_CMD_SUCCESS;
2068 
2069 bail:
2071  return MUTT_CMD_ERROR;
2072 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:227
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: email_globals.c:50
char * data
pointer to data
Definition: buffer.h:35
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: email_globals.c:52
Success: Command worked.
Definition: mutt_commands.h:35
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: email_globals.c:51
int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:285
static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:541
void mutt_grouplist_destroy(struct GroupList *head)
Free a GroupList.
Definition: group.c:154
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: email_globals.c:49

+ Here is the call graph for this function:

static enum CommandResult parse_subscribe_to ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'subscribe-to' command - Implements command_t.

The 'subscribe-to' command allows to subscribe to an IMAP-Mailbox. Patterns are not supported. Use it as follows: subscribe-to =folder

Definition at line 2082 of file init.c.

2084 {
2085  if (!buf || !s || !err)
2086  return MUTT_CMD_ERROR;
2087 
2088  mutt_buffer_reset(err);
2089 
2090  if (MoreArgs(s))
2091  {
2093 
2094  if (MoreArgs(s))
2095  {
2096  mutt_buffer_printf(err, _("%s: too many arguments"), "subscribe-to");
2097  return MUTT_CMD_WARNING;
2098  }
2099 
2100  if (buf->data && (*buf->data != '\0'))
2101  {
2102  /* Expand and subscribe */
2103  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), true) != 0)
2104  {
2105  mutt_buffer_printf(err, _("Could not subscribe to %s"), buf->data);
2106  return MUTT_CMD_ERROR;
2107  }
2108  else
2109  {
2110  mutt_message(_("Subscribed to %s"), buf->data);
2111  return MUTT_CMD_SUCCESS;
2112  }
2113  }
2114  else
2115  {
2116  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2117  return MUTT_CMD_ERROR;
2118  }
2119  }
2120 
2121  mutt_buffer_addstr(err, _("No folder specified"));
2122  return MUTT_CMD_WARNING;
2123 }
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:83
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:82
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
size_t dsize
length of data
Definition: buffer.h:37
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:127
#define MoreArgs(buf)
Definition: buffer.h:44
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:264
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
Log at debug level 1.
Definition: logging.h:56
Warning: Help given to the user.
Definition: mutt_commands.h:34
#define mutt_debug(LEVEL,...)
Definition: logging.h:80
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1389

+ Here is the call graph for this function:

static enum CommandResult parse_tag_formats ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'tag-formats' command - Implements command_t.

Definition at line 2129 of file init.c.

2131 {
2132  if (!buf || !s)
2133  return MUTT_CMD_ERROR;
2134 
2135  char *tmp = NULL;
2136 
2137  while (MoreArgs(s))
2138  {
2139  char *tag = NULL, *format = NULL;
2140 
2142  if (buf->data && (*buf->data != '\0'))
2143  tag = mutt_str_strdup(buf->data);
2144  else
2145  continue;
2146 
2148  format = mutt_str_strdup(buf->data);
2149 
2150  /* avoid duplicates */
2151  tmp = mutt_hash_find(TagFormats, format);
2152  if (tmp)
2153  {
2154  mutt_debug(LL_DEBUG3, "tag format '%s' already registered as '%s'\n", format, tmp);
2155  FREE(&tag);
2156  FREE(&format);
2157  continue;
2158  }
2159 
2160  mutt_hash_insert(TagFormats, format, tag);
2161  }
2162  return MUTT_CMD_SUCCESS;
2163 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
void * mutt_hash_find(const struct Hash *table, const char *strkey)
Find the HashElem data in a Hash table element using a key.
Definition: hash.c:379
WHERE struct Hash * TagFormats
Hash table of tag-formats (tag -> format string)
Definition: globals.h:59
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:80
struct HashElem * mutt_hash_insert(struct Hash *table, const char *strkey, void *data)
Add a new element to the Hash table (with string keys)
Definition: hash.c:352
Log at debug level 3.
Definition: logging.h:58
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_tag_transforms ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'tag-transforms' command - Implements command_t.

Definition at line 2168 of file init.c.

2170 {
2171  if (!buf || !s)
2172  return MUTT_CMD_ERROR;
2173 
2174  char *tmp = NULL;
2175 
2176  while (MoreArgs(s))
2177  {
2178  char *tag = NULL, *transform = NULL;
2179 
2181  if (buf->data && (*buf->data != '\0'))
2182  tag = mutt_str_strdup(buf->data);
2183  else
2184  continue;
2185 
2187  transform = mutt_str_strdup(buf->data);
2188 
2189  /* avoid duplicates */
2190  tmp = mutt_hash_find(TagTransforms, tag);
2191  if (tmp)
2192  {
2193  mutt_debug(LL_DEBUG3, "tag transform '%s' already registered as '%s'\n", tag, tmp);
2194  FREE(&tag);
2195  FREE(&transform);
2196  continue;
2197  }
2198 
2199  mutt_hash_insert(TagTransforms, tag, transform);
2200  }
2201  return MUTT_CMD_SUCCESS;
2202 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:39
void * mutt_hash_find(const struct Hash *table, const char *strkey)
Find the HashElem data in a Hash table element using a key.
Definition: hash.c:379
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:80
struct HashElem * mutt_hash_insert(struct Hash *table, const char *strkey, void *data)
Add a new element to the Hash table (with string keys)
Definition: hash.c:352
Log at debug level 3.
Definition: logging.h:58
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_unalias ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unalias' command - Implements command_t.

Definition at line 2207 of file init.c.

2209 {
2210  struct Alias *a = NULL;
2211 
2212  do
2213  {
2215 
2216  if (mutt_str_strcmp("*", buf->data) == 0)
2217  {
2218  if (CurrentMenu == MENU_ALIAS)
2219  {
2220  TAILQ_FOREACH(a, &Aliases, entries)
2221  {
2222  a->del = true;
2223  }
2225  }
2226  else
2227  mutt_aliaslist_free(&Aliases);
2228  break;
2229  }
2230  else
2231  {
2232  TAILQ_FOREACH(a, &Aliases, entries)
2233  {
2234  if (mutt_str_strcasecmp(buf->data, a->name) == 0)
2235  {
2236  if (CurrentMenu == MENU_ALIAS)
2237  {
2238  a->del = true;
2240  }
2241  else
2242  {
2243  TAILQ_REMOVE(&Aliases, a, entries);
2244  mutt_alias_free(&a);
2245  }
2246  break;
2247  }
2248  }
2249  }
2250  } while (MoreArgs(s));
2251  return MUTT_CMD_SUCCESS;
2252 }
A shortcut for an email address.
Definition: alias.h:36
char * name
Definition: alias.h:38
void mutt_aliaslist_free(struct AliasList *a_list)
Free a List of Aliases.
Definition: alias.c:752
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
#define MoreArgs(buf)
Definition: buffer.h:44
bool del
Definition: alias.h:41
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:821
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Select an email address by its alias.
Definition: keymap.h:70
Success: Command worked.
Definition: mutt_commands.h:35
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
void mutt_alias_free(struct Alias **p)
Free an Alias.
Definition: alias.c:737
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:86
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_unalternates ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unalternates' command - Implements command_t.

Definition at line 2257 of file init.c.

2259 {
2260  alternates_clean();
2261  do
2262  {
2264  mutt_regexlist_remove(&Alternates, buf->data);
2265 
2266  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2267  (mutt_regexlist_add(&UnAlternates, buf->data, REG_ICASE, err) != 0))
2268  {
2269  return MUTT_CMD_ERROR;
2270  }
2271 
2272  } while (MoreArgs(s));
2273 
2274  return MUTT_CMD_SUCCESS;
2275 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:227
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
static void alternates_clean(void)
Clear the recipient valid flag of all emails.
Definition: init.c:138
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_unattachments ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unattachments' command - Implements command_t.

Definition at line 2280 of file init.c.

2282 {
2283  char op, *p = NULL;
2284  struct ListHead *head = NULL;
2285 
2287  if (!buf->data || (*buf->data == '\0'))
2288  {
2289  mutt_buffer_strcpy(err, _("unattachments: no disposition"));
2290  return MUTT_CMD_WARNING;
2291  }
2292 
2293  p = buf->data;
2294  op = *p++;
2295  if ((op != '+') && (op != '-'))
2296  {
2297  op = '+';
2298  p--;
2299  }
2300  if (mutt_str_startswith("attachment", p, CASE_IGNORE))
2301  {
2302  if (op == '+')
2303  head = &AttachAllow;
2304  else
2305  head = &AttachExclude;
2306  }
2307  else if (mutt_str_startswith("inline", p, CASE_IGNORE))
2308  {
2309  if (op == '+')
2310  head = &InlineAllow;
2311  else
2312  head = &InlineExclude;
2313  }
2314  else
2315  {
2316  mutt_buffer_strcpy(err, _("unattachments: invalid disposition"));
2317  return MUTT_CMD_ERROR;
2318  }
2319 
2320  return parse_unattach_list(buf, s, head, err);
2321 }
static enum CommandResult parse_unattach_list(struct Buffer *buf, struct Buffer *s, struct ListHead *head, struct Buffer *err)
Parse the "unattachments" command.
Definition: init.c:614
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define _(a)
Definition: message.h:28
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:322
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Ignore case when comparing strings.
Definition: string2.h:67
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
Warning: Help given to the user.
Definition: mutt_commands.h:34
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_unignore ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unignore' command - Implements command_t.

Definition at line 2326 of file init.c.

2328 {
2329  do
2330  {
2332 
2333  /* don't add "*" to the unignore list */
2334  if (strcmp(buf->data, "*") != 0)
2335  add_to_stailq(&UnIgnore, buf->data);
2336 
2337  remove_from_stailq(&Ignore, buf->data);
2338  } while (MoreArgs(s));
2339 
2340  return MUTT_CMD_SUCCESS;
2341 }
static void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: init.c:724
struct ListHead UnIgnore
List of header patterns to unignore (see)
Definition: email_globals.c:46
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
struct ListHead Ignore
List of header patterns to ignore.
Definition: email_globals.c:45
static void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: init.c:117
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_unlists ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unlists' command - Implements command_t.

Definition at line 2346 of file init.c.

2348 {
2350  do
2351  {
2355 
2356  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2357  (mutt_regexlist_add(&UnMailLists, buf->data, REG_ICASE, err) != 0))
2358  {
2359  return MUTT_CMD_ERROR;
2360  }
2361  } while (MoreArgs(s));
2362 
2363  return MUTT_CMD_SUCCESS;
2364 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:227
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
struct Hash * AutoSubscribeCache
Hash table of auto-subscribed mailing lists.
Definition: email_globals.c:48
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: email_globals.c:50
char * data
pointer to data
Definition: buffer.h:35
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: email_globals.c:52
Success: Command worked.
Definition: mutt_commands.h:35
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: email_globals.c:51
void mutt_hash_free(struct Hash **ptr)
elem_free a hash table
Definition: hash.c:472
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_unmailboxes ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unmailboxes' command - Implements command_t.

This is also used by 'unvirtual-mailboxes'

Definition at line 2371 of file init.c.

2373 {
2374  bool tmp_valid = false;
2375  bool clear_all = false;
2376 
2377  while (!clear_all && MoreArgs(s))
2378  {
2380 
2381  if (mutt_str_strcmp(buf->data, "*") == 0)
2382  {
2383  clear_all = true;
2384  tmp_valid = false;
2385  }
2386  else
2387  {
2389  tmp_valid = true;
2390  }
2391 
2392  struct MailboxNode *np = NULL;
2393  struct MailboxNode *nptmp = NULL;
2394  STAILQ_FOREACH_SAFE(np, &AllMailboxes, entries, nptmp)
2395  {
2396  /* Decide whether to delete all normal mailboxes or all virtual */
2397  bool virt = ((np->mailbox->magic == MUTT_NOTMUCH) && (data & MUTT_VIRTUAL));
2398  bool norm = ((np->mailbox->magic != MUTT_NOTMUCH) && !(data & MUTT_VIRTUAL));
2399  bool clear_this = clear_all && (virt || norm);
2400 
2401  /* Compare against path or desc? Ensure 'buf' is valid */
2402  if (!clear_this && tmp_valid)
2403  {
2404  clear_this =
2405  (mutt_str_strcasecmp(mutt_b2s(buf), mutt_b2s(np->mailbox->pathbuf)) == 0) ||
2406  (mutt_str_strcasecmp(mutt_b2s(buf), np->mailbox->desc) == 0);
2407  }
2408 
2409  if (clear_this)
2410  {
2411 #ifdef USE_SIDEBAR
2412  mutt_sb_notify_mailbox(np->mailbox, false);
2413 #endif
2414 #ifdef USE_INOTIFY
2416 #endif
2417  if (Context && (Context->mailbox == np->mailbox))
2418  {
2419  np->mailbox->flags |= MB_HIDDEN;
2420  }
2421  else
2422  {
2423  mx_ac_remove(np->mailbox);
2424  mailbox_free(&np->mailbox);
2425  }
2426  STAILQ_REMOVE(&AllMailboxes, np, MailboxNode, entries);
2427  FREE(&np);
2428  continue;
2429  }
2430  }
2431  }
2432  return MUTT_CMD_SUCCESS;
2433 }
The "current" mailbox.
Definition: context.h:38
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: magic.h:43
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:400
char * desc
Definition: mailbox.h:87
int mutt_monitor_remove(struct Mailbox *m)
Remove a watch for a mailbox.
Definition: monitor.c:506
#define MoreArgs(buf)
Definition: buffer.h:44
struct Mailbox * mailbox
Definition: context.h:52
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:105
enum MailboxType magic
mailbox type
Definition: mailbox.h:105
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:360
int flags
e.g.
Definition: mailbox.h:134
#define mutt_b2s(buf)
Definition: buffer.h:42
#define MB_HIDDEN
Definition: mailbox.h:47
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
#define MUTT_VIRTUAL
Definition: init.h:108
struct MailboxList AllMailboxes
List of all Mailboxes.
Definition: mailbox.c:86
struct Buffer * pathbuf
Definition: mailbox.h:85
Success: Command worked.
Definition: mutt_commands.h:35
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:324
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
#define FREE(x)
Definition: memory.h:40
List of Mailboxes.
Definition: mailbox.h:146
int mx_ac_remove(struct Mailbox *m)
Remove a Mailbox from an Account and delete Account if empty.
Definition: mx.c:1570
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75
struct Mailbox * mailbox
Definition: mailbox.h:148

+ Here is the call graph for this function:

static enum CommandResult parse_unmy_hdr ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unmy_hdr' command - Implements command_t.

Definition at line 2438 of file init.c.

2440 {
2441  struct ListNode *np, *tmp;
2442  size_t l;
2443 
2444  do
2445  {
2447  if (mutt_str_strcmp("*", buf->data) == 0)
2448  {
2449  mutt_list_free(&UserHeader);
2450  continue;
2451  }
2452 
2453  l = mutt_str_strlen(buf->data);
2454  if (buf->data[l - 1] == ':')
2455  l--;
2456 
2457  STAILQ_FOREACH_SAFE(np, &UserHeader, entries, tmp)
2458  {
2459  if ((mutt_str_strncasecmp(buf->data, np->data, l) == 0) && (np->data[l] == ':'))
2460  {
2461  STAILQ_REMOVE(&UserHeader, np, ListNode, entries);
2462  FREE(&np->data);
2463  FREE(&np);
2464  }
2465  }
2466  } while (MoreArgs(s));
2467  return MUTT_CMD_SUCCESS;
2468 }
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:400
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:669
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:117
#define MoreArgs(buf)
Definition: buffer.h:44
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:360
int mutt_str_strncasecmp(const char *a, const char *b, size_t l)
Compare two strings ignoring case (to a maximum), safely.
Definition: string.c:659
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
char * data
Definition: list.h:35
#define FREE(x)
Definition: memory.h:40
A List node for strings.
Definition: list.h:33
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_unstailq ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse an unlist command - Implements command_t.

This is used by 'unalternative_order', 'unauto_view' and several others.

Definition at line 2475 of file init.c.

2477 {
2478  do
2479  {
2481  /* Check for deletion of entire list */
2482  if (mutt_str_strcmp(buf->data, "*") == 0)
2483  {
2484  mutt_list_free((struct ListHead *) data);
2485  break;
2486  }
2487  remove_from_stailq((struct ListHead *) data, buf->data);
2488  } while (MoreArgs(s));
2489 
2490  return MUTT_CMD_SUCCESS;
2491 }
static void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: init.c:724
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:117
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
char * data
Definition: list.h:35
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75

+ Here is the call graph for this function:

static enum CommandResult parse_unsubjectrx_list ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unsubjectrx' command - Implements command_t.

Definition at line 2496 of file init.c.

2498 {
2499  enum CommandResult rc;
2500 
2501  rc = parse_unreplace_list(buf, s, data, err);
2502  if (rc == MUTT_CMD_SUCCESS)
2504  return rc;
2505 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:31
static void clear_subject_mods(void)
Clear out all modified email subjects.
Definition: init.c:210
Success: Command worked.
Definition: mutt_commands.h:35
char * data
Definition: list.h:35
static enum CommandResult parse_unreplace_list(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Remove a string replacement rule - Implements command_t.
Definition: init.c:672

+ Here is the call graph for this function:

static enum CommandResult parse_unsubscribe ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unsubscribe' command - Implements command_t.

Definition at line 2510 of file init.c.

2512 {
2514  do
2515  {
2518 
2519  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2520  (mutt_regexlist_add(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0))
2521  {
2522  return MUTT_CMD_ERROR;
2523  }
2524  } while (MoreArgs(s));
2525 
2526  return MUTT_CMD_SUCCESS;
2527 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:227
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
struct Hash * AutoSubscribeCache
Hash table of auto-subscribed mailing lists.
Definition: email_globals.c:48
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: email_globals.c:52
Success: Command worked.
Definition: mutt_commands.h:35
void mutt_hash_free(struct Hash **ptr)
elem_free a hash table
Definition: hash.c:472
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: email_globals.c:49

+ Here is the call graph for this function:

static enum CommandResult parse_unsubscribe_from ( struct Buffer buf,
struct Buffer s,
unsigned long  data,
struct Buffer err 
)
static

Parse the 'unsubscribe-from' command - Implements command_t.

The 'unsubscribe-from' command allows to unsubscribe from an IMAP-Mailbox. Patterns are not supported. Use it as follows: unsubscribe-from =folder

Definition at line 2537 of file init.c.

2539 {
2540  if (!buf || !s || !err)
2541  return MUTT_CMD_ERROR;
2542 
2543  if (MoreArgs(s))
2544  {
2546 
2547  if (MoreArgs(s))
2548  {
2549  mutt_buffer_printf(err, _("%s: too many arguments"), "unsubscribe-from");
2550  return MUTT_CMD_WARNING;
2551  }
2552 
2553  if (buf->data && (*buf->data != '\0'))
2554  {
2555  /* Expand and subscribe */
2556  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), false) != 0)
2557  {
2558  mutt_buffer_printf(err, _("Could not unsubscribe from %s"), buf->data);
2559  return MUTT_CMD_ERROR;
2560  }
2561  else
2562  {
2563  mutt_message(_("Unsubscribed from %s"), buf->data);
2564  return MUTT_CMD_SUCCESS;
2565  }
2566  }
2567  else
2568  {
2569  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2570  return MUTT_CMD_ERROR;
2571  }
2572  }
2573 
2574  mutt_buffer_addstr(err, _("No folder specified"));
2575  return MUTT_CMD_WARNING;
2576 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:82
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
size_t dsize
length of data
Definition: buffer.h:37
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:127
#define MoreArgs(buf)
Definition: buffer.h:44
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:264
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
Log at debug level 1.
Definition: logging.h:56
Warning: Help given to the user.
Definition: mutt_commands.h:34
#define mutt_debug(LEVEL,...)
Definition: logging.h:80
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:75
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1389

+ Here is the call graph for this function:

const struct Command* mutt_command_get ( const char *  s)

Get a Command by its name.

Parameters
sCommand string to lookup
Return values
ptrSuccess, Command
NULLError, no such command

Definition at line 2585 of file init.c.

2586 {
2587  for (int i = 0; Commands[i].name; i++)
2588  if (mutt_str_strcmp(s, Commands[i].name) == 0)
2589  return &Commands[i];
2590  return NULL;
2591 }
const char * name
Name of the command.
Definition: mutt_commands.h:54
const struct Command Commands[]
Definition: init.h:4854
const char * name
Definition: pgpmicalg.c:45
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:618

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_dump_variables ( bool  hide_sensitive)

Print a list of all variables with their values.

Parameters
hide_sensitiveDon't display the values of private config items
Return values
0Success
1Error

Definition at line 2614 of file init.c.

2615 {
2616  char cmd[256];
2617  struct Buffer *err = mutt_buffer_pool_get();
2618  struct Buffer *token = mutt_buffer_pool_get();
2619 
2620  for (int i = 0; MuttVars[i].name; i++)
2621  {
2622  if (MuttVars[i].type == DT_SYNONYM)
2623  continue;
2624 
2625  if (hide_sensitive && IS_SENSITIVE(MuttVars[i]))
2626  {
2627  mutt_message("%s='***'", MuttVars[i].name);
2628  continue;
2629  }
2630  snprintf(cmd, sizeof(cmd), "set ?%s\n", MuttVars[i].name);
2631  if (mutt_parse_rc_line(cmd, token, err) == MUTT_CMD_ERROR)
2632  {
2633  mutt_message("%s", mutt_b2s(err));
2634  mutt_buffer_pool_release(&token);
2636 
2637  return 1; // TEST17: can't test
2638  }
2639  mutt_message("%s", mutt_b2s(err));
2640  }
2641 
2642  mutt_buffer_pool_release(&token);
2644 
2645  return 0;
2646 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:82
String manipulation buffer.
Definition: buffer.h:33
#define IS_SENSITIVE(x)
Definition: types.h:73
const char * name
Definition: pgpmicalg.c:45
const char * name
User-visible name.
Definition: set.h:164
#define mutt_b2s(buf)
Definition: buffer.h:42
#define DT_SYNONYM
synonym for another variable
Definition: types.h:42
struct ConfigDef MuttVars[]
Definition: init.h:127
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: buffer.c:409
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: buffer.c:398
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3257

+ Here is the call graph for this function:

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 2656 of file init.c.

2657 {
2658  if (!dest || !tok)
2659  return -1;
2660 
2661  char ch;
2662  char qc = '\0'; /* quote char */
2663  char *pc = NULL;
2664 
2665  mutt_buffer_reset(dest);
2666 
2667  SKIPWS(tok->dptr);
2668  while ((ch = *tok->dptr))
2669  {
2670  if (qc == '\0')
2671  {
2672  if ((IS_SPACE(ch) && !(flags & MUTT_TOKEN_SPACE)) ||
2673  ((ch == '#') && !(flags & MUTT_TOKEN_COMMENT)) ||
2674  ((ch == '=') && (flags & MUTT_TOKEN_EQUAL)) ||
2675  ((ch == '?') && (flags & MUTT_TOKEN_QUESTION)) ||
2676  ((ch == ';') && !(flags & MUTT_TOKEN_SEMICOLON)) ||
2677  ((flags & MUTT_TOKEN_PATTERN) && strchr("~%=!|", ch)))
2678  {
2679  break;
2680  }
2681  }
2682 
2683  tok->dptr++;
2684 
2685  if (ch == qc)
2686  qc = 0; /* end of quote */
2687  else if (!qc && ((ch == '\'') || (ch == '"')) && !(flags & MUTT_TOKEN_QUOTE))
2688  qc = ch;
2689  else if ((ch == '\\') && (qc != '\''))
2690  {
2691  if (!*tok->dptr)
2692  return -1; /* premature end of token */
2693  switch (ch = *tok->dptr++)
2694  {
2695  case 'c':
2696  case 'C':
2697  if (!*tok->dptr)
2698  return -1; /* premature end of token */
2699  mutt_buffer_addch(dest, (toupper((unsigned char) *tok->dptr) - '@') & 0x7f);
2700  tok->dptr++;
2701  break;
2702  case 'e':
2703  mutt_buffer_addch(dest, '\033'); // Escape
2704  break;
2705  case 'f':
2706  mutt_buffer_addch(dest, '\f');
2707  break;
2708  case 'n':
2709  mutt_buffer_addch(dest, '\n');
2710  break;
2711  case 'r':
2712  mutt_buffer_addch(dest, '\r');
2713  break;
2714  case 't':
2715  mutt_buffer_addch(dest, '\t');
2716  break;
2717  default:
2718  if (isdigit((unsigned char) ch) && isdigit((unsigned char) *tok->dptr) &&
2719  isdigit((unsigned char) *(tok->dptr + 1)))
2720  {
2721  mutt_buffer_addch(dest, (ch << 6) + (*tok->dptr << 3) + *(tok->dptr + 1) - 3504);
2722  tok->dptr += 2;
2723  }
2724  else
2725  mutt_buffer_addch(dest, ch);
2726  }
2727  }
2728  else if ((ch == '^') && (flags & MUTT_TOKEN_CONDENSE))
2729  {
2730  if (!*tok->dptr)
2731  return -1; /* premature end of token */
2732  ch = *tok->dptr++;
2733  if (ch == '^')
2734  mutt_buffer_addch(dest, ch);
2735  else if (ch == '[')
2736  mutt_buffer_addch(dest, '\033'); // Escape
2737  else if (isalpha((unsigned char) ch))
2738  mutt_buffer_addch(dest, toupper((unsigned char) ch) - '@');
2739  else
2740  {
2741  mutt_buffer_addch(dest, '^');
2742  mutt_buffer_addch(dest, ch);
2743  }
2744  }
2745  else if ((ch == '`') && (!qc || (qc == '"')))
2746  {
2747  FILE *fp = NULL;
2748  pid_t pid;
2749  char *ptr = NULL;
2750  size_t expnlen;
2751  struct Buffer expn;
2752  int line = 0;
2753 
2754  pc = tok->dptr;
2755  do
2756  {
2757  pc = strpbrk(pc, "\\`");
2758  if (pc)
2759  {
2760  /* skip any quoted chars */
2761  if (*pc == '\\')
2762  pc += 2;
2763  }
2764  } while (pc && *pc != '`');
2765  if (!pc)
2766  {
2767  mutt_debug(LL_DEBUG1, "mismatched backticks\n");
2768  return -1;
2769  }
2770  struct Buffer cmd;
2771  mutt_buffer_init(&cmd);
2772  *pc = '\0';
2773  if (flags & MUTT_TOKEN_BACKTICK_VARS)
2774  {
2775  /* recursively extract tokens to interpolate variables */
2776  mutt_extract_token(&cmd, tok,
2777  MUTT_TOKEN_QUOTE | MUTT_TOKEN_SPACE | MUTT_TOKEN_COMMENT |
2778  MUTT_TOKEN_SEMICOLON | MUTT_TOKEN_NOSHELL);
2779  }
2780  else
2781  {
2782  cmd.data = mutt_str_strdup(tok->dptr);
2783  }
2784  *pc = '`';
2785  pid = mutt_create_filter(cmd.data, NULL, &fp, NULL);
2786  if (pid < 0)
2787  {
2788  mutt_debug(LL_DEBUG1, "unable to fork command: %s\n", cmd);
2789  FREE(&cmd.data);
2790  return -1;
2791  }
2792  FREE(&cmd.data);
2793 
2794  tok->dptr = pc + 1;
2795 
2796  /* read line */
2797  mutt_buffer_init(&expn);
2798  expn.data = mutt_file_read_line(NULL, &expn.dsize, fp, &line, 0);
2799  mutt_file_fclose(&fp);
2800  mutt_wait_filter(pid);
2801 
2802  /* if we got output, make a new string consisting of the shell output
2803  * plus whatever else was left on the original line */
2804  /* BUT: If this is inside a quoted string, directly add output to
2805  * the token */
2806  if (expn.data && qc)
2807  {
2808  mutt_buffer_addstr(dest, expn.data);
2809  FREE(&expn.data);
2810  }
2811  else if (expn.data)
2812  {
2813  expnlen = mutt_str_strlen(expn.data);
2814  tok->dsize = expnlen + mutt_str_strlen(tok->dptr) + 1;
2815  ptr = mutt_mem_malloc(tok->dsize);
2816  memcpy(ptr, expn.data, expnlen);
2817  strcpy(ptr + expnlen, tok->dptr);
2818  if (tok->destroy)
2819  FREE(&tok->data);
2820  tok->data = ptr;
2821  tok->dptr = ptr;
2822  tok->destroy = 1; /* mark that the caller should destroy this data */
2823  ptr = NULL;
2824  FREE(&expn.data);
2825  }
2826  }
2827  else if ((ch == '$') && (!qc || (qc == '"')) &&
2828  ((*tok->dptr == '{') || isalpha((unsigned char) *tok->dptr)))
2829  {
2830  const char *env = NULL;
2831  char *var = NULL;
2832 
2833  if (*tok->dptr == '{')
2834  {
2835  pc = strchr(tok->dptr, '}');
2836  if (pc)
2837  {
2838  var = mutt_str_substr_dup(tok->dptr + 1, pc);
2839  tok->dptr = pc + 1;
2840 
2841  if ((flags & MUTT_TOKEN_NOSHELL))
2842  {
2843  mutt_buffer_addch(dest, ch);
2844  mutt_buffer_addch(dest, '{');
2845  mutt_buffer_addstr(dest, var);
2846  mutt_buffer_addch(dest, '}');
2847  FREE(&var);
2848  }
2849  }
2850  }
2851  else
2852  {
2853  for (pc = tok->dptr; isalnum((unsigned char) *pc) || *pc == '_'; pc++)
2854  ;
2855  var = mutt_str_substr_dup(tok->dptr, pc);
2856  tok->dptr = pc;
2857  }
2858  if (var)
2859  {
2860  struct Buffer result;
2861  mutt_buffer_init(&result);
2862  int rc = cs_str_string_get(Config, var, &result);
2863 
2864  if (CSR_RESULT(rc) == CSR_SUCCESS)
2865  {
2866  mutt_buffer_addstr(dest, result.data);
2867  FREE(&result.data);
2868  }
2869  else if ((env = myvar_get(var)))
2870  {
2871  mutt_buffer_addstr(dest, env);
2872  }
2873  else if (!(flags & MUTT_TOKEN_NOSHELL) && (env = mutt_str_getenv(var)))
2874  {
2875  mutt_buffer_addstr(dest, env);
2876  }
2877  else
2878  {
2879  mutt_buffer_addch(dest, ch);
2880  mutt_buffer_addstr(dest, var);
2881  }
2882  FREE(&var);
2883  }
2884  }
2885  else
2886  mutt_buffer_addch(dest, ch);
2887  }
2888  mutt_buffer_addch(dest, 0); /* terminate the string */
2889  SKIPWS(tok->dptr);
2890  return 0;
2891 }
pid_t mutt_create_filter(const char *s, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
Definition: filter.c:216
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:83
#define CSR_RESULT(x)
Definition: set.h:62
#define MUTT_TOKEN_COMMENT
Don&#39;t reap comments.
Definition: mutt.h:81
String manipulation buffer.
Definition: buffer.h:33
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:39
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:657
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:669
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1086
int destroy
destroy &#39;data&#39; when done?
Definition: buffer.h:38
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:149
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:716
#define SKIPWS(ch)
Definition: string2.h:46
#define MUTT_TOKEN_NOSHELL
Don&#39;t expand environment variables.
Definition: mutt.h:84
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:264
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:46
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:79
#define MUTT_TOKEN_CONDENSE
^(char) to control chars (macros)
Definition: mutt.h:77
const char * line
Definition: common.c:35
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2656
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:97
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:78
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:279
const char * myvar_get(const char *var)
Get the value of a "my_" variable.
Definition: myvar.c:42
#define MUTT_TOKEN_SEMICOLON
Don&#39;t treat ; as special.
Definition: mutt.h:82
#define IS_SPACE(ch)
Definition: string2.h:37
Log at debug level 1.
Definition: logging.h:56
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:83
#define FREE(x)
Definition: memory.h:40
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:76
#define mutt_debug(LEVEL,...)
Definition: logging.h:80
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:68
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:227
char * mutt_str_substr_dup(const char *begin, const char *end)
Duplicate a sub-string.
Definition: string.c:582
#define MUTT_TOKEN_PATTERN
~%=!| are terms (for patterns)
Definition: mutt.h:80
#define MUTT_TOKEN_QUESTION
Treat &#39;?&#39; as a special.
Definition: mutt.h:85
void mutt_free_attachmatch ( struct AttachMatch **  am)

Free an AttachMatch - Implements list_free_t.

Note
We don't free minor because it is either a pointer into major, or a static string.

Definition at line 2899 of file init.c.

2900 {
2901  if (!am || !*am)
2902  return;
2903 
2904  regfree(&(*am)->minor_regex);
2905  FREE(&(*am)->major);
2906  FREE(am);
2907 }
#define FREE(x)
Definition: memory.h:40

+ Here is the caller graph for this function:

void mutt_free_opts ( void  )

clean up before quitting

Definition at line 2912 of file init.c.

2913 {
2915 
2916  FREE(&Matches);
2917 
2918  mutt_aliaslist_free(&Aliases);
2919 
2920  mutt_regexlist_free(&Alternates);
2924  mutt_regexlist_free(&UnAlternates);
2927 
2932 
2933  /* Lists of strings */
2934  mutt_list_free(&AlternativeOrderList);
2935  mutt_list_free(&AutoViewList);
2936  mutt_list_free(&HeaderOrderList);
2939  mutt_list_free(&MimeLookupList);
2940  mutt_list_free(&Muttrc);
2942 #ifdef USE_SIDEBAR
2943  mutt_list_free(&SidebarWhitelist);
2944 #endif
2946  mutt_list_free(&UserHeader);
2947 
2948  /* Lists of AttachMatch */
2953 
2954  mutt_free_colors();
2955 
2956  FREE(&CurrentFolder);
2957  FREE(&HomeDir);
2958  FREE(&LastFolder);
2959  FREE(&ShortHostname);
2960  FREE(&Username);
2961 
2964 
2966 
2967  mutt_hist_free();
2968  mutt_free_keys();
2969 
2971 }
WHERE char * Username
User&#39;s login name.
Definition: globals.h:51
void mutt_aliaslist_free(struct AliasList *a_list)
Free a List of Aliases.
Definition: alias.c:752
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:39
static struct ListHead MuttrcStack
Definition: init.c:78
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:138
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:59
void mutt_delete_hooks(HookFlags type)
Delete matching hooks.
Definition: hook.c:314
WHERE char * LastFolder
Previously selected mailbox.
Definition: globals.h:54
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:446
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:117
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:48
WHERE char * CurrentFolder
Currently selected mailbox.
Definition: globals.h:53
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
WHERE struct Hash * ReverseAliases
Hash table of aliases (email address -> alias)
Definition: globals.h:58
static const char ** Matches
Definition: init.c:91
void mutt_free_colors(void)
Free all the colours (on shutdown)
Definition: color.c:1260
WHERE char * ShortHostname
Short version of the hostname.
Definition: globals.h:49
#define FREE(x)
Definition: memory.h:40
void mutt_free_keys(void)
Free the key maps.
Definition: keymap.c:1576
#define MUTT_HOOK_NO_FLAGS
No flags are set.
Definition: hook.h:43
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:53
void mutt_hash_free(struct Hash **ptr)
elem_free a hash table
Definition: hash.c:472
struct RegexList NoSpamList
List of regexes to whitelist non-spam emails.
Definition: email_globals.c:43
void mutt_free_attachmatch(struct AttachMatch **am)
Free an AttachMatch - Implements list_free_t.
Definition: init.c:2899
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:169
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:

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 2979 of file init.c.

2980 {
2981  for (const struct Command *c = Commands; c->name; c++)
2982  {
2983  if (((c->func == mutt_parse_hook) || (c->func == mutt_parse_idxfmt_hook)) &&
2984  (mutt_str_strcasecmp(c->name, name) == 0))
2985  {
2986  return c->data;
2987  }
2988  }
2989  return MUTT_HOOK_NO_FLAGS;
2990 }
A user-callable command.
Definition: mutt_commands.h:52
const char * name
Name of the command.
Definition: mutt_commands.h:54
const struct Command Commands[]
Definition: init.h:4854
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:45
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:631
#define MUTT_HOOK_NO_FLAGS
No flags are set.
Definition: hook.h:43
int 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:361

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 2999 of file init.c.

3000 {
3001  char buf[1024];
3002  int need_pause = 0;
3003  struct Buffer err;
3004 
3005  mutt_buffer_init(&err);
3006  mutt_buffer_increase_size(&err, 256);
3007 
3009  /* reverse alias keys need to be strdup'ed because of idna conversions */
3014 
3015  mutt_menu_init();
3016 
3017  snprintf(AttachmentMarker, sizeof(AttachmentMarker), "\033]9;%" PRIu64 "\a", // Escape
3018  mutt_rand64());
3019 
3020  snprintf(ProtectedHeaderMarker, sizeof(ProtectedHeaderMarker), "\033]8;%ld\a", // Escape
3021  (long) time(NULL));
3022 
3023  /* "$spoolfile" precedence: config file, environment */
3024  const char *p = mutt_str_getenv("MAIL");
3025  if (!p)
3026  p = mutt_str_getenv("MAILDIR");
3027  if (!p)
3028  {
3029 #ifdef HOMESPOOL
3030  mutt_path_concat(buf, NONULL(HomeDir), MAILPATH, sizeof(buf));
3031 #else
3032  mutt_path_concat(buf, MAILPATH, NONULL(Username), sizeof(buf));
3033 #endif
3034  p = buf;
3035  }
3036  cs_str_initial_set(Config, "spoolfile", p, NULL);
3037  cs_str_reset(Config, "spoolfile", NULL);
3038 
3039  p = mutt_str_getenv("REPLYTO");
3040  if (p)
3041  {
3042  struct Buffer tmp, token;
3043 
3044  snprintf(buf, sizeof(buf), "Reply-To: %s", p);
3045 
3046  mutt_buffer_init(&tmp);
3047  tmp.data = buf;
3048  tmp.dptr = buf;
3049  tmp.dsize = mutt_str_strlen(buf);
3050 
3051  mutt_buffer_init(&token);
3052  parse_my_hdr(&token, &tmp, 0, &err); /* adds to UserHeader */
3053  FREE(&token.data);
3054  }
3055 
3056  p = mutt_str_getenv("EMAIL");
3057  if (p)
3058  {
3059  cs_str_initial_set(Config, "from", p, NULL);
3060  cs_str_reset(Config, "from", NULL);
3061  }
3062 
3063  /* "$mailcap_path" precedence: config file, environment, code */
3064  const char *env_mc = mutt_str_getenv("MAILCAPS");
3065  if (env_mc)
3066  cs_str_string_set(Config, "mailcap_path", env_mc, NULL);
3067 
3068  /* "$tmpdir" precedence: config file, environment, code */
3069  const char *env_tmp = mutt_str_getenv("TMPDIR");
3070  if (env_tmp)
3071  cs_str_string_set(Config, "tmpdir", env_tmp, NULL);
3072 
3073  /* "$visual", "$editor" precedence: config file, environment, code */
3074  const char *env_ed = mutt_str_getenv("VISUAL");
3075  if (!env_ed)
3076  env_ed = mutt_str_getenv("EDITOR");
3077  if (env_ed)
3078  {
3079  cs_str_string_set(Config, "editor", env_ed, NULL);
3080  cs_str_string_set(Config, "visual", env_ed, NULL);
3081  }
3082 
3085 
3086  Matches = mutt_mem_calloc(MatchesListsize, sizeof(char *));
3087 
3089 
3090 #ifdef HAVE_GETSID
3091  /* Unset suspend by default if we're the session leader */
3092  if (getsid(0) == getpid())
3093  C_Suspend = false;
3094 #endif
3095 
3096  /* RFC2368, "4. Unsafe headers"
3097  * The creator of a mailto URL can't expect the resolver of a URL to
3098  * understand more than the "subject" and "body" headers. Clients that
3099  * resolve mailto URLs into mail messages should be able to correctly
3100  * create RFC822-compliant mail messages using the "subject" and "body"
3101  * headers. */
3102  add_to_stailq(&MailToAllow, "body");
3103  add_to_stailq(&MailToAllow, "subject");
3104  /* Cc, In-Reply-To, and References help with not breaking threading on
3105  * mailing lists, see https://github.com/neomutt/neomutt/issues/115 */
3106  add_to_stailq(&MailToAllow, "cc");
3107  add_to_stailq(&MailToAllow, "in-reply-to");
3108  add_to_stailq(&MailToAllow, "references");
3109 
3110  if (STAILQ_EMPTY(&Muttrc))
3111  {
3112  const char *xdg_cfg_home = mutt_str_getenv("XDG_CONFIG_HOME");
3113 
3114  if (!xdg_cfg_home && HomeDir)
3115  {
3116  snprintf(buf, sizeof(buf), "%s/.config", HomeDir);
3117  xdg_cfg_home = buf;
3118  }
3119 
3120  char *config = find_cfg(HomeDir, xdg_cfg_home);
3121  if (config)
3122  {
3123  mutt_list_insert_tail(&Muttrc, config);
3124  }
3125  }
3126  else
3127  {
3128  struct ListNode *np = NULL;
3129  STAILQ_FOREACH(np, &Muttrc, entries)
3130  {
3131  mutt_str_strfcpy(buf, np->data, sizeof(buf));
3132  FREE(&np->data);
3133  mutt_expand_path(buf, sizeof(buf));
3134  np->data = mutt_str_strdup(buf);
3135  if (access(np->data, F_OK))
3136  {
3137  mutt_perror(np->data);
3138  return 1; // TEST10: neomutt -F missing
3139  }
3140  }
3141  }
3142 
3143  if (!