NeoMutt  2018-07-16 +1360-3df4a2
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 "email/lib.h"
#include "mutt.h"
#include "init.h"
#include "account.h"
#include "alias.h"
#include "context.h"
#include "filter.h"
#include "hcache/hcache.h"
#include "keymap.h"
#include "monitor.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mutt_window.h"
#include "mx.h"
#include "myvar.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "protos.h"
#include "sidebar.h"
#include "version.h"
#include "notmuch/mutt_notmuch.h"
#include "imap/imap.h"
#include <libintl.h>
+ Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define MAXERRS   128
 
#define NUMVARS   mutt_array_size(MuttVars)
 
#define NUMCOMMANDS   mutt_array_size(Commands)
 

Enumerations

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

Functions

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

Detailed Description

Config/command parsing.

Authors
  • Michael R. Elkins

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

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

Definition in file init.c.

Macro Definition Documentation

#define MAXERRS   128

Definition at line 79 of file init.c.

#define NUMVARS   mutt_array_size(MuttVars)

Definition at line 81 of file init.c.

#define NUMCOMMANDS   mutt_array_size(Commands)

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

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void alternates_clean ( void  )
static

Clear the recipient valid flag of all emails.

Definition at line 137 of file init.c.

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

+ Here is the caller graph for this function:

static void attachments_clean ( void  )
static

always wise to do what someone else did before

Definition at line 149 of file init.c.

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

+ Here is the caller graph for this function:

static void matches_ensure_morespace ( int  current)
static

Allocate more space for auto-completion.

Parameters
currentCurrent allocation

Definition at line 162 of file init.c.

163 {
164  if (current <= (MatchesListsize - 2))
165  return;
166 
167  int base_space = MAX(NUMVARS, NUMCOMMANDS) + 1;
168  int extra_space = MatchesListsize - base_space;
169  extra_space *= 2;
170  const int space = base_space + extra_space;
171  mutt_mem_realloc(&Matches, space * sizeof(char *));
172  memset(&Matches[current + 1], 0, space - current);
173  MatchesListsize = space;
174 }
#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:124
static int MatchesListsize
Definition: init.c:92
#define NUMVARS
Definition: init.c:81
static const char ** Matches
Definition: init.c:90
#define NUMCOMMANDS
Definition: init.c:82

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

helper function for completion

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

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

Definition at line 185 of file init.c.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void clear_subject_mods ( void  )
static

Clear out all modified email subjects.

Definition at line 209 of file init.c.

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

+ Here is the caller graph for this function:

static int complete_all_nm_tags ( const char *  pt)
static

Pass a list of Notmuch tags to the completion code.

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

Definition at line 225 of file init.c.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int execute_commands ( struct ListHead *  p)
static

Execute a set of NeoMutt commands.

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

Definition at line 282 of file init.c.

283 {
284  struct Buffer err, token;
285 
286  mutt_buffer_init(&err);
287  err.dsize = 256;
288  err.data = mutt_mem_malloc(err.dsize);
289  mutt_buffer_init(&token);
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"), err.data);
296  FREE(&token.data);
297  FREE(&err.data);
298 
299  return -1;
300  }
301  }
302  FREE(&token.data);
303  FREE(&err.data);
304 
305  return 0;
306 }
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
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:99
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
char * data
Definition: list.h:35
#define mutt_error(...)
Definition: logging.h:88
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:66
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:3259

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Find a config file.

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

Definition at line 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:383

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static char* getmailname ( void  )
static

Try to retrieve the FQDN from mailname files.

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

Definition at line 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:630
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
#define mutt_array_size(x)
Definition: memory.h:33
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:546
#define FREE(x)
Definition: memory.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool get_hostname ( void  )
static

Find the Fully-Qualified Domain Name.

Return values
trueSuccess
falseError, failed to find any name

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

Definition at line 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:36
#define mutt_perror(...)
Definition: logging.h:89
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:662
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:509
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:99
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:383
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:114
char * mutt_str_substr_dup(const char *begin, const char *end)
Duplicate a sub-string.
Definition: string.c:575

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Parse the "attachments" command.

Parameters
bufBuffer for temporary storage
sBuffer containing the attachments command
headList of AttachMatch to add to
errBuffer for error messages
Return values
enume.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  {
476  mutt_extract_token(buf, s, 0);
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 = REGCOMP(&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 }
int major_int
Definition: mutt.h:130
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
size_t dsize
length of data
Definition: buffer.h:37
#define MoreArgs(buf)
Definition: buffer.h:44
const char * major
Definition: mutt.h:129
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:58
static void attachments_clean(void)
always wise to do what someone else did before
Definition: init.c:149
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:99
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:383
regex_t minor_regex
Definition: mutt.h:132
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:624
int mutt_check_mime_type(const char *s)
Check a MIME type string.
Definition: parse.c:294
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
#define REGCOMP(preg, regex, cflags)
Compile a regular expression.
Definition: regex3.h:52
An attachment matching a regex.
Definition: mutt.h:127
const char * minor
Definition: mutt.h:131
Log at debug level 3.
Definition: logging.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Parse a group context.

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

Definition at line 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 
553  mutt_extract_token(buf, s, 0);
554 
556 
557  if (!MoreArgs(s))
558  {
559  mutt_buffer_strcpy(err, _("out of arguments"));
560  goto bail;
561  }
562 
563  mutt_extract_token(buf, s, 0);
564  }
565 
566  return 0;
567 
568 bail:
569  return -1;
570 }
struct Group * mutt_pattern_group(const char *k)
Match a pattern to a Group.
Definition: group.c:64
#define _(a)
Definition: message.h:28
#define MoreArgs(buf)
Definition: buffer.h:44
void mutt_grouplist_add(struct GroupList *head, struct Group *group)
Add a Group to a GroupList.
Definition: group.c:133
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:316
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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:624

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Parse a string replacement rule - Implements command_t.

Definition at line 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  }
587  mutt_extract_token(buf, s, 0);
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  }
595  mutt_extract_token(&templ, s, 0);
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:261
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Parse the "unattachments" command.

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

Definition at line 615 of file init.c.

617 {
618  struct AttachMatch *a = NULL;
619  char *tmp = NULL;
620  char *minor = NULL;
621 
622  do
623  {
624  mutt_extract_token(buf, s, 0);
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 int major = mutt_check_mime_type(tmp);
645 
646  struct ListNode *np, *tmp2;
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 }
int major_int
Definition: mutt.h:130
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:400
#define MoreArgs(buf)
Definition: buffer.h:44
const char * major
Definition: mutt.h:129
#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:149
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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:383
regex_t minor_regex
Definition: mutt.h:132
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:624
int mutt_check_mime_type(const char *s)
Check a MIME type string.
Definition: parse.c:294
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
An attachment matching a regex.
Definition: mutt.h:127
A List node for strings.
Definition: list.h:33
const char * minor
Definition: mutt.h:131
Log at debug level 3.
Definition: logging.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Remove a string replacement rule - Implements command_t.

Definition at line 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 
685  mutt_extract_token(buf, s, 0);
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:200
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:442
#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:2659
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:559
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Print a list of attachments.

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

Definition at line 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:127
A List node for strings.
Definition: list.h:33

+ Here is the caller graph for this function:

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

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

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

Definition at line 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, *tmp;
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:105
#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:624
#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:611

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Read an initialization file.

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Parse the 'alias' command - Implements command_t.

Definition at line 890 of file init.c.

892 {
893  struct Alias *tmp = NULL;
894  char *estr = NULL;
895  struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
896 
897  if (!MoreArgs(s))
898  {
899  mutt_buffer_strcpy(err, _("alias: no address"));
900  return MUTT_CMD_WARNING;
901  }
902 
903  mutt_extract_token(buf, s, 0);
904 
905  if (parse_grouplist(&gc, buf, s, data, err) == -1)
906  return MUTT_CMD_ERROR;
907 
908  /* check to see if an alias with this name already exists */
909  TAILQ_FOREACH(tmp, &Aliases, entries)
910  {
911  if (mutt_str_strcasecmp(tmp->name, buf->data) == 0)
912  break;
913  }
914 
915  if (!tmp)
916  {
917  /* create a new alias */
918  tmp = mutt_mem_calloc(1, sizeof(struct Alias));
919  tmp->name = mutt_str_strdup(buf->data);
920  TAILQ_INSERT_TAIL(&Aliases, tmp, entries);
921  /* give the main addressbook code a chance */
922  if (CurrentMenu == MENU_ALIAS)
923  OptMenuCaller = true;
924  }
925  else
926  {
928  /* override the previous value */
929  mutt_addr_free(&tmp->addr);
930  if (CurrentMenu == MENU_ALIAS)
932  }
933 
935  mutt_debug(5, "Second token is '%s'.\n", buf->data);
936 
937  tmp->addr = mutt_addr_parse_list2(tmp->addr, buf->data);
938 
939  if (mutt_addrlist_to_intl(tmp->addr, &estr))
940  {
941  mutt_buffer_printf(err, _("Warning: Bad IDN '%s' in alias '%s'"), estr, tmp->name);
942  FREE(&estr);
943  goto bail;
944  }
945 
948 
949  if (C_DebugLevel > 2)
950  {
951  /* A group is terminated with an empty address, so check a->mailbox */
952  for (struct Address *a = tmp->addr; a && a->mailbox; a = a->next)
953  {
954  if (!a->group)
955  mutt_debug(5, " %s\n", a->mailbox);
956  else
957  mutt_debug(5, " Group %s\n", a->mailbox);
958  }
959  }
961  return MUTT_CMD_SUCCESS;
962 
963 bail:
965  return MUTT_CMD_ERROR;
966 }
void mutt_alias_delete_reverse(struct Alias *t)
Remove an email address lookup for an Alias.
Definition: alias.c:571
A shortcut for an email address.
Definition: alias.h:36
char * name
Definition: alias.h:38
struct Address * mutt_addr_parse_list2(struct Address *p, const char *s)
Parse a list of email addresses.
Definition: address.c:630
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
void mutt_grouplist_add_addrlist(struct GroupList *head, struct Address *a)
Add Address list to a GroupList.
Definition: group.c:237
WHERE bool OptMenuCaller
(pseudo) tell menu to give caller a take
Definition: options.h:37
#define _(a)
Definition: message.h:28
An email address.
Definition: address.h:32
char * mailbox
mailbox and host address
Definition: address.h:35
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
int mutt_addrlist_to_intl(struct Address *a, char **err)
Convert an Address list to Punycode.
Definition: address.c:1208
#define MoreArgs(buf)
Definition: buffer.h:44
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:78
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:316
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:2659
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:77
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:68
#define MUTT_TOKEN_SEMICOLON
Don&#39;t treat ; as special.
Definition: mutt.h:81
Success: Command worked.
Definition: mutt_commands.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:34
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:383
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:624
void mutt_alias_add_reverse(struct Alias *t)
Add an email address lookup for an Alias.
Definition: alias.c:549
#define FREE(x)
Definition: memory.h:40
struct Address * addr
Definition: alias.h:39
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:94
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
void mutt_addr_free(struct Address **p)
Free a list of Addresses.
Definition: address.c:446
static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:542
void mutt_grouplist_destroy(struct GroupList *head)
Free a GroupList.
Definition: group.c:150

+ Here is the call graph for this function:

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

Parse the 'alternates' command - Implements command_t.

Definition at line 971 of file init.c.

973 {
974  struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
975 
977 
978  do
979  {
980  mutt_extract_token(buf, s, 0);
981 
982  if (parse_grouplist(&gc, buf, s, data, err) == -1)
983  goto bail;
984 
985  mutt_regexlist_remove(&UnAlternates, buf->data);
986 
987  if (mutt_regexlist_add(&Alternates, buf->data, REG_ICASE, err) != 0)
988  goto bail;
989 
990  if (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0)
991  goto bail;
992  } while (MoreArgs(s));
993 
995  return MUTT_CMD_SUCCESS;
996 
997 bail:
999  return MUTT_CMD_ERROR;
1000 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
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:137
#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:129
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:278
static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:542
void mutt_grouplist_destroy(struct GroupList *head)
Free a GroupList.
Definition: group.c:150

+ Here is the call graph for this function:

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

Parse the 'attachments' command - Implements command_t.

Definition at line 1005 of file init.c.

1007 {
1008  char op, *category = NULL;
1009  struct ListHead *head = NULL;
1010 
1011  mutt_extract_token(buf, s, 0);
1012  if (!buf->data || (*buf->data == '\0'))
1013  {
1014  mutt_buffer_strcpy(err, _("attachments: no disposition"));
1015  return MUTT_CMD_WARNING;
1016  }
1017 
1018  category = buf->data;
1019  op = *category++;
1020 
1021  if (op == '?')
1022  {
1023  mutt_endwin();
1024  fflush(stdout);
1025  printf("\n%s\n\n", _("Current attachments settings:"));
1026  print_attach_list(&AttachAllow, '+', "A");
1027  print_attach_list(&AttachExclude, '-', "A");
1028  print_attach_list(&InlineAllow, '+', "I");
1029  print_attach_list(&InlineExclude, '-', "I");
1031  return MUTT_CMD_SUCCESS;
1032  }
1033 
1034  if ((op != '+') && (op != '-'))
1035  {
1036  op = '+';
1037  category--;
1038  }
1039  if (mutt_str_startswith("attachment", category, CASE_IGNORE))
1040  {
1041  if (op == '+')
1042  head = &AttachAllow;
1043  else
1044  head = &AttachExclude;
1045  }
1046  else if (mutt_str_startswith("inline", category, CASE_IGNORE))
1047  {
1048  if (op == '+')
1049  head = &InlineAllow;
1050  else
1051  head = &InlineExclude;
1052  }
1053  else
1054  {
1055  mutt_buffer_strcpy(err, _("attachments: invalid disposition"));
1056  return MUTT_CMD_ERROR;
1057  }
1058 
1059  return parse_attach_list(buf, s, head, err);
1060 }
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:316
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:497
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
char * data
pointer to data
Definition: buffer.h:35
Ignore case when comparing strings.
Definition: string2.h:67
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:165
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:530
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

+ Here is the call graph for this function:

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

Parse the 'echo' command - Implements command_t.

Definition at line 1065 of file init.c.

1067 {
1068  if (!MoreArgs(s))
1069  {
1070  mutt_buffer_printf(err, _("%s: too few arguments"), "echo");
1071  return MUTT_CMD_WARNING;
1072  }
1073  mutt_extract_token(buf, s, 0);
1074  OptForceRefresh = true;
1075  mutt_message("%s", buf->data);
1076  OptForceRefresh = false;
1077  mutt_sleep(0);
1078 
1079  return MUTT_CMD_SUCCESS;
1080 }
#define mutt_message(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MoreArgs(buf)
Definition: buffer.h:44
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1471
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:2659
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

+ Here is the call graph for this function:

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

Parse the 'finish' command - Implements command_t.

Return values
MUTT_CMD_FINISHStop processing the current file
MUTT_CMD_WARNINGFailed

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

Definition at line 1089 of file init.c.

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

+ Here is the call graph for this function:

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

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

Definition at line 1104 of file init.c.

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

+ Here is the call graph for this function:

static bool is_function ( const char *  name)
static

Is the argument a neomutt function?

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

Definition at line 1193 of file init.c.

1194 {
1195  for (int i = 0; i < MENU_MAX; i++)
1196  {
1197  const struct Binding *b = km_get_table(Menus[i].value);
1198  if (!b)
1199  continue;
1200 
1201  for (int j = 0; b[j].name; j++)
1202  if (mutt_str_strcmp(name, b[j].name) == 0)
1203  return true;
1204  }
1205  return false;
1206 }
const char * name
Definition: pgpmicalg.c:45
const char * name
name of the function
Definition: keymap.h:102
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:1201
Mapping between a user key and a function.
Definition: keymap.h:100
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

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

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

Definition at line 1221 of file init.c.

1223 {
1224  struct Buffer token = { 0 };
1225 
1226  mutt_extract_token(buf, s, 0);
1227 
1228  // is the item defined as:
1229  bool res = cs_get_elem(Config, buf->data) // a variable?
1230  || feature_enabled(buf->data) // a compiled-in feature?
1231  || is_function(buf->data) // a function?
1232  || mutt_command_get(buf->data) // a command?
1233  || myvar_get(buf->data) // a my_ variable?
1234  || mutt_str_getenv(buf->data); // an environment variable?
1235 
1236  if (!MoreArgs(s))
1237  {
1238  mutt_buffer_printf(err, _("%s: too few arguments"), (data ? "ifndef" : "ifdef"));
1239  return MUTT_CMD_WARNING;
1240  }
1242 
1243  /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
1244  if ((res && (data == 0)) || (!res && (data == 1)))
1245  {
1246  enum CommandResult rc = mutt_parse_rc_line(buf->data, &token, err);
1247  if (rc == MUTT_CMD_ERROR)
1248  {
1249  mutt_error(_("Error: %s"), err->data);
1250  FREE(&token.data);
1251  return MUTT_CMD_ERROR;
1252  }
1253  FREE(&token.data);
1254  return rc;
1255  }
1256  return MUTT_CMD_SUCCESS;
1257 }
static bool is_function(const char *name)
Is the argument a neomutt function?
Definition: init.c:1193
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:471
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:39
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
const struct Command * mutt_command_get(const char *s)
Get a Command by its name.
Definition: init.c:2582
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1048
#define MoreArgs(buf)
Definition: buffer.h:44
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
Definition: set.c:188
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:77
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:88
#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:3259

+ Here is the call graph for this function:

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

Parse the 'ignore' command - Implements command_t.

Definition at line 1262 of file init.c.

1264 {
1265  do
1266  {
1267  mutt_extract_token(buf, s, 0);
1269  add_to_stailq(&Ignore, buf->data);
1270  } while (MoreArgs(s));
1271 
1272  return MUTT_CMD_SUCCESS;
1273 }
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:45
#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:2659
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:44
static void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: init.c:116

+ Here is the call graph for this function:

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

Parse the 'lists' command - Implements command_t.

Definition at line 1278 of file init.c.

1280 {
1281  struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
1282 
1283  do
1284  {
1285  mutt_extract_token(buf, s, 0);
1286 
1287  if (parse_grouplist(&gc, buf, s, data, err) == -1)
1288  goto bail;
1289 
1290  mutt_regexlist_remove(&UnMailLists, buf->data);
1291 
1292  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
1293  goto bail;
1294 
1295  if (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0)
1296  goto bail;
1297  } while (MoreArgs(s));
1298 
1300  return MUTT_CMD_SUCCESS;
1301 
1302 bail:
1304  return MUTT_CMD_ERROR;
1305 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:129
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:278
static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:542
void mutt_grouplist_destroy(struct GroupList *head)
Free a GroupList.
Definition: group.c:150

+ Here is the call graph for this function:

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

Parse the 'mailboxes' command - Implements command_t.

This is also used by 'virtual-mailboxes'.

Definition at line 1312 of file init.c.

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

+ Here is the call graph for this function:

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

Parse the 'my_hdr' command - Implements command_t.

Definition at line 1396 of file init.c.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Parse the 'sidebar_whitelist' command - Implements command_t.

Definition at line 1441 of file init.c.

1443 {
1444  char path[PATH_MAX];
1445 
1446  do
1447  {
1448  mutt_extract_token(buf, s, 0);
1449  mutt_str_strfcpy(path, buf->data, sizeof(path));
1450  mutt_expand_path(path, sizeof(path));
1451  add_to_stailq((struct ListHead *) data, path);
1452  } while (MoreArgs(s));
1453 
1454  return MUTT_CMD_SUCCESS;
1455 }
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:157
#define MoreArgs(buf)
Definition: buffer.h:44
#define PATH_MAX
Definition: mutt.h:48
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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:741
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:116

+ Here is the call graph for this function:

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

Parse the 'unsidebar_whitelist' command - Implements command_t.

Definition at line 1462 of file init.c.

1464 {
1465  char path[PATH_MAX];
1466 
1467  do
1468  {
1469  mutt_extract_token(buf, s, 0);
1470  /* Check for deletion of entire list */
1471  if (mutt_str_strcmp(buf->data, "*") == 0)
1472  {
1473  mutt_list_free((struct ListHead *) data);
1474  break;
1475  }
1476  mutt_str_strfcpy(path, buf->data, sizeof(path));
1477  mutt_expand_path(path, sizeof(path));
1478  remove_from_stailq((struct ListHead *) data, path);
1479  } while (MoreArgs(s));
1480 
1481  return MUTT_CMD_SUCCESS;
1482 }
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:105
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:157
#define MoreArgs(buf)
Definition: buffer.h:44
#define PATH_MAX
Definition: mutt.h:48
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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:741
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:611

+ Here is the call graph for this function:

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

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

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

Definition at line 1490 of file init.c.

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

+ Here is the call graph for this function:

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

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

Definition at line 1820 of file init.c.

1822 {
1823  char **envp = mutt_envlist_getlist();
1824 
1825  bool query = false;
1826  bool unset = (data == MUTT_SET_UNSET);
1827 
1828  if (!MoreArgs(s))
1829  {
1830  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1831  return MUTT_CMD_WARNING;
1832  }
1833 
1834  if (*s->dptr == '?')
1835  {
1836  query = true;
1837  s->dptr++;
1838  }
1839 
1840  /* get variable name */
1842 
1843  if (query)
1844  {
1845  bool found = false;
1846  while (envp && *envp)
1847  {
1848  /* This will display all matches for "^QUERY" */
1849  if (mutt_str_startswith(*envp, buf->data, CASE_MATCH))
1850  {
1851  if (!found)
1852  {
1853  mutt_endwin();
1854  found = true;
1855  }
1856  puts(*envp);
1857  }
1858  envp++;
1859  }
1860 
1861  if (found)
1862  {
1864  return MUTT_CMD_SUCCESS;
1865  }
1866 
1867  mutt_buffer_printf(err, _("%s is unset"), buf->data);
1868  return MUTT_CMD_WARNING;
1869  }
1870 
1871  if (unset)
1872  {
1873  if (mutt_envlist_unset(buf->data))
1874  return MUTT_CMD_SUCCESS;
1875  return MUTT_CMD_ERROR;
1876  }
1877 
1878  /* set variable */
1879 
1880  if (*s->dptr == '=')
1881  {
1882  s->dptr++;
1883  SKIPWS(s->dptr);
1884  }
1885 
1886  if (!MoreArgs(s))
1887  {
1888  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1889  return MUTT_CMD_WARNING;
1890  }
1891 
1892  char *name = mutt_str_strdup(buf->data);
1893  mutt_extract_token(buf, s, 0);
1894  mutt_envlist_set(name, buf->data, true);
1895  FREE(&name);
1896 
1897  return MUTT_CMD_SUCCESS;
1898 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define _(a)
Definition: message.h:28
Match case when comparing strings.
Definition: string2.h:66
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
#define MoreArgs(buf)
Definition: buffer.h:44
const char * name
Definition: pgpmicalg.c:45
#define SKIPWS(ch)
Definition: string2.h:46
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:497
bool mutt_envlist_unset(const char *name)
Unset an environment variable.
Definition: envlist.c:129
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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:165
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:530
default is to unset all vars
Definition: init.h:101
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:383
#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:75
char ** mutt_envlist_getlist(void)
Get the private environment.
Definition: envlist.c:165

+ Here is the call graph for this function:

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

Parse the 'source' command - Implements command_t.

Definition at line 1903 of file init.c.

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

+ Here is the call graph for this function:

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

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

Definition at line 1932 of file init.c.

1934 {
1935  struct Buffer templ;
1936 
1937  mutt_buffer_init(&templ);
1938 
1939  /* Insist on at least one parameter */
1940  if (!MoreArgs(s))
1941  {
1942  if (data == MUTT_SPAM)
1943  mutt_buffer_strcpy(err, _("spam: no matching pattern"));
1944  else
1945  mutt_buffer_strcpy(err, _("nospam: no matching pattern"));
1946  return MUTT_CMD_ERROR;
1947  }
1948 
1949  /* Extract the first token, a regex */
1950  mutt_extract_token(buf, s, 0);
1951 
1952  /* data should be either MUTT_SPAM or MUTT_NOSPAM. MUTT_SPAM is for spam commands. */
1953  if (data == MUTT_SPAM)
1954  {
1955  /* If there's a second parameter, it's a template for the spam tag. */
1956  if (MoreArgs(s))
1957  {
1958  mutt_extract_token(&templ, s, 0);
1959 
1960  /* Add to the spam list. */
1961  if (mutt_replacelist_add(&SpamList, buf->data, templ.data, err) != 0)
1962  {
1963  FREE(&templ.data);
1964  return MUTT_CMD_ERROR;
1965  }
1966  FREE(&templ.data);
1967  }
1968  /* If not, try to remove from the nospam list. */
1969  else
1970  {
1972  }
1973 
1974  return MUTT_CMD_SUCCESS;
1975  }
1976  /* MUTT_NOSPAM is for nospam commands. */
1977  else if (data == MUTT_NOSPAM)
1978  {
1979  /* nospam only ever has one parameter. */
1980 
1981  /* "*" is a special case. */
1982  if (mutt_str_strcmp(buf->data, "*") == 0)
1983  {
1986  return MUTT_CMD_SUCCESS;
1987  }
1988 
1989  /* If it's on the spam list, just remove it. */
1990  if (mutt_replacelist_remove(&SpamList, buf->data) != 0)
1991  return MUTT_CMD_SUCCESS;
1992 
1993  /* Otherwise, add it to the nospam list. */
1994  if (mutt_regexlist_add(&NoSpamList, buf->data, REG_ICASE, err) != 0)
1995  return MUTT_CMD_ERROR;
1996 
1997  return MUTT_CMD_SUCCESS;
1998  }
1999 
2000  /* This should not happen. */
2001  mutt_buffer_strcpy(err, "This is no good at all.");
2002  return MUTT_CMD_ERROR;
2003 }
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:261
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define MUTT_NOSPAM
Definition: mutt.h:117
struct ReplaceList SpamList
List of regexes and patterns to match spam emails.
Definition: email_globals.c:43
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:442
#define MoreArgs(buf)
Definition: buffer.h:44
#define MUTT_SPAM
Definition: mutt.h:116
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:129
void mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:316
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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:559
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:66
struct RegexList NoSpamList
List of regexes to whitelist non-spam emails.
Definition: email_globals.c:42
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition: regex.c:167

+ Here is the call graph for this function:

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

Parse a list command - Implements command_t.

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

Definition at line 2010 of file init.c.

2012 {
2013  do
2014  {
2015  mutt_extract_token(buf, s, 0);
2016  add_to_stailq((struct ListHead *) data, buf->data);
2017  } while (MoreArgs(s));
2018 
2019  return MUTT_CMD_SUCCESS;
2020 }
#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:2659
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:116

+ Here is the call graph for this function:

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

Parse the 'subjectrx' command - Implements command_t.

Definition at line 2025 of file init.c.

2027 {
2028  enum CommandResult rc;
2029 
2030  rc = parse_replace_list(buf, s, data, err);
2031  if (rc == MUTT_CMD_SUCCESS)
2033  return rc;
2034 }
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:209
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35

+ Here is the call graph for this function:

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

Parse the 'subscribe' command - Implements command_t.

Definition at line 2039 of file init.c.

2041 {
2042  struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
2043 
2044  do
2045  {
2046  mutt_extract_token(buf, s, 0);
2047 
2048  if (parse_grouplist(&gc, buf, s, data, err) == -1)
2049  goto bail;
2050 
2051  mutt_regexlist_remove(&UnMailLists, buf->data);
2052  mutt_regexlist_remove(&UnSubscribedLists, buf->data);
2053 
2054  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
2055  goto bail;
2056  if (mutt_regexlist_add(&SubscribedLists, buf->data, REG_ICASE, err) != 0)
2057  goto bail;
2058  if (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0)
2059  goto bail;
2060  } while (MoreArgs(s));
2061 
2063  return MUTT_CMD_SUCCESS;
2064 
2065 bail:
2067  return MUTT_CMD_ERROR;
2068 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:129
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:278
static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Definition: init.c:542
void mutt_grouplist_destroy(struct GroupList *head)
Free a GroupList.
Definition: group.c:150

+ Here is the call graph for this function:

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

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

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

Definition at line 2078 of file init.c.

2080 {
2081  if (!buf || !s || !err)
2082  return MUTT_CMD_ERROR;
2083 
2084  mutt_buffer_reset(err);
2085 
2086  if (MoreArgs(s))
2087  {
2088  mutt_extract_token(buf, s, 0);
2089 
2090  if (MoreArgs(s))
2091  {
2092  mutt_buffer_printf(err, _("%s: too many arguments"), "subscribe-to");
2093  return MUTT_CMD_WARNING;
2094  }
2095 
2096  if (buf->data && (*buf->data != '\0'))
2097  {
2098  /* Expand and subscribe */
2099  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), true) != 0)
2100  {
2101  mutt_buffer_printf(err, _("Could not subscribe to %s"), buf->data);
2102  return MUTT_CMD_ERROR;
2103  }
2104  else
2105  {
2106  mutt_message(_("Subscribed to %s"), buf->data);
2107  return MUTT_CMD_SUCCESS;
2108  }
2109  }
2110  else
2111  {
2112  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2113  return MUTT_CMD_ERROR;
2114  }
2115  }
2116 
2117  mutt_buffer_addstr(err, _("No folder specified"));
2118  return MUTT_CMD_WARNING;
2119 }
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:81
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
size_t dsize
length of data
Definition: buffer.h:37
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:157
#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:258
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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:85
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1392

+ Here is the call graph for this function:

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

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

Definition at line 2125 of file init.c.

2127 {
2128  if (!buf || !s)
2129  return MUTT_CMD_ERROR;
2130 
2131  char *tmp = NULL;
2132 
2133  while (MoreArgs(s))
2134  {
2135  char *tag = NULL, *format = NULL;
2136 
2137  mutt_extract_token(buf, s, 0);
2138  if (buf->data && (*buf->data != '\0'))
2139  tag = mutt_str_strdup(buf->data);
2140  else
2141  continue;
2142 
2143  mutt_extract_token(buf, s, 0);
2144  format = mutt_str_strdup(buf->data);
2145 
2146  /* avoid duplicates */
2147  tmp = mutt_hash_find(TagFormats, format);
2148  if (tmp)
2149  {
2150  mutt_debug(LL_DEBUG3, "tag format '%s' already registered as '%s'\n", format, tmp);
2151  FREE(&tag);
2152  FREE(&format);
2153  continue;
2154  }
2155 
2156  mutt_hash_insert(TagFormats, format, tag);
2157  }
2158  return MUTT_CMD_SUCCESS;
2159 }
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:373
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:2659
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:383
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
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:348
Log at debug level 3.
Definition: logging.h:58

+ Here is the call graph for this function:

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

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

Definition at line 2164 of file init.c.

2166 {
2167  if (!buf || !s)
2168  return MUTT_CMD_ERROR;
2169 
2170  char *tmp = NULL;
2171 
2172  while (MoreArgs(s))
2173  {
2174  char *tag = NULL, *transform = NULL;
2175 
2176  mutt_extract_token(buf, s, 0);
2177  if (buf->data && (*buf->data != '\0'))
2178  tag = mutt_str_strdup(buf->data);
2179  else
2180  continue;
2181 
2182  mutt_extract_token(buf, s, 0);
2183  transform = mutt_str_strdup(buf->data);
2184 
2185  /* avoid duplicates */
2186  tmp = mutt_hash_find(TagTransforms, tag);
2187  if (tmp)
2188  {
2189  mutt_debug(LL_DEBUG3, "tag transform '%s' already registered as '%s'\n", tag, tmp);
2190  FREE(&tag);
2191  FREE(&transform);
2192  continue;
2193  }
2194 
2195  mutt_hash_insert(TagTransforms, tag, transform);
2196  }
2197  return MUTT_CMD_SUCCESS;
2198 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:39
void * mutt_hash_find(const struct Hash *table, const char *strkey)
Find the HashElem data in a Hash table element using a key.
Definition: hash.c:373
#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:2659
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:383
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
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:348
Log at debug level 3.
Definition: logging.h:58

+ Here is the call graph for this function:

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

Parse the 'unalias' command - Implements command_t.

Definition at line 2203 of file init.c.

2205 {
2206  struct Alias *a = NULL;
2207 
2208  do
2209  {
2210  mutt_extract_token(buf, s, 0);
2211 
2212  if (mutt_str_strcmp("*", buf->data) == 0)
2213  {
2214  if (CurrentMenu == MENU_ALIAS)
2215  {
2216  TAILQ_FOREACH(a, &Aliases, entries)
2217  {
2218  a->del = true;
2219  }
2221  }
2222  else
2223  mutt_aliaslist_free(&Aliases);
2224  break;
2225  }
2226  else
2227  {
2228  TAILQ_FOREACH(a, &Aliases, entries)
2229  {
2230  if (mutt_str_strcasecmp(buf->data, a->name) == 0)
2231  {
2232  if (CurrentMenu == MENU_ALIAS)
2233  {
2234  a->del = true;
2236  }
2237  else
2238  {
2239  TAILQ_REMOVE(&Aliases, a, entries);
2240  mutt_alias_free(&a);
2241  }
2242  break;
2243  }
2244  }
2245  }
2246  } while (MoreArgs(s));
2247  return MUTT_CMD_SUCCESS;
2248 }
A shortcut for an email address.
Definition: alias.h:36
char * name
Definition: alias.h:38
void mutt_aliaslist_free(struct AliasList *a_list)
Free a List of Aliases.
Definition: alias.c:755
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
#define MoreArgs(buf)
Definition: buffer.h:44
bool del
Definition: alias.h:41
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:821
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
char * data
pointer to data
Definition: buffer.h:35
Select an email address by its alias.
Definition: keymap.h:68
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:624
void mutt_alias_free(struct Alias **p)
Free an Alias.
Definition: alias.c:740
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:94
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611

+ Here is the call graph for this function:

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

Parse the 'unalternates' command - Implements command_t.

Definition at line 2253 of file init.c.

2255 {
2256  alternates_clean();
2257  do
2258  {
2259  mutt_extract_token(buf, s, 0);
2260  mutt_regexlist_remove(&Alternates, buf->data);
2261 
2262  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2263  (mutt_regexlist_add(&UnAlternates, buf->data, REG_ICASE, err) != 0))
2264  {
2265  return MUTT_CMD_ERROR;
2266  }
2267 
2268  } while (MoreArgs(s));
2269 
2270  return MUTT_CMD_SUCCESS;
2271 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
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:137
#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:129
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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:611

+ Here is the call graph for this function:

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

Parse the 'unattachments' command - Implements command_t.

Definition at line 2276 of file init.c.

2278 {
2279  char op, *p = NULL;
2280  struct ListHead *head = NULL;
2281 
2282  mutt_extract_token(buf, s, 0);
2283  if (!buf->data || (*buf->data == '\0'))
2284  {
2285  mutt_buffer_strcpy(err, _("unattachments: no disposition"));
2286  return MUTT_CMD_WARNING;
2287  }
2288 
2289  p = buf->data;
2290  op = *p++;
2291  if ((op != '+') && (op != '-'))
2292  {
2293  op = '+';
2294  p--;
2295  }
2296  if (mutt_str_startswith("attachment", p, CASE_IGNORE))
2297  {
2298  if (op == '+')
2299  head = &AttachAllow;
2300  else
2301  head = &AttachExclude;
2302  }
2303  else if (mutt_str_startswith("inline", p, CASE_IGNORE))
2304  {
2305  if (op == '+')
2306  head = &InlineAllow;
2307  else
2308  head = &InlineExclude;
2309  }
2310  else
2311  {
2312  mutt_buffer_strcpy(err, _("unattachments: invalid disposition"));
2313  return MUTT_CMD_ERROR;
2314  }
2315 
2316  return parse_unattach_list(buf, s, head, err);
2317 }
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:316
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
char * data
pointer to data
Definition: buffer.h:35
Ignore case when comparing strings.
Definition: string2.h:67
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:165
Warning: Help given to the user.
Definition: mutt_commands.h:34

+ Here is the call graph for this function:

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

Parse the 'unignore' command - Implements command_t.

Definition at line 2322 of file init.c.

2324 {
2325  do
2326  {
2327  mutt_extract_token(buf, s, 0);
2328 
2329  /* don't add "*" to the unignore list */
2330  if (strcmp(buf->data, "*") != 0)
2331  add_to_stailq(&UnIgnore, buf->data);
2332 
2333  remove_from_stailq(&Ignore, buf->data);
2334  } while (MoreArgs(s));
2335 
2336  return MUTT_CMD_SUCCESS;
2337 }
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:45
#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:2659
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:44
static void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: init.c:116

+ Here is the call graph for this function:

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

Parse the 'unlists' command - Implements command_t.

Definition at line 2342 of file init.c.

2344 {
2346  do
2347  {
2348  mutt_extract_token(buf, s, 0);
2349  mutt_regexlist_remove(&SubscribedLists, buf->data);
2350  mutt_regexlist_remove(&MailLists, buf->data);
2351 
2352  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2353  (mutt_regexlist_add(&UnMailLists, buf->data, REG_ICASE, err) != 0))
2354  {
2355  return MUTT_CMD_ERROR;
2356  }
2357  } while (MoreArgs(s));
2358 
2359  return MUTT_CMD_SUCCESS;
2360 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:129
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
WHERE struct Hash * AutoSubscribeCache
Hash table of auto-subscribed mailing lists.
Definition: globals.h:60
void mutt_hash_free(struct Hash **ptr)
elem_free a hash table
Definition: hash.c:457
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611

+ Here is the call graph for this function:

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

Parse the 'unmailboxes' command - Implements command_t.

This is also used by 'unvirtual-mailboxes'

Definition at line 2367 of file init.c.

2369 {
2370  char tmp[PATH_MAX];
2371  bool tmp_valid = false;
2372  bool clear_all = false;
2373 
2374  while (!clear_all && MoreArgs(s))
2375  {
2376  mutt_extract_token(buf, s, 0);
2377 
2378  if (mutt_str_strcmp(buf->data, "*") == 0)
2379  {
2380  clear_all = true;
2381  tmp_valid = false;
2382  }
2383  else
2384  {
2385  mutt_str_strfcpy(tmp, buf->data, sizeof(tmp));
2386  mutt_expand_path(tmp, sizeof(tmp));
2387  tmp_valid = true;
2388  }
2389 
2390  struct MailboxNode *np = NULL;
2391  struct MailboxNode *nptmp = NULL;
2392  STAILQ_FOREACH_SAFE(np, &AllMailboxes, entries, nptmp)
2393  {
2394  /* Decide whether to delete all normal mailboxes or all virtual */
2395  bool virt = ((np->mailbox->magic == MUTT_NOTMUCH) && (data & MUTT_VIRTUAL));
2396  bool norm = ((np->mailbox->magic != MUTT_NOTMUCH) && !(data & MUTT_VIRTUAL));
2397  bool clear_this = clear_all && (virt || norm);
2398 
2399  /* Compare against path or desc? Ensure 'tmp' is valid */
2400  if (!clear_this && tmp_valid)
2401  {
2402  clear_this = (mutt_str_strcasecmp(tmp, np->mailbox->path) == 0) ||
2403  (mutt_str_strcasecmp(tmp, np->mailbox->desc) == 0);
2404  }
2405 
2406  if (clear_this)
2407  {
2408 #ifdef USE_SIDEBAR
2409  mutt_sb_notify_mailbox(np->mailbox, false);
2410 #endif
2411 #ifdef USE_INOTIFY
2413 #endif
2414  if (Context && (Context->mailbox == np->mailbox))
2415  {
2416  np->mailbox->flags |= MB_HIDDEN;
2417  }
2418  else
2419  {
2420  mx_ac_remove(np->mailbox);
2421  mailbox_free(&np->mailbox);
2422  }
2423  STAILQ_REMOVE(&AllMailboxes, np, MailboxNode, entries);
2424  FREE(&np);
2425  continue;
2426  }
2427  }
2428  }
2429  return MUTT_CMD_SUCCESS;
2430 }
The "current" mailbox.
Definition: context.h:37
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: magic.h:43
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:400
char * desc
Definition: mailbox.h:88
int mutt_monitor_remove(struct Mailbox *m)
Remove a watch for a mailbox.
Definition: monitor.c:479
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:157
#define MoreArgs(buf)
Definition: buffer.h:44
struct Mailbox * mailbox
Definition: context.h:51
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:103
enum MailboxType magic
mailbox type
Definition: mailbox.h:106
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:360
int flags
e.g.
Definition: mailbox.h:135
#define MB_HIDDEN
Definition: mailbox.h:47
#define PATH_MAX
Definition: mutt.h:48
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
char * data
pointer to data
Definition: buffer.h:35
#define MUTT_VIRTUAL
Definition: init.h:107
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:741
struct MailboxList AllMailboxes
List of all Mailboxes.
Definition: mailbox.c:86
char path[PATH_MAX]
Definition: mailbox.h:85
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:624
#define FREE(x)
Definition: memory.h:40
List of Mailboxes.
Definition: mailbox.h:147
int mx_ac_remove(struct Mailbox *m)
Remove a Mailbox from an Account and delete Account if empty.
Definition: mx.c:1545
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611
struct Mailbox * mailbox
Definition: mailbox.h:149

+ Here is the call graph for this function:

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

Parse the 'unmy_hdr' command - Implements command_t.

Definition at line 2435 of file init.c.

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

+ Here is the call graph for this function:

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

Parse an unlist command - Implements command_t.

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

Definition at line 2472 of file init.c.

2474 {
2475  do
2476  {
2477  mutt_extract_token(buf, s, 0);
2478  /* Check for deletion of entire list */
2479  if (mutt_str_strcmp(buf->data, "*") == 0)
2480  {
2481  mutt_list_free((struct ListHead *) data);
2482  break;
2483  }
2484  remove_from_stailq((struct ListHead *) data, buf->data);
2485  } while (MoreArgs(s));
2486 
2487  return MUTT_CMD_SUCCESS;
2488 }
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:105
#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:2659
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:611

+ Here is the call graph for this function:

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

Parse the 'unsubjectrx' command - Implements command_t.

Definition at line 2493 of file init.c.

2495 {
2496  enum CommandResult rc;
2497 
2498  rc = parse_unreplace_list(buf, s, data, err);
2499  if (rc == MUTT_CMD_SUCCESS)
2501  return rc;
2502 }
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:209
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

+ Here is the call graph for this function:

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

Parse the 'unsubscribe' command - Implements command_t.

Definition at line 2507 of file init.c.

2509 {
2511  do
2512  {
2513  mutt_extract_token(buf, s, 0);
2514  mutt_regexlist_remove(&SubscribedLists, buf->data);
2515 
2516  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2517  (mutt_regexlist_add(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0))
2518  {
2519  return MUTT_CMD_ERROR;
2520  }
2521  } while (MoreArgs(s));
2522 
2523  return MUTT_CMD_SUCCESS;
2524 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define MoreArgs(buf)
Definition: buffer.h:44
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:129
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
WHERE struct Hash * AutoSubscribeCache
Hash table of auto-subscribed mailing lists.
Definition: globals.h:60
void mutt_hash_free(struct Hash **ptr)
elem_free a hash table
Definition: hash.c:457
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611

+ Here is the call graph for this function:

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

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

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

Definition at line 2534 of file init.c.

2536 {
2537  if (!buf || !s || !err)
2538  return MUTT_CMD_ERROR;
2539 
2540  if (MoreArgs(s))
2541  {
2542  mutt_extract_token(buf, s, 0);
2543 
2544  if (MoreArgs(s))
2545  {
2546  mutt_buffer_printf(err, _("%s: too many arguments"), "unsubscribe-from");
2547  return MUTT_CMD_WARNING;
2548  }
2549 
2550  if (buf->data && (*buf->data != '\0'))
2551  {
2552  /* Expand and subscribe */
2553  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), false) != 0)
2554  {
2555  mutt_buffer_printf(err, _("Could not unsubscribe from %s"), buf->data);
2556  return MUTT_CMD_ERROR;
2557  }
2558  else
2559  {
2560  mutt_message(_("Unsubscribed from %s"), buf->data);
2561  return MUTT_CMD_SUCCESS;
2562  }
2563  }
2564  else
2565  {
2566  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2567  return MUTT_CMD_ERROR;
2568  }
2569  }
2570 
2571  mutt_buffer_addstr(err, _("No folder specified"));
2572  return MUTT_CMD_WARNING;
2573 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:200
size_t dsize
length of data
Definition: buffer.h:37
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:157
#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:258
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:2659
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:85
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1392

+ Here is the call graph for this function:

const struct Command* mutt_command_get ( const char *  s)

Get a Command by its name.

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

Definition at line 2582 of file init.c.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_dump_variables ( bool  hide_sensitive)

Print a list of all variables with their values.

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

Definition at line 2611 of file init.c.

2612 {
2613  char cmd[256];
2614 
2615  struct Buffer err, token;
2616 
2617  mutt_buffer_init(&err);
2618  mutt_buffer_init(&token);
2619 
2620  err.dsize = 256;
2621  err.data = mutt_mem_malloc(err.dsize);
2622 
2623  for (int i = 0; MuttVars[i].name; i++)
2624  {
2625  if (MuttVars[i].type == DT_SYNONYM)
2626  continue;
2627 
2628  if (hide_sensitive && IS_SENSITIVE(MuttVars[i]))
2629  {
2630  mutt_message("%s='***'", MuttVars[i].name);
2631  continue;
2632  }
2633  snprintf(cmd, sizeof(cmd), "set ?%s\n", MuttVars[i].name);
2634  if (mutt_parse_rc_line(cmd, &token, &err) == MUTT_CMD_ERROR)
2635  {
2636  mutt_message("%s", err.data);
2637  FREE(&token.data);
2638  FREE(&err.data);
2639 
2640  return 1; // TEST17: can't test
2641  }
2642  mutt_message("%s", err.data);
2643  }
2644 
2645  FREE(&token.data);
2646  FREE(&err.data);
2647 
2648  return 0;
2649 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:87
String manipulation buffer.
Definition: buffer.h:33
#define IS_SENSITIVE(x)
Definition: types.h:73
const char * name
Definition: pgpmicalg.c:45
const char * name
User-visible name.
Definition: set.h:163
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:99
#define DT_SYNONYM
synonym for another variable
Definition: types.h:42
struct ConfigDef MuttVars[]
Definition: init.h:126
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:66
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3259

+ Here is the call graph for this function:

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

Extract one token from a string.

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

Definition at line 2659 of file init.c.

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

+ Here is the call graph for this function:

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

2904 {
2905  if (!am || !*am)
2906  return;
2907 
2908  regfree(&(*am)->minor_regex);
2909  FREE(&(*am)->major);
2910  FREE(am);
2911 }
#define FREE(x)
Definition: memory.h:40

+ Here is the caller graph for this function:

void mutt_free_opts ( void  )

clean up before quitting

Definition at line 2916 of file init.c.

2917 {
2919 
2920  FREE(&Matches);
2921 
2922  mutt_aliaslist_free(&Aliases);
2923 
2924  mutt_regexlist_free(&Alternates);
2925  mutt_regexlist_free(&MailLists);
2927  mutt_regexlist_free(&SubscribedLists);
2928  mutt_regexlist_free(&UnAlternates);
2929  mutt_regexlist_free(&UnMailLists);
2930  mutt_regexlist_free(&UnSubscribedLists);
2931 
2936 
2937  /* Lists of strings */
2938  mutt_list_free(&AlternativeOrderList);
2939  mutt_list_free(&AutoViewList);
2940  mutt_list_free(&HeaderOrderList);
2942  mutt_list_free(&MailToAllow);
2943  mutt_list_free(&MimeLookupList);
2944  mutt_list_free(&Muttrc);
2946 #ifdef USE_SIDEBAR
2947  mutt_list_free(&SidebarWhitelist);
2948 #endif
2950  mutt_list_free(&UserHeader);
2951 
2952  /* Lists of AttachMatch */
2957 
2958  mutt_free_colors();
2959 
2960  FREE(&CurrentFolder);
2961  FREE(&HomeDir);
2962  FREE(&LastFolder);
2963  FREE(&ShortHostname);
2964  FREE(&Username);
2965 
2967  mutt_replacelist_free(&SubjectRegexList);
2968 
2969  mutt_delete_hooks(0);
2970 
2971  mutt_hist_free();
2972  mutt_free_keys();
2973 
2975 }
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:755
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:39
static struct ListHead MuttrcStack
Definition: init.c:77
struct ReplaceList SpamList
List of regexes and patterns to match spam emails.
Definition: email_globals.c:43
void mutt_list_free_type(struct ListHead *h, list_free_t fn)
Free a List of type.
Definition: list.c:123
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:309
WHERE char * LastFolder
Previously selected mailbox.
Definition: globals.h:54
struct ListHead UnIgnore
List of header patterns to unignore (see)
Definition: email_globals.c:45
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:442
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:105
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:48
WHERE char * CurrentFolder
Currently selected mailbox.
Definition: globals.h:53
WHERE struct Hash * ReverseAliases
Hash table of aliases (email address -> alias)
Definition: globals.h:58
static const char ** Matches
Definition: init.c:90
void mutt_free_colors(void)
Free all the colours (on shutdown)
Definition: color.c:1220
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:1427
void mutt_grouplist_free(void)
Free GroupList singleton resource.
Definition: group.c:53
void mutt_hash_free(struct Hash **ptr)
elem_free a hash table
Definition: hash.c:457
struct RegexList NoSpamList
List of regexes to whitelist non-spam emails.
Definition: email_globals.c:42
void mutt_free_attachmatch(struct AttachMatch **am)
Free an AttachMatch - Implements list_free_t.
Definition: init.c:2903
void mutt_hist_free(void)
Free all the history lists.
Definition: history.c:438
struct ListHead Ignore
List of header patterns to ignore.
Definition: email_globals.c:44
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition: regex.c:167
void(* list_free_t)(void **ptr)
typedef list_free_t - Prototype for a function to free List data
Definition: list.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_get_hook_type ( const char *  name)

Find a hook by name.

Parameters
nameName to find
Return values
numData associated with the hook
0Error, no matching hook

Definition at line 2983 of file init.c.

2984 {
2985  for (const struct Command *c = Commands; c->name; c++)
2986  if ((c->func == mutt_parse_hook) && (mutt_str_strcasecmp(c->name, name) == 0))
2987  return c->data;
2988  return MUTT_CMD_SUCCESS;
2989 }
enum CommandResult mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
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:4805
const char * name
Definition: pgpmicalg.c:45
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:624

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_init ( bool  skip_sys_rc,
struct ListHead *  commands 
)

Initialise NeoMutt.

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

Definition at line 2998 of file init.c.

2999 {
3000  char buf[1024];
3001  int need_pause = 0;
3002  struct Buffer err;
3003 
3004  mutt_buffer_init(&err);
3005  err.dsize = 256;
3006  err.data = mutt_mem_malloc(err.dsize);
3007  err.dptr = err.data;
3008 
3010  /* reverse alias keys need to be strdup'ed because of idna conversions */
3015 
3016  mutt_menu_init();
3018 
3019  snprintf(AttachmentMarker, sizeof(AttachmentMarker), "\033]9;%" PRIu64 "\a",
3020  mutt_rand64());
3021 
3022  snprintf(ProtectedHeaderMarker, sizeof(ProtectedHeaderMarker), "\033]8;%ld\a",
3023  (long) time(NULL));
3024 
3025  /* "$spoolfile" precedence: config file, environment */
3026  const char *p = mutt_str_getenv("MAIL");
3027  if (!p)
3028  p = mutt_str_getenv("MAILDIR");
3029  if (!p)
3030  {
3031 #ifdef HOMESPOOL
3032  mutt_path_concat(buf, NONULL(HomeDir), MAILPATH, sizeof(buf));
3033 #else
3034  mutt_path_concat(buf, MAILPATH, NONULL(Username), sizeof(buf));
3035 #endif
3036  p = buf;
3037  }
3038  cs_str_initial_set(Config, "spoolfile", p, NULL);
3039  cs_str_reset(Config, "spoolfile", NULL);
3040 
3041  p = mutt_str_getenv("REPLYTO");
3042  if (p)
3043  {
3044  struct Buffer tmp, token;
3045 
3046  snprintf(buf, sizeof(buf), "Reply-To: %s", p);
3047 
3048  mutt_buffer_init(&tmp);
3049  tmp.data = buf;
3050  tmp.dptr = buf;
3051  tmp.dsize = mutt_str_strlen(buf);
3052 
3053  mutt_buffer_init(&token);
3054  parse_my_hdr(&token, &tmp, 0, &err); /* adds to UserHeader */
3055  FREE(&token.data);
3056  }
3057 
3058  p = mutt_str_getenv("EMAIL");
3059  if (p)
3060  {
3061  cs_str_initial_set(Config, "from", p, NULL);
3062  cs_str_reset(Config, "from", NULL);
3063  }
3064 
3065  /* "$mailcap_path" precedence: config file, environment, code */
3066  const char *env_mc = mutt_str_getenv("MAILCAPS");
3067  if (env_mc)
3068  cs_str_string_set(Config, "mailcap_path", env_mc, NULL);
3069 
3070  /* "$tmpdir" precedence: config file, environment, code */
3071  const char *env_tmp = mutt_str_getenv("TMPDIR");
3072  if (env_tmp)
3073  cs_str_string_set(Config, "tmpdir", env_tmp, NULL);
3074 
3075  /* "$visual", "$editor" precedence: config file, environment, code */
3076  const char *env_ed = mutt_str_getenv("VISUAL");
3077  if (!env_ed)
3078  env_ed = mutt_str_getenv("EDITOR");
3079  if (env_ed)
3080  {
3081  cs_str_string_set(Config, "editor", env_ed, NULL);
3082  cs_str_string_set(Config, "visual", env_ed, NULL);
3083  }
3084 
3087 
3088  Matches = mutt_mem_calloc(MatchesListsize, sizeof(char *));
3089 
3091 
3092 #ifdef HAVE_GETSID
3093  /* Unset suspend by default if we're the session leader */
3094  if (getsid(0) == getpid())
3095  C_Suspend = false;
3096 #endif
3097 
3098  /* RFC2368, "4. Unsafe headers"
3099  * The creator of a mailto URL cannot expect the resolver of a URL to
3100  * understand more than the "subject" and "body" headers. Clients that
3101  * resolve mailto URLs into mail messages should be able to correctly
3102  * create RFC822-compliant mail messages using the "subject" and "body"
3103  * headers. */
3104  add_to_stailq(&MailToAllow, "body");
3105  add_to_stailq(&MailToAllow, "subject");
3106  /* Cc, In-Reply-To, and References help with not breaking threading on
3107  * mailing lists, see https://github.com/neomutt/neomutt/issues/115 */
3108  add_to_stailq(&MailToAllow, "cc");
3109  add_to_stailq(&MailToAllow, "in-reply-to");
3110  add_to_stailq(&MailToAllow, "references");
3111 
3112  if (STAILQ_EMPTY(&Muttrc))
3113  {
3114  const char *xdg_cfg_home = mutt_str_getenv("XDG_CONFIG_HOME");
3115 
3116  if (!xdg_cfg_home && HomeDir)
3117  {
3118  snprintf(buf, sizeof(buf), "%s/.config", HomeDir);
3119  xdg_cfg_home = buf;
3120  }
3121 
3122  char *config = find_cfg(HomeDir, xdg_cfg_home);
3123  if (config)
3124  {
3125  mutt_list_insert_tail(&Muttrc, config);
3126  }
3127  }
3128  else
3129  {
3130  struct ListNode *np = NULL;
3131  STAILQ_FOREACH(np, &Muttrc, entries)
3132  {
3133  mutt_str_strfcpy(buf, np->data, sizeof(buf));
3134  FREE(&np->data);
3135  mutt_expand_path(buf, sizeof(buf));
3136  np->data = mutt_str_strdup(buf);
3137  if (access(np->data, F_OK))
3138  {
3139  mutt_perror(np->data);
3140  return 1; // TEST10: neomutt -F missing
3141  }
3142  }
3143  }
3144 
3145  if (!STAILQ_EMPTY(&Muttrc))
3146  {
3147  cs_str_string_set(Config, "alias_file", STAILQ_FIRST(&Muttrc)->data, NULL);
3148  }
3149 
3150  /* Process the global rc file if it exists and the user hasn't explicitly
3151  * requested not to via "-n". */
3152  if (!skip_sys_rc)
3153  {
3154  do
3155  {
3156  if (mutt_set_xdg_path(XDG_CONFIG_DIRS, buf, sizeof(buf)))
3157  break;
3158 
3159  snprintf(buf, sizeof(buf), "%s/neomuttrc", SYSCONFDIR);
3160  if (access(buf, F_OK) == 0)
3161  break;
3162 
3163  snprintf(buf, sizeof(buf), "%s/Muttrc", SYSCONFDIR);
3164  if (access(buf, F_OK) == 0)
3165  break;
3166 
3167  snprintf(buf, sizeof(buf), "%s/neomuttrc", PKGDATADIR);
3168  if (access(buf, F_OK) == 0)
3169  break;
3170 
3171  snprintf(buf, sizeof(buf), "%s/Muttrc", PKGDATADIR);
3172  } while (false);
3173 
3174  if (access(buf, F_OK) == 0)
3175  {
3176  if (source_rc(buf, &err) != 0)
3177  {
3178  mutt_error("%s", err.data);
3179  need_pause = 1; // TEST11: neomutt (error in /etc/neomuttrc)
3180  }
3181  }
3182  }
3183 
3184  /* Read the user's initialization file. */
3185  struct ListNode *np = NULL;
3186  STAILQ_FOREACH(np, &Muttrc, entries)
3187  {
3188  if (np->data)
3189  {
3190  if (source_rc(np->data, &err) != 0)
3191  {
3192  mutt_error("%s", err.data);
3193  need_pause = 1; // TEST12: neomutt (error in ~/.neomuttrc)
3194  }
3195  }
3196  }
3197 
3198  if (execute_commands(commands) != 0)
3199  need_pause = 1; // TEST13: neomutt -e broken
3200 
3201  if (!get_hostname())
3202  return 1;
3203 
3204  if (!C_Realname)
3205  {
3206  struct passwd *pw = getpwuid(getuid());
3207  if (pw)
3208  {
3209  char name[256];
3210  C_Realname = mutt_str_strdup(mutt_gecos_name(name, sizeof(name), pw));
3211  }
3212  }
3213  cs_str_initial_set(Config, "realname", C_Realname, NULL);
3214 
3215  if (need_pause && !OptNoCurses)
3216  {
3218  if (mutt_any_key_to_continue(NULL) == 'q')
3219  return 1; // TEST14: neomutt -e broken (press 'q')
3220  }
3221 
3222  mutt_file_mkdir(C_Tmpdir, S_IRWXU);
3223 
3224  mutt_hist_init();
3226 
3227 #ifdef USE_NOTMUCH
3228  if (C_VirtualSpoolfile)
3229  {
3230  /* Find the first virtual folder and open it */
3231  struct MailboxNode *mp = NULL;
3232  STAILQ_FOREACH(mp, &AllMailboxes, entries)
3233  {
3234  if (mp->mailbox->magic == MUTT_NOTMUCH)
3235  {
3236  cs_str_string_set(Config, "spoolfile", mp->mailbox->path, NULL);
3237  break;
3238  }
3239  }
3240  }
3241 #endif
3242 
3243  FREE(&err.data);
3244  return 0;
3245 }
WHERE char * Username
User&#39;s login name.
Definition: globals.h:51
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: magic.h:43
#define NONULL(x)
Definition: string2.h:36
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
#define mutt_perror(...)
Definition: logging.h:89
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:39
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:654
WHERE char AttachmentMarker[256]
Unique ANSI string to mark PGP messages in an email.
Definition: globals.h:45
String manipulation buffer.
Definition: buffer.h:33
static int execute_commands(struct ListHead *p)
Execute a set of NeoMutt commands.
Definition: init.c:282
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:662
Index panel (list of emails)
Definition: keymap.h:74
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
Definition: charset.c:956
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:1396
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
Definition: logging.c:349
static char * find_cfg(const char *home, const char *xdg_cfg_home)
Find a config file.
Definition: init.c:315
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1048
int cs_str_initial_set(const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err)
Set the initial value of a config item.
Definition: set.c:509
#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:157
void mutt_hist_read_file(void)
Read the History from a file.
Definition: history.c:583
enum MailboxType magic
mailbox type
Definition: mailbox.h:106
const char * name
Definition: pgpmicalg.c:45
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:48
void mutt_buffer_pool_init(void)
Initialise the Buffer pool.
Definition: buffer.c:362
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:58