NeoMutt  2019-12-07-168-gc45f47
Teaching an old dog new tricks
DOXYGEN
command_parse.c File Reference

Functions to parse commands in a config file. More...

#include "config.h"
#include <errno.h>
#include <string.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "alias.h"
#include "context.h"
#include "globals.h"
#include "init.h"
#include "monitor.h"
#include "mutt_commands.h"
#include "mutt_logging.h"
#include "mutt_menu.h"
#include "mutt_parse.h"
#include "muttlib.h"
#include "mx.h"
#include "myvar.h"
#include "options.h"
#include "sidebar.h"
#include "version.h"
#include "imap/lib.h"
+ Include dependency graph for command_parse.c:

Go to the source code of this file.

Macros

#define MAX_ERRS   128
 

Enumerations

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

Functions

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 void attachments_clean (void)
 always wise to do what someone else did before 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 void clear_subject_mods (void)
 Clear out all modified email subjects. 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 bool is_function (const char *name)
 Is the argument a neomutt function? More...
 
static struct AttachMatchmutt_attachmatch_new (void)
 Create a new AttachMatch. 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 print_attach_list (struct ListHead *h, const char op, const char *name)
 Print a list of attachments. More...
 
static void alternates_clean (void)
 Clear the recipient valid flag of all emails. More...
 
static int parse_grouplist (struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse a group context. More...
 
int source_rc (const char *rcfile_path, struct Buffer *err)
 Read an initialization file. More...
 
enum CommandResult parse_alias (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'alias' command - Implements command_t. More...
 
enum CommandResult parse_alternates (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'alternates' command - Implements command_t. More...
 
enum CommandResult parse_attachments (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'attachments' command - Implements command_t. More...
 
enum CommandResult parse_echo (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'echo' command - Implements command_t. More...
 
enum CommandResult parse_finish (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'finish' command - Implements command_t. More...
 
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...
 
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...
 
enum CommandResult parse_ignore (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'ignore' command - Implements command_t. More...
 
enum CommandResult parse_lists (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'lists' command - Implements command_t. More...
 
enum CommandResult parse_mailboxes (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'mailboxes' command - Implements command_t. More...
 
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...
 
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...
 
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...
 
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...
 
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...
 
enum CommandResult parse_source (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'source' command - Implements command_t. More...
 
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...
 
enum CommandResult parse_stailq (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse a list command - Implements command_t. More...
 
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...
 
enum CommandResult parse_subscribe (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'subscribe' command - Implements command_t. More...
 
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...
 
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...
 
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...
 
enum CommandResult parse_unalias (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unalias' command - Implements command_t. More...
 
enum CommandResult parse_unalternates (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unalternates' command - Implements command_t. More...
 
enum CommandResult parse_unattachments (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unattachments' command - Implements command_t. More...
 
enum CommandResult parse_unignore (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unignore' command - Implements command_t. More...
 
enum CommandResult parse_unlists (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unlists' command - Implements command_t. More...
 
enum CommandResult parse_unmailboxes (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unmailboxes' command - Implements command_t. More...
 
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...
 
enum CommandResult parse_unstailq (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse an unlist command - Implements command_t. More...
 
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...
 
enum CommandResult parse_unsubscribe (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
 Parse the 'unsubscribe' command - Implements command_t. More...
 
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...
 
void clear_source_stack (void)
 Free memory from the stack used for the souce command. More...
 

Variables

static struct ListHead MuttrcStack = STAILQ_HEAD_INITIALIZER(MuttrcStack)
 

Detailed Description

Functions to parse commands in a config file.

Authors
  • Michael R. Elkins
  • g10 Code GmbH

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

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

Definition in file command_parse.c.

Macro Definition Documentation

◆ MAX_ERRS

#define MAX_ERRS   128

Definition at line 60 of file command_parse.c.

Enumeration Type Documentation

◆ GroupState

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 65 of file command_parse.c.

66 {
67  GS_NONE,
68  GS_RX,
69  GS_ADDR,
70 };
Entry is an address.
Definition: command_parse.c:69
Group is missing an argument.
Definition: command_parse.c:67
Entry is a regular expression.
Definition: command_parse.c:68

Function Documentation

◆ parse_unreplace_list()

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 75 of file command_parse.c.

77 {
78  struct ReplaceList *list = (struct ReplaceList *) data;
79 
80  /* First token is a regex. */
81  if (!MoreArgs(s))
82  {
83  mutt_buffer_printf(err, _("%s: too few arguments"), "unsubjectrx");
84  return MUTT_CMD_WARNING;
85  }
86 
88 
89  /* "*" is a special case. */
90  if (mutt_str_strcmp(buf->data, "*") == 0)
91  {
93  return MUTT_CMD_SUCCESS;
94  }
95 
96  mutt_replacelist_remove(list, buf->data);
97  return MUTT_CMD_SUCCESS;
98 }
#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:160
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:447
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
Warning: Help given to the user.
Definition: mutt_commands.h:36
int mutt_replacelist_remove(struct ReplaceList *rl, const char *pat)
Remove a pattern from a list.
Definition: regex.c:564
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attachments_clean()

static void attachments_clean ( void  )
static

always wise to do what someone else did before

Definition at line 103 of file command_parse.c.

104 {
105  if (!Context || !Context->mailbox)
106  return;
107 
108  struct Mailbox *m = Context->mailbox;
109  for (int i = 0; i < m->msg_count; i++)
110  {
111  struct Email *e = m->emails[i];
112  if (!e)
113  break;
114  e->attach_valid = false;
115  }
116 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:98
The "current" mailbox.
Definition: context.h:36
int msg_count
Total number of messages.
Definition: mailbox.h:90
The envelope/body of an email.
Definition: email.h:37
struct Mailbox * mailbox
Definition: context.h:50
A mailbox.
Definition: mailbox.h:80
bool attach_valid
true when the attachment count is valid
Definition: email.h:70
+ Here is the caller graph for this function:

◆ parse_unattach_list()

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 126 of file command_parse.c.

128 {
129  struct AttachMatch *a = NULL;
130  char *tmp = NULL;
131  char *minor = NULL;
132 
133  do
134  {
136  FREE(&tmp);
137 
138  if (mutt_str_strcasecmp(buf->data, "any") == 0)
139  tmp = mutt_str_strdup("*/.*");
140  else if (mutt_str_strcasecmp(buf->data, "none") == 0)
141  tmp = mutt_str_strdup("cheap_hack/this_should_never_match");
142  else
143  tmp = mutt_str_strdup(buf->data);
144 
145  minor = strchr(tmp, '/');
146  if (minor)
147  {
148  *minor = '\0';
149  minor++;
150  }
151  else
152  {
153  minor = "unknown";
154  }
155  const enum ContentType major = mutt_check_mime_type(tmp);
156 
157  struct ListNode *np = NULL, *tmp2 = NULL;
158  STAILQ_FOREACH_SAFE(np, head, entries, tmp2)
159  {
160  a = (struct AttachMatch *) np->data;
161  mutt_debug(LL_DEBUG3, "check %s/%s [%d] : %s/%s [%d]\n", a->major,
162  a->minor, a->major_int, tmp, minor, major);
163  if ((a->major_int == major) && (mutt_str_strcasecmp(minor, a->minor) == 0))
164  {
165  mutt_debug(LL_DEBUG3, "removed %s/%s [%d]\n", a->major, a->minor, a->major_int);
166  regfree(&a->minor_regex);
167  FREE(&a->major);
168  STAILQ_REMOVE(head, np, ListNode, entries);
169  FREE(&np->data);
170  FREE(&np);
171  }
172  }
173 
174  } while (MoreArgs(s));
175 
176  FREE(&tmp);
178  return MUTT_CMD_SUCCESS;
179 }
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:399
static void attachments_clean(void)
always wise to do what someone else did before
enum ContentType major_int
Definition: mutt_parse.h:38
#define MoreArgs(buf)
Definition: buffer.h:43
enum ContentType mutt_check_mime_type(const char *s)
Check a MIME type string.
Definition: parse.c:319
const char * major
Definition: mutt_parse.h:37
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:359
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
regex_t minor_regex
Definition: mutt_parse.h:40
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
An attachment matching a regex for attachment counter.
Definition: mutt_parse.h:35
A List node for strings.
Definition: list.h:33
const char * minor
Definition: mutt_parse.h:39
Log at debug level 3.
Definition: logging.h:42
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
ContentType
Content-Type.
Definition: mime.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear_subject_mods()

static void clear_subject_mods ( void  )
static

Clear out all modified email subjects.

Definition at line 184 of file command_parse.c.

185 {
186  if (!Context || !Context->mailbox)
187  return;
188 
189  struct Mailbox *m = Context->mailbox;
190  for (int i = 0; i < m->msg_count; i++)
191  {
192  struct Email *e = m->emails[i];
193  if (!e || !e->env)
194  continue;
195  FREE(&e->env->disp_subj);
196  }
197 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:98
The "current" mailbox.
Definition: context.h:36
int msg_count
Total number of messages.
Definition: mailbox.h:90
The envelope/body of an email.
Definition: email.h:37
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:68
struct Mailbox * mailbox
Definition: context.h:50
struct Envelope * env
Envelope information.
Definition: email.h:89
A mailbox.
Definition: mailbox.h:80
#define FREE(x)
Definition: memory.h:40
+ Here is the caller graph for this function:

◆ parse_replace_list()

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 202 of file command_parse.c.

204 {
205  struct ReplaceList *list = (struct ReplaceList *) data;
206  struct Buffer templ = mutt_buffer_make(0);
207 
208  /* First token is a regex. */
209  if (!MoreArgs(s))
210  {
211  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
212  return MUTT_CMD_WARNING;
213  }
215 
216  /* Second token is a replacement template */
217  if (!MoreArgs(s))
218  {
219  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
220  return MUTT_CMD_WARNING;
221  }
223 
224  if (mutt_replacelist_add(list, buf->data, templ.data, err) != 0)
225  {
226  FREE(&templ.data);
227  return MUTT_CMD_ERROR;
228  }
229  FREE(&templ.data);
230 
231  return MUTT_CMD_SUCCESS;
232 }
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:262
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
Warning: Help given to the user.
Definition: mutt_commands.h:36
#define FREE(x)
Definition: memory.h:40
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_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 240 of file command_parse.c.

241 {
242  for (enum MenuType i = 0; i < MENU_MAX; i++)
243  {
244  const struct Binding *b = km_get_table(Menus[i].value);
245  if (!b)
246  continue;
247 
248  for (int j = 0; b[j].name; j++)
249  if (mutt_str_strcmp(name, b[j].name) == 0)
250  return true;
251  }
252  return false;
253 }
MenuType
Types of GUI selections.
Definition: keymap.h:69
const char * name
Definition: pgpmicalg.c:46
const char * name
name of the function
Definition: keymap.h:116
const struct Mapping Menus[]
Menu name lookup table.
Definition: keymap.c:60
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu&#39;s keybindings.
Definition: keymap.c:1221
Mapping between a user key and a function.
Definition: keymap.h:114
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_attachmatch_new()

static struct AttachMatch* mutt_attachmatch_new ( void  )
static

Create a new AttachMatch.

Return values
ptrNew AttachMatch

Definition at line 259 of file command_parse.c.

260 {
261  return mutt_mem_calloc(1, sizeof(struct AttachMatch));
262 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
An attachment matching a regex for attachment counter.
Definition: mutt_parse.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_attach_list()

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

Parse the "attachments" command.

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

Definition at line 272 of file command_parse.c.

274 {
275  struct AttachMatch *a = NULL;
276  char *p = NULL;
277  char *tmpminor = NULL;
278  size_t len;
279  int ret;
280 
281  do
282  {
284 
285  if (!buf->data || (*buf->data == '\0'))
286  continue;
287 
288  a = mutt_attachmatch_new();
289 
290  /* some cheap hacks that I expect to remove */
291  if (mutt_str_strcasecmp(buf->data, "any") == 0)
292  a->major = mutt_str_strdup("*/.*");
293  else if (mutt_str_strcasecmp(buf->data, "none") == 0)
294  a->major = mutt_str_strdup("cheap_hack/this_should_never_match");
295  else
296  a->major = mutt_str_strdup(buf->data);
297 
298  p = strchr(a->major, '/');
299  if (p)
300  {
301  *p = '\0';
302  p++;
303  a->minor = p;
304  }
305  else
306  {
307  a->minor = "unknown";
308  }
309 
310  len = strlen(a->minor);
311  tmpminor = mutt_mem_malloc(len + 3);
312  strcpy(&tmpminor[1], a->minor);
313  tmpminor[0] = '^';
314  tmpminor[len + 1] = '$';
315  tmpminor[len + 2] = '\0';
316 
318  ret = REG_COMP(&a->minor_regex, tmpminor, REG_ICASE);
319 
320  FREE(&tmpminor);
321 
322  if (ret != 0)
323  {
324  regerror(ret, &a->minor_regex, err->data, err->dsize);
325  FREE(&a->major);
326  FREE(&a);
327  return MUTT_CMD_ERROR;
328  }
329 
330  mutt_debug(LL_DEBUG3, "added %s/%s [%d]\n", a->major, a->minor, a->major_int);
331 
332  mutt_list_insert_tail(head, (char *) a);
333  } while (MoreArgs(s));
334 
336  return MUTT_CMD_SUCCESS;
337 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
static void attachments_clean(void)
always wise to do what someone else did before
enum ContentType major_int
Definition: mutt_parse.h:38
static struct AttachMatch * mutt_attachmatch_new(void)
Create a new AttachMatch.
size_t dsize
Length of data.
Definition: buffer.h:37
#define MoreArgs(buf)
Definition: buffer.h:43
enum ContentType mutt_check_mime_type(const char *s)
Check a MIME type string.
Definition: parse.c:319
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition: regex3.h:52
const char * major
Definition: mutt_parse.h:37
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
regex_t minor_regex
Definition: mutt_parse.h:40
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
An attachment matching a regex for attachment counter.
Definition: mutt_parse.h:35
const char * minor
Definition: mutt_parse.h:39
Log at debug level 3.
Definition: logging.h:42
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_attach_list()

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 346 of file command_parse.c.

347 {
348  struct ListNode *np = NULL;
349  STAILQ_FOREACH(np, h, entries)
350  {
351  printf("attachments %c%s %s/%s\n", op, name,
352  ((struct AttachMatch *) np->data)->major,
353  ((struct AttachMatch *) np->data)->minor);
354  }
355 
356  return 0;
357 }
const char * name
Definition: pgpmicalg.c:46
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
char * data
String.
Definition: list.h:35
An attachment matching a regex for attachment counter.
Definition: mutt_parse.h:35
A List node for strings.
Definition: list.h:33
+ Here is the caller graph for this function:

◆ alternates_clean()

static void alternates_clean ( void  )
static

Clear the recipient valid flag of all emails.

Definition at line 362 of file command_parse.c.

363 {
364  if (!Context || !Context->mailbox)
365  return;
366 
367  struct Mailbox *m = Context->mailbox;
368  for (int i = 0; i < m->msg_count; i++)
369  {
370  struct Email *e = m->emails[i];
371  if (!e)
372  break;
373  e->recip_valid = false;
374  }
375 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:98
The "current" mailbox.
Definition: context.h:36
int msg_count
Total number of messages.
Definition: mailbox.h:90
The envelope/body of an email.
Definition: email.h:37
struct Mailbox * mailbox
Definition: context.h:50
A mailbox.
Definition: mailbox.h:80
bool recip_valid
Is_recipient is valid.
Definition: email.h:58
+ Here is the caller graph for this function:

◆ parse_grouplist()

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

Parse a group context.

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

Definition at line 387 of file command_parse.c.

389 {
390  while (mutt_str_strcasecmp(buf->data, "-group") == 0)
391  {
392  if (!MoreArgs(s))
393  {
394  mutt_buffer_strcpy(err, _("-group: no group name"));
395  return -1;
396  }
397 
399 
401 
402  if (!MoreArgs(s))
403  {
404  mutt_buffer_strcpy(err, _("out of arguments"));
405  return -1;
406  }
407 
409  }
410 
411  return 0;
412 }
void mutt_grouplist_add(struct GroupList *gl, struct Group *group)
Add a Group to a GroupList.
Definition: group.c:138
#define _(a)
Definition: message.h:28
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
struct Group * mutt_pattern_group(const char *pat)
Match a pattern to a Group.
Definition: group.c:66
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ source_rc()

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

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 420 of file command_parse.c.

421 {
422  int line = 0, rc = 0, warnings = 0;
423  enum CommandResult line_rc;
424  struct Buffer token;
425  char *linebuf = NULL;
426  char *currentline = NULL;
427  char rcfile[PATH_MAX];
428  size_t buflen;
429 
430  pid_t pid;
431 
432  mutt_str_strfcpy(rcfile, rcfile_path, sizeof(rcfile));
433 
434  size_t rcfilelen = mutt_str_strlen(rcfile);
435  if (rcfilelen == 0)
436  return -1;
437 
438  bool ispipe = rcfile[rcfilelen - 1] == '|';
439 
440  if (!ispipe)
441  {
442  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
443  if (!mutt_path_to_absolute(rcfile, np ? NONULL(np->data) : ""))
444  {
445  mutt_error(_("Error: Can't build path of '%s'"), rcfile_path);
446  return -1;
447  }
448 
449  STAILQ_FOREACH(np, &MuttrcStack, entries)
450  {
451  if (mutt_str_strcmp(np->data, rcfile) == 0)
452  {
453  break;
454  }
455  }
456  if (np)
457  {
458  mutt_error(_("Error: Cyclic sourcing of configuration file '%s'"), rcfile);
459  return -1;
460  }
461 
463  }
464 
465  mutt_debug(LL_DEBUG2, "Reading configuration file '%s'\n", rcfile);
466 
467  FILE *fp = mutt_open_read(rcfile, &pid);
468  if (!fp)
469  {
470  mutt_buffer_printf(err, "%s: %s", rcfile, strerror(errno));
471  return -1;
472  }
473 
474  mutt_buffer_init(&token);
475  while ((linebuf = mutt_file_read_line(linebuf, &buflen, fp, &line, MUTT_CONT)))
476  {
477  const bool conv = C_ConfigCharset && C_Charset;
478  if (conv)
479  {
480  currentline = mutt_str_strdup(linebuf);
481  if (!currentline)
482  continue;
483  mutt_ch_convert_string(&currentline, C_ConfigCharset, C_Charset, 0);
484  }
485  else
486  currentline = linebuf;
487  mutt_buffer_reset(err);
488  line_rc = mutt_parse_rc_line(currentline, &token, err);
489  if (line_rc == MUTT_CMD_ERROR)
490  {
491  mutt_error(_("Error in %s, line %d: %s"), rcfile, line, err->data);
492  if (--rc < -MAX_ERRS)
493  {
494  if (conv)
495  FREE(&currentline);
496  break;
497  }
498  }
499  else if (line_rc == MUTT_CMD_WARNING)
500  {
501  /* Warning */
502  mutt_warning(_("Warning in %s, line %d: %s"), rcfile, line, err->data);
503  warnings++;
504  }
505  else if (line_rc == MUTT_CMD_FINISH)
506  {
507  break; /* Found "finish" command */
508  }
509  else
510  {
511  if (rc < 0)
512  rc = -1;
513  }
514  if (conv)
515  FREE(&currentline);
516  }
517  FREE(&token.data);
518  FREE(&linebuf);
519  mutt_file_fclose(&fp);
520  if (pid != -1)
521  filter_wait(pid);
522  if (rc)
523  {
524  /* the neomuttrc source keyword */
525  mutt_buffer_reset(err);
526  mutt_buffer_printf(err, (rc >= -MAX_ERRS) ? _("source: errors in %s") : _("source: reading aborted due to too many errors in %s"),
527  rcfile);
528  rc = -1;
529  }
530  else
531  {
532  /* Don't alias errors with warnings */
533  if (warnings > 0)
534  {
535  mutt_buffer_printf(err, ngettext("source: %d warning in %s", "source: %d warnings in %s", warnings),
536  warnings, rcfile);
537  rc = -2;
538  }
539  }
540 
541  if (!ispipe && !STAILQ_EMPTY(&MuttrcStack))
542  {
543  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
544  STAILQ_REMOVE_HEAD(&MuttrcStack, entries);
545  FREE(&np->data);
546  FREE(&np);
547  }
548 
549  return rc;
550 }
#define mutt_warning(...)
Definition: logging.h:82
#define NONULL(x)
Definition: string2.h:37
int mutt_ch_convert_string(char **ps, const char *from, const char *to, int flags)
Convert a string between encodings.
Definition: charset.c:748
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, int flags)
Read a line from a file.
Definition: file.c:664
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:689
#define STAILQ_REMOVE_HEAD(head, field)
Definition: queue.h:419
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define MUTT_CONT
-continuation
Definition: file.h:38
WHERE char * C_ConfigCharset
Config: Character set that the config files are in.
Definition: globals.h:104
Log at debug level 2.
Definition: logging.h:41
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
const char * line
Definition: common.c:36
#define PATH_MAX
Definition: mutt.h:50
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
Definition: path.c:394
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:773
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition: list.c:46
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
char * data
String.
Definition: list.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:36
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
Finish: Stop processing this file.
Definition: mutt_commands.h:38
#define MAX_ERRS
Definition: command_parse.c:60
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
static struct ListHead MuttrcStack
Definition: command_parse.c:58
#define STAILQ_EMPTY(head)
Definition: queue.h:345
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:54
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
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:1402
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
#define STAILQ_FIRST(head)
Definition: queue.h:347
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:1001
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_alias()

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

Parse the 'alias' command - Implements command_t.

Definition at line 555 of file command_parse.c.

557 {
558  struct Alias *tmp = NULL;
559  char *estr = NULL;
560  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
561 
562  if (!MoreArgs(s))
563  {
564  mutt_buffer_strcpy(err, _("alias: no address"));
565  return MUTT_CMD_WARNING;
566  }
567 
569 
570  if (parse_grouplist(&gl, buf, s, data, err) == -1)
571  return MUTT_CMD_ERROR;
572 
573  /* check to see if an alias with this name already exists */
574  TAILQ_FOREACH(tmp, &Aliases, entries)
575  {
576  if (mutt_str_strcasecmp(tmp->name, buf->data) == 0)
577  break;
578  }
579 
580  if (tmp)
581  {
583  /* override the previous value */
584  mutt_addrlist_clear(&tmp->addr);
585  if (CurrentMenu == MENU_ALIAS)
587  }
588  else
589  {
590  /* create a new alias */
591  tmp = mutt_alias_new();
592  tmp->name = mutt_str_strdup(buf->data);
593  TAILQ_INSERT_TAIL(&Aliases, tmp, entries);
594  /* give the main addressbook code a chance */
595  if (CurrentMenu == MENU_ALIAS)
596  OptMenuCaller = true;
597  }
598 
600  mutt_debug(LL_DEBUG5, "Second token is '%s'\n", buf->data);
601 
602  mutt_addrlist_parse2(&tmp->addr, buf->data);
603 
604  if (mutt_addrlist_to_intl(&tmp->addr, &estr))
605  {
606  mutt_buffer_printf(err, _("Warning: Bad IDN '%s' in alias '%s'"), estr, tmp->name);
607  FREE(&estr);
608  goto bail;
609  }
610 
611  mutt_grouplist_add_addrlist(&gl, &tmp->addr);
613 
614  if (C_DebugLevel > LL_DEBUG4)
615  {
616  /* A group is terminated with an empty address, so check a->mailbox */
617  struct Address *a = NULL;
618  TAILQ_FOREACH(a, &tmp->addr, entries)
619  {
620  if (!a->mailbox)
621  break;
622 
623  if (a->group)
624  mutt_debug(LL_DEBUG5, " Group %s\n", a->mailbox);
625  else
626  mutt_debug(LL_DEBUG5, " %s\n", a->mailbox);
627  }
628  }
630  return MUTT_CMD_SUCCESS;
631 
632 bail:
634  return MUTT_CMD_ERROR;
635 }
void mutt_alias_delete_reverse(struct Alias *t)
Remove an email address lookup for an Alias.
Definition: alias.c:579
A shortcut for an email address.
Definition: alias.h:37
Log at debug level 4.
Definition: logging.h:43
char * name
Short name.
Definition: alias.h:39
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1382
WHERE bool OptMenuCaller
(pseudo) tell menu to give caller a take
Definition: options.h:38
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:82
#define _(a)
Definition: message.h:28
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
void mutt_grouplist_add_addrlist(struct GroupList *gl, struct AddressList *al)
Add Address list to a GroupList.
Definition: group.c:227
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:607
#define MoreArgs(buf)
Definition: buffer.h:43
struct Alias * mutt_alias_new(void)
Create a new Alias.
Definition: alias.c:144
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:80
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:426
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:79
char * data
Pointer to data.
Definition: buffer.h:35
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:802
Select an email address by its alias.
Definition: keymap.h:71
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
#define MUTT_TOKEN_SEMICOLON
Don&#39;t treat ; as special.
Definition: mutt.h:83
Success: Command worked.
Definition: mutt_commands.h:37
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1217
bool group
Group mailbox?
Definition: address.h:38
Warning: Help given to the user.
Definition: mutt_commands.h:36
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
void mutt_alias_add_reverse(struct Alias *t)
Add an email address lookup for an Alias.
Definition: alias.c:557
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:158
#define FREE(x)
Definition: memory.h:40
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct AddressList addr
List of Addresses the Alias expands to.
Definition: alias.h:40
Log at debug level 5.
Definition: logging.h:44
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_alternates()

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

Parse the 'alternates' command - Implements command_t.

Definition at line 640 of file command_parse.c.

642 {
643  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
644 
646 
647  do
648  {
650 
651  if (parse_grouplist(&gl, buf, s, data, err) == -1)
652  goto bail;
653 
654  mutt_regexlist_remove(&UnAlternates, buf->data);
655 
656  if (mutt_regexlist_add(&Alternates, buf->data, REG_ICASE, err) != 0)
657  goto bail;
658 
659  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
660  goto bail;
661  } while (MoreArgs(s));
662 
664  return MUTT_CMD_SUCCESS;
665 
666 bail:
668  return MUTT_CMD_ERROR;
669 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:277
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:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
static void alternates_clean(void)
Clear the recipient valid flag of all emails.
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:158
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_attachments()

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

Parse the 'attachments' command - Implements command_t.

Definition at line 674 of file command_parse.c.

676 {
677  char op;
678  char *category = NULL;
679  struct ListHead *head = NULL;
680 
682  if (!buf->data || (*buf->data == '\0'))
683  {
684  mutt_buffer_strcpy(err, _("attachments: no disposition"));
685  return MUTT_CMD_WARNING;
686  }
687 
688  category = buf->data;
689  op = *category++;
690 
691  if (op == '?')
692  {
693  mutt_endwin();
694  fflush(stdout);
695  printf("\n%s\n\n", _("Current attachments settings:"));
696  print_attach_list(&AttachAllow, '+', "A");
697  print_attach_list(&AttachExclude, '-', "A");
698  print_attach_list(&InlineAllow, '+', "I");
699  print_attach_list(&InlineExclude, '-', "I");
701  return MUTT_CMD_SUCCESS;
702  }
703 
704  if ((op != '+') && (op != '-'))
705  {
706  op = '+';
707  category--;
708  }
709  if (mutt_str_startswith("attachment", category, CASE_IGNORE))
710  {
711  if (op == '+')
712  head = &AttachAllow;
713  else
714  head = &AttachExclude;
715  }
716  else if (mutt_str_startswith("inline", category, CASE_IGNORE))
717  {
718  if (op == '+')
719  head = &InlineAllow;
720  else
721  head = &InlineExclude;
722  }
723  else
724  {
725  mutt_buffer_strcpy(err, _("attachments: invalid disposition"));
726  return MUTT_CMD_ERROR;
727  }
728 
729  return parse_attach_list(buf, s, head, err);
730 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
struct ListHead InlineAllow
List of inline types to counted.
Definition: mutt_parse.c:41
#define _(a)
Definition: message.h:28
static enum CommandResult parse_attach_list(struct Buffer *buf, struct Buffer *s, struct ListHead *head, struct Buffer *err)
Parse the "attachments" command.
static int print_attach_list(struct ListHead *h, const char op, const char *name)
Print a list of attachments.
struct ListHead InlineExclude
List of inline types to ignore.
Definition: mutt_parse.c:42
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:545
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Ignore case when comparing strings.
Definition: string2.h:68
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:578
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: mutt_parse.c:40
Success: Command worked.
Definition: mutt_commands.h:37
Warning: Help given to the user.
Definition: mutt_commands.h:36
struct ListHead AttachAllow
List of attachment types to be counted.
Definition: mutt_parse.c:39
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_echo()

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

Parse the 'echo' command - Implements command_t.

Definition at line 735 of file command_parse.c.

737 {
738  if (!MoreArgs(s))
739  {
740  mutt_buffer_printf(err, _("%s: too few arguments"), "echo");
741  return MUTT_CMD_WARNING;
742  }
744  OptForceRefresh = true;
745  mutt_message("%s", buf->data);
746  OptForceRefresh = false;
747  mutt_sleep(0);
748 
749  return MUTT_CMD_SUCCESS;
750 }
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define MoreArgs(buf)
Definition: buffer.h:43
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1544
WHERE bool OptForceRefresh
(pseudo) refresh even during macros
Definition: options.h:35
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
Warning: Help given to the user.
Definition: mutt_commands.h:36
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_finish()

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

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 759 of file command_parse.c.

761 {
762  if (MoreArgs(s))
763  {
764  mutt_buffer_printf(err, _("%s: too many arguments"), "finish");
765  return MUTT_CMD_WARNING;
766  }
767 
768  return MUTT_CMD_FINISH;
769 }
#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:160
#define MoreArgs(buf)
Definition: buffer.h:43
Warning: Help given to the user.
Definition: mutt_commands.h:36
Finish: Stop processing this file.
Definition: mutt_commands.h:38
+ Here is the call graph for this function:

◆ parse_group()

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.

Definition at line 774 of file command_parse.c.

776 {
777  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
778  enum GroupState state = GS_NONE;
779 
780  do
781  {
783  if (parse_grouplist(&gl, buf, s, data, err) == -1)
784  goto bail;
785 
786  if ((data == MUTT_UNGROUP) && (mutt_str_strcasecmp(buf->data, "*") == 0))
787  {
789  goto out;
790  }
791 
792  if (mutt_str_strcasecmp(buf->data, "-rx") == 0)
793  state = GS_RX;
794  else if (mutt_str_strcasecmp(buf->data, "-addr") == 0)
795  state = GS_ADDR;
796  else
797  {
798  switch (state)
799  {
800  case GS_NONE:
801  mutt_buffer_printf(err, _("%sgroup: missing -rx or -addr"),
802  (data == MUTT_UNGROUP) ? "un" : "");
803  goto warn;
804 
805  case GS_RX:
806  if ((data == MUTT_GROUP) &&
807  (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0))
808  {
809  goto bail;
810  }
811  else if ((data == MUTT_UNGROUP) &&
812  (mutt_grouplist_remove_regex(&gl, buf->data) < 0))
813  {
814  goto bail;
815  }
816  break;
817 
818  case GS_ADDR:
819  {
820  char *estr = NULL;
821  struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
822  mutt_addrlist_parse2(&al, buf->data);
823  if (TAILQ_EMPTY(&al))
824  goto bail;
825  if (mutt_addrlist_to_intl(&al, &estr))
826  {
827  mutt_buffer_printf(err, _("%sgroup: warning: bad IDN '%s'"),
828  (data == 1) ? "un" : "", estr);
829  mutt_addrlist_clear(&al);
830  FREE(&estr);
831  goto bail;
832  }
833  if (data == MUTT_GROUP)
834  mutt_grouplist_add_addrlist(&gl, &al);
835  else if (data == MUTT_UNGROUP)
837  mutt_addrlist_clear(&al);
838  break;
839  }
840  }
841  }
842  } while (MoreArgs(s));
843 
844 out:
846  return MUTT_CMD_SUCCESS;
847 
848 bail:
850  return MUTT_CMD_ERROR;
851 
852 warn:
854  return MUTT_CMD_WARNING;
855 }
#define MUTT_UNGROUP
&#39;ungroup&#39; config command
Definition: group.h:33
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
void mutt_grouplist_clear(struct GroupList *gl)
Clear a GroupList.
Definition: group.c:104
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1382
#define _(a)
Definition: message.h:28
void mutt_grouplist_add_addrlist(struct GroupList *gl, struct AddressList *al)
Add Address list to a GroupList.
Definition: group.c:227
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:607
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:277
int mutt_grouplist_remove_regex(struct GroupList *gl, const char *s)
Remove matching addresses from a GroupList.
Definition: group.c:301
GroupState
Type of email address group.
Definition: command_parse.c:65
int mutt_grouplist_remove_addrlist(struct GroupList *gl, struct AddressList *al)
Remove an AddressList from a GroupList.
Definition: group.c:246
Entry is an address.
Definition: command_parse.c:69
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Group is missing an argument.
Definition: command_parse.c:67
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Success: Command worked.
Definition: mutt_commands.h:37
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1217
Warning: Help given to the user.
Definition: mutt_commands.h:36
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:158
#define FREE(x)
Definition: memory.h:40
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
#define TAILQ_EMPTY(head)
Definition: queue.h:714
Entry is a regular expression.
Definition: command_parse.c:68
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:630
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
#define MUTT_GROUP
&#39;group&#39; config command
Definition: group.h:32
+ Here is the call graph for this function:

◆ parse_ifdef()

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.

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 870 of file command_parse.c.

872 {
873  struct Buffer token = mutt_buffer_make(0);
874 
876 
877  // is the item defined as:
878  bool res = cs_subset_lookup(NeoMutt->sub, buf->data) // a variable?
879  || feature_enabled(buf->data) // a compiled-in feature?
880  || is_function(buf->data) // a function?
881  || mutt_command_get(buf->data) // a command?
882  || myvar_get(buf->data) // a my_ variable?
883  || mutt_str_getenv(buf->data); // an environment variable?
884 
885  if (!MoreArgs(s))
886  {
887  mutt_buffer_printf(err, _("%s: too few arguments"), (data ? "ifndef" : "ifdef"));
888  return MUTT_CMD_WARNING;
889  }
891 
892  /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
893  if ((res && (data == 0)) || (!res && (data == 1)))
894  {
895  enum CommandResult rc = mutt_parse_rc_line(buf->data, &token, err);
896  if (rc == MUTT_CMD_ERROR)
897  {
898  mutt_error(_("Error: %s"), err->data);
899  FREE(&token.data);
900  return MUTT_CMD_ERROR;
901  }
902  FREE(&token.data);
903  return rc;
904  }
905  return MUTT_CMD_SUCCESS;
906 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
bool feature_enabled(const char *name)
Test if a compile-time feature is enabled.
Definition: version.c:505
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
static bool is_function(const char *name)
Is the argument a neomutt function?
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:166
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
Container for Accounts, Notifications.
Definition: neomutt.h:35
const struct Command * mutt_command_get(const char *s)
Get a Command by its name.
Definition: init.c:395
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1071
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:79
char * data
Pointer to data.
Definition: buffer.h:35
const char * myvar_get(const char *var)
Get the value of a "my_" variable.
Definition: myvar.c:73
Success: Command worked.
Definition: mutt_commands.h:37
Warning: Help given to the user.
Definition: mutt_commands.h:36
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:1001
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_ignore()

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

Parse the 'ignore' command - Implements command_t.

Definition at line 911 of file command_parse.c.

913 {
914  do
915  {
918  add_to_stailq(&Ignore, buf->data);
919  } while (MoreArgs(s));
920 
921  return MUTT_CMD_SUCCESS;
922 }
struct ListHead UnIgnore
List of header patterns to unignore (see)
Definition: email_globals.c:46
#define MoreArgs(buf)
Definition: buffer.h:43
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1801
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: muttlib.c:1826
Success: Command worked.
Definition: mutt_commands.h:37
struct ListHead Ignore
List of header patterns to ignore.
Definition: email_globals.c:45
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_lists()

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

Parse the 'lists' command - Implements command_t.

Definition at line 927 of file command_parse.c.

929 {
930  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
931 
932  do
933  {
935 
936  if (parse_grouplist(&gl, buf, s, data, err) == -1)
937  goto bail;
938 
940 
941  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
942  goto bail;
943 
944  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
945  goto bail;
946  } while (MoreArgs(s));
947 
949  return MUTT_CMD_SUCCESS;
950 
951 bail:
953  return MUTT_CMD_ERROR;
954 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:277
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:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: email_globals.c:50
char * data
Pointer to data.
Definition: buffer.h:35
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:158
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: email_globals.c:51
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_mailboxes()

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

Parse the 'mailboxes' command - Implements command_t.

This is also used by 'virtual-mailboxes'.

Definition at line 961 of file command_parse.c.

963 {
964  while (MoreArgs(s))
965  {
966  struct Mailbox *m = mailbox_new();
967 
968  if (data & MUTT_NAMED)
969  {
971  if (buf->data && (*buf->data != '\0'))
972  {
973  m->name = mutt_str_strdup(buf->data);
974  }
975  else
976  {
977  mailbox_free(&m);
978  continue;
979  }
980  }
981 
983  if (mutt_buffer_is_empty(buf))
984  {
985  /* Skip empty tokens. */
986  mailbox_free(&m);
987  continue;
988  }
989 
990  mutt_buffer_strcpy(&m->pathbuf, buf->data);
991  /* int rc = */ mx_path_canon2(m, C_Folder);
992 
993  if (m->magic <= MUTT_UNKNOWN)
994  {
995  mutt_error("Unknown Mailbox: %s", m->realpath);
996  mailbox_free(&m);
997  return MUTT_CMD_ERROR;
998  }
999 
1000  bool new_account = false;
1001  struct Account *a = mx_ac_find(m);
1002  if (!a)
1003  {
1004  a = account_new(NULL, NeoMutt->sub);
1005  a->magic = m->magic;
1006  new_account = true;
1007  }
1008 
1009  if (!new_account)
1010  {
1011  struct Mailbox *m_old = mx_mbox_find(a, m->realpath);
1012  if (m_old)
1013  {
1014  if (m_old->flags == MB_HIDDEN)
1015  {
1016  m_old->flags = MB_NORMAL;
1017  mutt_sb_notify_mailbox(m_old, true);
1018  }
1019  mailbox_free(&m);
1020  continue;
1021  }
1022  }
1023 
1024  if (mx_ac_add(a, m) < 0)
1025  {
1026  //error
1027  mailbox_free(&m);
1028  if (new_account)
1029  {
1030  cs_subset_free(&a->sub);
1031  FREE(&a->name);
1032  notify_free(&a->notify);
1033  FREE(&a);
1034  }
1035  continue;
1036  }
1037  if (new_account)
1038  {
1040  }
1041 
1042 #ifdef USE_SIDEBAR
1043  mutt_sb_notify_mailbox(m, true);
1044 #endif
1045 #ifdef USE_INOTIFY
1046  mutt_monitor_add(m);
1047 #endif
1048  }
1049  return MUTT_CMD_SUCCESS;
1050 }
char * name
Name of Account.
Definition: account.h:39
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
int mx_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Wrapper for MxOps::ac_add()
Definition: mx.c:1664
int mx_path_canon2(struct Mailbox *m, const char *folder)
Canonicalise the path to realpath.
Definition: mx.c:1451
struct Notify * notify
Notifications handler.
Definition: account.h:42
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:83
A group of associated Mailboxes.
Definition: account.h:36
Mailbox wasn&#39;t recognised.
Definition: mailbox.h:46
#define MUTT_NAMED
Definition: mutt_commands.h:73
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
Find a Mailbox on an Account.
Definition: mx.c:1558
void cs_subset_free(struct ConfigSubset **ptr)
Free a Config Subset.
Definition: subset.c:91
int mutt_monitor_add(struct Mailbox *m)
Add a watch for a mailbox.
Definition: monitor.c:478
struct Account * mx_ac_find(struct Mailbox *m)
Find the Account owning a Mailbox.
Definition: mx.c:1534
Container for Accounts, Notifications.
Definition: neomutt.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
char * name
A short name for the Mailbox.
Definition: mailbox.h:84
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:60
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:104
struct Account * account_new(const char *name, struct ConfigSubset *sub)
Create a new Account.
Definition: account.c:43
int flags
e.g. MB_NORMAL
Definition: mailbox.h:133
#define MB_HIDDEN
Definition: mailbox.h:37
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
Definition: globals.h:119
A mailbox.
Definition: mailbox.h:80
enum MailboxType magic
Type of Mailboxes this Account contains.
Definition: account.h:38
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:63
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition: mailbox.c:42
Success: Command worked.
Definition: mutt_commands.h:37
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: account.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
bool neomutt_account_add(struct NeoMutt *n, struct Account *a)
Add an Account to the global list.
Definition: neomutt.c:84
struct Buffer pathbuf
Definition: mailbox.h:82
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
#define MB_NORMAL
Definition: mailbox.h:36
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_my_hdr()

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.

Definition at line 1055 of file command_parse.c.

1057 {
1058  struct ListNode *n = NULL;
1059  size_t keylen;
1060 
1062  char *p = strpbrk(buf->data, ": \t");
1063  if (!p || (*p != ':'))
1064  {
1065  mutt_buffer_strcpy(err, _("invalid header field"));
1066  return MUTT_CMD_WARNING;
1067  }
1068  keylen = p - buf->data + 1;
1069 
1070  STAILQ_FOREACH(n, &UserHeader, entries)
1071  {
1072  /* see if there is already a field by this name */
1073  if (mutt_str_strncasecmp(buf->data, n->data, keylen) == 0)
1074  {
1075  break;
1076  }
1077  }
1078 
1079  if (!n)
1080  {
1081  /* not found, allocate memory for a new node and add it to the list */
1082  n = mutt_list_insert_tail(&UserHeader, NULL);
1083  }
1084  else
1085  {
1086  /* found, free the existing data */
1087  FREE(&n->data);
1088  }
1089 
1090  n->data = buf->data;
1091  mutt_buffer_init(buf);
1092 
1093  return MUTT_CMD_SUCCESS;
1094 }
#define _(a)
Definition: message.h:28
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:80
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:679
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:79
char * data
Pointer to data.
Definition: buffer.h:35
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:36
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
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:

◆ parse_path_list()

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.

Definition at line 1100 of file command_parse.c.

1102 {
1103  struct Buffer *path = mutt_buffer_pool_get();
1104 
1105  do
1106  {
1109  add_to_stailq((struct ListHead *) data, mutt_b2s(path));
1110  } while (MoreArgs(s));
1111  mutt_buffer_pool_release(&path);
1112 
1113  return MUTT_CMD_SUCCESS;
1114 }
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
#define MoreArgs(buf)
Definition: buffer.h:43
#define mutt_b2s(buf)
Definition: buffer.h:41
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1801
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:341
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_path_unlist()

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.

Definition at line 1121 of file command_parse.c.

1123 {
1124  struct Buffer *path = mutt_buffer_pool_get();
1125 
1126  do
1127  {
1129  /* Check for deletion of entire list */
1130  if (mutt_str_strcmp(mutt_b2s(path), "*") == 0)
1131  {
1132  mutt_list_free((struct ListHead *) data);
1133  break;
1134  }
1136  remove_from_stailq((struct ListHead *) data, mutt_b2s(path));
1137  } while (MoreArgs(s));
1138  mutt_buffer_pool_release(&path);
1139 
1140  return MUTT_CMD_SUCCESS;
1141 }
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
#define MoreArgs(buf)
Definition: buffer.h:43
#define mutt_b2s(buf)
Definition: buffer.h:41
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: muttlib.c:1826
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:341
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_set()

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.

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

Definition at line 1149 of file command_parse.c.

1151 {
1152  /* The order must match `enum MuttSetCommand` */
1153  static const char *set_commands[] = { "set", "toggle", "unset", "reset" };
1154 
1155  int rc = 0;
1156 
1157  while (MoreArgs(s))
1158  {
1159  bool prefix = false;
1160  bool query = false;
1161  bool inv = (data == MUTT_SET_INV);
1162  bool reset = (data == MUTT_SET_RESET);
1163  bool unset = (data == MUTT_SET_UNSET);
1164 
1165  if (*s->dptr == '?')
1166  {
1167  prefix = true;
1168  query = true;
1169  s->dptr++;
1170  }
1171  else if (mutt_str_startswith(s->dptr, "no", CASE_MATCH))
1172  {
1173  prefix = true;
1174  unset = !unset;
1175  s->dptr += 2;
1176  }
1177  else if (mutt_str_startswith(s->dptr, "inv", CASE_MATCH))
1178  {
1179  prefix = true;
1180  inv = !inv;
1181  s->dptr += 3;
1182  }
1183  else if (*s->dptr == '&')
1184  {
1185  prefix = true;
1186  reset = true;
1187  s->dptr++;
1188  }
1189 
1190  if (prefix && (data != MUTT_SET_SET))
1191  {
1192  mutt_buffer_printf(err, "ERR22 can't use 'inv', 'no', '&' or '?' with the '%s' command",
1193  set_commands[data]);
1194  return MUTT_CMD_WARNING;
1195  }
1196 
1197  /* get the variable name */
1199 
1200  bool bq = false;
1201  bool equals = false;
1202 
1203  struct HashElem *he = NULL;
1204  bool my = mutt_str_startswith(buf->data, "my_", CASE_MATCH);
1205  if (!my)
1206  {
1207  he = cs_subset_lookup(NeoMutt->sub, buf->data);
1208  if (!he)
1209  {
1210  if (reset && (mutt_str_strcmp(buf->data, "all") == 0))
1211  {
1212  struct HashElem **list = get_elem_list(NeoMutt->sub->cs);
1213  if (!list)
1214  return MUTT_CMD_ERROR;
1215 
1216  for (size_t i = 0; list[i]; i++)
1217  cs_subset_he_reset(NeoMutt->sub, list[i], NULL);
1218 
1219  FREE(&list);
1220  break;
1221  }
1222  else
1223  {
1224  mutt_buffer_printf(err, "ERR01 unknown variable: %s", buf->data);
1225  return MUTT_CMD_ERROR;
1226  }
1227  }
1228 
1229  bq = ((DTYPE(he->type) == DT_BOOL) || (DTYPE(he->type) == DT_QUAD));
1230  }
1231 
1232  if (*s->dptr == '?')
1233  {
1234  if (prefix)
1235  {
1236  mutt_buffer_printf(err,
1237  "ERR02 can't use a prefix when querying a variable");
1238  return MUTT_CMD_WARNING;
1239  }
1240 
1241  if (reset || unset || inv)
1242  {
1243  mutt_buffer_printf(err, "ERR03 can't query a variable with the '%s' command",
1244  set_commands[data]);
1245  return MUTT_CMD_WARNING;
1246  }
1247 
1248  query = true;
1249  s->dptr++;
1250  }
1251  else if (*s->dptr == '=')
1252  {
1253  if (prefix)
1254  {
1255  mutt_buffer_printf(err,
1256  "ERR04 can't use prefix when setting a variable");
1257  return MUTT_CMD_WARNING;
1258  }
1259 
1260  if (reset || unset || inv)
1261  {
1262  mutt_buffer_printf(err, "ERR05 can't set a variable with the '%s' command",
1263  set_commands[data]);
1264  return MUTT_CMD_WARNING;
1265  }
1266 
1267  equals = true;
1268  s->dptr++;
1269  }
1270 
1271  if (!bq && (inv || (unset && prefix)))
1272  {
1273  if (data == MUTT_SET_SET)
1274  {
1275  mutt_buffer_printf(err, "ERR06 prefixes 'no' and 'inv' may only be "
1276  "used with bool/quad variables");
1277  }
1278  else
1279  {
1280  mutt_buffer_printf(err, "ERR07 command '%s' can only be used with bool/quad variables",
1281  set_commands[data]);
1282  }
1283  return MUTT_CMD_WARNING;
1284  }
1285 
1286  if (reset)
1287  {
1288  // mutt_buffer_printf(err, "ACT24 reset variable %s", buf->data);
1289  if (he)
1290  {
1291  rc = cs_subset_he_reset(NeoMutt->sub, he, err);
1292  if (CSR_RESULT(rc) != CSR_SUCCESS)
1293  return MUTT_CMD_ERROR;
1294  }
1295  else
1296  {
1297  myvar_del(buf->data);
1298  }
1299  continue;
1300  }
1301 
1302  if ((data == MUTT_SET_SET) && !inv && !unset)
1303  {
1304  if (query)
1305  {
1306  // mutt_buffer_printf(err, "ACT08 query variable %s", buf->data);
1307  if (he)
1308  {
1309  mutt_buffer_addstr(err, buf->data);
1310  mutt_buffer_addch(err, '=');
1311  mutt_buffer_reset(buf);
1312  rc = cs_subset_he_string_get(NeoMutt->sub, he, buf);
1313  if (CSR_RESULT(rc) != CSR_SUCCESS)
1314  {
1315  mutt_buffer_addstr(err, buf->data);
1316  return MUTT_CMD_ERROR;
1317  }
1318  pretty_var(buf->data, err);
1319  }
1320  else
1321  {
1322  const char *val = myvar_get(buf->data);
1323  if (val)
1324  {
1325  mutt_buffer_addstr(err, buf->data);
1326  mutt_buffer_addch(err, '=');
1327  pretty_var(val, err);
1328  }
1329  else
1330  {
1331  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1332  return MUTT_CMD_ERROR;
1333  }
1334  }
1335  break;
1336  }
1337  else if (equals)
1338  {
1339  // mutt_buffer_printf(err, "ACT11 set variable %s to ", buf->data);
1340  const char *name = NULL;
1341  if (my)
1342  {
1343  name = mutt_str_strdup(buf->data);
1344  }
1346  if (my)
1347  {
1348  myvar_set(name, buf->data);
1349  FREE(&name);
1350  }
1351  else
1352  {
1353  if (IS_PATH(he))
1354  {
1356  struct Buffer scratch = mutt_buffer_make(1024);
1357  mutt_buffer_copy(&scratch, buf);
1358  size_t scratchlen = mutt_buffer_len(&scratch);
1359  if (!(he->type & DT_MAILBOX) && (scratchlen != 0))
1360  {
1361  if ((mutt_b2s(&scratch)[scratchlen - 1] != '|') && /* not a command */
1362  (url_check_scheme(mutt_b2s(&scratch)) == U_UNKNOWN)) /* probably a local file */
1363  {
1364  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
1365  if (mutt_path_to_absolute(scratch.data, np ? NONULL(np->data) : "./"))
1366  {
1367  mutt_buffer_reset(buf);
1368  mutt_buffer_addstr(buf, mutt_b2s(&scratch));
1369  }
1370  else
1371  {
1372  mutt_error(_("Error: Can't build path of '%s'"), mutt_b2s(&scratch));
1373  }
1374  }
1375  }
1376  mutt_buffer_dealloc(&scratch);
1377  }
1378  else if (IS_COMMAND(he))
1379  {
1380  struct Buffer scratch = mutt_buffer_make(1024);
1381  mutt_buffer_copy(&scratch, buf);
1382 
1383  if (mutt_str_strcmp(buf->data, "builtin") != 0)
1384  {
1385  mutt_buffer_expand_path(&scratch);
1386  }
1387  mutt_buffer_reset(buf);
1388  mutt_buffer_addstr(buf, mutt_b2s(&scratch));
1389  mutt_buffer_dealloc(&scratch);
1390  }
1391 
1392  rc = cs_subset_he_string_set(NeoMutt->sub, he, buf->data, err);
1393  if (CSR_RESULT(rc) != CSR_SUCCESS)
1394  return MUTT_CMD_ERROR;
1395  }
1396  continue;
1397  }
1398  else
1399  {
1400  if (bq)
1401  {
1402  // mutt_buffer_printf(err, "ACT23 set variable %s to 'yes'", buf->data);
1403  rc = cs_subset_he_native_set(NeoMutt->sub, he, true, err);
1404  if (CSR_RESULT(rc) != CSR_SUCCESS)
1405  return MUTT_CMD_ERROR;
1406  continue;
1407  }
1408  else
1409  {
1410  // mutt_buffer_printf(err, "ACT10 query variable %s", buf->data);
1411  if (he)
1412  {
1413  mutt_buffer_addstr(err, buf->data);
1414  mutt_buffer_addch(err, '=');
1415  mutt_buffer_reset(buf);
1416  rc = cs_subset_he_string_get(NeoMutt->sub, he, buf);
1417  if (CSR_RESULT(rc) != CSR_SUCCESS)
1418  {
1419  mutt_buffer_addstr(err, buf->data);
1420  return MUTT_CMD_ERROR;
1421  }
1422  pretty_var(buf->data, err);
1423  }
1424  else
1425  {
1426  const char *val = myvar_get(buf->data);
1427  if (val)
1428  {
1429  mutt_buffer_addstr(err, buf->data);
1430  mutt_buffer_addch(err, '=');
1431  pretty_var(val, err);
1432  }
1433  else
1434  {
1435  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1436  return MUTT_CMD_ERROR;
1437  }
1438  }
1439  break;
1440  }
1441  }
1442  }
1443 
1444  if (my)
1445  {
1446  myvar_del(buf->data);
1447  }
1448  else if (bq)
1449  {
1450  if (inv)
1451  {
1452  // mutt_buffer_printf(err, "ACT25 TOGGLE bool/quad variable %s", buf->data);
1453  if (DTYPE(he->type) == DT_BOOL)
1454  bool_he_toggle(NeoMutt->sub, he, err);
1455  else
1456  quad_he_toggle(NeoMutt->sub, he, err);
1457  }
1458  else
1459  {
1460  // mutt_buffer_printf(err, "ACT26 UNSET bool/quad variable %s", buf->data);
1461  rc = cs_subset_he_native_set(NeoMutt->sub, he, false, err);
1462  if (CSR_RESULT(rc) != CSR_SUCCESS)
1463  return MUTT_CMD_ERROR;
1464  }
1465  continue;
1466  }
1467  else
1468  {
1469  rc = cs_subset_he_string_set(NeoMutt->sub, he, NULL, err);
1470  if (CSR_RESULT(rc) != CSR_SUCCESS)
1471  return MUTT_CMD_ERROR;
1472  }
1473  }
1474 
1475  return MUTT_CMD_SUCCESS;
1476 }
#define NONULL(x)
Definition: string2.h:37
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
#define IS_PATH(x)
Definition: types.h:55
#define CSR_RESULT(x)
Definition: set.h:53
struct HashElem ** get_elem_list(struct ConfigSet *cs)
Create a sorted list of all config items.
Definition: subset.c:62
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
size_t mutt_buffer_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer&#39;s contents to another Buffer.
Definition: buffer.c:445
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
int cs_subset_he_string_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: subset.c:339
Url wasn&#39;t recognised.
Definition: url.h:34
#define _(a)
Definition: message.h:28
Match case when comparing strings.
Definition: string2.h:67
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:166
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:36
Container for Accounts, Notifications.
Definition: neomutt.h:35
enum UrlScheme url_check_scheme(const char *s)
Check the protocol of a URL.
Definition: url.c:132
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:43
default is to reset all vars to default
Definition: mutt_commands.h:69
#define MoreArgs(buf)
Definition: buffer.h:43
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:49
const char * name
Definition: pgpmicalg.c:46
int cs_subset_he_string_set(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Set a config item by string.
Definition: subset.c:371
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
void myvar_del(const char *var)
Unset the value of a "my_" variable.
Definition: myvar.c:112
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:37
#define mutt_b2s(buf)
Definition: buffer.h:41
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:356
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
#define DT_MAILBOX
Don&#39;t perform path expansions.
Definition: types.h:47
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
Definition: path.c:394
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
void myvar_set(const char *var, const char *val)
Set the value of a "my_" variable.
Definition: myvar.c:91
default is to unset all vars
Definition: mutt_commands.h:68
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:240
const char * myvar_get(const char *var)
Get the value of a "my_" variable.
Definition: myvar.c:73
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
void * data
Definition: hash.h:46
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
Definition: dump.c:80
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:35
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:341
Warning: Help given to the user.
Definition: mutt_commands.h:36
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
int bool_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:211
#define mutt_error(...)
Definition: logging.h:84
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:84
int type
Definition: hash.h:44
#define FREE(x)
Definition: memory.h:40
static struct ListHead MuttrcStack
Definition: command_parse.c:58
int quad_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a quad.
Definition: quad.c:228
The item stored in a Hash Table.
Definition: hash.h:42
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:77
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
#define IS_COMMAND(x)
Definition: types.h:56
default is to set all vars
Definition: mutt_commands.h:66
A List node for strings.
Definition: list.h:33
int cs_subset_he_native_set(const struct ConfigSubset *sub, struct HashElem *he, intptr_t value, struct Buffer *err)
Natively set the value of a HashElem config item.
Definition: subset.c:268
#define STAILQ_FIRST(head)
Definition: queue.h:347
int cs_subset_he_reset(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Reset a config item to its initial value.
Definition: subset.c:305
#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:638
default is to invert all vars
Definition: mutt_commands.h:67
#define MUTT_TOKEN_QUESTION
Treat &#39;?&#39; as a special.
Definition: mutt.h:86
+ Here is the call graph for this function:

◆ parse_setenv()

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.

Definition at line 1481 of file command_parse.c.

1483 {
1484  char **envp = mutt_envlist_getlist();
1485 
1486  bool query = false;
1487  bool unset = (data == MUTT_SET_UNSET);
1488 
1489  if (!MoreArgs(s))
1490  {
1491  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1492  return MUTT_CMD_WARNING;
1493  }
1494 
1495  if (*s->dptr == '?')
1496  {
1497  query = true;
1498  s->dptr++;
1499  }
1500 
1501  /* get variable name */
1503 
1504  if (query)
1505  {
1506  bool found = false;
1507  while (envp && *envp)
1508  {
1509  /* This will display all matches for "^QUERY" */
1510  if (mutt_str_startswith(*envp, buf->data, CASE_MATCH))
1511  {
1512  if (!found)
1513  {
1514  mutt_endwin();
1515  found = true;
1516  }
1517  puts(*envp);
1518  }
1519  envp++;
1520  }
1521 
1522  if (found)
1523  {
1525  return MUTT_CMD_SUCCESS;
1526  }
1527 
1528  mutt_buffer_printf(err, _("%s is unset"), buf->data);
1529  return MUTT_CMD_WARNING;
1530  }
1531 
1532  if (unset)
1533  {
1534  if (mutt_envlist_unset(buf->data))
1535  return MUTT_CMD_SUCCESS;
1536  return MUTT_CMD_ERROR;
1537  }
1538 
1539  /* set variable */
1540 
1541  if (*s->dptr == '=')
1542  {
1543  s->dptr++;
1544  SKIPWS(s->dptr);
1545  }
1546 
1547  if (!MoreArgs(s))
1548  {
1549  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1550  return MUTT_CMD_WARNING;
1551  }
1552 
1553  char *name = mutt_str_strdup(buf->data);
1555  mutt_envlist_set(name, buf->data, true);
1556  FREE(&name);
1557 
1558  return MUTT_CMD_SUCCESS;
1559 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define _(a)
Definition: message.h:28
Match case when comparing strings.
Definition: string2.h:67
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define MoreArgs(buf)
Definition: buffer.h:43
const char * name
Definition: pgpmicalg.c:46
#define SKIPWS(ch)
Definition: string2.h:47
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:545
bool mutt_envlist_unset(const char *name)
Unset an environment variable.
Definition: envlist.c:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
default is to unset all vars
Definition: mutt_commands.h:68
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:578
Success: Command worked.
Definition: mutt_commands.h:37
Warning: Help given to the user.
Definition: mutt_commands.h:36
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define FREE(x)
Definition: memory.h:40
bool mutt_envlist_set(const char *name, const char *value, bool overwrite)
Set an environment variable.
Definition: envlist.c:85
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:77
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
char ** mutt_envlist_getlist(void)
Get the private environment.
Definition: envlist.c:169
+ Here is the call graph for this function:

◆ parse_source()

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

Parse the 'source' command - Implements command_t.

Definition at line 1564 of file command_parse.c.

1566 {
1567  char path[PATH_MAX];
1568 
1569  do
1570  {
1571  if (mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS) != 0)
1572  {
1573  mutt_buffer_printf(err, _("source: error at %s"), s->dptr);
1574  return MUTT_CMD_ERROR;
1575  }
1576  mutt_str_strfcpy(path, buf->data, sizeof(path));
1577  mutt_expand_path(path, sizeof(path));
1578 
1579  if (source_rc(path, err) < 0)
1580  {
1581  mutt_buffer_printf(err, _("source: file %s could not be sourced"), path);
1582  return MUTT_CMD_ERROR;
1583  }
1584 
1585  } while (MoreArgs(s));
1586 
1587  return MUTT_CMD_SUCCESS;
1588 }
int source_rc(const char *rcfile_path, struct Buffer *err)
Read an initialization file.
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#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:160
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:132
#define MoreArgs(buf)
Definition: buffer.h:43
#define PATH_MAX
Definition: mutt.h:50
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
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:773
Success: Command worked.
Definition: mutt_commands.h:37
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_spam_list()

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.

Definition at line 1593 of file command_parse.c.

1595 {
1596  struct Buffer templ;
1597 
1598  mutt_buffer_init(&templ);
1599 
1600  /* Insist on at least one parameter */
1601  if (!MoreArgs(s))
1602  {
1603  if (data == MUTT_SPAM)
1604  mutt_buffer_strcpy(err, _("spam: no matching pattern"));
1605  else
1606  mutt_buffer_strcpy(err, _("nospam: no matching pattern"));
1607  return MUTT_CMD_ERROR;
1608  }
1609 
1610  /* Extract the first token, a regex */
1612 
1613  /* data should be either MUTT_SPAM or MUTT_NOSPAM. MUTT_SPAM is for spam commands. */
1614  if (data == MUTT_SPAM)
1615  {
1616  /* If there's a second parameter, it's a template for the spam tag. */
1617  if (MoreArgs(s))
1618  {
1620 
1621  /* Add to the spam list. */
1622  if (mutt_replacelist_add(&SpamList, buf->data, templ.data, err) != 0)
1623  {
1624  FREE(&templ.data);
1625  return MUTT_CMD_ERROR;
1626  }
1627  FREE(&templ.data);
1628  }
1629  /* If not, try to remove from the nospam list. */
1630  else
1631  {
1633  }
1634 
1635  return MUTT_CMD_SUCCESS;
1636  }
1637  /* MUTT_NOSPAM is for nospam commands. */
1638  else if (data == MUTT_NOSPAM)
1639  {
1640  /* nospam only ever has one parameter. */
1641 
1642  /* "*" is a special case. */
1643  if (mutt_str_strcmp(buf->data, "*") == 0)
1644  {
1647  return MUTT_CMD_SUCCESS;
1648  }
1649 
1650  /* If it's on the spam list, just remove it. */
1651  if (mutt_replacelist_remove(&SpamList, buf->data) != 0)
1652  return MUTT_CMD_SUCCESS;
1653 
1654  /* Otherwise, add it to the nospam list. */
1655  if (mutt_regexlist_add(&NoSpamList, buf->data, REG_ICASE, err) != 0)
1656  return MUTT_CMD_ERROR;
1657 
1658  return MUTT_CMD_SUCCESS;
1659  }
1660 
1661  /* This should not happen. */
1662  mutt_buffer_strcpy(err, "This is no good at all.");
1663  return MUTT_CMD_ERROR;
1664 }
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:262
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define MUTT_NOSPAM
Definition: mutt.h:119
struct ReplaceList SpamList
List of regexes and patterns to match spam emails.
Definition: email_globals.c:44
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:447
#define MoreArgs(buf)
Definition: buffer.h:43
#define MUTT_SPAM
Definition: mutt.h:118
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
Success: Command worked.
Definition: mutt_commands.h:37
int mutt_replacelist_remove(struct ReplaceList *rl, const char *pat)
Remove a pattern from a list.
Definition: regex.c:564
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
struct RegexList NoSpamList
List of regexes to whitelist non-spam emails.
Definition: email_globals.c:43
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition: regex.c:170
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_stailq()

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

Parse a list command - Implements command_t.

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

Definition at line 1671 of file command_parse.c.

1673 {
1674  do
1675  {
1677  add_to_stailq((struct ListHead *) data, buf->data);
1678  } while (MoreArgs(s));
1679 
1680  return MUTT_CMD_SUCCESS;
1681 }
#define MoreArgs(buf)
Definition: buffer.h:43
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1801
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_subjectrx_list()

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

Parse the 'subjectrx' command - Implements command_t.

Definition at line 1686 of file command_parse.c.

1688 {
1689  enum CommandResult rc;
1690 
1691  rc = parse_replace_list(buf, s, data, err);
1692  if (rc == MUTT_CMD_SUCCESS)
1694  return rc;
1695 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
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.
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
static void clear_subject_mods(void)
Clear out all modified email subjects.
+ Here is the call graph for this function:

◆ parse_subscribe()

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

Parse the 'subscribe' command - Implements command_t.

Definition at line 1700 of file command_parse.c.

1702 {
1703  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
1704 
1705  do
1706  {
1708 
1709  if (parse_grouplist(&gl, buf, s, data, err) == -1)
1710  goto bail;
1711 
1714 
1715  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
1716  goto bail;
1717  if (mutt_regexlist_add(&SubscribedLists, buf->data, REG_ICASE, err) != 0)
1718  goto bail;
1719  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
1720  goto bail;
1721  } while (MoreArgs(s));
1722 
1724  return MUTT_CMD_SUCCESS;
1725 
1726 bail:
1728  return MUTT_CMD_ERROR;
1729 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:277
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:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: email_globals.c:50
char * data
Pointer to data.
Definition: buffer.h:35
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: email_globals.c:52
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse a group context.
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:158
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: email_globals.c:51
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: email_globals.c:49
+ Here is the call graph for this function:

◆ parse_subscribe_to()

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.

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 1739 of file command_parse.c.

1741 {
1742  if (!buf || !s || !err)
1743  return MUTT_CMD_ERROR;
1744 
1745  mutt_buffer_reset(err);
1746 
1747  if (MoreArgs(s))
1748  {
1750 
1751  if (MoreArgs(s))
1752  {
1753  mutt_buffer_printf(err, _("%s: too many arguments"), "subscribe-to");
1754  return MUTT_CMD_WARNING;
1755  }
1756 
1757  if (buf->data && (*buf->data != '\0'))
1758  {
1759  /* Expand and subscribe */
1760  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), true) == 0)
1761  {
1762  mutt_message(_("Subscribed to %s"), buf->data);
1763  return MUTT_CMD_SUCCESS;
1764  }
1765 
1766  mutt_buffer_printf(err, _("Could not subscribe to %s"), buf->data);
1767  return MUTT_CMD_ERROR;
1768  }
1769 
1770  mutt_debug(LL_DEBUG1, "Corrupted buffer");
1771  return MUTT_CMD_ERROR;
1772  }
1773 
1774  mutt_buffer_addstr(err, _("No folder specified"));
1775  return MUTT_CMD_WARNING;
1776 }
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
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:132
#define MoreArgs(buf)
Definition: buffer.h:43
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
Log at debug level 1.
Definition: logging.h:40
Warning: Help given to the user.
Definition: mutt_commands.h:36
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1404
+ Here is the call graph for this function:

◆ parse_tag_formats()

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.

Definition at line 1782 of file command_parse.c.

1784 {
1785  if (!buf || !s)
1786  return MUTT_CMD_ERROR;
1787 
1788  char *tmp = NULL;
1789 
1790  while (MoreArgs(s))
1791  {
1792  char *tag = NULL, *format = NULL;
1793 
1795  if (buf->data && (*buf->data != '\0'))
1796  tag = mutt_str_strdup(buf->data);
1797  else
1798  continue;
1799 
1801  format = mutt_str_strdup(buf->data);
1802 
1803  /* avoid duplicates */
1804  tmp = mutt_hash_find(TagFormats, format);
1805  if (tmp)
1806  {
1807  mutt_debug(LL_DEBUG3, "tag format '%s' already registered as '%s'\n", format, tmp);
1808  FREE(&tag);
1809  FREE(&format);
1810  continue;
1811  }
1812 
1813  mutt_hash_insert(TagFormats, format, tag);
1814  }
1815  return MUTT_CMD_SUCCESS;
1816 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
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:378
WHERE struct Hash * TagFormats
Hash table of tag-formats (tag -> format string)
Definition: globals.h:60
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct HashElem * mutt_hash_insert(struct Hash *table, const char *strkey, void *data)
Add a new element to the Hash table (with string keys)
Definition: hash.c:351
Log at debug level 3.
Definition: logging.h:42
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_tag_transforms()

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.

Definition at line 1821 of file command_parse.c.

1823 {
1824  if (!buf || !s)
1825  return MUTT_CMD_ERROR;
1826 
1827  char *tmp = NULL;
1828 
1829  while (MoreArgs(s))
1830  {
1831  char *tag = NULL, *transform = NULL;
1832 
1834  if (buf->data && (*buf->data != '\0'))
1835  tag = mutt_str_strdup(buf->data);
1836  else
1837  continue;
1838 
1840  transform = mutt_str_strdup(buf->data);
1841 
1842  /* avoid duplicates */
1843  tmp = mutt_hash_find(TagTransforms, tag);
1844  if (tmp)
1845  {
1846  mutt_debug(LL_DEBUG3, "tag transform '%s' already registered as '%s'\n", tag, tmp);
1847  FREE(&tag);
1848  FREE(&transform);
1849  continue;
1850  }
1851 
1852  mutt_hash_insert(TagTransforms, tag, transform);
1853  }
1854  return MUTT_CMD_SUCCESS;
1855 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:38
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:378
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct HashElem * mutt_hash_insert(struct Hash *table, const char *strkey, void *data)
Add a new element to the Hash table (with string keys)
Definition: hash.c:351
Log at debug level 3.
Definition: logging.h:42
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_unalias()

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

Parse the 'unalias' command - Implements command_t.

Definition at line 1860 of file command_parse.c.

1862 {
1863  struct Alias *a = NULL;
1864 
1865  do
1866  {
1868 
1869  if (mutt_str_strcmp("*", buf->data) == 0)
1870  {
1871  if (CurrentMenu == MENU_ALIAS)
1872  {
1873  TAILQ_FOREACH(a, &Aliases, entries)
1874  {
1875  a->del = true;
1876  }
1878  }
1879  else
1880  mutt_aliaslist_free(&Aliases);
1881  break;
1882  }
1883  else
1884  {
1885  TAILQ_FOREACH(a, &Aliases, entries)
1886  {
1887  if (mutt_str_strcasecmp(buf->data, a->name) == 0)
1888  {
1889  if (CurrentMenu == MENU_ALIAS)
1890  {
1891  a->del = true;
1893  }
1894  else
1895  {
1896  TAILQ_REMOVE(&Aliases, a, entries);
1897  mutt_alias_free(&a);
1898  }
1899  break;
1900  }
1901  }
1902  }
1903  } while (MoreArgs(s));
1904  return MUTT_CMD_SUCCESS;
1905 }
A shortcut for an email address.
Definition: alias.h:37
char * name
Short name.
Definition: alias.h:39
void mutt_aliaslist_free(struct AliasList *a_list)
Free a List of Aliases.
Definition: alias.c:762
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:82
#define MoreArgs(buf)
Definition: buffer.h:43
bool del
Is it deleted?
Definition: alias.h:42
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:834
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
void mutt_alias_free(struct Alias **ptr)
Free an Alias.
Definition: alias.c:745
char * data
Pointer to data.
Definition: buffer.h:35
Select an email address by its alias.
Definition: keymap.h:71
Success: Command worked.
Definition: mutt_commands.h:37
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_unalternates()

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

Parse the 'unalternates' command - Implements command_t.

Definition at line 1910 of file command_parse.c.

1912 {
1913  alternates_clean();
1914  do
1915  {
1917  mutt_regexlist_remove(&Alternates, buf->data);
1918 
1919  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
1920  (mutt_regexlist_add(&UnAlternates, buf->data, REG_ICASE, err) != 0))
1921  {
1922  return MUTT_CMD_ERROR;
1923  }
1924 
1925  } while (MoreArgs(s));
1926 
1927  return MUTT_CMD_SUCCESS;
1928 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
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:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
static void alternates_clean(void)
Clear the recipient valid flag of all emails.
Success: Command worked.
Definition: mutt_commands.h:37
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_unattachments()

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

Parse the 'unattachments' command - Implements command_t.

Definition at line 1933 of file command_parse.c.

1935 {
1936  char op;
1937  char *p = NULL;
1938  struct ListHead *head = NULL;
1939 
1941  if (!buf->data || (*buf->data == '\0'))
1942  {
1943  mutt_buffer_strcpy(err, _("unattachments: no disposition"));
1944  return MUTT_CMD_WARNING;
1945  }
1946 
1947  p = buf->data;
1948  op = *p++;
1949 
1950  if (op == '*')
1951  {
1957  return 0;
1958  }
1959 
1960  if ((op != '+') && (op != '-'))
1961  {
1962  op = '+';
1963  p--;
1964  }
1965  if (mutt_str_startswith("attachment", p, CASE_IGNORE))
1966  {
1967  if (op == '+')
1968  head = &AttachAllow;
1969  else
1970  head = &AttachExclude;
1971  }
1972  else if (mutt_str_startswith("inline", p, CASE_IGNORE))
1973  {
1974  if (op == '+')
1975  head = &InlineAllow;
1976  else
1977  head = &InlineExclude;
1978  }
1979  else
1980  {
1981  mutt_buffer_strcpy(err, _("unattachments: invalid disposition"));
1982  return MUTT_CMD_ERROR;
1983  }
1984 
1985  return parse_unattach_list(buf, s, head, err);
1986 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
struct ListHead InlineAllow
List of inline types to counted.
Definition: mutt_parse.c:41
static void attachments_clean(void)
always wise to do what someone else did before
void mutt_list_free_type(struct ListHead *h, list_free_t fn)
Free a List of type.
Definition: list.c:145
#define _(a)
Definition: message.h:28
struct ListHead InlineExclude
List of inline types to ignore.
Definition: mutt_parse.c:42
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Ignore case when comparing strings.
Definition: string2.h:68
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: mutt_parse.c:40
Warning: Help given to the user.
Definition: mutt_commands.h:36
static enum CommandResult parse_unattach_list(struct Buffer *buf, struct Buffer *s, struct ListHead *head, struct Buffer *err)
Parse the "unattachments" command.
void mutt_attachmatch_free(struct AttachMatch **ptr)
Free an AttachMatch - Implements list_free_t.
Definition: mutt_parse.c:241
struct ListHead AttachAllow
List of attachment types to be counted.
Definition: mutt_parse.c:39
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
void(* list_free_t)(void **ptr)
typedef list_free_t - Prototype for a function to free List data
Definition: list.h:44
+ Here is the call graph for this function:

◆ parse_unignore()

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

Parse the 'unignore' command - Implements command_t.

Definition at line 1991 of file command_parse.c.

1993 {
1994  do
1995  {
1997 
1998  /* don't add "*" to the unignore list */
1999  if (strcmp(buf->data, "*") != 0)
2000  add_to_stailq(&UnIgnore, buf->data);
2001 
2002  remove_from_stailq(&Ignore, buf->data);
2003  } while (MoreArgs(s));
2004 
2005  return MUTT_CMD_SUCCESS;
2006 }
struct ListHead UnIgnore
List of header patterns to unignore (see)
Definition: email_globals.c:46
#define MoreArgs(buf)
Definition: buffer.h:43
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1801
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: muttlib.c:1826
Success: Command worked.
Definition: mutt_commands.h:37
struct ListHead Ignore
List of header patterns to ignore.
Definition: email_globals.c:45
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_unlists()

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

Parse the 'unlists' command - Implements command_t.

Definition at line 2011 of file command_parse.c.

2013 {
2015  do
2016  {
2020 
2021  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2022  (mutt_regexlist_add(&UnMailLists, buf->data, REG_ICASE, err) != 0))
2023  {
2024  return MUTT_CMD_ERROR;
2025  }
2026  } while (MoreArgs(s));
2027 
2028  return MUTT_CMD_SUCCESS;
2029 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
struct Hash * AutoSubscribeCache
Hash table of auto-subscribed mailing lists.
Definition: email_globals.c:48
#define MoreArgs(buf)
Definition: buffer.h:43
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:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: email_globals.c:50
char * data
Pointer to data.
Definition: buffer.h:35
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: email_globals.c:52
Success: Command worked.
Definition: mutt_commands.h:37
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: email_globals.c:51
void mutt_hash_free(struct Hash **ptr)
Free a hash table.
Definition: hash.c:471
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_unmailboxes()

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

Parse the 'unmailboxes' command - Implements command_t.

This is also used by 'unvirtual-mailboxes'

Definition at line 2036 of file command_parse.c.

2038 {
2039  bool tmp_valid = false;
2040  bool clear_all = false;
2041 
2042  while (!clear_all && MoreArgs(s))
2043  {
2045 
2046  if (mutt_str_strcmp(buf->data, "*") == 0)
2047  {
2048  clear_all = true;
2049  tmp_valid = false;
2050  }
2051  else
2052  {
2054  tmp_valid = true;
2055  }
2056 
2057  struct MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_MAILBOX_ANY);
2058  struct MailboxNode *np = NULL;
2059  struct MailboxNode *nptmp = NULL;
2060  STAILQ_FOREACH_SAFE(np, &ml, entries, nptmp)
2061  {
2062  /* Compare against path or desc? Ensure 'buf' is valid */
2063  if (!clear_all && tmp_valid &&
2064  (mutt_str_strcasecmp(mutt_b2s(buf), mailbox_path(np->mailbox)) != 0) &&
2065  (mutt_str_strcasecmp(mutt_b2s(buf), np->mailbox->name) != 0))
2066  {
2067  continue;
2068  }
2069 
2070 #ifdef USE_SIDEBAR
2071  mutt_sb_notify_mailbox(np->mailbox, false);
2072 #endif
2073 #ifdef USE_INOTIFY
2075 #endif
2076  if (Context && (Context->mailbox == np->mailbox))
2077  {
2078  np->mailbox->flags |= MB_HIDDEN;
2079  }
2080  else
2081  {
2083  mailbox_free(&np->mailbox);
2084  }
2085  }
2087  }
2088  return MUTT_CMD_SUCCESS;
2089 }
The "current" mailbox.
Definition: context.h:36
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:191
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:135
int mutt_monitor_remove(struct Mailbox *m)
Remove a watch for a mailbox.
Definition: monitor.c:523
Match any Mailbox type.
Definition: mailbox.h:44
Container for Accounts, Notifications.
Definition: neomutt.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
char * name
A short name for the Mailbox.
Definition: mailbox.h:84
struct Mailbox * mailbox
Definition: context.h:50
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:60
struct MailboxList neomutt_mailboxlist_get_all(struct NeoMutt *n, enum MailboxType magic)
Get a List of all Mailboxes.
Definition: neomutt.c:157
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:359
int flags
e.g. MB_NORMAL
Definition: mailbox.h:133
#define mutt_b2s(buf)
Definition: buffer.h:41
#define MB_HIDDEN
Definition: mailbox.h:37
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:341
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:130
bool account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
Definition: account.c:95
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
List of Mailboxes.
Definition: mailbox.h:144
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:146
+ Here is the call graph for this function:

◆ parse_unmy_hdr()

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.

Definition at line 2094 of file command_parse.c.

2096 {
2097  struct ListNode *np = NULL, *tmp = NULL;
2098  size_t l;
2099 
2100  do
2101  {
2103  if (mutt_str_strcmp("*", buf->data) == 0)
2104  {
2105  mutt_list_free(&UserHeader);
2106  continue;
2107  }
2108 
2109  l = mutt_str_strlen(buf->data);
2110  if (buf->data[l - 1] == ':')
2111  l--;
2112 
2113  STAILQ_FOREACH_SAFE(np, &UserHeader, entries, tmp)
2114  {
2115  if ((mutt_str_strncasecmp(buf->data, np->data, l) == 0) && (np->data[l] == ':'))
2116  {
2117  STAILQ_REMOVE(&UserHeader, np, ListNode, entries);
2118  FREE(&np->data);
2119  FREE(&np);
2120  }
2121  }
2122  } while (MoreArgs(s));
2123  return MUTT_CMD_SUCCESS;
2124 }
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:399
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:689
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
#define MoreArgs(buf)
Definition: buffer.h:43
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:359
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:679
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
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:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_unstailq()

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

Parse an unlist command - Implements command_t.

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

Definition at line 2131 of file command_parse.c.

2133 {
2134  do
2135  {
2137  /* Check for deletion of entire list */
2138  if (mutt_str_strcmp(buf->data, "*") == 0)
2139  {
2140  mutt_list_free((struct ListHead *) data);
2141  break;
2142  }
2143  remove_from_stailq((struct ListHead *) data, buf->data);
2144  } while (MoreArgs(s));
2145 
2146  return MUTT_CMD_SUCCESS;
2147 }
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: muttlib.c:1826
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:35
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
+ Here is the call graph for this function:

◆ parse_unsubjectrx_list()

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

Parse the 'unsubjectrx' command - Implements command_t.

Definition at line 2152 of file command_parse.c.

2154 {
2155  enum CommandResult rc;
2156 
2157  rc = parse_unreplace_list(buf, s, data, err);
2158  if (rc == MUTT_CMD_SUCCESS)
2160  return rc;
2161 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:35
static void clear_subject_mods(void)
Clear out all modified email subjects.
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: command_parse.c:75
+ Here is the call graph for this function:

◆ parse_unsubscribe()

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

Parse the 'unsubscribe' command - Implements command_t.

Definition at line 2166 of file command_parse.c.

2168 {
2170  do
2171  {
2174 
2175  if ((mutt_str_strcmp(buf->data, "*") != 0) &&
2176  (mutt_regexlist_add(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0))
2177  {
2178  return MUTT_CMD_ERROR;
2179  }
2180  } while (MoreArgs(s));
2181 
2182  return MUTT_CMD_SUCCESS;
2183 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
struct Hash * AutoSubscribeCache
Hash table of auto-subscribed mailing lists.
Definition: email_globals.c:48
#define MoreArgs(buf)
Definition: buffer.h:43
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:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: email_globals.c:52
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_hash_free(struct Hash **ptr)
Free a hash table.
Definition: hash.c:471
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: email_globals.c:49
+ Here is the call graph for this function:

◆ parse_unsubscribe_from()

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.

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 2193 of file command_parse.c.

2195 {
2196  if (!buf || !s || !err)
2197  return MUTT_CMD_ERROR;
2198 
2199  if (MoreArgs(s))
2200  {
2202 
2203  if (MoreArgs(s))
2204  {
2205  mutt_buffer_printf(err, _("%s: too many arguments"), "unsubscribe-from");
2206  return MUTT_CMD_WARNING;
2207  }
2208 
2209  if (buf->data && (*buf->data != '\0'))
2210  {
2211  /* Expand and subscribe */
2212  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), false) == 0)
2213  {
2214  mutt_message(_("Unsubscribed from %s"), buf->data);
2215  return MUTT_CMD_SUCCESS;
2216  }
2217 
2218  mutt_buffer_printf(err, _("Could not unsubscribe from %s"), buf->data);
2219  return MUTT_CMD_ERROR;
2220  }
2221 
2222  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2223  return MUTT_CMD_ERROR;
2224  }
2225 
2226  mutt_buffer_addstr(err, _("No folder specified"));
2227  return MUTT_CMD_WARNING;
2228 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
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:132
#define MoreArgs(buf)
Definition: buffer.h:43
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:426
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
Log at debug level 1.
Definition: logging.h:40
Warning: Help given to the user.
Definition: mutt_commands.h:36
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:76
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1404
+ Here is the call graph for this function:

◆ clear_source_stack()

void clear_source_stack ( void  )

Free memory from the stack used for the souce command.

Definition at line 2234 of file command_parse.c.

2235 {
2237 }
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
static struct ListHead MuttrcStack
Definition: command_parse.c:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MuttrcStack

struct ListHead MuttrcStack = STAILQ_HEAD_INITIALIZER(MuttrcStack)
static

Definition at line 58 of file command_parse.c.