NeoMutt  2020-06-26-30-g76c339
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 <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "alias/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "command_parse.h"
#include "context.h"
#include "globals.h"
#include "init.h"
#include "keymap.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 <libintl.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, struct ReplaceList *list, struct Buffer *err)
 Remove a string replacement rule - Implements Command::parse() 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, struct ReplaceList *list, struct Buffer *err)
 Parse a string replacement rule - Implements Command::parse() 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...
 
int parse_grouplist (struct GroupList *gl, struct Buffer *buf, struct Buffer *s, 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_alternates (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'alternates' command - Implements Command::parse() More...
 
enum CommandResult parse_attachments (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'attachments' command - Implements Command::parse() More...
 
enum CommandResult parse_echo (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'echo' command - Implements Command::parse() More...
 
enum CommandResult parse_finish (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'finish' command - Implements Command::parse() More...
 
enum CommandResult parse_group (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'group' and 'ungroup' commands - Implements Command::parse() More...
 
enum CommandResult parse_ifdef (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'ifdef' and 'ifndef' commands - Implements Command::parse() More...
 
enum CommandResult parse_ignore (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'ignore' command - Implements Command::parse() More...
 
enum CommandResult parse_lists (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'lists' command - Implements Command::parse() More...
 
enum CommandResult parse_mailboxes (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'mailboxes' command - Implements Command::parse() More...
 
enum CommandResult parse_my_hdr (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'my_hdr' command - Implements Command::parse() More...
 
enum CommandResult parse_path_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'sidebar_whitelist' command - Implements Command::parse() More...
 
enum CommandResult parse_path_unlist (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsidebar_whitelist' command - Implements Command::parse() More...
 
enum CommandResult parse_set (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'set' family of commands - Implements Command::parse() More...
 
enum CommandResult parse_setenv (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'setenv' and 'unsetenv' commands - Implements Command::parse() More...
 
enum CommandResult parse_source (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'source' command - Implements Command::parse() More...
 
enum CommandResult parse_spam_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'spam' and 'nospam' commands - Implements Command::parse() More...
 
enum CommandResult parse_stailq (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse a list command - Implements Command::parse() More...
 
enum CommandResult parse_subjectrx_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subjectrx' command - Implements Command::parse() More...
 
enum CommandResult parse_subscribe (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subscribe' command - Implements Command::parse() More...
 
enum CommandResult parse_subscribe_to (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subscribe-to' command - Implements Command::parse() More...
 
enum CommandResult parse_tag_formats (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'tag-formats' command - Implements Command::parse() More...
 
enum CommandResult parse_tag_transforms (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'tag-transforms' command - Implements Command::parse() More...
 
enum CommandResult parse_unalternates (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unalternates' command - Implements Command::parse() More...
 
enum CommandResult parse_unattachments (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unattachments' command - Implements Command::parse() More...
 
enum CommandResult parse_unignore (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unignore' command - Implements Command::parse() More...
 
enum CommandResult parse_unlists (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unlists' command - Implements Command::parse() More...
 
enum CommandResult parse_unmailboxes (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unmailboxes' command - Implements Command::parse() More...
 
enum CommandResult parse_unmy_hdr (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unmy_hdr' command - Implements Command::parse() More...
 
enum CommandResult parse_unstailq (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse an unlist command - Implements Command::parse() More...
 
enum CommandResult parse_unsubjectrx_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubjectrx' command - Implements Command::parse() More...
 
enum CommandResult parse_unsubscribe (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubscribe' command - Implements Command::parse() More...
 
enum CommandResult parse_unsubscribe_from (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubscribe-from' command - Implements Command::parse() 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 70 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 75 of file command_parse.c.

76 {
77  GS_NONE,
78  GS_RX,
79  GS_ADDR,
80 };
Entry is an address.
Definition: command_parse.c:79
Group is missing an argument.
Definition: command_parse.c:77
Entry is a regular expression.
Definition: command_parse.c:78

Function Documentation

◆ parse_unreplace_list()

static enum CommandResult parse_unreplace_list ( struct Buffer buf,
struct Buffer s,
struct ReplaceList *  list,
struct Buffer err 
)
static

Remove a string replacement rule - Implements Command::parse()

Definition at line 85 of file command_parse.c.

87 {
88  /* First token is a regex. */
89  if (!MoreArgs(s))
90  {
91  mutt_buffer_printf(err, _("%s: too few arguments"), "unsubjectrx");
92  return MUTT_CMD_WARNING;
93  }
94 
96 
97  /* "*" is a special case. */
98  if (mutt_str_equal(buf->data, "*"))
99  {
100  mutt_replacelist_free(list);
101  return MUTT_CMD_SUCCESS;
102  }
103 
104  mutt_replacelist_remove(list, buf->data);
105  return MUTT_CMD_SUCCESS;
106 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
#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:446
#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:414
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:563
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ 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 111 of file command_parse.c.

112 {
113  if (!Context || !Context->mailbox)
114  return;
115 
116  struct Mailbox *m = Context->mailbox;
117  for (int i = 0; i < m->msg_count; i++)
118  {
119  struct Email *e = m->emails[i];
120  if (!e)
121  break;
122  e->attach_valid = false;
123  }
124 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
The "current" mailbox.
Definition: context.h:37
int msg_count
Total number of messages.
Definition: mailbox.h:91
The envelope/body of an email.
Definition: email.h:37
struct Mailbox * mailbox
Definition: context.h:50
A mailbox.
Definition: mailbox.h:81
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 134 of file command_parse.c.

136 {
137  struct AttachMatch *a = NULL;
138  char *tmp = NULL;
139  char *minor = NULL;
140 
141  do
142  {
144  FREE(&tmp);
145 
146  if (mutt_istr_equal(buf->data, "any"))
147  tmp = mutt_str_dup("*/.*");
148  else if (mutt_istr_equal(buf->data, "none"))
149  tmp = mutt_str_dup("cheap_hack/this_should_never_match");
150  else
151  tmp = mutt_str_dup(buf->data);
152 
153  minor = strchr(tmp, '/');
154  if (minor)
155  {
156  *minor = '\0';
157  minor++;
158  }
159  else
160  {
161  minor = "unknown";
162  }
163  const enum ContentType major = mutt_check_mime_type(tmp);
164 
165  struct ListNode *np = NULL, *tmp2 = NULL;
166  STAILQ_FOREACH_SAFE(np, head, entries, tmp2)
167  {
168  a = (struct AttachMatch *) np->data;
169  mutt_debug(LL_DEBUG3, "check %s/%s [%d] : %s/%s [%d]\n", a->major,
170  a->minor, a->major_int, tmp, minor, major);
171  if ((a->major_int == major) && mutt_istr_equal(minor, a->minor))
172  {
173  mutt_debug(LL_DEBUG3, "removed %s/%s [%d]\n", a->major, a->minor, a->major_int);
174  regfree(&a->minor_regex);
175  FREE(&a->major);
176  STAILQ_REMOVE(head, np, ListNode, entries);
177  FREE(&np->data);
178  FREE(&np);
179  }
180  }
181 
182  } while (MoreArgs(s));
183 
184  FREE(&tmp);
186  return MUTT_CMD_SUCCESS;
187 }
#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
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
enum ContentType major_int
Definition: mutt_parse.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:318
const char * major
Definition: mutt_parse.h:36
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:359
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:891
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:36
regex_t minor_regex
Definition: mutt_parse.h:39
#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:34
A List node for strings.
Definition: list.h:34
const char * minor
Definition: mutt_parse.h:38
Log at debug level 3.
Definition: logging.h:42
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
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 192 of file command_parse.c.

193 {
194  if (!Context || !Context->mailbox)
195  return;
196 
197  struct Mailbox *m = Context->mailbox;
198  for (int i = 0; i < m->msg_count; i++)
199  {
200  struct Email *e = m->emails[i];
201  if (!e || !e->env)
202  continue;
203  FREE(&e->env->disp_subj);
204  }
205 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
The "current" mailbox.
Definition: context.h:37
int msg_count
Total number of messages.
Definition: mailbox.h:91
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:81
#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,
struct ReplaceList *  list,
struct Buffer err 
)
static

Parse a string replacement rule - Implements Command::parse()

Definition at line 210 of file command_parse.c.

212 {
213  struct Buffer templ = mutt_buffer_make(0);
214 
215  /* First token is a regex. */
216  if (!MoreArgs(s))
217  {
218  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
219  return MUTT_CMD_WARNING;
220  }
222 
223  /* Second token is a replacement template */
224  if (!MoreArgs(s))
225  {
226  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
227  return MUTT_CMD_WARNING;
228  }
230 
231  if (mutt_replacelist_add(list, buf->data, templ.data, err) != 0)
232  {
233  FREE(&templ.data);
234  return MUTT_CMD_ERROR;
235  }
236  FREE(&templ.data);
237 
238  return MUTT_CMD_SUCCESS;
239 }
int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, const char *templ, struct Buffer *err)
Add a pattern and a template to a list.
Definition: regex.c:261
Error: Can&#39;t help the user.
Definition: mutt_commands.h: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:414
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:70
+ 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 247 of file command_parse.c.

248 {
249  for (enum MenuType i = 0; i < MENU_MAX; i++)
250  {
251  const struct Binding *b = km_get_table(Menus[i].value);
252  if (!b)
253  continue;
254 
255  for (int j = 0; b[j].name; j++)
256  if (mutt_str_equal(name, b[j].name))
257  return true;
258  }
259  return false;
260 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
MenuType
Types of GUI selections.
Definition: keymap.h:70
const char * name
name of the function
Definition: keymap.h:120
const struct Mapping Menus[]
Menu name lookup table.
Definition: keymap.c:61
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu&#39;s keybindings.
Definition: keymap.c:1265
Mapping between a user key and a function.
Definition: keymap.h:118
+ 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 266 of file command_parse.c.

267 {
268  return mutt_mem_calloc(1, sizeof(struct AttachMatch));
269 }
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:34
+ 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 279 of file command_parse.c.

281 {
282  struct AttachMatch *a = NULL;
283  char *p = NULL;
284  char *tmpminor = NULL;
285  size_t len;
286  int ret;
287 
288  do
289  {
291 
292  if (!buf->data || (*buf->data == '\0'))
293  continue;
294 
295  a = mutt_attachmatch_new();
296 
297  /* some cheap hacks that I expect to remove */
298  if (mutt_istr_equal(buf->data, "any"))
299  a->major = mutt_str_dup("*/.*");
300  else if (mutt_istr_equal(buf->data, "none"))
301  a->major = mutt_str_dup("cheap_hack/this_should_never_match");
302  else
303  a->major = mutt_str_dup(buf->data);
304 
305  p = strchr(a->major, '/');
306  if (p)
307  {
308  *p = '\0';
309  p++;
310  a->minor = p;
311  }
312  else
313  {
314  a->minor = "unknown";
315  }
316 
317  len = strlen(a->minor);
318  tmpminor = mutt_mem_malloc(len + 3);
319  strcpy(&tmpminor[1], a->minor);
320  tmpminor[0] = '^';
321  tmpminor[len + 1] = '$';
322  tmpminor[len + 2] = '\0';
323 
325  ret = REG_COMP(&a->minor_regex, tmpminor, REG_ICASE);
326 
327  FREE(&tmpminor);
328 
329  if (ret != 0)
330  {
331  regerror(ret, &a->minor_regex, err->data, err->dsize);
332  FREE(&a->major);
333  FREE(&a);
334  return MUTT_CMD_ERROR;
335  }
336 
337  mutt_debug(LL_DEBUG3, "added %s/%s [%d]\n", a->major, a->minor, a->major_int);
338 
339  mutt_list_insert_tail(head, (char *) a);
340  } while (MoreArgs(s));
341 
343  return MUTT_CMD_SUCCESS;
344 }
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
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
enum ContentType major_int
Definition: mutt_parse.h:37
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:318
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition: regex3.h:53
const char * major
Definition: mutt_parse.h:36
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:891
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:64
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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
regex_t minor_regex
Definition: mutt_parse.h:39
#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:34
const char * minor
Definition: mutt_parse.h:38
Log at debug level 3.
Definition: logging.h:42
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ 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 353 of file command_parse.c.

354 {
355  struct ListNode *np = NULL;
356  STAILQ_FOREACH(np, h, entries)
357  {
358  printf("attachments %c%s %s/%s\n", op, name,
359  ((struct AttachMatch *) np->data)->major,
360  ((struct AttachMatch *) np->data)->minor);
361  }
362 
363  return 0;
364 }
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
char * data
String.
Definition: list.h:36
An attachment matching a regex for attachment counter.
Definition: mutt_parse.h:34
A List node for strings.
Definition: list.h:34
+ 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 369 of file command_parse.c.

370 {
371  if (!Context || !Context->mailbox)
372  return;
373 
374  struct Mailbox *m = Context->mailbox;
375  for (int i = 0; i < m->msg_count; i++)
376  {
377  struct Email *e = m->emails[i];
378  if (!e)
379  break;
380  e->recip_valid = false;
381  }
382 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
The "current" mailbox.
Definition: context.h:37
int msg_count
Total number of messages.
Definition: mailbox.h:91
The envelope/body of an email.
Definition: email.h:37
struct Mailbox * mailbox
Definition: context.h:50
A mailbox.
Definition: mailbox.h:81
bool recip_valid
Is_recipient is valid.
Definition: email.h:58
+ Here is the caller graph for this function:

◆ parse_grouplist()

int parse_grouplist ( struct GroupList *  gl,
struct Buffer buf,
struct Buffer s,
struct Buffer err 
)

Parse a group context.

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

Definition at line 393 of file command_parse.c.

395 {
396  while (mutt_istr_equal(buf->data, "-group"))
397  {
398  if (!MoreArgs(s))
399  {
400  mutt_buffer_strcpy(err, _("-group: no group name"));
401  return -1;
402  }
403 
405 
407 
408  if (!MoreArgs(s))
409  {
410  mutt_buffer_strcpy(err, _("out of arguments"));
411  return -1;
412  }
413 
415  }
416 
417  return 0;
418 }
void mutt_grouplist_add(struct GroupList *gl, struct Group *group)
Add a Group to a GroupList.
Definition: group.c:137
#define _(a)
Definition: message.h:28
#define MoreArgs(buf)
Definition: buffer.h:43
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:891
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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
struct Group * mutt_pattern_group(const char *pat)
Match a pattern to a Group.
Definition: group.c:65
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ 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 426 of file command_parse.c.

427 {
428  int lineno = 0, rc = 0, warnings = 0;
429  enum CommandResult line_rc;
430  struct Buffer *token = NULL, *linebuf = NULL;
431  char *line = NULL;
432  char *currentline = NULL;
433  char rcfile[PATH_MAX];
434  size_t linelen = 0;
435  pid_t pid;
436 
437  mutt_str_copy(rcfile, rcfile_path, sizeof(rcfile));
438 
439  size_t rcfilelen = mutt_str_len(rcfile);
440  if (rcfilelen == 0)
441  return -1;
442 
443  bool ispipe = rcfile[rcfilelen - 1] == '|';
444 
445  if (!ispipe)
446  {
447  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
448  if (!mutt_path_to_absolute(rcfile, np ? NONULL(np->data) : ""))
449  {
450  mutt_error(_("Error: Can't build path of '%s'"), rcfile_path);
451  return -1;
452  }
453 
454  STAILQ_FOREACH(np, &MuttrcStack, entries)
455  {
456  if (mutt_str_equal(np->data, rcfile))
457  {
458  break;
459  }
460  }
461  if (np)
462  {
463  mutt_error(_("Error: Cyclic sourcing of configuration file '%s'"), rcfile);
464  return -1;
465  }
466 
468  }
469 
470  mutt_debug(LL_DEBUG2, "Reading configuration file '%s'\n", rcfile);
471 
472  FILE *fp = mutt_open_read(rcfile, &pid);
473  if (!fp)
474  {
475  mutt_buffer_printf(err, "%s: %s", rcfile, strerror(errno));
476  return -1;
477  }
478 
479  token = mutt_buffer_pool_get();
480  linebuf = mutt_buffer_pool_get();
481 
482  while ((line = mutt_file_read_line(line, &linelen, fp, &lineno, MUTT_CONT)) != NULL)
483  {
484  const bool conv = C_ConfigCharset && C_Charset;
485  if (conv)
486  {
487  currentline = mutt_str_dup(line);
488  if (!currentline)
489  continue;
490  mutt_ch_convert_string(&currentline, C_ConfigCharset, C_Charset, 0);
491  }
492  else
493  currentline = line;
494 
495  mutt_buffer_strcpy(linebuf, currentline);
496 
497  mutt_buffer_reset(err);
498  line_rc = mutt_parse_rc_buffer(linebuf, token, err);
499  if (line_rc == MUTT_CMD_ERROR)
500  {
501  mutt_error(_("Error in %s, line %d: %s"), rcfile, lineno, err->data);
502  if (--rc < -MAX_ERRS)
503  {
504  if (conv)
505  FREE(&currentline);
506  break;
507  }
508  }
509  else if (line_rc == MUTT_CMD_WARNING)
510  {
511  /* Warning */
512  mutt_warning(_("Warning in %s, line %d: %s"), rcfile, lineno, err->data);
513  warnings++;
514  }
515  else if (line_rc == MUTT_CMD_FINISH)
516  {
517  break; /* Found "finish" command */
518  }
519  else
520  {
521  if (rc < 0)
522  rc = -1;
523  }
524  if (conv)
525  FREE(&currentline);
526  }
527 
528  FREE(&line);
529  mutt_file_fclose(&fp);
530  if (pid != -1)
531  filter_wait(pid);
532 
533  if (rc)
534  {
535  /* the neomuttrc source keyword */
536  mutt_buffer_reset(err);
537  mutt_buffer_printf(err, (rc >= -MAX_ERRS) ? _("source: errors in %s") : _("source: reading aborted due to too many errors in %s"),
538  rcfile);
539  rc = -1;
540  }
541  else
542  {
543  /* Don't alias errors with warnings */
544  if (warnings > 0)
545  {
546  mutt_buffer_printf(err, ngettext("source: %d warning in %s", "source: %d warnings in %s", warnings),
547  warnings, rcfile);
548  rc = -2;
549  }
550  }
551 
552  if (!ispipe && !STAILQ_EMPTY(&MuttrcStack))
553  {
554  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
555  STAILQ_REMOVE_HEAD(&MuttrcStack, entries);
556  FREE(&np->data);
557  FREE(&np);
558  }
559 
560  mutt_buffer_pool_release(&token);
561  mutt_buffer_pool_release(&linebuf);
562  return rc;
563 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
#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:745
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
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
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
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
#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:667
#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:37
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:153
#define PATH_MAX
Definition: mutt.h:44
char * data
Pointer to data.
Definition: buffer.h:35
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
Definition: path.c:397
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition: list.c:45
enum CommandResult mutt_parse_rc_buffer(struct Buffer *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:983
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:639
char * data
String.
Definition: list.h:36
Warning: Help given to the user.
Definition: mutt_commands.h:36
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:724
Finish: Stop processing this file.
Definition: mutt_commands.h:38
#define MAX_ERRS
Definition: command_parse.c:70
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
static struct ListHead MuttrcStack
Definition: command_parse.c:68
#define STAILQ_EMPTY(head)
Definition: queue.h:345
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:53
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
int const char int line
Definition: acutest.h:617
A List node for strings.
Definition: list.h:34
FILE * mutt_open_read(const char *path, pid_t *thepid)
Run a command to read from.
Definition: muttlib.c:1394
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_alternates()

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

Parse the 'alternates' command - Implements Command::parse()

Definition at line 568 of file command_parse.c.

570 {
571  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
572 
574 
575  do
576  {
578 
579  if (parse_grouplist(&gl, buf, s, err) == -1)
580  goto bail;
581 
582  mutt_regexlist_remove(&UnAlternates, buf->data);
583 
584  if (mutt_regexlist_add(&Alternates, buf->data, REG_ICASE, err) != 0)
585  goto bail;
586 
587  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
588  goto bail;
589  } while (MoreArgs(s));
590 
592  return MUTT_CMD_SUCCESS;
593 
594 bail:
596  return MUTT_CMD_ERROR;
597 }
int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h: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:276
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_attachments()

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

Parse the 'attachments' command - Implements Command::parse()

Definition at line 602 of file command_parse.c.

604 {
605  char op;
606  char *category = NULL;
607  struct ListHead *head = NULL;
608 
610  if (!buf->data || (*buf->data == '\0'))
611  {
612  mutt_buffer_strcpy(err, _("attachments: no disposition"));
613  return MUTT_CMD_WARNING;
614  }
615 
616  category = buf->data;
617  op = *category++;
618 
619  if (op == '?')
620  {
621  mutt_endwin();
622  fflush(stdout);
623  printf("\n%s\n\n", _("Current attachments settings:"));
624  print_attach_list(&AttachAllow, '+', "A");
625  print_attach_list(&AttachExclude, '-', "A");
626  print_attach_list(&InlineAllow, '+', "I");
627  print_attach_list(&InlineExclude, '-', "I");
629  return MUTT_CMD_SUCCESS;
630  }
631 
632  if ((op != '+') && (op != '-'))
633  {
634  op = '+';
635  category--;
636  }
637  if (mutt_istr_startswith("attachment", category))
638  {
639  if (op == '+')
640  head = &AttachAllow;
641  else
642  head = &AttachExclude;
643  }
644  else if (mutt_istr_startswith("inline", category))
645  {
646  if (op == '+')
647  head = &InlineAllow;
648  else
649  head = &InlineExclude;
650  }
651  else
652  {
653  mutt_buffer_strcpy(err, _("attachments: invalid disposition"));
654  return MUTT_CMD_ERROR;
655  }
656 
657  return parse_attach_list(buf, s, head, err);
658 }
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:40
#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:41
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:546
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:177
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:579
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: mutt_parse.c:39
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:38
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_echo()

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

Parse the 'echo' command - Implements Command::parse()

Definition at line 663 of file command_parse.c.

665 {
666  if (!MoreArgs(s))
667  {
668  mutt_buffer_printf(err, _("%s: too few arguments"), "echo");
669  return MUTT_CMD_WARNING;
670  }
672  OptForceRefresh = true;
673  mutt_message("%s", buf->data);
674  OptForceRefresh = false;
675  mutt_sleep(0);
676 
677  return MUTT_CMD_SUCCESS;
678 }
#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:1536
WHERE bool OptForceRefresh
(pseudo) refresh even during macros
Definition: options.h:37
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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:70
+ Here is the call graph for this function:

◆ parse_finish()

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

Parse the 'finish' command - Implements Command::parse()

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

689 {
690  if (MoreArgs(s))
691  {
692  mutt_buffer_printf(err, _("%s: too many arguments"), "finish");
693  return MUTT_CMD_WARNING;
694  }
695 
696  return MUTT_CMD_FINISH;
697 }
#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,
intptr_t  data,
struct Buffer err 
)

Parse the 'group' and 'ungroup' commands - Implements Command::parse()

Definition at line 702 of file command_parse.c.

704 {
705  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
706  enum GroupState state = GS_NONE;
707 
708  do
709  {
711  if (parse_grouplist(&gl, buf, s, err) == -1)
712  goto bail;
713 
714  if ((data == MUTT_UNGROUP) && mutt_istr_equal(buf->data, "*"))
715  {
717  goto out;
718  }
719 
720  if (mutt_istr_equal(buf->data, "-rx"))
721  state = GS_RX;
722  else if (mutt_istr_equal(buf->data, "-addr"))
723  state = GS_ADDR;
724  else
725  {
726  switch (state)
727  {
728  case GS_NONE:
729  mutt_buffer_printf(err, _("%sgroup: missing -rx or -addr"),
730  (data == MUTT_UNGROUP) ? "un" : "");
731  goto warn;
732 
733  case GS_RX:
734  if ((data == MUTT_GROUP) &&
735  (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0))
736  {
737  goto bail;
738  }
739  else if ((data == MUTT_UNGROUP) &&
740  (mutt_grouplist_remove_regex(&gl, buf->data) < 0))
741  {
742  goto bail;
743  }
744  break;
745 
746  case GS_ADDR:
747  {
748  char *estr = NULL;
749  struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
750  mutt_addrlist_parse2(&al, buf->data);
751  if (TAILQ_EMPTY(&al))
752  goto bail;
753  if (mutt_addrlist_to_intl(&al, &estr))
754  {
755  mutt_buffer_printf(err, _("%sgroup: warning: bad IDN '%s'"),
756  (data == 1) ? "un" : "", estr);
757  mutt_addrlist_clear(&al);
758  FREE(&estr);
759  goto bail;
760  }
761  if (data == MUTT_GROUP)
762  mutt_grouplist_add_addrlist(&gl, &al);
763  else if (data == MUTT_UNGROUP)
765  mutt_addrlist_clear(&al);
766  break;
767  }
768  }
769  }
770  } while (MoreArgs(s));
771 
772 out:
774  return MUTT_CMD_SUCCESS;
775 
776 bail:
778  return MUTT_CMD_ERROR;
779 
780 warn:
782  return MUTT_CMD_WARNING;
783 }
int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
#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:103
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1414
#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:226
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:616
#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:276
int mutt_grouplist_remove_regex(struct GroupList *gl, const char *s)
Remove matching addresses from a GroupList.
Definition: group.c:300
GroupState
Type of email address group.
Definition: command_parse.c:75
int mutt_grouplist_remove_addrlist(struct GroupList *gl, struct AddressList *al)
Remove an AddressList from a GroupList.
Definition: group.c:245
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:891
Entry is an address.
Definition: command_parse.c:79
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
char * data
Pointer to data.
Definition: buffer.h:35
Group is missing an argument.
Definition: command_parse.c:77
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:1250
Warning: Help given to the user.
Definition: mutt_commands.h:36
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#define FREE(x)
Definition: memory.h:40
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
#define TAILQ_EMPTY(head)
Definition: queue.h:714
Entry is a regular expression.
Definition: command_parse.c:78
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:630
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
#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,
intptr_t  data,
struct Buffer err 
)

Parse the 'ifdef' and 'ifndef' commands - Implements Command::parse()

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

800 {
802 
803  // is the item defined as:
804  bool res = cs_subset_lookup(NeoMutt->sub, buf->data) // a variable?
805  || feature_enabled(buf->data) // a compiled-in feature?
806  || is_function(buf->data) // a function?
807  || mutt_command_get(buf->data) // a command?
808  || myvar_get(buf->data) // a my_ variable?
809  || mutt_str_getenv(buf->data); // an environment variable?
810 
811  if (!MoreArgs(s))
812  {
813  mutt_buffer_printf(err, _("%s: too few arguments"), (data ? "ifndef" : "ifdef"));
814  return MUTT_CMD_WARNING;
815  }
817 
818  /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
819  if ((res && (data == 0)) || (!res && (data == 1)))
820  {
821  enum CommandResult rc = mutt_parse_rc_line(buf->data, err);
822  if (rc == MUTT_CMD_ERROR)
823  {
824  mutt_error(_("Error: %s"), err->data);
825  return MUTT_CMD_ERROR;
826  }
827  return rc;
828  }
829  return MUTT_CMD_SUCCESS;
830 }
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:565
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
enum CommandResult mutt_parse_rc_line(const char *line, struct Buffer *err)
Parse a line of user config.
Definition: init.c:1038
#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:168
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:36
const struct Command * mutt_command_get(const char *s)
Get a Command by its name.
Definition: init.c:383
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:999
#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:414
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:73
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
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_ignore()

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

Parse the 'ignore' command - Implements Command::parse()

Definition at line 835 of file command_parse.c.

837 {
838  do
839  {
842  add_to_stailq(&Ignore, buf->data);
843  } while (MoreArgs(s));
844 
845  return MUTT_CMD_SUCCESS;
846 }
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:1790
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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:1815
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:70
+ Here is the call graph for this function:

◆ parse_lists()

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

Parse the 'lists' command - Implements Command::parse()

Definition at line 851 of file command_parse.c.

853 {
854  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
855 
856  do
857  {
859 
860  if (parse_grouplist(&gl, buf, s, err) == -1)
861  goto bail;
862 
864 
865  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
866  goto bail;
867 
868  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
869  goto bail;
870  } while (MoreArgs(s));
871 
873  return MUTT_CMD_SUCCESS;
874 
875 bail:
877  return MUTT_CMD_ERROR;
878 }
int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h: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:276
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: email_globals.c:50
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#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:70
+ Here is the call graph for this function:

◆ parse_mailboxes()

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

Parse the 'mailboxes' command - Implements Command::parse()

This is also used by 'virtual-mailboxes'.

Definition at line 885 of file command_parse.c.

887 {
888  while (MoreArgs(s))
889  {
890  struct Mailbox *m = mailbox_new();
891 
892  if (data & MUTT_NAMED)
893  {
894  // This may be empty, e.g. `named-mailboxes "" +inbox`
896  m->name = mutt_buffer_strdup(buf);
897  }
898 
900  if (mutt_buffer_is_empty(buf))
901  {
902  /* Skip empty tokens. */
903  mailbox_free(&m);
904  continue;
905  }
906 
907  mutt_buffer_strcpy(&m->pathbuf, buf->data);
908  /* int rc = */ mx_path_canon2(m, C_Folder);
909 
910  if (m->type <= MUTT_UNKNOWN)
911  {
912  mutt_error("Unknown Mailbox: %s", m->realpath);
913  mailbox_free(&m);
914  return MUTT_CMD_ERROR;
915  }
916 
917  bool new_account = false;
918  struct Account *a = mx_ac_find(m);
919  if (!a)
920  {
921  a = account_new(NULL, NeoMutt->sub);
922  a->type = m->type;
923  new_account = true;
924  }
925 
926  if (!new_account)
927  {
928  struct Mailbox *m_old = mx_mbox_find(a, m->realpath);
929  if (m_old)
930  {
931  const bool show = (m_old->flags == MB_HIDDEN);
932  if (show)
933  {
934  m_old->flags = MB_NORMAL;
935  }
936 
937  const bool rename = (data & MUTT_NAMED) && !mutt_str_equal(m_old->name, m->name);
938  if (rename)
939  {
940  mutt_str_replace(&m_old->name, m->name);
941  }
942 
943 #ifdef USE_SIDEBAR
944  if (show || rename)
945  {
946  sb_notify_mailbox(m_old, show ? SBN_CREATED : SBN_RENAMED);
947  }
948 #endif
949  mailbox_free(&m);
950  continue;
951  }
952  }
953 
954  if (mx_ac_add(a, m) < 0)
955  {
956  //error
957  mailbox_free(&m);
958  if (new_account)
959  {
960  cs_subset_free(&a->sub);
961  FREE(&a->name);
962  notify_free(&a->notify);
963  FREE(&a);
964  }
965  continue;
966  }
967  if (new_account)
968  {
970  }
971 
972 #ifdef USE_SIDEBAR
974 #endif
975 #ifdef USE_INOTIFY
976  mutt_monitor_add(m);
977 #endif
978  }
979  return MUTT_CMD_SUCCESS;
980 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
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:1691
int mx_path_canon2(struct Mailbox *m, const char *folder)
Canonicalise the path to realpath.
Definition: mx.c:1475
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:62
struct Notify * notify
Notifications handler.
Definition: account.h:42
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:84
char * mutt_buffer_strdup(struct Buffer *buf)
Copy a Buffer&#39;s string.
Definition: buffer.c:432
A group of associated Mailboxes.
Definition: account.h:36
Mailbox wasn&#39;t recognised.
Definition: mailbox.h:47
#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:1582
enum MailboxType type
Type of Mailboxes this Account contains.
Definition: account.h:38
void cs_subset_free(struct ConfigSubset **ptr)
Free a Config Subset.
Definition: subset.c:93
int mutt_monitor_add(struct Mailbox *m)
Add a watch for a mailbox.
Definition: monitor.c:479
struct Account * mx_ac_find(struct Mailbox *m)
Find the Account owning a Mailbox.
Definition: mx.c:1558
Container for Accounts, Notifications.
Definition: neomutt.h:36
#define MoreArgs(buf)
Definition: buffer.h:43
char * name
A short name for the Mailbox.
Definition: mailbox.h:85
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:60
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:134
#define MB_HIDDEN
Definition: mailbox.h:38
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
Definition: globals.h:119
A mailbox.
Definition: mailbox.h:81
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
char * data
Pointer to data.
Definition: buffer.h:35
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:450
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition: mailbox.c:42
Success: Command worked.
Definition: mutt_commands.h:37
#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:39
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:83
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
#define MB_NORMAL
Definition: mailbox.h:37
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_my_hdr()

enum CommandResult parse_my_hdr ( struct Buffer buf,
struct Buffer s,
intptr_t  data,
struct Buffer err 
)

Parse the 'my_hdr' command - Implements Command::parse()

Definition at line 985 of file command_parse.c.

987 {
988  struct ListNode *n = NULL;
989  size_t keylen;
990 
992  char *p = strpbrk(buf->data, ": \t");
993  if (!p || (*p != ':'))
994  {
995  mutt_buffer_strcpy(err, _("invalid header field"));
996  return MUTT_CMD_WARNING;
997  }
998  keylen = p - buf->data + 1;
999 
1000  STAILQ_FOREACH(n, &UserHeader, entries)
1001  {
1002  /* see if there is already a field by this name */
1003  if (mutt_istrn_equal(buf->data, n->data, keylen))
1004  {
1005  break;
1006  }
1007  }
1008 
1009  if (!n)
1010  {
1011  /* not found, allocate memory for a new node and add it to the list */
1012  n = mutt_list_insert_tail(&UserHeader, NULL);
1013  }
1014  else
1015  {
1016  /* found, free the existing data */
1017  FREE(&n->data);
1018  }
1019 
1020  n->data = buf->data;
1021  mutt_buffer_init(buf);
1022 
1023  return MUTT_CMD_SUCCESS;
1024 }
#define _(a)
Definition: message.h:28
bool mutt_istrn_equal(const char *a, const char *b, size_t l)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition: string.c:629
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:64
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:74
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
#define MUTT_TOKEN_SPACE
Don&#39;t treat whitespace as a term.
Definition: mutt.h:73
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:36
Warning: Help given to the user.
Definition: mutt_commands.h:36
int n
Definition: acutest.h:492
#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:34
+ 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,
intptr_t  data,
struct Buffer err 
)

Parse the 'sidebar_whitelist' command - Implements Command::parse()

Definition at line 1030 of file command_parse.c.

1032 {
1033  struct Buffer *path = mutt_buffer_pool_get();
1034 
1035  do
1036  {
1039  add_to_stailq((struct ListHead *) data, mutt_b2s(path));
1040  } while (MoreArgs(s));
1041  mutt_buffer_pool_release(&path);
1042 
1043  return MUTT_CMD_SUCCESS;
1044 }
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:1790
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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:327
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:78
+ Here is the call graph for this function:

◆ parse_path_unlist()

enum CommandResult parse_path_unlist ( struct Buffer buf,
struct Buffer s,
intptr_t  data,
struct Buffer err 
)

Parse the 'unsidebar_whitelist' command - Implements Command::parse()

Definition at line 1051 of file command_parse.c.

1053 {
1054  struct Buffer *path = mutt_buffer_pool_get();
1055 
1056  do
1057  {
1059  /* Check for deletion of entire list */
1060  if (mutt_str_equal(mutt_b2s(path), "*"))
1061  {
1062  mutt_list_free((struct ListHead *) data);
1063  break;
1064  }
1066  remove_from_stailq((struct ListHead *) data, mutt_b2s(path));
1067  } while (MoreArgs(s));
1068  mutt_buffer_pool_release(&path);
1069 
1070  return MUTT_CMD_SUCCESS;
1071 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
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:122
#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:414
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:1815
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:327
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:78
+ Here is the call graph for this function:

◆ parse_set()

enum CommandResult parse_set ( struct Buffer buf,
struct Buffer s,
intptr_t  data,
struct Buffer err 
)

Parse the 'set' family of commands - Implements Command::parse()

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

Definition at line 1079 of file command_parse.c.

1081 {
1082  /* The order must match `enum MuttSetCommand` */
1083  static const char *set_commands[] = { "set", "toggle", "unset", "reset" };
1084 
1085  int rc = 0;
1086 
1087  while (MoreArgs(s))
1088  {
1089  bool prefix = false;
1090  bool query = false;
1091  bool inv = (data == MUTT_SET_INV);
1092  bool reset = (data == MUTT_SET_RESET);
1093  bool unset = (data == MUTT_SET_UNSET);
1094 
1095  if (*s->dptr == '?')
1096  {
1097  prefix = true;
1098  query = true;
1099  s->dptr++;
1100  }
1101  else if (mutt_str_startswith(s->dptr, "no"))
1102  {
1103  prefix = true;
1104  unset = !unset;
1105  s->dptr += 2;
1106  }
1107  else if (mutt_str_startswith(s->dptr, "inv"))
1108  {
1109  prefix = true;
1110  inv = !inv;
1111  s->dptr += 3;
1112  }
1113  else if (*s->dptr == '&')
1114  {
1115  prefix = true;
1116  reset = true;
1117  s->dptr++;
1118  }
1119 
1120  if (prefix && (data != MUTT_SET_SET))
1121  {
1122  mutt_buffer_printf(err, "ERR22 can't use 'inv', 'no', '&' or '?' with the '%s' command",
1123  set_commands[data]);
1124  return MUTT_CMD_WARNING;
1125  }
1126 
1127  /* get the variable name */
1129 
1130  bool bq = false;
1131  bool equals = false;
1132  bool increment = false;
1133  bool decrement = false;
1134 
1135  struct HashElem *he = NULL;
1136  bool my = mutt_str_startswith(buf->data, "my_");
1137  if (!my)
1138  {
1139  he = cs_subset_lookup(NeoMutt->sub, buf->data);
1140  if (!he)
1141  {
1142  if (reset && mutt_str_equal(buf->data, "all"))
1143  {
1144  struct HashElem **list = get_elem_list(NeoMutt->sub->cs);
1145  if (!list)
1146  return MUTT_CMD_ERROR;
1147 
1148  for (size_t i = 0; list[i]; i++)
1149  cs_subset_he_reset(NeoMutt->sub, list[i], NULL);
1150 
1151  FREE(&list);
1152  break;
1153  }
1154  else
1155  {
1156  mutt_buffer_printf(err, "ERR01 unknown variable: %s", buf->data);
1157  return MUTT_CMD_ERROR;
1158  }
1159  }
1160 
1161  bq = ((DTYPE(he->type) == DT_BOOL) || (DTYPE(he->type) == DT_QUAD));
1162  }
1163 
1164  if (*s->dptr == '?')
1165  {
1166  if (prefix)
1167  {
1168  mutt_buffer_printf(err,
1169  "ERR02 can't use a prefix when querying a variable");
1170  return MUTT_CMD_WARNING;
1171  }
1172 
1173  if (reset || unset || inv)
1174  {
1175  mutt_buffer_printf(err, "ERR03 can't query a variable with the '%s' command",
1176  set_commands[data]);
1177  return MUTT_CMD_WARNING;
1178  }
1179 
1180  query = true;
1181  s->dptr++;
1182  }
1183  else if (*s->dptr == '+' || *s->dptr == '-')
1184  {
1185  if (prefix)
1186  {
1187  mutt_buffer_printf(err, "ERR04 can't use prefix when incrementing or "
1188  "decrementing a variable");
1189  return MUTT_CMD_WARNING;
1190  }
1191 
1192  if (reset || unset || inv)
1193  {
1194  mutt_buffer_printf(err, "ERR05 can't set a variable with the '%s' command",
1195  set_commands[data]);
1196  return MUTT_CMD_WARNING;
1197  }
1198  if (*s->dptr == '+')
1199  increment = true;
1200  else
1201  decrement = true;
1202 
1203  s->dptr++;
1204  if (*s->dptr == '=')
1205  {
1206  equals = true;
1207  s->dptr++;
1208  }
1209  }
1210  else if (*s->dptr == '=')
1211  {
1212  if (prefix)
1213  {
1214  mutt_buffer_printf(err,
1215  "ERR04 can't use prefix when setting a variable");
1216  return MUTT_CMD_WARNING;
1217  }
1218 
1219  if (reset || unset || inv)
1220  {
1221  mutt_buffer_printf(err, "ERR05 can't set a variable with the '%s' command",
1222  set_commands[data]);
1223  return MUTT_CMD_WARNING;
1224  }
1225 
1226  equals = true;
1227  s->dptr++;
1228  }
1229 
1230  if (!bq && (inv || (unset && prefix)))
1231  {
1232  if (data == MUTT_SET_SET)
1233  {
1234  mutt_buffer_printf(err, "ERR06 prefixes 'no' and 'inv' may only be "
1235  "used with bool/quad variables");
1236  }
1237  else
1238  {
1239  mutt_buffer_printf(err, "ERR07 command '%s' can only be used with bool/quad variables",
1240  set_commands[data]);
1241  }
1242  return MUTT_CMD_WARNING;
1243  }
1244 
1245  if (reset)
1246  {
1247  // mutt_buffer_printf(err, "ACT24 reset variable %s", buf->data);
1248  if (he)
1249  {
1250  rc = cs_subset_he_reset(NeoMutt->sub, he, err);
1251  if (CSR_RESULT(rc) != CSR_SUCCESS)
1252  return MUTT_CMD_ERROR;
1253  }
1254  else
1255  {
1256  myvar_del(buf->data);
1257  }
1258  continue;
1259  }
1260 
1261  if ((data == MUTT_SET_SET) && !inv && !unset)
1262  {
1263  if (query)
1264  {
1265  // mutt_buffer_printf(err, "ACT08 query variable %s", buf->data);
1266  if (he)
1267  {
1268  mutt_buffer_addstr(err, buf->data);
1269  mutt_buffer_addch(err, '=');
1270  mutt_buffer_reset(buf);
1271  rc = cs_subset_he_string_get(NeoMutt->sub, he, buf);
1272  if (CSR_RESULT(rc) != CSR_SUCCESS)
1273  {
1274  mutt_buffer_addstr(err, buf->data);
1275  return MUTT_CMD_ERROR;
1276  }
1277  if (DTYPE(he->type) == DT_PATH)
1278  mutt_pretty_mailbox(buf->data, buf->dsize);
1279  pretty_var(buf->data, err);
1280  }
1281  else
1282  {
1283  const char *val = myvar_get(buf->data);
1284  if (val)
1285  {
1286  mutt_buffer_addstr(err, buf->data);
1287  mutt_buffer_addch(err, '=');
1288  pretty_var(val, err);
1289  }
1290  else
1291  {
1292  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1293  return MUTT_CMD_ERROR;
1294  }
1295  }
1296  break;
1297  }
1298  else if (equals)
1299  {
1300  // mutt_buffer_printf(err, "ACT11 set variable %s to ", buf->data);
1301  const char *name = NULL;
1302  if (my)
1303  {
1304  name = mutt_str_dup(buf->data);
1305  }
1307  if (my)
1308  {
1309  myvar_set(name, buf->data);
1310  FREE(&name);
1311  }
1312  else
1313  {
1314  if (DTYPE(he->type) == DT_PATH)
1315  {
1316  if (he->type & (DT_PATH_DIR | DT_PATH_FILE))
1318  else
1319  mutt_path_tilde(buf->data, buf->dsize, HomeDir);
1320  }
1321  else if (IS_MAILBOX(he))
1322  {
1324  }
1325  else if (IS_COMMAND(he))
1326  {
1327  struct Buffer scratch = mutt_buffer_make(1024);
1328  mutt_buffer_copy(&scratch, buf);
1329 
1330  if (!mutt_str_equal(buf->data, "builtin"))
1331  {
1332  mutt_buffer_expand_path(&scratch);
1333  }
1334  mutt_buffer_reset(buf);
1335  mutt_buffer_addstr(buf, mutt_b2s(&scratch));
1336  mutt_buffer_dealloc(&scratch);
1337  }
1338  if (increment)
1339  {
1340  rc = cs_subset_he_string_plus_equals(NeoMutt->sub, he, buf->data, err);
1341  }
1342  else if (decrement)
1343  {
1344  rc = cs_subset_he_string_minus_equals(NeoMutt->sub, he, buf->data, err);
1345  }
1346  else
1347  {
1348  rc = cs_subset_he_string_set(NeoMutt->sub, he, buf->data, err);
1349  }
1350  if (CSR_RESULT(rc) != CSR_SUCCESS)
1351  return MUTT_CMD_ERROR;
1352  }
1353  continue;
1354  }
1355  else
1356  {
1357  if (bq)
1358  {
1359  // mutt_buffer_printf(err, "ACT23 set variable %s to 'yes'", buf->data);
1360  rc = cs_subset_he_native_set(NeoMutt->sub, he, true, err);
1361  if (CSR_RESULT(rc) != CSR_SUCCESS)
1362  return MUTT_CMD_ERROR;
1363  continue;
1364  }
1365  else
1366  {
1367  // mutt_buffer_printf(err, "ACT10 query variable %s", buf->data);
1368  if (he)
1369  {
1370  mutt_buffer_addstr(err, buf->data);
1371  mutt_buffer_addch(err, '=');
1372  mutt_buffer_reset(buf);
1373  rc = cs_subset_he_string_get(NeoMutt->sub, he, buf);
1374  if (CSR_RESULT(rc) != CSR_SUCCESS)
1375  {
1376  mutt_buffer_addstr(err, buf->data);
1377  return MUTT_CMD_ERROR;
1378  }
1379  if (DTYPE(he->type) == DT_PATH)
1380  mutt_pretty_mailbox(buf->data, buf->dsize);
1381  pretty_var(buf->data, err);
1382  }
1383  else
1384  {
1385  const char *val = myvar_get(buf->data);
1386  if (val)
1387  {
1388  mutt_buffer_addstr(err, buf->data);
1389  mutt_buffer_addch(err, '=');
1390  pretty_var(val, err);
1391  }
1392  else
1393  {
1394  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1395  return MUTT_CMD_ERROR;
1396  }
1397  }
1398  break;
1399  }
1400  }
1401  }
1402 
1403  if (my)
1404  {
1405  myvar_del(buf->data);
1406  }
1407  else if (bq)
1408  {
1409  if (inv)
1410  {
1411  // mutt_buffer_printf(err, "ACT25 TOGGLE bool/quad variable %s", buf->data);
1412  if (DTYPE(he->type) == DT_BOOL)
1413  bool_he_toggle(NeoMutt->sub, he, err);
1414  else
1415  quad_he_toggle(NeoMutt->sub, he, err);
1416  }
1417  else
1418  {
1419  // mutt_buffer_printf(err, "ACT26 UNSET bool/quad variable %s", buf->data);
1420  rc = cs_subset_he_native_set(NeoMutt->sub, he, false, err);
1421  if (CSR_RESULT(rc) != CSR_SUCCESS)
1422  return MUTT_CMD_ERROR;
1423  }
1424  continue;
1425  }
1426  else
1427  {
1428  rc = cs_subset_he_string_set(NeoMutt->sub, he, NULL, err);
1429  if (CSR_RESULT(rc) != CSR_SUCCESS)
1430  return MUTT_CMD_ERROR;
1431  }
1432  }
1433 
1434  return MUTT_CMD_SUCCESS;
1435 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
#define CSR_RESULT(x)
Definition: set.h:52
struct HashElem ** get_elem_list(struct ConfigSet *cs)
Create a sorted list of all config items.
Definition: subset.c:64
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:341
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
#define _(a)
Definition: message.h:28
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:168
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:37
Container for Accounts, Notifications.
Definition: neomutt.h:36
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:44
#define DT_PATH_DIR
Path is a directory.
Definition: types.h:53
int cs_subset_he_string_plus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Add to a config item by string.
Definition: subset.c:411
char * HomeDir
User&#39;s home directory.
Definition: globals.h:50
default is to reset all vars to default
Definition: mutt_commands.h:69
size_t dsize
Length of data.
Definition: buffer.h:37
#define MoreArgs(buf)
Definition: buffer.h:43
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:51
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:373
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
bool mutt_path_tilde(char *buf, size_t buflen, const char *homedir)
Expand &#39;~&#39; in a path.
Definition: path.c:223
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:35
#define DT_PATH_FILE
Path is a file.
Definition: types.h:54
#define mutt_b2s(buf)
Definition: buffer.h:41
int cs_subset_he_string_minus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Remove from a config item by string.
Definition: subset.c:449
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:165
#define DT_PATH
a path to a file/directory
Definition: types.h:36
#define IS_MAILBOX(x)
Definition: types.h:57
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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
#define MUTT_TOKEN_PLUS
Treat &#39;+&#39; as a special.
Definition: mutt.h:81
default is to unset all vars
Definition: mutt_commands.h:68
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:612
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
void * data
User-supplied data.
Definition: hash.h:47
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
Definition: dump.c:83
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:327
Warning: Help given to the user.
Definition: mutt_commands.h:36
int bool_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:212
#define MUTT_TOKEN_MINUS
Treat &#39;-&#39; as a special.
Definition: mutt.h:82
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:78
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition: hash.h:45
#define FREE(x)
Definition: memory.h:40
int quad_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a quad.
Definition: quad.c:229
The item stored in a Hash Table.
Definition: hash.h:43
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:71
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
#define IS_COMMAND(x)
Definition: types.h:58
default is to set all vars
Definition: mutt_commands.h:66
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:270
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:307
#define DT_BOOL
boolean option
Definition: types.h:30
default is to invert all vars
Definition: mutt_commands.h:67
#define MUTT_TOKEN_QUESTION
Treat &#39;?&#39; as a special.
Definition: mutt.h:80
+ Here is the call graph for this function:

◆ parse_setenv()

enum CommandResult parse_setenv ( struct Buffer buf,
struct Buffer s,
intptr_t  data,
struct Buffer err 
)

Parse the 'setenv' and 'unsetenv' commands - Implements Command::parse()

Definition at line 1440 of file command_parse.c.

1442 {
1443  char **envp = mutt_envlist_getlist();
1444 
1445  bool query = false;
1446  bool unset = (data == MUTT_SET_UNSET);
1447 
1448  if (!MoreArgs(s))
1449  {
1450  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1451  return MUTT_CMD_WARNING;
1452  }
1453 
1454  if (*s->dptr == '?')
1455  {
1456  query = true;
1457  s->dptr++;
1458  }
1459 
1460  /* get variable name */
1462 
1463  if (query)
1464  {
1465  bool found = false;
1466  while (envp && *envp)
1467  {
1468  /* This will display all matches for "^QUERY" */
1469  if (mutt_str_startswith(*envp, buf->data))
1470  {
1471  if (!found)
1472  {
1473  mutt_endwin();
1474  found = true;
1475  }
1476  puts(*envp);
1477  }
1478  envp++;
1479  }
1480 
1481  if (found)
1482  {
1484  return MUTT_CMD_SUCCESS;
1485  }
1486 
1487  mutt_buffer_printf(err, _("%s is unset"), buf->data);
1488  return MUTT_CMD_WARNING;
1489  }
1490 
1491  if (unset)
1492  {
1493  if (mutt_envlist_unset(buf->data))
1494  return MUTT_CMD_SUCCESS;
1495  return MUTT_CMD_ERROR;
1496  }
1497 
1498  /* set variable */
1499 
1500  if (*s->dptr == '=')
1501  {
1502  s->dptr++;
1503  SKIPWS(s->dptr);
1504  }
1505 
1506  if (!MoreArgs(s))
1507  {
1508  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1509  return MUTT_CMD_WARNING;
1510  }
1511 
1512  char *name = mutt_str_dup(buf->data);
1514  mutt_envlist_set(name, buf->data, true);
1515  FREE(&name);
1516 
1517  return MUTT_CMD_SUCCESS;
1518 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
#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
#define SKIPWS(ch)
Definition: string2.h:46
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:165
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:546
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:414
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
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:579
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
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:71
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
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,
intptr_t  data,
struct Buffer err 
)

Parse the 'source' command - Implements Command::parse()

Definition at line 1523 of file command_parse.c.

1525 {
1526  char path[PATH_MAX];
1527 
1528  do
1529  {
1530  if (mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS) != 0)
1531  {
1532  mutt_buffer_printf(err, _("source: error at %s"), s->dptr);
1533  return MUTT_CMD_ERROR;
1534  }
1535  mutt_str_copy(path, buf->data, sizeof(path));
1536  mutt_expand_path(path, sizeof(path));
1537 
1538  if (source_rc(path, err) < 0)
1539  {
1540  mutt_buffer_printf(err, _("source: file %s could not be sourced"), path);
1541  return MUTT_CMD_ERROR;
1542  }
1543 
1544  } while (MoreArgs(s));
1545 
1546  return MUTT_CMD_SUCCESS;
1547 }
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:44
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:724
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_spam_list()

enum CommandResult parse_spam_list ( struct Buffer buf,
struct Buffer s,
intptr_t  data,
struct Buffer err 
)

Parse the 'spam' and 'nospam' commands - Implements Command::parse()

Definition at line 1552 of file command_parse.c.

1554 {
1555  struct Buffer templ;
1556 
1557  mutt_buffer_init(&templ);
1558 
1559  /* Insist on at least one parameter */
1560  if (!MoreArgs(s))
1561  {
1562  if (data == MUTT_SPAM)
1563  mutt_buffer_strcpy(err, _("spam: no matching pattern"));
1564  else
1565  mutt_buffer_strcpy(err, _("nospam: no matching pattern"));
1566  return MUTT_CMD_ERROR;
1567  }
1568 
1569  /* Extract the first token, a regex */
1571 
1572  /* data should be either MUTT_SPAM or MUTT_NOSPAM. MUTT_SPAM is for spam commands. */
1573  if (data == MUTT_SPAM)
1574  {
1575  /* If there's a second parameter, it's a template for the spam tag. */
1576  if (MoreArgs(s))
1577  {
1579 
1580  /* Add to the spam list. */
1581  if (mutt_replacelist_add(&SpamList, buf->data, templ.data, err) != 0)
1582  {
1583  FREE(&templ.data);
1584  return MUTT_CMD_ERROR;
1585  }
1586  FREE(&templ.data);
1587  }
1588  /* If not, try to remove from the nospam list. */
1589  else
1590  {
1592  }
1593 
1594  return MUTT_CMD_SUCCESS;
1595  }
1596  /* MUTT_NOSPAM is for nospam commands. */
1597  else if (data == MUTT_NOSPAM)
1598  {
1599  /* nospam only ever has one parameter. */
1600 
1601  /* "*" is a special case. */
1602  if (mutt_str_equal(buf->data, "*"))
1603  {
1606  return MUTT_CMD_SUCCESS;
1607  }
1608 
1609  /* If it's on the spam list, just remove it. */
1610  if (mutt_replacelist_remove(&SpamList, buf->data) != 0)
1611  return MUTT_CMD_SUCCESS;
1612 
1613  /* Otherwise, add it to the nospam list. */
1614  if (mutt_regexlist_add(&NoSpamList, buf->data, REG_ICASE, err) != 0)
1615  return MUTT_CMD_ERROR;
1616 
1617  return MUTT_CMD_SUCCESS;
1618  }
1619 
1620  /* This should not happen. */
1621  mutt_buffer_strcpy(err, "This is no good at all.");
1622  return MUTT_CMD_ERROR;
1623 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, const char *templ, struct Buffer *err)
Add a pattern and a template to a list.
Definition: regex.c:261
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define MUTT_NOSPAM
Definition: mutt.h:115
struct ReplaceList SpamList
List of regexes and patterns to match spam emails.
Definition: email_globals.c:44
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:446
#define MoreArgs(buf)
Definition: buffer.h:43
#define MUTT_SPAM
Definition: mutt.h:114
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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:563
#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
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition: regex.c:169
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_stailq()

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

Parse a list command - Implements Command::parse()

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

Definition at line 1630 of file command_parse.c.

1632 {
1633  do
1634  {
1636  add_to_stailq((struct ListHead *) data, buf->data);
1637  } while (MoreArgs(s));
1638 
1639  return MUTT_CMD_SUCCESS;
1640 }
#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:1790
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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:70
+ Here is the call graph for this function:

◆ parse_subjectrx_list()

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

Parse the 'subjectrx' command - Implements Command::parse()

Definition at line 1645 of file command_parse.c.

1647 {
1648  enum CommandResult rc;
1649 
1650  rc = parse_replace_list(buf, s, &SubjectRegexList, err);
1651  if (rc == MUTT_CMD_SUCCESS)
1653  return rc;
1654 }
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, struct ReplaceList *list, struct Buffer *err)
Parse a string replacement rule - Implements Command::parse()
Success: Command worked.
Definition: mutt_commands.h:37
static void clear_subject_mods(void)
Clear out all modified email subjects.
struct ReplaceList SubjectRegexList
List of regexes to tidy the view of the email&#39;s subject.
Definition: email_globals.c:53
+ Here is the call graph for this function:

◆ parse_subscribe()

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

Parse the 'subscribe' command - Implements Command::parse()

Definition at line 1659 of file command_parse.c.

1661 {
1662  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
1663 
1664  do
1665  {
1667 
1668  if (parse_grouplist(&gl, buf, s, err) == -1)
1669  goto bail;
1670 
1673 
1674  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
1675  goto bail;
1676  if (mutt_regexlist_add(&SubscribedLists, buf->data, REG_ICASE, err) != 0)
1677  goto bail;
1678  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
1679  goto bail;
1680  } while (MoreArgs(s));
1681 
1683  return MUTT_CMD_SUCCESS;
1684 
1685 bail:
1687  return MUTT_CMD_ERROR;
1688 }
int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h: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:276
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#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:70
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,
intptr_t  data,
struct Buffer err 
)

Parse the 'subscribe-to' command - Implements Command::parse()

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

1700 {
1701  if (!buf || !s || !err)
1702  return MUTT_CMD_ERROR;
1703 
1704  mutt_buffer_reset(err);
1705 
1706  if (MoreArgs(s))
1707  {
1709 
1710  if (MoreArgs(s))
1711  {
1712  mutt_buffer_printf(err, _("%s: too many arguments"), "subscribe-to");
1713  return MUTT_CMD_WARNING;
1714  }
1715 
1716  if (buf->data && (*buf->data != '\0'))
1717  {
1718  /* Expand and subscribe */
1719  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), true) == 0)
1720  {
1721  mutt_message(_("Subscribed to %s"), buf->data);
1722  return MUTT_CMD_SUCCESS;
1723  }
1724 
1725  mutt_buffer_printf(err, _("Could not subscribe to %s"), buf->data);
1726  return MUTT_CMD_ERROR;
1727  }
1728 
1729  mutt_debug(LL_DEBUG1, "Corrupted buffer");
1730  return MUTT_CMD_ERROR;
1731  }
1732 
1733  mutt_buffer_addstr(err, _("No folder specified"));
1734  return MUTT_CMD_WARNING;
1735 }
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:414
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:70
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1229
+ Here is the call graph for this function:

◆ parse_tag_formats()

enum CommandResult parse_tag_formats ( struct Buffer buf,
struct Buffer s,
intptr_t  data,
struct Buffer err 
)

Parse the 'tag-formats' command - Implements Command::parse()

Definition at line 1741 of file command_parse.c.

1743 {
1744  if (!buf || !s)
1745  return MUTT_CMD_ERROR;
1746 
1747  char *tmp = NULL;
1748 
1749  while (MoreArgs(s))
1750  {
1751  char *tag = NULL, *format = NULL;
1752 
1754  if (buf->data && (*buf->data != '\0'))
1755  tag = mutt_str_dup(buf->data);
1756  else
1757  continue;
1758 
1760  format = mutt_str_dup(buf->data);
1761 
1762  /* avoid duplicates */
1763  tmp = mutt_hash_find(TagFormats, format);
1764  if (tmp)
1765  {
1766  mutt_debug(LL_DEBUG3, "tag format '%s' already registered as '%s'\n", format, tmp);
1767  FREE(&tag);
1768  FREE(&format);
1769  continue;
1770  }
1771 
1772  mutt_hash_insert(TagFormats, format, tag);
1773  }
1774  return MUTT_CMD_SUCCESS;
1775 }
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:354
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
Definition: hash.c:327
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
#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:414
WHERE struct HashTable * TagFormats
Hash Table of tag-formats (tag -> format string)
Definition: globals.h:60
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Log at debug level 3.
Definition: logging.h:42
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_tag_transforms()

enum CommandResult parse_tag_transforms ( struct Buffer buf,
struct Buffer s,
intptr_t  data,
struct Buffer err 
)

Parse the 'tag-transforms' command - Implements Command::parse()

Definition at line 1780 of file command_parse.c.

1782 {
1783  if (!buf || !s)
1784  return MUTT_CMD_ERROR;
1785 
1786  char *tmp = NULL;
1787 
1788  while (MoreArgs(s))
1789  {
1790  char *tag = NULL, *transform = NULL;
1791 
1793  if (buf->data && (*buf->data != '\0'))
1794  tag = mutt_str_dup(buf->data);
1795  else
1796  continue;
1797 
1799  transform = mutt_str_dup(buf->data);
1800 
1801  /* avoid duplicates */
1802  tmp = mutt_hash_find(TagTransforms, tag);
1803  if (tmp)
1804  {
1805  mutt_debug(LL_DEBUG3, "tag transform '%s' already registered as '%s'\n", tag, tmp);
1806  FREE(&tag);
1807  FREE(&transform);
1808  continue;
1809  }
1810 
1811  mutt_hash_insert(TagTransforms, tag, transform);
1812  }
1813  return MUTT_CMD_SUCCESS;
1814 }
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:354
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
Definition: hash.c:327
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
#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:414
char * data
Pointer to data.
Definition: buffer.h:35
struct HashTable * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:38
Success: Command worked.
Definition: mutt_commands.h:37
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Log at debug level 3.
Definition: logging.h:42
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_unalternates()

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

Parse the 'unalternates' command - Implements Command::parse()

Definition at line 1819 of file command_parse.c.

1821 {
1822  alternates_clean();
1823  do
1824  {
1826  mutt_regexlist_remove(&Alternates, buf->data);
1827 
1828  if (!mutt_str_equal(buf->data, "*") &&
1829  (mutt_regexlist_add(&UnAlternates, buf->data, REG_ICASE, err) != 0))
1830  {
1831  return MUTT_CMD_ERROR;
1832  }
1833 
1834  } while (MoreArgs(s));
1835 
1836  return MUTT_CMD_SUCCESS;
1837 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h: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:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_unattachments()

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

Parse the 'unattachments' command - Implements Command::parse()

Definition at line 1842 of file command_parse.c.

1844 {
1845  char op;
1846  char *p = NULL;
1847  struct ListHead *head = NULL;
1848 
1850  if (!buf->data || (*buf->data == '\0'))
1851  {
1852  mutt_buffer_strcpy(err, _("unattachments: no disposition"));
1853  return MUTT_CMD_WARNING;
1854  }
1855 
1856  p = buf->data;
1857  op = *p++;
1858 
1859  if (op == '*')
1860  {
1866  return 0;
1867  }
1868 
1869  if ((op != '+') && (op != '-'))
1870  {
1871  op = '+';
1872  p--;
1873  }
1874  if (mutt_istr_startswith("attachment", p))
1875  {
1876  if (op == '+')
1877  head = &AttachAllow;
1878  else
1879  head = &AttachExclude;
1880  }
1881  else if (mutt_istr_startswith("inline", p))
1882  {
1883  if (op == '+')
1884  head = &InlineAllow;
1885  else
1886  head = &InlineExclude;
1887  }
1888  else
1889  {
1890  mutt_buffer_strcpy(err, _("unattachments: invalid disposition"));
1891  return MUTT_CMD_ERROR;
1892  }
1893 
1894  return parse_unattach_list(buf, s, head, err);
1895 }
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:40
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:144
#define _(a)
Definition: message.h:28
struct ListHead InlineExclude
List of inline types to ignore.
Definition: mutt_parse.c:41
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:177
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: mutt_parse.c:39
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:240
struct ListHead AttachAllow
List of attachment types to be counted.
Definition: mutt_parse.c:38
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
void(* list_free_t)(void **ptr)
Prototype for a function to free List data.
Definition: list.h:45
+ Here is the call graph for this function:

◆ parse_unignore()

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

Parse the 'unignore' command - Implements Command::parse()

Definition at line 1900 of file command_parse.c.

1902 {
1903  do
1904  {
1906 
1907  /* don't add "*" to the unignore list */
1908  if (strcmp(buf->data, "*") != 0)
1909  add_to_stailq(&UnIgnore, buf->data);
1910 
1911  remove_from_stailq(&Ignore, buf->data);
1912  } while (MoreArgs(s));
1913 
1914  return MUTT_CMD_SUCCESS;
1915 }
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:1790
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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:1815
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:70
+ Here is the call graph for this function:

◆ parse_unlists()

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

Parse the 'unlists' command - Implements Command::parse()

Definition at line 1920 of file command_parse.c.

1922 {
1924  do
1925  {
1929 
1930  if (!mutt_str_equal(buf->data, "*") &&
1931  (mutt_regexlist_add(&UnMailLists, buf->data, REG_ICASE, err) != 0))
1932  {
1933  return MUTT_CMD_ERROR;
1934  }
1935  } while (MoreArgs(s));
1936 
1937  return MUTT_CMD_SUCCESS;
1938 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition: hash.c:447
#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:131
struct HashTable * AutoSubscribeCache
Hash Table of auto-subscribed mailing lists.
Definition: email_globals.c:48
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_unmailboxes()

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

Parse the 'unmailboxes' command - Implements Command::parse()

This is also used by 'unvirtual-mailboxes'

Definition at line 1945 of file command_parse.c.

1947 {
1948  bool tmp_valid = false;
1949  bool clear_all = false;
1950 
1951  while (!clear_all && MoreArgs(s))
1952  {
1954 
1955  if (mutt_str_equal(buf->data, "*"))
1956  {
1957  clear_all = true;
1958  tmp_valid = false;
1959  }
1960  else
1961  {
1963  tmp_valid = true;
1964  }
1965 
1966  struct MailboxList ml = STAILQ_HEAD_INITIALIZER(ml);
1968  struct MailboxNode *np = NULL;
1969  struct MailboxNode *nptmp = NULL;
1970  STAILQ_FOREACH_SAFE(np, &ml, entries, nptmp)
1971  {
1972  /* Compare against path or desc? Ensure 'buf' is valid */
1973  if (!clear_all && tmp_valid &&
1975  !mutt_istr_equal(mutt_b2s(buf), np->mailbox->name))
1976  {
1977  continue;
1978  }
1979 
1980 #ifdef USE_SIDEBAR
1982 #endif
1983 #ifdef USE_INOTIFY
1985 #endif
1986  if (Context && (Context->mailbox == np->mailbox))
1987  {
1988  np->mailbox->flags |= MB_HIDDEN;
1989  }
1990  else
1991  {
1993  mailbox_free(&np->mailbox);
1994  }
1995  }
1997  }
1998  return MUTT_CMD_SUCCESS;
1999 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
The "current" mailbox.
Definition: context.h:37
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:194
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:524
Match any Mailbox type.
Definition: mailbox.h:45
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Definition: neomutt.c:158
Container for Accounts, Notifications.
Definition: neomutt.h:36
#define MoreArgs(buf)
Definition: buffer.h:43
char * name
A short name for the Mailbox.
Definition: mailbox.h:85
struct Mailbox * mailbox
Definition: context.h:50
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:60
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:359
int flags
e.g. MB_NORMAL
Definition: mailbox.h:134
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:891
#define mutt_b2s(buf)
Definition: buffer.h:41
#define MB_HIDDEN
Definition: mailbox.h:38
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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:327
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:131
bool account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
Definition: account.c:95
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
List of Mailboxes.
Definition: mailbox.h:145
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:147
+ Here is the call graph for this function:

◆ parse_unmy_hdr()

enum CommandResult parse_unmy_hdr ( struct Buffer buf,
struct Buffer s,
intptr_t  data,
struct Buffer err 
)

Parse the 'unmy_hdr' command - Implements Command::parse()

Definition at line 2004 of file command_parse.c.

2006 {
2007  struct ListNode *np = NULL, *tmp = NULL;
2008  size_t l;
2009 
2010  do
2011  {
2013  if (mutt_str_equal("*", buf->data))
2014  {
2015  mutt_list_free(&UserHeader);
2016  continue;
2017  }
2018 
2019  l = mutt_str_len(buf->data);
2020  if (buf->data[l - 1] == ':')
2021  l--;
2022 
2023  STAILQ_FOREACH_SAFE(np, &UserHeader, entries, tmp)
2024  {
2025  if (mutt_istrn_equal(buf->data, np->data, l) && (np->data[l] == ':'))
2026  {
2027  STAILQ_REMOVE(&UserHeader, np, ListNode, entries);
2028  FREE(&np->data);
2029  FREE(&np);
2030  }
2031  }
2032  } while (MoreArgs(s));
2033  return MUTT_CMD_SUCCESS;
2034 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:399
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
bool mutt_istrn_equal(const char *a, const char *b, size_t l)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition: string.c:629
#define MoreArgs(buf)
Definition: buffer.h:43
#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:414
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:639
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:36
#define FREE(x)
Definition: memory.h:40
A List node for strings.
Definition: list.h:34
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_unstailq()

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

Parse an unlist command - Implements Command::parse()

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

Definition at line 2041 of file command_parse.c.

2043 {
2044  do
2045  {
2047  /* Check for deletion of entire list */
2048  if (mutt_str_equal(buf->data, "*"))
2049  {
2050  mutt_list_free((struct ListHead *) data);
2051  break;
2052  }
2053  remove_from_stailq((struct ListHead *) data, buf->data);
2054  } while (MoreArgs(s));
2055 
2056  return MUTT_CMD_SUCCESS;
2057 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
#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:414
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:1815
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:36
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_unsubjectrx_list()

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

Parse the 'unsubjectrx' command - Implements Command::parse()

Definition at line 2062 of file command_parse.c.

2064 {
2065  enum CommandResult rc;
2066 
2067  rc = parse_unreplace_list(buf, s, &SubjectRegexList, err);
2068  if (rc == MUTT_CMD_SUCCESS)
2070  return rc;
2071 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
static enum CommandResult parse_unreplace_list(struct Buffer *buf, struct Buffer *s, struct ReplaceList *list, struct Buffer *err)
Remove a string replacement rule - Implements Command::parse()
Definition: command_parse.c:85
Success: Command worked.
Definition: mutt_commands.h:37
static void clear_subject_mods(void)
Clear out all modified email subjects.
struct ReplaceList SubjectRegexList
List of regexes to tidy the view of the email&#39;s subject.
Definition: email_globals.c:53
+ Here is the call graph for this function:

◆ parse_unsubscribe()

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

Parse the 'unsubscribe' command - Implements Command::parse()

Definition at line 2076 of file command_parse.c.

2078 {
2080  do
2081  {
2084 
2085  if (!mutt_str_equal(buf->data, "*") &&
2086  (mutt_regexlist_add(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0))
2087  {
2088  return MUTT_CMD_ERROR;
2089  }
2090  } while (MoreArgs(s));
2091 
2092  return MUTT_CMD_SUCCESS;
2093 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition: hash.c:447
#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:131
struct HashTable * AutoSubscribeCache
Hash Table of auto-subscribed mailing lists.
Definition: email_globals.c:48
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:414
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
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
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,
intptr_t  data,
struct Buffer err 
)

Parse the 'unsubscribe-from' command - Implements Command::parse()

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

2105 {
2106  if (!buf || !s || !err)
2107  return MUTT_CMD_ERROR;
2108 
2109  if (MoreArgs(s))
2110  {
2112 
2113  if (MoreArgs(s))
2114  {
2115  mutt_buffer_printf(err, _("%s: too many arguments"), "unsubscribe-from");
2116  return MUTT_CMD_WARNING;
2117  }
2118 
2119  if (buf->data && (*buf->data != '\0'))
2120  {
2121  /* Expand and subscribe */
2122  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), false) == 0)
2123  {
2124  mutt_message(_("Unsubscribed from %s"), buf->data);
2125  return MUTT_CMD_SUCCESS;
2126  }
2127 
2128  mutt_buffer_printf(err, _("Could not unsubscribe from %s"), buf->data);
2129  return MUTT_CMD_ERROR;
2130  }
2131 
2132  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2133  return MUTT_CMD_ERROR;
2134  }
2135 
2136  mutt_buffer_addstr(err, _("No folder specified"));
2137  return MUTT_CMD_WARNING;
2138 }
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:414
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:70
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1229
+ 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 2144 of file command_parse.c.

2145 {
2147 }
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
static struct ListHead MuttrcStack
Definition: command_parse.c:68
+ 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 68 of file command_parse.c.