NeoMutt  2018-07-16 +2225-8687db
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 "alias.h"
#include "context.h"
#include "core/lib.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>

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 *user, 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 *gl, 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_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
  • Pietro Cerutti

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

#define NUM_VARS   mutt_array_size(MuttVars)

Definition at line 83 of file init.c.

#define NUM_COMMANDS   mutt_array_size(Commands)

Definition at line 84 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 104 of file init.c.

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

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

119 {
120  /* don't add a NULL or empty string to the list */
121  if (!str || (*str == '\0'))
122  return;
123 
124  /* check to make sure the item is not already on this list */
125  struct ListNode *np = NULL;
126  STAILQ_FOREACH(np, head, entries)
127  {
128  if (mutt_str_strcasecmp(str, np->data) == 0)
129  {
130  return;
131  }
132  }
134 }
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
#define 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:628
A List node for strings.
Definition: list.h:33
static void alternates_clean ( void  )
static

Clear the recipient valid flag of all emails.

Definition at line 139 of file init.c.

140 {
141  if (!Context)
142  return;
143 
144  for (int i = 0; i < Context->mailbox->msg_count; i++)
145  Context->mailbox->emails[i]->recip_valid = false;
146 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:111
The "current" mailbox.
Definition: context.h:39
int msg_count
Total number of messages.
Definition: mailbox.h:103
struct Mailbox * mailbox
Definition: context.h:53
bool recip_valid
Is_recipient is valid.
Definition: email.h:58
static void attachments_clean ( void  )
static

always wise to do what someone else did before

Definition at line 151 of file init.c.

152 {
153  if (!Context)
154  return;
155 
156  for (int i = 0; i < Context->mailbox->msg_count; i++)
157  Context->mailbox->emails[i]->attach_valid = false;
158 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:111
The "current" mailbox.
Definition: context.h:39
int msg_count
Total number of messages.
Definition: mailbox.h:103
struct Mailbox * mailbox
Definition: context.h:53
bool attach_valid
true when the attachment count is valid
Definition: email.h:70
static void matches_ensure_morespace ( int  current)
static

Allocate more space for auto-completion.

Parameters
currentCurrent allocation

Definition at line 164 of file init.c.

165 {
166  if (current <= (MatchesListsize - 2))
167  return;
168 
169  int base_space = MAX(NUM_VARS, NUM_COMMANDS) + 1;
170  int extra_space = MatchesListsize - base_space;
171  extra_space *= 2;
172  const int space = base_space + extra_space;
173  mutt_mem_realloc(&Matches, space * sizeof(char *));
174  memset(&Matches[current + 1], 0, space - current);
175  MatchesListsize = space;
176 }
#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:114
static int MatchesListsize
Definition: init.c:94
#define NUM_VARS
Definition: init.c:83
static const char ** Matches
Definition: init.c:92
#define NUM_COMMANDS
Definition: init.c:84
static void candidate ( char *  user,
const char *  src,
char *  dest,
size_t  dlen 
)
static

helper function for completion

Parameters
userUser 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 187 of file init.c.

188 {
189  if (!dest || !user || !src)
190  return;
191 
192  if (strstr(src, user) != src)
193  return;
194 
196  Matches[NumMatched++] = src;
197  if (dest[0] == '\0')
198  mutt_str_strfcpy(dest, src, dlen);
199  else
200  {
201  int l;
202  for (l = 0; src[l] && src[l] == dest[l]; l++)
203  ;
204  dest[l] = '\0';
205  }
206 }
static int NumMatched
Definition: init.c:90
static void matches_ensure_morespace(int current)
Allocate more space for auto-completion.
Definition: init.c:164
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
static const char ** Matches
Definition: init.c:92
static void clear_subject_mods ( void  )
static

Clear out all modified email subjects.

Definition at line 211 of file init.c.

212 {
213  if (!Context)
214  return;
215 
216  for (int i = 0; i < Context->mailbox->msg_count; i++)
218 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:111
The "current" mailbox.
Definition: context.h:39
int msg_count
Total number of messages.
Definition: mailbox.h:103
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:54
struct Mailbox * mailbox
Definition: context.h:53
struct Envelope * env
Envelope information.
Definition: email.h:89
#define FREE(x)
Definition: memory.h:40
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 227 of file init.c.

228 {
229  int tag_count_1 = 0;
230  int tag_count_2 = 0;
231 
232  NumMatched = 0;
233  mutt_str_strfcpy(UserTyped, pt, sizeof(UserTyped));
234  memset(Matches, 0, MatchesListsize);
235  memset(Completed, 0, sizeof(Completed));
236 
238 
239  /* Work out how many tags there are. */
240  if (nm_get_all_tags(Context->mailbox, NULL, &tag_count_1) || (tag_count_1 == 0))
241  goto done;
242 
243  /* Free the old list, if any. */
244  if (nm_tags)
245  {
246  for (int i = 0; nm_tags[i]; i++)
247  FREE(&nm_tags[i]);
248  FREE(&nm_tags);
249  }
250  /* Allocate a new list, with sentinel. */
251  nm_tags = mutt_mem_malloc((tag_count_1 + 1) * sizeof(char *));
252  nm_tags[tag_count_1] = NULL;
253 
254  /* Get all the tags. */
255  if (nm_get_all_tags(Context->mailbox, nm_tags, &tag_count_2) || (tag_count_1 != tag_count_2))
256  {
257  FREE(&nm_tags);
258  nm_tags = NULL;
260  return -1;
261  }
262 
263  /* Put them into the completion machinery. */
264  for (int num = 0; num < tag_count_1; num++)
265  {
266  candidate(UserTyped, nm_tags[num], Completed, sizeof(Completed));
267  }
268 
271 
272 done:
274  return 0;
275 }
The "current" mailbox.
Definition: context.h:39
static int NumMatched
Definition: init.c:90
static char ** nm_tags
Definition: init.c:98
struct Mailbox * mailbox
Definition: context.h:53
static char Completed[256]
Definition: init.c:91
void nm_db_longrun_done(struct Mailbox *m)
Finish a long transaction.
Definition: nm_db.c:307
static int MatchesListsize
Definition: init.c:94
static void matches_ensure_morespace(int current)
Allocate more space for auto-completion.
Definition: init.c:164
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
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:88
static const char ** Matches
Definition: init.c:92
#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
static void candidate(char *user, const char *src, char *dest, size_t dlen)
helper function for completion
Definition: init.c:187
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 284 of file init.c.

285 {
286  int rc = 0;
287  struct Buffer *err = mutt_buffer_pool_get();
288  struct Buffer *token = mutt_buffer_pool_get();
289 
290  struct ListNode *np = NULL;
291  STAILQ_FOREACH(np, p, entries)
292  {
293  if (mutt_parse_rc_line(np->data, token, err) == MUTT_CMD_ERROR)
294  {
295  mutt_error(_("Error in command line: %s"), mutt_b2s(err));
296  mutt_buffer_pool_release(&token);
298 
299  return -1;
300  }
301  }
302  mutt_buffer_pool_release(&token);
304 
305  return rc;
306 }
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:75
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:86
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:84
A List node for strings.
Definition: list.h:33
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3211
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 315 of file init.c.

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

357 {
358  char *mailname = NULL;
359  static const char *mn_files[] = { "/etc/mailname", "/etc/mail/mailname" };
360 
361  for (size_t i = 0; i < mutt_array_size(mn_files); i++)
362  {
363  FILE *fp = mutt_file_fopen(mn_files[i], "r");
364  if (!fp)
365  continue;
366 
367  size_t len = 0;
368  mailname = mutt_file_read_line(NULL, &len, fp, NULL, 0);
369  mutt_file_fclose(&fp);
370  if (mailname && *mailname)
371  break;
372 
373  FREE(&mailname);
374  }
375 
376  return mailname;
377 }
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:663
#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:584
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 388 of file init.c.

389 {
390  char *str = NULL;
391  struct utsname utsname;
392 
393  if (C_Hostname)
394  {
395  str = C_Hostname;
396  }
397  else
398  {
399  /* The call to uname() shouldn't fail, but if it does, the system is horribly
400  * broken, and the system's networking configuration is in an unreliable
401  * state. We should bail. */
402  if ((uname(&utsname)) == -1)
403  {
404  mutt_perror(_("unable to determine nodename via uname()"));
405  return false; // TEST09: can't test
406  }
407 
408  str = utsname.nodename;
409  }
410 
411  /* some systems report the FQDN instead of just the hostname */
412  char *dot = strchr(str, '.');
413  if (dot)
415  else
417 
418  if (!C_Hostname)
419  {
420  /* now get FQDN. Use configured domain first, DNS next, then uname */
421 #ifdef DOMAIN
422  /* we have a compile-time domain name, use that for C_Hostname */
423  C_Hostname =
425  sprintf((char *) C_Hostname, "%s.%s", NONULL(ShortHostname), DOMAIN);
426 #else
428  if (!C_Hostname)
429  {
430  char buffer[1024];
431  if (getdnsdomainname(buffer, sizeof(buffer)) == 0)
432  {
435  sprintf((char *) C_Hostname, "%s.%s", NONULL(ShortHostname), buffer);
436  }
437  else
438  {
439  /* DNS failed, use the nodename. Whether or not the nodename had a '.'
440  * in it, we can use the nodename as the FQDN. On hosts where DNS is
441  * not being used, e.g. small network that relies on hosts files, a
442  * short host name is all that is required for SMTP to work correctly.
443  * It could be wrong, but we've done the best we can, at this point the
444  * onus is on the user to provide the correct hostname if the nodename
445  * won't work in their network. */
446  C_Hostname = mutt_str_strdup(utsname.nodename);
447  }
448  }
449 #endif
450  }
451  if (C_Hostname)
452  cs_str_initial_set(Config, "hostname", C_Hostname, NULL);
453 
454  return true;
455 }
#define NONULL(x)
Definition: string2.h:37
#define mutt_perror(...)
Definition: logging.h:85
static char * getmailname(void)
Try to retrieve the FQDN from mailname files.
Definition: init.c:356
#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:666
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:486
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
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:579
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 465 of file init.c.

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

Parse a group context.

Parameters
glGroupList 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 542 of file init.c.

544 {
545  while (mutt_str_strcasecmp(buf->data, "-group") == 0)
546  {
547  if (!MoreArgs(s))
548  {
549  mutt_buffer_strcpy(err, _("-group: no group name"));
550  goto bail;
551  }
552 
554 
556 
557  if (!MoreArgs(s))
558  {
559  mutt_buffer_strcpy(err, _("out of arguments"));
560  goto bail;
561  }
562 
564  }
565 
566  return 0;
567 
568 bail:
569  return -1;
570 }
void mutt_grouplist_add(struct GroupList *gl, struct Group *group)
Add a Group to a GroupList.
Definition: group.c:137
#define _(a)
Definition: message.h:28
#define MoreArgs(buf)
Definition: buffer.h:44
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:314
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
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:628
struct Group * mutt_pattern_group(const char *pat)
Match a pattern to a Group.
Definition: group.c:66
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 575 of file init.c.

577 {
578  struct ReplaceList *list = (struct ReplaceList *) data;
579  struct Buffer templ = { 0 };
580 
581  /* First token is a regex. */
582  if (!MoreArgs(s))
583  {
584  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
585  return MUTT_CMD_WARNING;
586  }
588 
589  /* Second token is a replacement template */
590  if (!MoreArgs(s))
591  {
592  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
593  return MUTT_CMD_WARNING;
594  }
596 
597  if (mutt_replacelist_add(list, buf->data, templ.data, err) != 0)
598  {
599  FREE(&templ.data);
600  return MUTT_CMD_ERROR;
601  }
602  FREE(&templ.data);
603 
604  return MUTT_CMD_SUCCESS;
605 }
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:191
#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:2614
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:76
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 615 of file init.c.

617 {
618  struct AttachMatch *a = NULL;
619  char *tmp = NULL;
620  char *minor = NULL;
621 
622  do
623  {
625  FREE(&tmp);
626 
627  if (mutt_str_strcasecmp(buf->data, "any") == 0)
628  tmp = mutt_str_strdup("*/.*");
629  else if (mutt_str_strcasecmp(buf->data, "none") == 0)
630  tmp = mutt_str_strdup("cheap_hack/this_should_never_match");
631  else
632  tmp = mutt_str_strdup(buf->data);
633 
634  minor = strchr(tmp, '/');
635  if (minor)
636  {
637  *minor = '\0';
638  minor++;
639  }
640  else
641  {
642  minor = "unknown";
643  }
644  const enum ContentType major = mutt_check_mime_type(tmp);
645 
646  struct ListNode *np = NULL, *tmp2 = NULL;
647  STAILQ_FOREACH_SAFE(np, head, entries, tmp2)
648  {
649  a = (struct AttachMatch *) np->data;
650  mutt_debug(LL_DEBUG3, "check %s/%s [%d] : %s/%s [%d]\n", a->major,
651  a->minor, a->major_int, tmp, minor, major);
652  if ((a->major_int == major) && (mutt_str_strcasecmp(minor, a->minor) == 0))
653  {
654  mutt_debug(LL_DEBUG3, "removed %s/%s [%d]\n", a->major, a->minor, a->major_int);
655  regfree(&a->minor_regex);
656  FREE(&a->major);
657  STAILQ_REMOVE(head, np, ListNode, entries);
658  FREE(&np->data);
659  FREE(&np);
660  }
661  }
662 
663  } while (MoreArgs(s));
664 
665  FREE(&tmp);
667  return MUTT_CMD_SUCCESS;
668 }
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:400
enum ContentType major_int
Definition: mutt.h:132
#define MoreArgs(buf)
Definition: buffer.h:44
enum ContentType mutt_check_mime_type(const char *s)
Check a MIME type string.
Definition: parse.c:296
const char * major
Definition: mutt.h:131
#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:151
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
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:134
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
An attachment matching a regex.
Definition: mutt.h:129
A List node for strings.
Definition: list.h:33
const char * minor
Definition: mutt.h:133
Log at debug level 3.
Definition: logging.h:58
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
ContentType
Content-Type.
Definition: mime.h:29
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 673 of file init.c.

675 {
676  struct ReplaceList *list = (struct ReplaceList *) data;
677 
678  /* First token is a regex. */
679  if (!MoreArgs(s))
680  {
681  mutt_buffer_printf(err, _("%s: too few arguments"), "unsubjectrx");
682  return MUTT_CMD_WARNING;
683  }
684 
686 
687  /* "*" is a special case. */
688  if (mutt_str_strcmp(buf->data, "*") == 0)
689  {
690  mutt_replacelist_free(list);
691  return MUTT_CMD_SUCCESS;
692  }
693 
694  mutt_replacelist_remove(list, buf->data);
695  return MUTT_CMD_SUCCESS;
696 }
#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:191
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:448
#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:2614
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:565
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 705 of file init.c.

706 {
707  struct ListNode *np = NULL;
708  STAILQ_FOREACH(np, h, entries)
709  {
710  printf("attachments %c%s %s/%s\n", op, name,
711  ((struct AttachMatch *) np->data)->major,
712  ((struct AttachMatch *) np->data)->minor);
713  }
714 
715  return 0;
716 }
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:129
A List node for strings.
Definition: list.h:33
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 725 of file init.c.

726 {
727  if (mutt_str_strcmp("*", str) == 0)
728  mutt_list_free(head); /* "unCMD *" means delete all current entries */
729  else
730  {
731  struct ListNode *np = NULL, *tmp = NULL;
732  STAILQ_FOREACH_SAFE(np, head, entries, tmp)
733  {
734  if (mutt_str_strcasecmp(str, np->data) == 0)
735  {
736  STAILQ_REMOVE(head, np, ListNode, entries);
737  FREE(&np->data);
738  FREE(&np);
739  break;
740  }
741  }
742  }
743 }
#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:123
#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:628
#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:615
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 751 of file init.c.

752 {
753  int line = 0, rc = 0, warnings = 0;
754  enum CommandResult line_rc;
755  struct Buffer token;
756  char *linebuf = NULL;
757  char *currentline = NULL;
758  char rcfile[PATH_MAX];
759  size_t buflen;
760 
761  pid_t pid;
762 
763  mutt_str_strfcpy(rcfile, rcfile_path, sizeof(rcfile));
764 
765  size_t rcfilelen = mutt_str_strlen(rcfile);
766  if (rcfilelen == 0)
767  return -1;
768 
769  bool ispipe = rcfile[rcfilelen - 1] == '|';
770 
771  if (!ispipe)
772  {
773  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
774  if (!mutt_path_to_absolute(rcfile, np ? NONULL(np->data) : ""))
775  {
776  mutt_error(_("Error: Can't build path of '%s'"), rcfile_path);
777  return -1;
778  }
779 
780  STAILQ_FOREACH(np, &MuttrcStack, entries)
781  {
782  if (mutt_str_strcmp(np->data, rcfile) == 0)
783  {
784  break;
785  }
786  }
787  if (!np)
788  {
790  }
791  else
792  {
793  mutt_error(_("Error: Cyclic sourcing of configuration file '%s'"), rcfile);
794  return -1;
795  }
796  }
797 
798  mutt_debug(LL_DEBUG2, "Reading configuration file '%s'\n", rcfile);
799 
800  FILE *fp = mutt_open_read(rcfile, &pid);
801  if (!fp)
802  {
803  mutt_buffer_printf(err, "%s: %s", rcfile, strerror(errno));
804  return -1;
805  }
806 
807  mutt_buffer_init(&token);
808  while ((linebuf = mutt_file_read_line(linebuf, &buflen, fp, &line, MUTT_CONT)))
809  {
810  const bool conv = C_ConfigCharset && C_Charset;
811  if (conv)
812  {
813  currentline = mutt_str_strdup(linebuf);
814  if (!currentline)
815  continue;
816  mutt_ch_convert_string(&currentline, C_ConfigCharset, C_Charset, 0);
817  }
818  else
819  currentline = linebuf;
820  mutt_buffer_reset(err);
821  line_rc = mutt_parse_rc_line(currentline, &token, err);
822  if (line_rc == MUTT_CMD_ERROR)
823  {
824  mutt_error(_("Error in %s, line %d: %s"), rcfile, line, err->data);
825  if (--rc < -MAX_ERRS)
826  {
827  if (conv)
828  FREE(&currentline);
829  break;
830  }
831  }
832  else if (line_rc == MUTT_CMD_WARNING)
833  {
834  /* Warning */
835  mutt_warning(_("Warning in %s, line %d: %s"), rcfile, line, err->data);
836  warnings++;
837  }
838  else if (line_rc == MUTT_CMD_FINISH)
839  {
840  break; /* Found "finish" command */
841  }
842  else
843  {
844  if (rc < 0)
845  rc = -1;
846  }
847  if (conv)
848  FREE(&currentline);
849  }
850  FREE(&token.data);
851  FREE(&linebuf);
852  mutt_file_fclose(&fp);
853  if (pid != -1)
854  mutt_wait_filter(pid);
855  if (rc)
856  {
857  /* the neomuttrc source keyword */
858  mutt_buffer_reset(err);
859  mutt_buffer_printf(err, (rc >= -MAX_ERRS) ? _("source: errors in %s") : _("source: reading aborted due to too many errors in %s"),
860  rcfile);
861  rc = -1;
862  }
863  else
864  {
865  /* Don't alias errors with warnings */
866  if (warnings > 0)
867  {
868  mutt_buffer_printf(err, ngettext("source: %d warning in %s", "source: %d warnings in %s", warnings),
869  warnings, rcfile);
870  rc = -2;
871  }
872  }
873 
874  if (!ispipe && !STAILQ_EMPTY(&MuttrcStack))
875  {
876  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
877  STAILQ_REMOVE_HEAD(&MuttrcStack, entries);
878  FREE(&np->data);
879  FREE(&np);
880  }
881 
882  return rc;
883 }
#define mutt_warning(...)
Definition: logging.h:82
#define NONULL(x)
Definition: string2.h:37
int mutt_ch_convert_string(char **ps, const char *from, const char *to, int flags)
Convert a string between encodings.
Definition: charset.c:724
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:76
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:79
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:663
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
#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:191
#define MUTT_CONT
-continuation
Definition: file.h:38
#define MAX_ERRS
Definition: init.c:81
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:36
#define PATH_MAX
Definition: mutt.h:50
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
Definition: path.c:430
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition: list.c:46
#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:84
#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:81
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:61
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:1366
#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:615
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3211
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 888 of file init.c.

890 {
891  struct Alias *tmp = NULL;
892  char *estr = NULL;
893  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
894 
895  if (!MoreArgs(s))
896  {
897  mutt_buffer_strcpy(err, _("alias: no address"));
898  return MUTT_CMD_WARNING;
899  }
900 
902 
903  if (parse_grouplist(&gl, buf, s, data, err) == -1)
904  return MUTT_CMD_ERROR;
905 
906  /* check to see if an alias with this name already exists */
907  TAILQ_FOREACH(tmp, &Aliases, entries)
908  {
909  if (mutt_str_strcasecmp(tmp->name, buf->data) == 0)
910  break;
911  }
912 
913  if (!tmp)
914  {
915  /* create a new alias */
916  tmp = mutt_alias_new();
917  tmp->name = mutt_str_strdup(buf->data);
918  TAILQ_INSERT_TAIL(&Aliases, tmp, entries);
919  /* give the main addressbook code a chance */
920  if (CurrentMenu == MENU_ALIAS)
921  OptMenuCaller = true;
922  }
923  else
924  {
926  /* override the previous value */
927  mutt_addrlist_clear(&tmp->addr);
928  if (CurrentMenu == MENU_ALIAS)
930  }
931 
933  mutt_debug(LL_DEBUG5, "Second token is '%s'\n", buf->data);
934 
935  mutt_addrlist_parse2(&tmp->addr, buf->data);
936 
937  if (mutt_addrlist_to_intl(&tmp->addr, &estr))
938  {
939  mutt_buffer_printf(err, _("Warning: Bad IDN '%s' in alias '%s'"), estr, tmp->name);
940  FREE(&estr);
941  goto bail;
942  }
943 
944  mutt_grouplist_add_addrlist(&gl, &tmp->addr);
946 
947  if (C_DebugLevel > LL_DEBUG4)
948  {
949  /* A group is terminated with an empty address, so check a->mailbox */
950  struct Address *a = NULL;
951  TAILQ_FOREACH(a, &tmp->addr, entries)
952  {
953  if (!a->mailbox)
954  break;
955 
956  if (a->group)
957  mutt_debug(LL_DEBUG5, " Group %s\n", a->mailbox);
958  else
959  mutt_debug(LL_DEBUG5, " %s\n", a->mailbox);
960  }
961  }
963  return MUTT_CMD_SUCCESS;
964 
965 bail:
967  return MUTT_CMD_ERROR;
968 }
void mutt_alias_delete_reverse(struct Alias *t)
Remove an email address lookup for an Alias.
Definition: alias.c:562
A shortcut for an email address.
Definition: alias.h:37
Log at debug level 4.
Definition: logging.h:59
char * name
Definition: alias.h:39
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1351
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:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
void mutt_grouplist_add_addrlist(struct GroupList *gl, struct AddressList *al)
Add Address list to a GroupList.
Definition: group.c:225
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:191
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:603
#define MoreArgs(buf)
Definition: buffer.h:44
struct Alias * mutt_alias_new()
Create a new Alias.
Definition: alias.c:131
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:80
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:542
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:314
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:2614
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:79
char * data
Pointer to data.
Definition: buffer.h:35
#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:83
Success: Command worked.
Definition: mutt_commands.h:35
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1186
bool group
Group mailbox?
Definition: address.h:38
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:628
void mutt_alias_add_reverse(struct Alias *t)
Add an email address lookup for an Alias.
Definition: alias.c:540
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#define FREE(x)
Definition: memory.h:40
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:86
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct AddressList addr
Definition: alias.h:40
Log at debug level 5.
Definition: logging.h:60
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 973 of file init.c.

975 {
976  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
977 
979 
980  do
981  {
983 
984  if (parse_grouplist(&gl, buf, s, data, err) == -1)
985  goto bail;
986 
987  mutt_regexlist_remove(&UnAlternates, buf->data);
988 
989  if (mutt_regexlist_add(&Alternates, buf->data, REG_ICASE, err) != 0)
990  goto bail;
991 
992  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
993  goto bail;
994  } while (MoreArgs(s));
995 
997  return MUTT_CMD_SUCCESS;
998 
999 bail:
1001  return MUTT_CMD_ERROR;
1002 }
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:139
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:275
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
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:542
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 1007 of file init.c.

1009 {
1010  char op;
1011  char *category = NULL;
1012  struct ListHead *head = NULL;
1013 
1015  if (!buf->data || (*buf->data == '\0'))
1016  {
1017  mutt_buffer_strcpy(err, _("attachments: no disposition"));
1018  return MUTT_CMD_WARNING;
1019  }
1020 
1021  category = buf->data;
1022  op = *category++;
1023 
1024  if (op == '?')
1025  {
1026  mutt_endwin();
1027  fflush(stdout);
1028  printf("\n%s\n\n", _("Current attachments settings:"));
1029  print_attach_list(&AttachAllow, '+', "A");
1030  print_attach_list(&AttachExclude, '-', "A");
1031  print_attach_list(&InlineAllow, '+', "I");
1032  print_attach_list(&InlineExclude, '-', "I");
1034  return MUTT_CMD_SUCCESS;
1035  }
1036 
1037  if ((op != '+') && (op != '-'))
1038  {
1039  op = '+';
1040  category--;
1041  }
1042  if (mutt_str_startswith("attachment", category, CASE_IGNORE))
1043  {
1044  if (op == '+')
1045  head = &AttachAllow;
1046  else
1047  head = &AttachExclude;
1048  }
1049  else if (mutt_str_startswith("inline", category, CASE_IGNORE))
1050  {
1051  if (op == '+')
1052  head = &InlineAllow;
1053  else
1054  head = &InlineExclude;
1055  }
1056  else
1057  {
1058  mutt_buffer_strcpy(err, _("attachments: invalid disposition"));
1059  return MUTT_CMD_ERROR;
1060  }
1061 
1062  return parse_attach_list(buf, s, head, err);
1063 }
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:314
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:2614
char * data
Pointer to data.
Definition: buffer.h:35
Ignore case when comparing strings.
Definition: string2.h:68
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:544
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:465
static int print_attach_list(struct ListHead *h, const char op, const char *name)
Print a list of attachments.
Definition: init.c:705
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 1068 of file init.c.

1070 {
1071  if (!MoreArgs(s))
1072  {
1073  mutt_buffer_printf(err, _("%s: too few arguments"), "echo");
1074  return MUTT_CMD_WARNING;
1075  }
1077  OptForceRefresh = true;
1078  mutt_message("%s", buf->data);
1079  OptForceRefresh = false;
1080  mutt_sleep(0);
1081 
1082  return MUTT_CMD_SUCCESS;
1083 }
#define mutt_message(...)
Definition: logging.h:83
#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:191
#define MoreArgs(buf)
Definition: buffer.h:44
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1505
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:2614
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:76
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 1092 of file init.c.

1094 {
1095  if (MoreArgs(s))
1096  {
1097  mutt_buffer_printf(err, _("%s: too many arguments"), "finish");
1098  return MUTT_CMD_WARNING;
1099  }
1100 
1101  return MUTT_CMD_FINISH;
1102 }
#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:191
#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
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 1107 of file init.c.

1109 {
1110  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
1111  enum GroupState state = GS_NONE;
1112 
1113  do
1114  {
1116  if (parse_grouplist(&gl, buf, s, data, err) == -1)
1117  goto bail;
1118 
1119  if ((data == MUTT_UNGROUP) && (mutt_str_strcasecmp(buf->data, "*") == 0))
1120  {
1121  mutt_grouplist_clear(&gl);
1122  goto out;
1123  }
1124 
1125  if (mutt_str_strcasecmp(buf->data, "-rx") == 0)
1126  state = GS_RX;
1127  else if (mutt_str_strcasecmp(buf->data, "-addr") == 0)
1128  state = GS_ADDR;
1129  else
1130  {
1131  switch (state)
1132  {
1133  case GS_NONE:
1134  mutt_buffer_printf(err, _("%sgroup: missing -rx or -addr"),
1135  (data == MUTT_UNGROUP) ? "un" : "");
1136  goto warn;
1137 
1138  case GS_RX:
1139  if ((data == MUTT_GROUP) &&
1140  (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0))
1141  {
1142  goto bail;
1143  }
1144  else if ((data == MUTT_UNGROUP) &&
1145  (mutt_grouplist_remove_regex(&gl, buf->data) < 0))
1146  {
1147  goto bail;
1148  }
1149  break;
1150 
1151  case GS_ADDR:
1152  {
1153  char *estr = NULL;
1154  struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
1155  mutt_addrlist_parse2(&al, buf->data);
1156  if (TAILQ_EMPTY(&al))
1157  goto bail;
1158  if (mutt_addrlist_to_intl(&al, &estr))
1159  {
1160  mutt_buffer_printf(err, _("%sgroup: warning: bad IDN '%s'"),
1161  (data == 1) ? "un" : "", estr);
1162  mutt_addrlist_clear(&al);
1163  FREE(&estr);
1164  goto bail;
1165  }
1166  if (data == MUTT_GROUP)
1167  mutt_grouplist_add_addrlist(&gl, &al);
1168  else if (data == MUTT_UNGROUP)
1170  mutt_addrlist_clear(&al);
1171  break;
1172  }
1173  }
1174  }
1175  } while (MoreArgs(s));
1176 
1177 out:
1179  return MUTT_CMD_SUCCESS;
1180 
1181 bail:
1183  return MUTT_CMD_ERROR;
1184 
1185 warn:
1187  return MUTT_CMD_WARNING;
1188 }
#define MUTT_UNGROUP
&#39;ungroup&#39; config command
Definition: group.h:33
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
void mutt_grouplist_clear(struct GroupList *gl)
Clear a GroupList.
Definition: group.c:103
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1351
#define _(a)
Definition: message.h:28
void mutt_grouplist_add_addrlist(struct GroupList *gl, struct AddressList *al)
Add Address list to a GroupList.
Definition: group.c:225
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:191
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:603
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:275
int mutt_grouplist_remove_regex(struct GroupList *gl, const char *s)
Remove matching addresses from a GroupList.
Definition: group.c:299
int mutt_grouplist_remove_addrlist(struct GroupList *gl, struct AddressList *al)
Remove an AddressList from a GroupList.
Definition: group.c:244
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:542
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
char * data
Pointer to data.
Definition: buffer.h:35
Group is missing an argument.
Definition: init.c:106
Success: Command worked.
Definition: mutt_commands.h:35
GroupState
Type of email address group.
Definition: init.c:104
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1186
Warning: Help given to the user.
Definition: mutt_commands.h:34
Entry is an address.
Definition: init.c:108
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#define FREE(x)
Definition: memory.h:40
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
Entry is a regular expression.
Definition: init.c:107
#define TAILQ_EMPTY(head)
Definition: queue.h:715
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:631
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
#define MUTT_GROUP
&#39;group&#39; config command
Definition: group.h:32
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 1196 of file init.c.

1197 {
1198  for (int i = 0; i < MENU_MAX; i++)
1199  {
1200  const struct Binding *b = km_get_table(Menus[i].value);
1201  if (!b)
1202  continue;
1203 
1204  for (int j = 0; b[j].name; j++)
1205  if (mutt_str_strcmp(name, b[j].name) == 0)
1206  return true;
1207  }
1208  return false;
1209 }
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:1205
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:615
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 1224 of file init.c.

1226 {
1227  struct Buffer token = { 0 };
1228 
1230 
1231  // is the item defined as:
1232  bool res = cs_get_elem(Config, buf->data) // a variable?
1233  || feature_enabled(buf->data) // a compiled-in feature?
1234  || is_function(buf->data) // a function?
1235  || mutt_command_get(buf->data) // a command?
1236  || myvar_get(buf->data) // a my_ variable?
1237  || mutt_str_getenv(buf->data); // an environment variable?
1238 
1239  if (!MoreArgs(s))
1240  {
1241  mutt_buffer_printf(err, _("%s: too few arguments"), (data ? "ifndef" : "ifdef"));
1242  return MUTT_CMD_WARNING;
1243  }
1245 
1246  /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
1247  if ((res && (data == 0)) || (!res && (data == 1)))
1248  {
1249  enum CommandResult rc = mutt_parse_rc_line(buf->data, &token, err);
1250  if (rc == MUTT_CMD_ERROR)
1251  {
1252  mutt_error(_("Error: %s"), err->data);
1253  FREE(&token.data);
1254  return MUTT_CMD_ERROR;
1255  }
1256  FREE(&token.data);
1257  return rc;
1258  }
1259  return MUTT_CMD_SUCCESS;
1260 }
static bool is_function(const char *name)
Is the argument a neomutt function?
Definition: init.c:1196
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:481
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:191
const struct Command * mutt_command_get(const char *s)
Get a Command by its name.
Definition: init.c:2583
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1084
#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:215
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:79
char * data
Pointer to data.
Definition: buffer.h:35
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:84
#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:3211
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 1265 of file init.c.

1267 {
1268  do
1269  {
1272  add_to_stailq(&Ignore, buf->data);
1273  } while (MoreArgs(s));
1274 
1275  return MUTT_CMD_SUCCESS;
1276 }
static void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: init.c:725
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:2614
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:118
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 1281 of file init.c.

1283 {
1284  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
1285 
1286  do
1287  {
1289 
1290  if (parse_grouplist(&gl, buf, s, data, err) == -1)
1291  goto bail;
1292 
1294 
1295  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
1296  goto bail;
1297 
1298  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
1299  goto bail;
1300  } while (MoreArgs(s));
1301 
1303  return MUTT_CMD_SUCCESS;
1304 
1305 bail:
1307  return MUTT_CMD_ERROR;
1308 }
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_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:275
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
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:542
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
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
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#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
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 1315 of file init.c.

1317 {
1318  while (MoreArgs(s))
1319  {
1320  struct Mailbox *m = mailbox_new();
1321 
1322  if (data & MUTT_NAMED)
1323  {
1325  if (buf->data && (*buf->data != '\0'))
1326  {
1327  m->name = mutt_str_strdup(buf->data);
1328  }
1329  else
1330  {
1331  mailbox_free(&m);
1332  continue;
1333  }
1334  }
1335 
1337  if (mutt_buffer_is_empty(buf))
1338  {
1339  /* Skip empty tokens. */
1340  mailbox_free(&m);
1341  continue;
1342  }
1343 
1344  mutt_buffer_strcpy(m->pathbuf, buf->data);
1345  /* int rc = */ mx_path_canon2(m, C_Folder);
1346 
1347  bool new_account = false;
1348  struct Account *a = mx_ac_find(m);
1349  if (!a)
1350  {
1351  a = account_new(NULL, NeoMutt->sub);
1352  a->magic = m->magic;
1353  new_account = true;
1354  }
1355 
1356  if (!new_account)
1357  {
1358  struct Mailbox *m_old = mx_mbox_find(a, m->realpath);
1359  if (m_old)
1360  {
1361  if (m_old->flags == MB_HIDDEN)
1362  {
1363  m_old->flags = MB_NORMAL;
1364  mutt_sb_notify_mailbox(m_old, true);
1365  }
1366  mailbox_free(&m);
1367  continue;
1368  }
1369  }
1370 
1371  if (mx_ac_add(a, m) < 0)
1372  {
1373  //error
1374  mailbox_free(&m);
1375  if (new_account)
1376  {
1377  FREE(&a);
1378  }
1379  continue;
1380  }
1381  if (new_account)
1382  {
1384  }
1385 
1386 #ifdef USE_SIDEBAR
1387  mutt_sb_notify_mailbox(m, true);
1388 #endif
1389 #ifdef USE_INOTIFY
1390  mutt_monitor_add(m);
1391 #endif
1392  }
1393  return MUTT_CMD_SUCCESS;
1394 }
int mx_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Wrapper for MxOps::ac_add.
Definition: mx.c:1564
int mx_path_canon2(struct Mailbox *m, const char *folder)
XXX canonicalise the path to realpath.
Definition: mx.c:1398
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:96
A group of associated Mailboxes.
Definition: account.h:36
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
XXX.
Definition: mx.c:1501
int mutt_monitor_add(struct Mailbox *m)
Add a watch for a mailbox.
Definition: monitor.c:466
struct Account * mx_ac_find(struct Mailbox *m)
XXX.
Definition: mx.c:1478
Container for Accounts, Notifications.
Definition: neomutt.h:35
#define MoreArgs(buf)
Definition: buffer.h:44
char * name
A short name for the Mailbox.
Definition: mailbox.h:97
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:56
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:117
struct Account * account_new(const char *name, struct ConfigSubset *sub)
Create a new Account.
Definition: account.c:43
int flags
e.g. MB_NORMAL
Definition: mailbox.h:146
#define MB_HIDDEN
Definition: mailbox.h:38
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:314
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
Definition: globals.h:114
A mailbox.
Definition: mailbox.h:93
enum MailboxType magic
Type of Mailboxes this Account contains.
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:2614
char * data
Pointer to data.
Definition: buffer.h:35
#define MUTT_NAMED
Definition: init.h:108
struct Buffer * pathbuf
Definition: mailbox.h:95
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition: mailbox.c:42
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
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
bool neomutt_account_add(struct NeoMutt *n, struct Account *a)
Add an Account to the global list.
Definition: neomutt.c:83
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:283
#define MB_NORMAL
Definition: mailbox.h:37
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 1399 of file init.c.

1401 {
1402  struct ListNode *n = NULL;
1403  size_t keylen;
1404 
1406  char *p = strpbrk(buf->data, ": \t");
1407  if (!p || (*p != ':'))
1408  {
1409  mutt_buffer_strcpy(err, _("invalid header field"));
1410  return MUTT_CMD_WARNING;
1411  }
1412  keylen = p - buf->data + 1;
1413 
1414  STAILQ_FOREACH(n, &UserHeader, entries)
1415  {
1416  /* see if there is already a field by this name */
1417  if (mutt_str_strncasecmp(buf->data, n->data, keylen) == 0)
1418  {
1419  break;
1420  }
1421  }
1422 
1423  if (!n)
1424  {
1425  /* not found, allocate memory for a new node and add it to the list */
1426  n = mutt_list_insert_tail(&UserHeader, NULL);
1427  }
1428  else
1429  {
1430  /* found, free the existing data */
1431  FREE(&n->data);
1432  }
1433 
1434  n->data = buf->data;
1435  mutt_buffer_init(buf);
1436 
1437  return MUTT_CMD_SUCCESS;
1438 }
#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:65
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:80
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:314
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:656
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:79
char * data
Pointer to data.
Definition: buffer.h:35
#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:61
A List node for strings.
Definition: list.h:33
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 1444 of file init.c.

1446 {
1447  char path[PATH_MAX];
1448 
1449  do
1450  {
1452  mutt_str_strfcpy(path, buf->data, sizeof(path));
1453  mutt_expand_path(path, sizeof(path));
1454  add_to_stailq((struct ListHead *) data, path);
1455  } while (MoreArgs(s));
1456 
1457  return MUTT_CMD_SUCCESS;
1458 }
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
#define MoreArgs(buf)
Definition: buffer.h:44
#define PATH_MAX
Definition: mutt.h:50
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
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:118
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 1465 of file init.c.

1467 {
1468  char path[PATH_MAX];
1469 
1470  do
1471  {
1473  /* Check for deletion of entire list */
1474  if (mutt_str_strcmp(buf->data, "*") == 0)
1475  {
1476  mutt_list_free((struct ListHead *) data);
1477  break;
1478  }
1479  mutt_str_strfcpy(path, buf->data, sizeof(path));
1480  mutt_expand_path(path, sizeof(path));
1481  remove_from_stailq((struct ListHead *) data, path);
1482  } while (MoreArgs(s));
1483 
1484  return MUTT_CMD_SUCCESS;
1485 }
static void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: init.c:725
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
#define MoreArgs(buf)
Definition: buffer.h:44
#define PATH_MAX
Definition: mutt.h:50
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
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:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 1493 of file init.c.

1495 {
1496  /* The order must match `enum MuttSetCommand` */
1497  static const char *set_commands[] = { "set", "toggle", "unset", "reset" };
1498 
1499  int rc = 0;
1500 
1501  while (MoreArgs(s))
1502  {
1503  bool prefix = false;
1504  bool query = false;
1505  bool inv = (data == MUTT_SET_INV);
1506  bool reset = (data == MUTT_SET_RESET);
1507  bool unset = (data == MUTT_SET_UNSET);
1508 
1509  if (*s->dptr == '?')
1510  {
1511  prefix = true;
1512  query = true;
1513  s->dptr++;
1514  }
1515  else if (mutt_str_startswith(s->dptr, "no", CASE_MATCH))
1516  {
1517  prefix = true;
1518  unset = !unset;
1519  s->dptr += 2;
1520  }
1521  else if (mutt_str_startswith(s->dptr, "inv", CASE_MATCH))
1522  {
1523  prefix = true;
1524  inv = !inv;
1525  s->dptr += 3;
1526  }
1527  else if (*s->dptr == '&')
1528  {
1529  prefix = true;
1530  reset = true;
1531  s->dptr++;
1532  }
1533 
1534  if (prefix && (data != MUTT_SET_SET))
1535  {
1536  mutt_buffer_printf(err, "ERR22 can't use 'inv', 'no', '&' or '?' with the '%s' command",
1537  set_commands[data]);
1538  return MUTT_CMD_WARNING;
1539  }
1540 
1541  /* get the variable name */
1543 
1544  bool bq = false;
1545  bool equals = false;
1546 
1547  struct HashElem *he = NULL;
1548  bool my = mutt_str_startswith(buf->data, "my_", CASE_MATCH);
1549  if (!my)
1550  {
1551  he = cs_get_elem(Config, buf->data);
1552  if (!he)
1553  {
1554  if (reset && (mutt_str_strcmp(buf->data, "all") == 0))
1555  {
1556  struct HashElem **list = get_elem_list(Config);
1557  if (!list)
1558  return MUTT_CMD_ERROR;
1559 
1560  for (size_t i = 0; list[i]; i++)
1561  cs_he_reset(Config, list[i], NULL);
1562 
1563  FREE(&list);
1564  break;
1565  }
1566  else
1567  {
1568  mutt_buffer_printf(err, "ERR01 unknown variable: %s", buf->data);
1569  return MUTT_CMD_ERROR;
1570  }
1571  }
1572 
1573  bq = ((DTYPE(he->type) == DT_BOOL) || (DTYPE(he->type) == DT_QUAD));
1574  }
1575 
1576  if (*s->dptr == '?')
1577  {
1578  if (prefix)
1579  {
1580  mutt_buffer_printf(err,
1581  "ERR02 can't use a prefix when querying a variable");
1582  return MUTT_CMD_WARNING;
1583  }
1584 
1585  if (reset || unset || inv)
1586  {
1587  mutt_buffer_printf(err, "ERR03 can't query a variable with the '%s' command",
1588  set_commands[data]);
1589  return MUTT_CMD_WARNING;
1590  }
1591 
1592  query = true;
1593  s->dptr++;
1594  }
1595  else if (*s->dptr == '=')
1596  {
1597  if (prefix)
1598  {
1599  mutt_buffer_printf(err,
1600  "ERR04 can't use prefix when setting a variable");
1601  return MUTT_CMD_WARNING;
1602  }
1603 
1604  if (reset || unset || inv)
1605  {
1606  mutt_buffer_printf(err, "ERR05 can't set a variable with the '%s' command",
1607  set_commands[data]);
1608  return MUTT_CMD_WARNING;
1609  }
1610 
1611  equals = true;
1612  s->dptr++;
1613  }
1614 
1615  if (!bq && (inv || (unset && prefix)))
1616  {
1617  if (data == MUTT_SET_SET)
1618  {
1619  mutt_buffer_printf(err, "ERR06 prefixes 'no' and 'inv' may only be "
1620  "used with bool/quad variables");
1621  }
1622  else
1623  {
1624  mutt_buffer_printf(err, "ERR07 command '%s' can only be used with bool/quad variables",
1625  set_commands[data]);
1626  }
1627  return MUTT_CMD_WARNING;
1628  }
1629 
1630  if (reset)
1631  {
1632  // mutt_buffer_printf(err, "ACT24 reset variable %s", buf->data);
1633  if (he)
1634  {
1635  rc = cs_he_reset(Config, he, err);
1636  if (CSR_RESULT(rc) != CSR_SUCCESS)
1637  return MUTT_CMD_ERROR;
1638  }
1639  else
1640  {
1641  myvar_del(buf->data);
1642  }
1643  continue;
1644  }
1645 
1646  if ((data == MUTT_SET_SET) && !inv && !unset)
1647  {
1648  if (query)
1649  {
1650  // mutt_buffer_printf(err, "ACT08 query variable %s", buf->data);
1651  if (he)
1652  {
1653  mutt_buffer_addstr(err, buf->data);
1654  mutt_buffer_addch(err, '=');
1655  mutt_buffer_reset(buf);
1656  rc = cs_he_string_get(Config, he, buf);
1657  if (CSR_RESULT(rc) != CSR_SUCCESS)
1658  {
1659  mutt_buffer_addstr(err, buf->data);
1660  return MUTT_CMD_ERROR;
1661  }
1662  pretty_var(buf->data, err);
1663  }
1664  else
1665  {
1666  const char *val = myvar_get(buf->data);
1667  if (val)
1668  {
1669  mutt_buffer_addstr(err, buf->data);
1670  mutt_buffer_addch(err, '=');
1671  pretty_var(val, err);
1672  }
1673  else
1674  {
1675  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1676  return MUTT_CMD_ERROR;
1677  }
1678  }
1679  break;
1680  }
1681  else if (equals)
1682  {
1683  // mutt_buffer_printf(err, "ACT11 set variable %s to ", buf->data);
1684  const char *name = NULL;
1685  if (my)
1686  {
1687  name = mutt_str_strdup(buf->data);
1688  }
1690  if (my)
1691  {
1692  myvar_set(name, buf->data);
1693  FREE(&name);
1694  }
1695  else
1696  {
1697  if (IS_PATH(he))
1698  {
1699  mutt_expand_path(buf->data, buf->dsize);
1700  char scratch[PATH_MAX];
1701  mutt_str_strfcpy(scratch, buf->data, sizeof(scratch));
1702  size_t scratchlen = mutt_str_strlen(scratch);
1703  if (!(he->type & DT_MAILBOX) && (scratchlen != 0))
1704  {
1705  if ((scratch[scratchlen - 1] != '|') && /* not a command */
1706  (url_check_scheme(scratch) == U_UNKNOWN)) /* probably a local file */
1707  {
1708  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
1709  if (mutt_path_to_absolute(scratch, np ? NONULL(np->data) : "./"))
1710  {
1711  mutt_buffer_reset(buf);
1712  mutt_buffer_addstr(buf, scratch);
1713  }
1714  else
1715  {
1716  mutt_error(_("Error: Can't build path of '%s'"), scratch);
1717  }
1718  }
1719  }
1720  }
1721  else if (IS_COMMAND(he))
1722  {
1723  char scratch[PATH_MAX];
1724  mutt_str_strfcpy(scratch, buf->data, sizeof(scratch));
1725 
1726  if (mutt_str_strcmp(buf->data, "builtin") != 0)
1727  {
1728  mutt_expand_path(scratch, sizeof(scratch));
1729  }
1730  mutt_buffer_reset(buf);
1731  mutt_buffer_addstr(buf, scratch);
1732  }
1733 
1734  rc = cs_he_string_set(Config, he, buf->data, err);
1735  if (CSR_RESULT(rc) != CSR_SUCCESS)
1736  return MUTT_CMD_ERROR;
1737  }
1738  continue;
1739  }
1740  else
1741  {
1742  if (bq)
1743  {
1744  // mutt_buffer_printf(err, "ACT23 set variable %s to 'yes'", buf->data);
1745  rc = cs_he_native_set(Config, he, true, err);
1746  if (CSR_RESULT(rc) != CSR_SUCCESS)
1747  return MUTT_CMD_ERROR;
1748  continue;
1749  }
1750  else
1751  {
1752  // mutt_buffer_printf(err, "ACT10 query variable %s", buf->data);
1753  if (he)
1754  {
1755  mutt_buffer_addstr(err, buf->data);
1756  mutt_buffer_addch(err, '=');
1757  mutt_buffer_reset(buf);
1758  rc = cs_he_string_get(Config, he, buf);
1759  if (CSR_RESULT(rc) != CSR_SUCCESS)
1760  {
1761  mutt_buffer_addstr(err, buf->data);
1762  return MUTT_CMD_ERROR;
1763  }
1764  pretty_var(buf->data, err);
1765  }
1766  else
1767  {
1768  const char *val = myvar_get(buf->data);
1769  if (val)
1770  {
1771  mutt_buffer_addstr(err, buf->data);
1772  mutt_buffer_addch(err, '=');
1773  pretty_var(val, err);
1774  }
1775  else
1776  {
1777  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1778  return MUTT_CMD_ERROR;
1779  }
1780  }
1781  break;
1782  }
1783  }
1784  }
1785 
1786  if (my)
1787  {
1788  myvar_del(buf->data);
1789  }
1790  else if (bq)
1791  {
1792  if (inv)
1793  {
1794  // mutt_buffer_printf(err, "ACT25 TOGGLE bool/quad variable %s", buf->data);
1795  if (DTYPE(he->type) == DT_BOOL)
1796  bool_he_toggle(Config, he, err);
1797  else
1798  quad_he_toggle(Config, he, err);
1799  }
1800  else
1801  {
1802  // mutt_buffer_printf(err, "ACT26 UNSET bool/quad variable %s", buf->data);
1803  rc = cs_he_native_set(Config, he, false, err);
1804  if (CSR_RESULT(rc) != CSR_SUCCESS)
1805  return MUTT_CMD_ERROR;
1806  }
1807  continue;
1808  }
1809  else
1810  {
1811  rc = cs_he_string_set(Config, he, NULL, err);
1812  if (CSR_RESULT(rc) != CSR_SUCCESS)
1813  return MUTT_CMD_ERROR;
1814  }
1815  }
1816 
1817  return MUTT_CMD_SUCCESS;
1818 }
#define NONULL(x)
Definition: string2.h:37
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:76
#define IS_PATH(x)
Definition: types.h:55
#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:79
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:67
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
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:191
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:36
enum UrlScheme url_check_scheme(const char *s)
Check the protocol of a URL.
Definition: url.c:132
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:43
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:128
#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:374
default is to invert all vars
Definition: init.h:102
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:720
default is to set all vars
Definition: init.h:101
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
Definition: set.c:215
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:256
#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 PATH_MAX
Definition: mutt.h:50
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
#define DT_MAILBOX
Don&#39;t perform path expansions.
Definition: types.h:47
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
Definition: path.c:430
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:750
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:271
default is to reset all vars to default
Definition: init.h:104
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:649
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:103
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:84
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:84
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:77
#define IS_COMMAND(x)
Definition: types.h:56
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:615
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:575
#define MUTT_TOKEN_QUESTION
Treat &#39;?&#39; as a special.
Definition: mutt.h:86
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 1823 of file init.c.

1825 {
1826  char **envp = mutt_envlist_getlist();
1827 
1828  bool query = false;
1829  bool unset = (data == MUTT_SET_UNSET);
1830 
1831  if (!MoreArgs(s))
1832  {
1833  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1834  return MUTT_CMD_WARNING;
1835  }
1836 
1837  if (*s->dptr == '?')
1838  {
1839  query = true;
1840  s->dptr++;
1841  }
1842 
1843  /* get variable name */
1845 
1846  if (query)
1847  {
1848  bool found = false;
1849  while (envp && *envp)
1850  {
1851  /* This will display all matches for "^QUERY" */
1852  if (mutt_str_startswith(*envp, buf->data, CASE_MATCH))
1853  {
1854  if (!found)
1855  {
1856  mutt_endwin();
1857  found = true;
1858  }
1859  puts(*envp);
1860  }
1861  envp++;
1862  }
1863 
1864  if (found)
1865  {
1867  return MUTT_CMD_SUCCESS;
1868  }
1869 
1870  mutt_buffer_printf(err, _("%s is unset"), buf->data);
1871  return MUTT_CMD_WARNING;
1872  }
1873 
1874  if (unset)
1875  {
1876  if (mutt_envlist_unset(buf->data))
1877  return MUTT_CMD_SUCCESS;
1878  return MUTT_CMD_ERROR;
1879  }
1880 
1881  /* set variable */
1882 
1883  if (*s->dptr == '=')
1884  {
1885  s->dptr++;
1886  SKIPWS(s->dptr);
1887  }
1888 
1889  if (!MoreArgs(s))
1890  {
1891  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1892  return MUTT_CMD_WARNING;
1893  }
1894 
1895  char *name = mutt_str_strdup(buf->data);
1897  mutt_envlist_set(name, buf->data, true);
1898  FREE(&name);
1899 
1900  return MUTT_CMD_SUCCESS;
1901 }
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:67
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:191
#define MoreArgs(buf)
Definition: buffer.h:44
const char * name
Definition: pgpmicalg.c:45
#define SKIPWS(ch)
Definition: string2.h:47
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:2614
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:544
default is to unset all vars
Definition: init.h:103
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:77
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
char ** mutt_envlist_getlist(void)
Get the private environment.
Definition: envlist.c:167
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 1906 of file init.c.

1908 {
1909  char path[PATH_MAX];
1910 
1911  do
1912  {
1913  if (mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS) != 0)
1914  {
1915  mutt_buffer_printf(err, _("source: error at %s"), s->dptr);
1916  return MUTT_CMD_ERROR;
1917  }
1918  mutt_str_strfcpy(path, buf->data, sizeof(path));
1919  mutt_expand_path(path, sizeof(path));
1920 
1921  if (source_rc(path, err) < 0)
1922  {
1923  mutt_buffer_printf(err, _("source: file %s could not be sourced"), path);
1924  return MUTT_CMD_ERROR;
1925  }
1926 
1927  } while (MoreArgs(s));
1928 
1929  return MUTT_CMD_SUCCESS;
1930 }
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:751
#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:191
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
#define MoreArgs(buf)
Definition: buffer.h:44
#define PATH_MAX
Definition: mutt.h:50
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
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:750
Success: Command worked.
Definition: mutt_commands.h:35
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 1935 of file init.c.

1937 {
1938  struct Buffer templ;
1939 
1940  mutt_buffer_init(&templ);
1941 
1942  /* Insist on at least one parameter */
1943  if (!MoreArgs(s))
1944  {
1945  if (data == MUTT_SPAM)
1946  mutt_buffer_strcpy(err, _("spam: no matching pattern"));
1947  else
1948  mutt_buffer_strcpy(err, _("nospam: no matching pattern"));
1949  return MUTT_CMD_ERROR;
1950  }
1951 
1952  /* Extract the first token, a regex */
1954 
1955  /* data should be either MUTT_SPAM or MUTT_NOSPAM. MUTT_SPAM is for spam commands. */
1956  if (data == MUTT_SPAM)
1957  {
1958  /* If there's a second parameter, it's a template for the spam tag. */
1959  if (MoreArgs(s))
1960  {
1962 
1963  /* Add to the spam list. */
1964  if (mutt_replacelist_add(&SpamList, buf->data, templ.data, err) != 0)
1965  {
1966  FREE(&templ.data);
1967  return MUTT_CMD_ERROR;
1968  }
1969  FREE(&templ.data);
1970  }
1971  /* If not, try to remove from the nospam list. */
1972  else
1973  {
1975  }
1976 
1977  return MUTT_CMD_SUCCESS;
1978  }
1979  /* MUTT_NOSPAM is for nospam commands. */
1980  else if (data == MUTT_NOSPAM)
1981  {
1982  /* nospam only ever has one parameter. */
1983 
1984  /* "*" is a special case. */
1985  if (mutt_str_strcmp(buf->data, "*") == 0)
1986  {
1989  return MUTT_CMD_SUCCESS;
1990  }
1991 
1992  /* If it's on the spam list, just remove it. */
1993  if (mutt_replacelist_remove(&SpamList, buf->data) != 0)
1994  return MUTT_CMD_SUCCESS;
1995 
1996  /* Otherwise, add it to the nospam list. */
1997  if (mutt_regexlist_add(&NoSpamList, buf->data, REG_ICASE, err) != 0)
1998  return MUTT_CMD_ERROR;
1999 
2000  return MUTT_CMD_SUCCESS;
2001  }
2002 
2003  /* This should not happen. */
2004  mutt_buffer_strcpy(err, "This is no good at all.");
2005  return MUTT_CMD_ERROR;
2006 }
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:119
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:448
#define MoreArgs(buf)
Definition: buffer.h:44
#define MUTT_SPAM
Definition: mutt.h:118
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:314
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
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:565
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:61
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:615
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:76
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 2013 of file init.c.

2015 {
2016  do
2017  {
2019  add_to_stailq((struct ListHead *) data, buf->data);
2020  } while (MoreArgs(s));
2021 
2022  return MUTT_CMD_SUCCESS;
2023 }
#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:2614
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:118
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 2028 of file init.c.

2030 {
2031  enum CommandResult rc;
2032 
2033  rc = parse_replace_list(buf, s, data, err);
2034  if (rc == MUTT_CMD_SUCCESS)
2036  return rc;
2037 }
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:575
static void clear_subject_mods(void)
Clear out all modified email subjects.
Definition: init.c:211
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
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 2042 of file init.c.

2044 {
2045  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
2046 
2047  do
2048  {
2050 
2051  if (parse_grouplist(&gl, buf, s, data, err) == -1)
2052  goto bail;
2053 
2056 
2057  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
2058  goto bail;
2059  if (mutt_regexlist_add(&SubscribedLists, buf->data, REG_ICASE, err) != 0)
2060  goto bail;
2061  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
2062  goto bail;
2063  } while (MoreArgs(s));
2064 
2066  return MUTT_CMD_SUCCESS;
2067 
2068 bail:
2070  return MUTT_CMD_ERROR;
2071 }
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_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:275
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
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:542
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
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
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#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
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: email_globals.c:49
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 2081 of file init.c.

2083 {
2084  if (!buf || !s || !err)
2085  return MUTT_CMD_ERROR;
2086 
2087  mutt_buffer_reset(err);
2088 
2089  if (MoreArgs(s))
2090  {
2092 
2093  if (MoreArgs(s))
2094  {
2095  mutt_buffer_printf(err, _("%s: too many arguments"), "subscribe-to");
2096  return MUTT_CMD_WARNING;
2097  }
2098 
2099  if (buf->data && (*buf->data != '\0'))
2100  {
2101  /* Expand and subscribe */
2102  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), true) != 0)
2103  {
2104  mutt_buffer_printf(err, _("Could not subscribe to %s"), buf->data);
2105  return MUTT_CMD_ERROR;
2106  }
2107  else
2108  {
2109  mutt_message(_("Subscribed to %s"), buf->data);
2110  return MUTT_CMD_SUCCESS;
2111  }
2112  }
2113  else
2114  {
2115  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2116  return MUTT_CMD_ERROR;
2117  }
2118  }
2119 
2120  mutt_buffer_addstr(err, _("No folder specified"));
2121  return MUTT_CMD_WARNING;
2122 }
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:76
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:83
#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:191
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:128
#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:256
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
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:81
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1385
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 2128 of file init.c.

2130 {
2131  if (!buf || !s)
2132  return MUTT_CMD_ERROR;
2133 
2134  char *tmp = NULL;
2135 
2136  while (MoreArgs(s))
2137  {
2138  char *tag = NULL, *format = NULL;
2139 
2141  if (buf->data && (*buf->data != '\0'))
2142  tag = mutt_str_strdup(buf->data);
2143  else
2144  continue;
2145 
2147  format = mutt_str_strdup(buf->data);
2148 
2149  /* avoid duplicates */
2150  tmp = mutt_hash_find(TagFormats, format);
2151  if (tmp)
2152  {
2153  mutt_debug(LL_DEBUG3, "tag format '%s' already registered as '%s'\n", format, tmp);
2154  FREE(&tag);
2155  FREE(&format);
2156  continue;
2157  }
2158 
2159  mutt_hash_insert(TagFormats, format, tag);
2160  }
2161  return MUTT_CMD_SUCCESS;
2162 }
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:2614
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:81
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:76
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 2167 of file init.c.

2169 {
2170  if (!buf || !s)
2171  return MUTT_CMD_ERROR;
2172 
2173  char *tmp = NULL;
2174 
2175  while (MoreArgs(s))
2176  {
2177  char *tag = NULL, *transform = NULL;
2178 
2180  if (buf->data && (*buf->data != '\0'))
2181  tag = mutt_str_strdup(buf->data);
2182  else
2183  continue;
2184 
2186  transform = mutt_str_strdup(buf->data);
2187 
2188  /* avoid duplicates */
2189  tmp = mutt_hash_find(TagTransforms, tag);
2190  if (tmp)
2191  {
2192  mutt_debug(LL_DEBUG3, "tag transform '%s' already registered as '%s'\n", tag, tmp);
2193  FREE(&tag);
2194  FREE(&transform);
2195  continue;
2196  }
2197 
2198  mutt_hash_insert(TagTransforms, tag, transform);
2199  }
2200  return MUTT_CMD_SUCCESS;
2201 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:40
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:2614
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:81
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:76
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 2206 of file init.c.

2208 {
2209  struct Alias *a = NULL;
2210 
2211  do
2212  {
2214 
2215  if (mutt_str_strcmp("*", buf->data) == 0)
2216  {
2217  if (CurrentMenu == MENU_ALIAS)
2218  {
2219  TAILQ_FOREACH(a, &Aliases, entries)
2220  {
2221  a->del = true;
2222  }
2224  }
2225  else
2226  mutt_aliaslist_free(&Aliases);
2227  break;
2228  }
2229  else
2230  {
2231  TAILQ_FOREACH(a, &Aliases, entries)
2232  {
2233  if (mutt_str_strcasecmp(buf->data, a->name) == 0)
2234  {
2235  if (CurrentMenu == MENU_ALIAS)
2236  {
2237  a->del = true;
2239  }
2240  else
2241  {
2242  TAILQ_REMOVE(&Aliases, a, entries);
2243  mutt_alias_free(&a);
2244  }
2245  break;
2246  }
2247  }
2248  }
2249  } while (MoreArgs(s));
2250  return MUTT_CMD_SUCCESS;
2251 }
A shortcut for an email address.
Definition: alias.h:37
char * name
Definition: alias.h:39
void mutt_aliaslist_free(struct AliasList *a_list)
Free a List of Aliases.
Definition: alias.c:743
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
#define MoreArgs(buf)
Definition: buffer.h:44
bool del
Definition: alias.h:42
#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:2614
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:628
void mutt_alias_free(struct Alias **p)
Free an Alias.
Definition: alias.c:728
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:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 2256 of file init.c.

2258 {
2259  alternates_clean();
2260  do
2261  {
2263  mutt_regexlist_remove(&Alternates, buf->data);
2264 
2265  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2266  (mutt_regexlist_add(&UnAlternates, buf->data, REG_ICASE, err) != 0))
2267  {
2268  return MUTT_CMD_ERROR;
2269  }
2270 
2271  } while (MoreArgs(s));
2272 
2273  return MUTT_CMD_SUCCESS;
2274 }
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:139
#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:2614
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:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 2279 of file init.c.

2281 {
2282  char op;
2283  char *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:615
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:314
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
char * data
Pointer to data.
Definition: buffer.h:35
Ignore case when comparing strings.
Definition: string2.h:68
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:76
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:725
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:2614
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:118
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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:2614
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:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_MAILBOX_ANY);
2393  struct MailboxNode *np = NULL;
2394  struct MailboxNode *nptmp = NULL;
2395  STAILQ_FOREACH_SAFE(np, &ml, entries, nptmp)
2396  {
2397  /* Decide whether to delete all normal mailboxes or all virtual */
2398  bool virt = ((np->mailbox->magic == MUTT_NOTMUCH) && (data & MUTT_VIRTUAL));
2399  bool norm = ((np->mailbox->magic != MUTT_NOTMUCH) && !(data & MUTT_VIRTUAL));
2400  bool clear_this = clear_all && (virt || norm);
2401 
2402  /* Compare against path or desc? Ensure 'buf' is valid */
2403  if (!clear_this && tmp_valid)
2404  {
2405  clear_this =
2406  (mutt_str_strcasecmp(mutt_b2s(buf), mutt_b2s(np->mailbox->pathbuf)) == 0) ||
2407  (mutt_str_strcasecmp(mutt_b2s(buf), np->mailbox->name) == 0);
2408  }
2409 
2410  if (clear_this)
2411  {
2412 #ifdef USE_SIDEBAR
2413  mutt_sb_notify_mailbox(np->mailbox, false);
2414 #endif
2415 #ifdef USE_INOTIFY
2417 #endif
2418  if (Context && (Context->mailbox == np->mailbox))
2419  {
2420  np->mailbox->flags |= MB_HIDDEN;
2421  }
2422  else
2423  {
2425  }
2426  }
2427  }
2429  }
2430  return MUTT_CMD_SUCCESS;
2431 }
The "current" mailbox.
Definition: context.h:39
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:134
int mutt_monitor_remove(struct Mailbox *m)
Remove a watch for a mailbox.
Definition: monitor.c:511
Match any Mailbox type.
Definition: mailbox.h:45
Container for Accounts, Notifications.
Definition: neomutt.h:35
#define MoreArgs(buf)
Definition: buffer.h:44
char * name
A short name for the Mailbox.
Definition: mailbox.h:97
struct Mailbox * mailbox
Definition: context.h:53
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:117
struct MailboxList neomutt_mailboxlist_get_all(struct NeoMutt *n, enum MailboxType magic)
Get a List of all Mailboxes.
Definition: neomutt.c:156
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:360
int flags
e.g. MB_NORMAL
Definition: mailbox.h:146
#define mutt_b2s(buf)
Definition: buffer.h:42
#define MB_HIDDEN
Definition: mailbox.h:38
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
char * data
Pointer to data.
Definition: buffer.h:35
#define MUTT_VIRTUAL
Definition: init.h:109
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
struct Buffer * pathbuf
Definition: mailbox.h:95
Success: Command worked.
Definition: mutt_commands.h:35
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:143
bool account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
Definition: account.c:84
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
List of Mailboxes.
Definition: mailbox.h:157
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:159
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 2436 of file init.c.

2438 {
2439  struct ListNode *np = NULL, *tmp = NULL;
2440  size_t l;
2441 
2442  do
2443  {
2445  if (mutt_str_strcmp("*", buf->data) == 0)
2446  {
2447  mutt_list_free(&UserHeader);
2448  continue;
2449  }
2450 
2451  l = mutt_str_strlen(buf->data);
2452  if (buf->data[l - 1] == ':')
2453  l--;
2454 
2455  STAILQ_FOREACH_SAFE(np, &UserHeader, entries, tmp)
2456  {
2457  if ((mutt_str_strncasecmp(buf->data, np->data, l) == 0) && (np->data[l] == ':'))
2458  {
2459  STAILQ_REMOVE(&UserHeader, np, ListNode, entries);
2460  FREE(&np->data);
2461  FREE(&np);
2462  }
2463  }
2464  } while (MoreArgs(s));
2465  return MUTT_CMD_SUCCESS;
2466 }
#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:666
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
#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:656
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
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:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 2473 of file init.c.

2475 {
2476  do
2477  {
2479  /* Check for deletion of entire list */
2480  if (mutt_str_strcmp(buf->data, "*") == 0)
2481  {
2482  mutt_list_free((struct ListHead *) data);
2483  break;
2484  }
2485  remove_from_stailq((struct ListHead *) data, buf->data);
2486  } while (MoreArgs(s));
2487 
2488  return MUTT_CMD_SUCCESS;
2489 }
static void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: init.c:725
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
#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:2614
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:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
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 2494 of file init.c.

2496 {
2497  enum CommandResult rc;
2498 
2499  rc = parse_unreplace_list(buf, s, data, err);
2500  if (rc == MUTT_CMD_SUCCESS)
2502  return rc;
2503 }
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:211
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:673
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 2508 of file init.c.

2510 {
2512  do
2513  {
2516 
2517  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2518  (mutt_regexlist_add(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0))
2519  {
2520  return MUTT_CMD_ERROR;
2521  }
2522  } while (MoreArgs(s));
2523 
2524  return MUTT_CMD_SUCCESS;
2525 }
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:2614
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:615
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: email_globals.c:49
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 2535 of file init.c.

2537 {
2538  if (!buf || !s || !err)
2539  return MUTT_CMD_ERROR;
2540 
2541  if (MoreArgs(s))
2542  {
2544 
2545  if (MoreArgs(s))
2546  {
2547  mutt_buffer_printf(err, _("%s: too many arguments"), "unsubscribe-from");
2548  return MUTT_CMD_WARNING;
2549  }
2550 
2551  if (buf->data && (*buf->data != '\0'))
2552  {
2553  /* Expand and subscribe */
2554  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), false) != 0)
2555  {
2556  mutt_buffer_printf(err, _("Could not unsubscribe from %s"), buf->data);
2557  return MUTT_CMD_ERROR;
2558  }
2559  else
2560  {
2561  mutt_message(_("Unsubscribed from %s"), buf->data);
2562  return MUTT_CMD_SUCCESS;
2563  }
2564  }
2565  else
2566  {
2567  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2568  return MUTT_CMD_ERROR;
2569  }
2570  }
2571 
2572  mutt_buffer_addstr(err, _("No folder specified"));
2573  return MUTT_CMD_WARNING;
2574 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:83
#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:191
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:128
#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:256
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
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:81
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1385
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 2583 of file init.c.

2584 {
2585  for (int i = 0; Commands[i].name; i++)
2586  if (mutt_str_strcmp(s, Commands[i].name) == 0)
2587  return &Commands[i];
2588  return NULL;
2589 }
const char * name
Name of the command.
Definition: mutt_commands.h:54
const struct Command Commands[]
Definition: init.h:4899
const char * name
Definition: pgpmicalg.c:45
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
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 2614 of file init.c.

2615 {
2616  if (!dest || !tok)
2617  return -1;
2618 
2619  char ch;
2620  char qc = '\0'; /* quote char */
2621  char *pc = NULL;
2622 
2623  mutt_buffer_reset(dest);
2624 
2625  SKIPWS(tok->dptr);
2626  while ((ch = *tok->dptr))
2627  {
2628  if (qc == '\0')
2629  {
2630  if ((IS_SPACE(ch) && !(flags & MUTT_TOKEN_SPACE)) ||
2631  ((ch == '#') && !(flags & MUTT_TOKEN_COMMENT)) ||
2632  ((ch == '=') && (flags & MUTT_TOKEN_EQUAL)) ||
2633  ((ch == '?') && (flags & MUTT_TOKEN_QUESTION)) ||
2634  ((ch == ';') && !(flags & MUTT_TOKEN_SEMICOLON)) ||
2635  ((flags & MUTT_TOKEN_PATTERN) && strchr("~%=!|", ch)))
2636  {
2637  break;
2638  }
2639  }
2640 
2641  tok->dptr++;
2642 
2643  if (ch == qc)
2644  qc = 0; /* end of quote */
2645  else if (!qc && ((ch == '\'') || (ch == '"')) && !(flags & MUTT_TOKEN_QUOTE))
2646  qc = ch;
2647  else if ((ch == '\\') && (qc != '\''))
2648  {
2649  if (tok->dptr[0] == '\0')
2650  return -1; /* premature end of token */
2651  switch (ch = *tok->dptr++)
2652  {
2653  case 'c':
2654  case 'C':
2655  if (tok->dptr[0] == '\0')
2656  return -1; /* premature end of token */
2657  mutt_buffer_addch(dest, (toupper((unsigned char) tok->dptr[0]) - '@') & 0x7f);
2658  tok->dptr++;
2659  break;
2660  case 'e':
2661  mutt_buffer_addch(dest, '\033'); // Escape
2662  break;
2663  case 'f':
2664  mutt_buffer_addch(dest, '\f');
2665  break;
2666  case 'n':
2667  mutt_buffer_addch(dest, '\n');
2668  break;
2669  case 'r':
2670  mutt_buffer_addch(dest, '\r');
2671  break;
2672  case 't':
2673  mutt_buffer_addch(dest, '\t');
2674  break;
2675  default:
2676  if (isdigit((unsigned char) ch) && isdigit((unsigned char) tok->dptr[0]) &&
2677  isdigit((unsigned char) tok->dptr[1]))
2678  {
2679  mutt_buffer_addch(dest, (ch << 6) + (tok->dptr[0] << 3) + tok->dptr[1] - 3504);
2680  tok->dptr += 2;
2681  }
2682  else
2683  mutt_buffer_addch(dest, ch);
2684  }
2685  }
2686  else if ((ch == '^') && (flags & MUTT_TOKEN_CONDENSE))
2687  {
2688  if (tok->dptr[0] == '\0')
2689  return -1; /* premature end of token */
2690  ch = *tok->dptr++;
2691  if (ch == '^')
2692  mutt_buffer_addch(dest, ch);
2693  else if (ch == '[')
2694  mutt_buffer_addch(dest, '\033'); // Escape
2695  else if (isalpha((unsigned char) ch))
2696  mutt_buffer_addch(dest, toupper((unsigned char) ch) - '@');
2697  else
2698  {
2699  mutt_buffer_addch(dest, '^');
2700  mutt_buffer_addch(dest, ch);
2701  }
2702  }
2703  else if ((ch == '`') && (!qc || (qc == '"')))
2704  {
2705  FILE *fp = NULL;
2706  pid_t pid;
2707  char *ptr = NULL;
2708  size_t expnlen;
2709  struct Buffer expn;
2710  int line = 0;
2711 
2712  pc = tok->dptr;
2713  do
2714  {
2715  pc = strpbrk(pc, "\\`");
2716  if (pc)
2717  {
2718  /* skip any quoted chars */
2719  if (*pc == '\\')
2720  pc += 2;
2721  }
2722  } while (pc && (pc[0] != '`'));
2723  if (!pc)
2724  {
2725  mutt_debug(LL_DEBUG1, "mismatched backticks\n");
2726  return -1;
2727  }
2728  struct Buffer cmd;
2729  mutt_buffer_init(&cmd);
2730  *pc = '\0';
2731  if (flags & MUTT_TOKEN_BACKTICK_VARS)
2732  {
2733  /* recursively extract tokens to interpolate variables */
2734  mutt_extract_token(&cmd, tok,
2735  MUTT_TOKEN_QUOTE | MUTT_TOKEN_SPACE | MUTT_TOKEN_COMMENT |
2736  MUTT_TOKEN_SEMICOLON | MUTT_TOKEN_NOSHELL);
2737  }
2738  else
2739  {
2740  cmd.data = mutt_str_strdup(tok->dptr);
2741  }
2742  *pc = '`';
2743  pid = mutt_create_filter(cmd.data, NULL, &fp, NULL);
2744  if (pid < 0)
2745  {
2746  mutt_debug(LL_DEBUG1, "unable to fork command: %s\n", cmd);
2747  FREE(&cmd.data);
2748  return -1;
2749  }
2750  FREE(&cmd.data);
2751 
2752  tok->dptr = pc + 1;
2753 
2754  /* read line */
2755  mutt_buffer_init(&expn);
2756  expn.data = mutt_file_read_line(NULL, &expn.dsize, fp, &line, 0);
2757  mutt_file_fclose(&fp);
2758  mutt_wait_filter(pid);
2759 
2760  /* if we got output, make a new string consisting of the shell output
2761  * plus whatever else was left on the original line */
2762  /* BUT: If this is inside a quoted string, directly add output to
2763  * the token */
2764  if (expn.data && qc)
2765  {
2766  mutt_buffer_addstr(dest, expn.data);
2767  FREE(&expn.data);
2768  }
2769  else if (expn.data)
2770  {
2771  expnlen = mutt_str_strlen(expn.data);
2772  tok->dsize = expnlen + mutt_str_strlen(tok->dptr) + 1;
2773  ptr = mutt_mem_malloc(tok->dsize);
2774  memcpy(ptr, expn.data, expnlen);
2775  strcpy(ptr + expnlen, tok->dptr);
2776  if (tok->destroy)
2777  FREE(&tok->data);
2778  tok->data = ptr;
2779  tok->dptr = ptr;
2780  tok->destroy = 1; /* mark that the caller should destroy this data */
2781  ptr = NULL;
2782  FREE(&expn.data);
2783  }
2784  }
2785  else if ((ch == '$') && (!qc || (qc == '"')) &&
2786  ((tok->dptr[0] == '{') || isalpha((unsigned char) tok->dptr[0])))
2787  {
2788  const char *env = NULL;
2789  char *var = NULL;
2790 
2791  if (tok->dptr[0] == '{')
2792  {
2793  pc = strchr(tok->dptr, '}');
2794  if (pc)
2795  {
2796  var = mutt_str_substr_dup(tok->dptr + 1, pc);
2797  tok->dptr = pc + 1;
2798 
2799  if ((flags & MUTT_TOKEN_NOSHELL))
2800  {
2801  mutt_buffer_addch(dest, ch);
2802  mutt_buffer_addch(dest, '{');
2803  mutt_buffer_addstr(dest, var);
2804  mutt_buffer_addch(dest, '}');
2805  FREE(&var);
2806  }
2807  }
2808  }
2809  else
2810  {
2811  for (pc = tok->dptr; isalnum((unsigned char) *pc) || (pc[0] == '_'); pc++)
2812  ;
2813  var = mutt_str_substr_dup(tok->dptr, pc);
2814  tok->dptr = pc;
2815  }
2816  if (var)
2817  {
2818  struct Buffer result;
2819  mutt_buffer_init(&result);
2820  int rc = cs_str_string_get(Config, var, &result);
2821 
2822  if (CSR_RESULT(rc) == CSR_SUCCESS)
2823  {
2824  mutt_buffer_addstr(dest, result.data);
2825  FREE(&result.data);
2826  }
2827  else if ((env = myvar_get(var)))
2828  {
2829  mutt_buffer_addstr(dest, env);
2830  }
2831  else if (!(flags & MUTT_TOKEN_NOSHELL) && (env = mutt_str_getenv(var)))
2832  {
2833  mutt_buffer_addstr(dest, env);
2834  }
2835  else
2836  {
2837  mutt_buffer_addch(dest, ch);
2838  mutt_buffer_addstr(dest, var);
2839  }
2840  FREE(&var);
2841  }
2842  }
2843  else
2844  mutt_buffer_addch(dest, ch);
2845  }
2846  mutt_buffer_addch(dest, 0); /* terminate the string */
2847  SKIPWS(tok->dptr);
2848  return 0;
2849 }
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:76
#define CSR_RESULT(x)
Definition: set.h:62
#define MUTT_TOKEN_COMMENT
Don&#39;t reap comments.
Definition: mutt.h:82
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:663
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1084
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:697
#define SKIPWS(ch)
Definition: string2.h:47
#define MUTT_TOKEN_NOSHELL
Don&#39;t expand environment variables.
Definition: mutt.h:85
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:256
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:46
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:80
#define MUTT_TOKEN_CONDENSE
^(char) to control chars (macros)
Definition: mutt.h:78
const char * line
Definition: common.c:36
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
char * dptr
Current read/write position.
Definition: buffer.h:36
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:79
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:271
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:83
#define IS_SPACE(ch)
Definition: string2.h:38
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:84
#define FREE(x)
Definition: memory.h:40
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:77
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:61
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:579
#define MUTT_TOKEN_PATTERN
~%=!| are terms (for patterns)
Definition: mutt.h:81
#define MUTT_TOKEN_QUESTION
Treat &#39;?&#39; as a special.
Definition: mutt.h:86
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 2857 of file init.c.

2858 {
2859  if (!am || !*am)
2860  return;
2861 
2862  regfree(&(*am)->minor_regex);
2863  FREE(&(*am)->major);
2864  FREE(am);
2865 }
#define FREE(x)
Definition: memory.h:40
void mutt_free_opts ( void  )

clean up before quitting

Definition at line 2870 of file init.c.

2871 {
2873 
2874  FREE(&Matches);
2875 
2876  mutt_aliaslist_free(&Aliases);
2877 
2878  mutt_regexlist_free(&Alternates);
2882  mutt_regexlist_free(&UnAlternates);
2885 
2890 
2891  /* Lists of strings */
2892  mutt_list_free(&AlternativeOrderList);
2893  mutt_list_free(&AutoViewList);
2894  mutt_list_free(&HeaderOrderList);
2897  mutt_list_free(&MimeLookupList);
2898  mutt_list_free(&Muttrc);
2900 #ifdef USE_SIDEBAR
2901  mutt_list_free(&SidebarWhitelist);
2902 #endif
2904  mutt_list_free(&UserHeader);
2905 
2906  /* Lists of AttachMatch */
2911 
2912  mutt_free_colors();
2913 
2914  FREE(&CurrentFolder);
2915  FREE(&HomeDir);
2916  FREE(&LastFolder);
2917  FREE(&ShortHostname);
2918  FREE(&Username);
2919 
2922 
2924 
2925  mutt_hist_free();
2926  mutt_free_keys();
2927 
2929 }
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:743
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:40
static struct ListHead MuttrcStack
Definition: init.c:79
struct ReplaceList SpamList
List of regexes and patterns to match spam emails.
Definition: email_globals.c:44
void mutt_list_free_type(struct ListHead *h, list_free_t fn)
Free a List of type.
Definition: list.c:145
struct ListHead MailToAllow
List of permitted fields in a mailto: uri.
Definition: email_globals.c:47
WHERE struct Hash * TagFormats
Hash table of tag-formats (tag -> format string)
Definition: globals.h:59
void mutt_delete_hooks(HookFlags type)
Delete matching hooks.
Definition: hook.c:315
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:448
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h: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:92
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:1578
#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:55
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:2857
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
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 2937 of file init.c.

2938 {
2939  for (const struct Command *c = Commands; c->name; c++)
2940  {
2941  if (((c->func == mutt_parse_hook) || (c->func == mutt_parse_idxfmt_hook)) &&
2942  (mutt_str_strcasecmp(c->name, name) == 0))
2943  {
2944  return c->data;
2945  }
2946  }
2947  return MUTT_HOOK_NO_FLAGS;
2948 }
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:4899
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:86
const char * name
Definition: pgpmicalg.c:45
enum CommandResult mutt_parse_idxfmt_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;index-format-hook&#39; command - Implements command_t.
Definition: hook.c:362
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
#define MUTT_HOOK_NO_FLAGS
No flags are set.
Definition: hook.h:43
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 2957 of file init.c.

2958 {
2959  char buf[1024];
2960  int need_pause = 0;
2961  struct Buffer err;
2962 
2963  mutt_buffer_init(&err);
2964  mutt_buffer_increase_size(&err, 256);
2965 
2967  /* reverse alias keys need to be strdup'ed because of idna conversions */
2972 
2973  mutt_menu_init();
2974 
2975  snprintf(AttachmentMarker, sizeof(AttachmentMarker), "\033]9;%" PRIu64 "\a", // Escape
2976  mutt_rand64());
2977 
2978  snprintf(ProtectedHeaderMarker, sizeof(ProtectedHeaderMarker), "\033]8;%ld\a", // Escape
2979  (long) time(NULL));
2980 
2981  /* "$spoolfile" precedence: config file, environment */
2982  const char *p = mutt_str_getenv("MAIL");
2983  if (!p)
2984  p = mutt_str_getenv("MAILDIR");
2985  if (!p)
2986  {
2987 #ifdef HOMESPOOL
2988  mutt_path_concat(buf, NONULL(HomeDir), MAILPATH, sizeof(buf));
2989 #else
2990  mutt_path_concat(buf, MAILPATH, NONULL(Username), sizeof(buf));
2991 #endif
2992  p = buf;
2993  }
2994  cs_str_initial_set(Config, "spoolfile", p, NULL);
2995  cs_str_reset(Config, "spoolfile", NULL);
2996 
2997  p = mutt_str_getenv("REPLYTO");
2998  if (p)
2999  {
3000  struct Buffer tmp, token;
3001 
3002  snprintf(buf, sizeof(buf), "Reply-To: %s", p);
3003 
3004  mutt_buffer_init(&tmp);
3005  tmp.data = buf;
3006  tmp.dptr = buf;
3007  tmp.dsize = mutt_str_strlen(buf);
3008 
3009  mutt_buffer_init(&token);
3010  parse_my_hdr(&token, &tmp, 0, &err); /* adds to UserHeader */
3011  FREE(&token.data);
3012  }
3013 
3014  p = mutt_str_getenv("EMAIL");
3015  if (p)
3016  {
3017  cs_str_initial_set(Config, "from", p, NULL);
3018  cs_str_reset(Config, "from", NULL);
3019  }
3020 
3021  /* "$mailcap_path" precedence: config file, environment, code */
3022  const char *env_mc = mutt_str_getenv("MAILCAPS");
3023  if (env_mc)
3024  cs_str_string_set(Config, "mailcap_path", env_mc, NULL);
3025 
3026  /* "$tmpdir" precedence: config file, environment, code */
3027  const char *env_tmp = mutt_str_getenv("TMPDIR");
3028  if (env_tmp)
3029  cs_str_string_set(Config, "tmpdir", env_tmp, NULL);
3030 
3031  /* "$visual", "$editor" precedence: config file, environment, code */
3032  const char *env_ed = mutt_str_getenv("VISUAL");
3033  if (!env_ed)
3034  env_ed = mutt_str_getenv("EDITOR");
3035  if (env_ed)
3036  {
3037  cs_str_string_set(Config, "editor", env_ed, NULL);
3038  cs_str_string_set(Config, "visual", env_ed, NULL);
3039  }
3040 
3043 
3044  Matches = mutt_mem_calloc(MatchesListsize, sizeof(char *));
3045 
3047 
3048 #ifdef HAVE_GETSID
3049  /* Unset suspend by default if we're the session leader */
3050  if (getsid(0) == getpid())
3051  C_Suspend = false;
3052 #endif
3053 
3054  /* RFC2368, "4. Unsafe headers"
3055  * The creator of a mailto URL can't expect the resolver of a URL to
3056  * understand more than the "subject" and "body" headers. Clients that
3057  * resolve mailto URLs into mail messages should be able to correctly
3058  * create RFC822-compliant mail messages using the "subject" and "body"
3059  * headers. */
3060  add_to_stailq(&MailToAllow, "body");
3061  add_to_stailq(&MailToAllow, "subject");
3062  /* Cc, In-Reply-To, and References help with not breaking threading on
3063  * mailing lists, see https://github.com/neomutt/neomutt/issues/115 */
3064  add_to_stailq(&MailToAllow, "cc");
3065  add_to_stailq(&MailToAllow, "in-reply-to");
3066  add_to_stailq(&MailToAllow, "references");
3067 
3068  if (STAILQ_EMPTY(&Muttrc))
3069  {
3070  const char *xdg_cfg_home = mutt_str_getenv("XDG_CONFIG_HOME");
3071 
3072  if (!xdg_cfg_home && HomeDir)
3073  {
3074  snprintf(buf, sizeof(buf), "%s/.config", HomeDir);
3075  xdg_cfg_home = buf;
3076  }
3077 
3078  char *config = find_cfg(HomeDir, xdg_cfg_home);
3079  if (config)
3080  {
3081  mutt_list_insert_tail(&Muttrc, config);
3082  }
3083  }
3084  else
3085  {
3086  struct ListNode *np = NULL;
3087  STAILQ_FOREACH(np, &Muttrc, entries)
3088  {
3089  mutt_str_strfcpy(buf, np->data, sizeof(buf));
3090  FREE(&np->data);
3091  mutt_expand_path(buf, sizeof(buf));
3092  np->data = mutt_str_strdup(buf);
3093  if (access(np->data, F_OK))
3094  {
3095  mutt_perror(np->data);
3096  return 1; // TEST10: neomutt -F missing
3097  }
3098  }
3099  }
3100 
3101  if (!STAILQ_EMPTY(&Muttrc))
3102  {
3103  cs_str_string_set(Config, "alias_file", STAILQ_FIRST(&Muttrc)->data, NULL);
3104  }
3105 
3106  /* Process the global rc file if it exists and the user hasn't explicitly
3107  * requested not to via "-n". */
3108  if (!skip_sys_rc)
3109  {
3110  do
3111  {
3112  if (mutt_set_xdg_path(XDG_CONFIG_DIRS, buf, sizeof(buf)))
3113  break;
3114 
3115  snprintf(buf, sizeof(buf), "%s/neomuttrc", SYSCONFDIR);
3116  if (access(buf, F_OK) == 0)
3117  break;
3118 
3119  snprintf(buf, sizeof(buf), "%s/Muttrc", SYSCONFDIR);
3120  if (access(buf, F_OK) == 0)
3121  break;
3122 
3123  snprintf(buf, sizeof(buf), "%s/neomuttrc", PKGDATADIR);
3124  if (access(buf, F_OK) == 0)
3125  break;
3126 
3127  snprintf(buf, sizeof(buf), "%s/Muttrc", PKGDATADIR);
3128  } while (false);
3129 
3130  if (access(buf, F_OK) == 0)
3131  {
3132  if (source_rc(buf, &err) != 0)
3133  {
3134  mutt_error("%s", err.data);
3135  need_pause = 1; // TEST11: neomutt (error in /etc/neomuttrc)
3136  }
3137  }
3138  }
3139 
3140  /* Read the user's initialization file. */
3141  struct ListNode *np = NULL;
3142  STAILQ_FOREACH(np, &Muttrc, entries)
3143  {
3144  if (np->data)
3145  {
3146  if (source_rc(np->data, &err) != 0)
3147  {
3148  mutt_error("%s", err.data);
3149  need_pause = 1; // TEST12: neomutt (error in ~/.neomuttrc)
3150  }
3151  }
3152  }
3153 
3154  if (execute_commands(commands) != 0)
3155  need_pause = 1; // TEST13: neomutt -e broken
3156 
3157  if (!get_hostname())
3158  return 1;
3159 
3160  if (!C_Realname)
3161  {
3162  struct passwd *pw = getpwuid(getuid());
3163  if (pw)
3164  {
3165  char name[256];
3166  C_Realname = mutt_str_strdup(mutt_gecos_name(name, sizeof(name), pw));
3167  }
3168  }
3169  cs_str_initial_set(Config, "realname", C_Realname, NULL);
3170 
3171  if (need_pause && !OptNoCurses)
3172  {
3174  if (mutt_any_key_to_continue(NULL) == 'q')
3175  return 1; // TEST14: neomutt -e broken (press 'q')
3176  }
3177 
3178  mutt_file_mkdir(C_Tmpdir, S_IRWXU);
3179 
3180  mutt_hist_init();
3182 
3183 #ifdef USE_NOTMUCH
3184  if (C_VirtualSpoolfile)
3185  {
3186  /* Find the first virtual folder and open it */
3187  struct MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_NOTMUCH);
3188  struct MailboxNode *mp = STAILQ_FIRST(&ml);
3189  if (mp)
3190  cs_str_string_set(Config, "spoolfile", mutt_b2s(mp->mailbox->pathbuf), NULL);
3192  }
3193 #endif
3194 
3195  FREE(&err.data);
3196  return 0;
3197 }
WHERE char * Username
User&#39;s login name.
Definition: globals.h:51
char * mutt_path_concat(char *d, const char *dir, const char *fname, size_t l)
Join a directory name and a filename.
Definition: path.c:329
#define NONULL(x)
Definition: string2.h:37
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
#define mutt_perror(...)
Definition: logging.h:85
void mutt_buffer_increase_size(struct Buffer *buf, size_t new_size)
Increase the allocated size of a buffer.
Definition: buffer.c:339
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:40
int cs_str_string_set(const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Definition: set.c:626
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:134
WHERE char AttachmentMarker[256]
Unique ANSI string to mark PGP messages in an email.
Definition: globals.h:45
struct ListHead MailToAllow
List of permitted fields in a mailto: uri.
Definition: email_globals.c:47
String manipulation buffer.
Definition: buffer.h:33
static int execute_commands(struct ListHead *p)
Execute a set of NeoMutt commands.
Definition: init.c:284
static int source_rc(const char *rcfile_path, struct Buffer *err)
Read an initialization file.
Definition: init.c:751
WHERE struct Hash * TagFormats
Hash table of tag-formats (tag -> format string)
Definition: globals.h:59
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:39
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:45
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
Index panel (list of emails)
Definition: keymap.h:76
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
Definition: charset.c:973
static enum CommandResult parse_my_hdr(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;my_hdr&#39; command - Implements command_t.
Definition: init.c:1399
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
Definition: logging.c:356
static char * find_cfg(const char *home, const char *xdg_cfg_home)
Find a config file.
Definition: init.c:315
Container for Accounts, Notifications.
Definition: neomutt.h:35
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1084
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:486
#define MUTT_HASH_STRCASECMP
use strcasecmp() to compare keys
Definition: hash.h:75
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
void mutt_hist_read_file(void)
Read the History from a file.
Definition: history.c:584
int mutt_file_mkdir(const char *path, mode_t mode)
Recursively create directories.
Definition: file.c:872
const char * name
Definition: pgpmicalg.c:45
struct MailboxList neomutt_mailboxlist_get_all(struct NeoMutt *n, enum MailboxType magic)
Get a List of all Mailboxes.
Definition: neomutt.c:156
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:48
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
#define mutt_b2s(buf)
Definition: buffer.h:42
#define MUTT_HASH_ALLOW_DUPS
allow duplicate keys to be inserted
Definition: hash.h:77
static int MatchesListsize
Definition: init.c:94
void mutt_grouplist_init(void)
Initialize the GroupList singleton.
Definition: group.c:45
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
struct Hash * mutt_hash_new(size_t nelem, HashFlags flags)
Create a new Hash table (with string keys)
Definition: hash.c:276
char * mutt_ch_get_langinfo_charset(void)
Get the user&#39;s choice of character set.
Definition: charset.c:426
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
void mutt_hist_init(void)
Create a set of empty History ring buffers.
Definition: history.c:462
uint64_t mutt_rand64(void)
Create a 64-bit random number.
Definition: muttlib.c:543
int mutt_set_xdg_path(enum XdgType type, char *buf, size_t bufsize)
Find an XDG path or its fallback.
Definition: muttlib.c:1561
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
WHERE char ProtectedHeaderMarker[256]
Unique ANSI string to mark protected headers in an email.
Definition: globals.h:46
struct Buffer * pathbuf
Definition: mailbox.h:95
int cs_str_reset(const struct ConfigSet *cs, const char *name, struct Buffer *err)
Reset a config item to its initial value.
Definition: set.c:422
WHERE struct Hash * ReverseAliases
Hash table of aliases (email address -> alias)
Definition: globals.h:58
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:544
char * data
Definition: list.h:35
WHERE bool C_Suspend
Config: Allow the user to suspend NeoMutt using &#39;^Z&#39;.
Definition: globals.h:254
char * mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw)
Lookup a user&#39;s real name in /etc/passwd.
Definition: muttlib.c:362
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define mutt_error(...)
Definition: logging.h:84
char * C_Tmpdir
Config: Directory for temporary files.
Definition: file.c:52
static const char ** Matches
Definition: init.c:92
#define FREE(x)
Definition: memory.h:40
#define STAILQ_EMPTY(head)
Definition: queue.h:346
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:54
List of Mailboxes.
Definition: mailbox.h:157
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:86
WHERE char * C_Realname
Config: Real name of the user.
Definition: globals.h:136
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:61
#define MUTT_HASH_STRDUP_KEYS
make a copy of the keys
Definition: hash.h:76
A List node for strings.
Definition: list.h:33
static bool get_hostname(void)
Find the Fully-Qualified Domain Name.
Definition: init.c:388
XDG system dir: /etc/xdg.
Definition: protos.h:48
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define MUTT_HASH_NO_FLAGS
No flags are set.
Definition: hash.h:74
int log_disp_terminal(time_t stamp, const char *file, int line, const char *function, int level,...)
Save a log line to the terminal - Implements log_dispatcher_t.
Definition: logging.c:449
static void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: init.c:118
WHERE bool C_VirtualSpoolfile
Config: (notmuch) Use the first virtual mailbox as a spool file.
Definition: globals.h:285
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:159
enum CommandResult mutt_parse_rc_line ( char *  line,
struct Buffer token,
struct Buffer err 
)

Parse a line of user config.

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

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

Definition at line 3211 of file init.c.

3213 {
3214  int i;
3215  enum CommandResult rc = MUTT_CMD_SUCCESS;
3216  struct Buffer expn;
3217 
3218  if (!line || !*line)
3219  return 0;
3220 
3221  mutt_buffer_init(&expn);
3222  expn.data = line;
3223  expn.dptr = line;
3224  expn.dsize = mutt_str_strlen(line);
3225 
3226  *err->data = 0;
3227 
3228  SKIPWS(expn.dptr);
3229  while (*expn.dptr)
3230  {
3231  if (*expn.dptr == '#')
3232  break; /* rest of line is a comment */
3233  if (*expn.dptr == ';')
3234  {
3235  expn.dptr++;
3236  continue;
3237  }
3238  mutt_extract_token(token, &expn, MUTT_TOKEN_NO_FLAGS);
3239  for (i = 0; Commands[i].name; i++)
3240  {
3241  if (mutt_str_strcmp(token->data, Commands[i].name) == 0)
3242  {
3243  rc = Commands[i].func(token, &expn, Commands[i].data, err);
3244  if (rc != MUTT_CMD_SUCCESS)
3245  { /* -1 Error, +1 Finish */
3246  goto finish; /* Propagate return code */
3247  }
3248  break; /* Continue with next command */
3249  }
3250  }
3251  if (!Commands[i].name)
3252  {
3253  mutt_buffer_printf(err, _("%s: unknown command"), NONULL(token->data));
3254  rc = MUTT_CMD_ERROR;
3255  break; /* Ignore the rest of the line */
3256  }
3257  }
3258 finish:
3259  if (expn.destroy)
3260  FREE(&expn.data);
3261  return rc;
3262 }
#define NONULL(x)
Definition: string2.h:37
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
command_t func
Function to parse the command.
Definition: mutt_commands.h:55
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
const char * name
Name of the command.
Definition: mutt_commands.h:54
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:191
const struct Command Commands[]
Definition: init.h:4899
const char * name
Definition: pgpmicalg.c:45
#define SKIPWS(ch)
Definition: string2.h:47
const char * line
Definition: common.c:36
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2614
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
#define FREE(x)
Definition: