NeoMutt  2020-03-20-65-g141838
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 <regex.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 "gui/lib.h"
#include "mutt.h"
#include "command_parse.h"
#include "alias.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, intptr_t data, 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, intptr_t data, 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...
 
static 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_alias (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'alias' command - Implements Command::parse() 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_unalias (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unalias' 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 71 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 76 of file command_parse.c.

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

Function Documentation

◆ parse_unreplace_list()

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

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

Definition at line 86 of file command_parse.c.

88 {
89  struct ReplaceList *list = (struct ReplaceList *) data;
90 
91  /* First token is a regex. */
92  if (!MoreArgs(s))
93  {
94  mutt_buffer_printf(err, _("%s: too few arguments"), "unsubjectrx");
95  return MUTT_CMD_WARNING;
96  }
97 
99 
100  /* "*" is a special case. */
101  if (mutt_str_strcmp(buf->data, "*") == 0)
102  {
103  mutt_replacelist_free(list);
104  return MUTT_CMD_SUCCESS;
105  }
106 
107  mutt_replacelist_remove(list, buf->data);
108  return MUTT_CMD_SUCCESS;
109 }
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:447
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
Warning: Help given to the user.
Definition: mutt_commands.h:36
int mutt_replacelist_remove(struct ReplaceList *rl, const char *pat)
Remove a pattern from a list.
Definition: regex.c:564
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h: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 114 of file command_parse.c.

115 {
116  if (!Context || !Context->mailbox)
117  return;
118 
119  struct Mailbox *m = Context->mailbox;
120  for (int i = 0; i < m->msg_count; i++)
121  {
122  struct Email *e = m->emails[i];
123  if (!e)
124  break;
125  e->attach_valid = false;
126  }
127 }
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:51
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 137 of file command_parse.c.

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

196 {
197  if (!Context || !Context->mailbox)
198  return;
199 
200  struct Mailbox *m = Context->mailbox;
201  for (int i = 0; i < m->msg_count; i++)
202  {
203  struct Email *e = m->emails[i];
204  if (!e || !e->env)
205  continue;
206  FREE(&e->env->disp_subj);
207  }
208 }
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:51
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,
intptr_t  data,
struct Buffer err 
)
static

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

Definition at line 213 of file command_parse.c.

215 {
216  struct ReplaceList *list = (struct ReplaceList *) data;
217  struct Buffer templ = mutt_buffer_make(0);
218 
219  /* First token is a regex. */
220  if (!MoreArgs(s))
221  {
222  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
223  return MUTT_CMD_WARNING;
224  }
226 
227  /* Second token is a replacement template */
228  if (!MoreArgs(s))
229  {
230  mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
231  return MUTT_CMD_WARNING;
232  }
234 
235  if (mutt_replacelist_add(list, buf->data, templ.data, err) != 0)
236  {
237  FREE(&templ.data);
238  return MUTT_CMD_ERROR;
239  }
240  FREE(&templ.data);
241 
242  return MUTT_CMD_SUCCESS;
243 }
int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, const char *templ, struct Buffer *err)
Add a pattern and a template to a list.
Definition: regex.c:262
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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 251 of file command_parse.c.

252 {
253  for (enum MenuType i = 0; i < MENU_MAX; i++)
254  {
255  const struct Binding *b = km_get_table(Menus[i].value);
256  if (!b)
257  continue;
258 
259  for (int j = 0; b[j].name; j++)
260  if (mutt_str_strcmp(name, b[j].name) == 0)
261  return true;
262  }
263  return false;
264 }
MenuType
Types of GUI selections.
Definition: keymap.h:69
const char * name
Definition: pgpmicalg.c:46
const char * name
name of the function
Definition: keymap.h:119
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:1264
Mapping between a user key and a function.
Definition: keymap.h:117
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_attachmatch_new()

static struct AttachMatch* mutt_attachmatch_new ( void  )
static

Create a new AttachMatch.

Return values
ptrNew AttachMatch

Definition at line 270 of file command_parse.c.

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

◆ parse_attach_list()

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

Parse the "attachments" command.

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

Definition at line 283 of file command_parse.c.

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

358 {
359  struct ListNode *np = NULL;
360  STAILQ_FOREACH(np, h, entries)
361  {
362  printf("attachments %c%s %s/%s\n", op, name,
363  ((struct AttachMatch *) np->data)->major,
364  ((struct AttachMatch *) np->data)->minor);
365  }
366 
367  return 0;
368 }
const char * name
Definition: pgpmicalg.c:46
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
char * data
String.
Definition: list.h:35
An attachment matching a regex for attachment counter.
Definition: mutt_parse.h:35
A List node for strings.
Definition: list.h:33
+ Here is the caller graph for this function:

◆ alternates_clean()

static void alternates_clean ( void  )
static

Clear the recipient valid flag of all emails.

Definition at line 373 of file command_parse.c.

374 {
375  if (!Context || !Context->mailbox)
376  return;
377 
378  struct Mailbox *m = Context->mailbox;
379  for (int i = 0; i < m->msg_count; i++)
380  {
381  struct Email *e = m->emails[i];
382  if (!e)
383  break;
384  e->recip_valid = false;
385  }
386 }
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:51
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()

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

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

399 {
400  while (mutt_str_strcasecmp(buf->data, "-group") == 0)
401  {
402  if (!MoreArgs(s))
403  {
404  mutt_buffer_strcpy(err, _("-group: no group name"));
405  return -1;
406  }
407 
409 
411 
412  if (!MoreArgs(s))
413  {
414  mutt_buffer_strcpy(err, _("out of arguments"));
415  return -1;
416  }
417 
419  }
420 
421  return 0;
422 }
void mutt_grouplist_add(struct GroupList *gl, struct Group *group)
Add a Group to a GroupList.
Definition: group.c:138
#define _(a)
Definition: message.h:28
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
struct Group * mutt_pattern_group(const char *pat)
Match a pattern to a Group.
Definition: group.c:66
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h: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 430 of file command_parse.c.

431 {
432  int line = 0, rc = 0, warnings = 0;
433  enum CommandResult line_rc;
434  struct Buffer token;
435  char *linebuf = NULL;
436  char *currentline = NULL;
437  char rcfile[PATH_MAX];
438  size_t buflen;
439 
440  pid_t pid;
441 
442  mutt_str_strfcpy(rcfile, rcfile_path, sizeof(rcfile));
443 
444  size_t rcfilelen = mutt_str_strlen(rcfile);
445  if (rcfilelen == 0)
446  return -1;
447 
448  bool ispipe = rcfile[rcfilelen - 1] == '|';
449 
450  if (!ispipe)
451  {
452  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
453  if (!mutt_path_to_absolute(rcfile, np ? NONULL(np->data) : ""))
454  {
455  mutt_error(_("Error: Can't build path of '%s'"), rcfile_path);
456  return -1;
457  }
458 
459  STAILQ_FOREACH(np, &MuttrcStack, entries)
460  {
461  if (mutt_str_strcmp(np->data, rcfile) == 0)
462  {
463  break;
464  }
465  }
466  if (np)
467  {
468  mutt_error(_("Error: Cyclic sourcing of configuration file '%s'"), rcfile);
469  return -1;
470  }
471 
473  }
474 
475  mutt_debug(LL_DEBUG2, "Reading configuration file '%s'\n", rcfile);
476 
477  FILE *fp = mutt_open_read(rcfile, &pid);
478  if (!fp)
479  {
480  mutt_buffer_printf(err, "%s: %s", rcfile, strerror(errno));
481  return -1;
482  }
483 
484  mutt_buffer_init(&token);
485  while ((linebuf = mutt_file_read_line(linebuf, &buflen, fp, &line, MUTT_CONT)))
486  {
487  const bool conv = C_ConfigCharset && C_Charset;
488  if (conv)
489  {
490  currentline = mutt_str_strdup(linebuf);
491  if (!currentline)
492  continue;
493  mutt_ch_convert_string(&currentline, C_ConfigCharset, C_Charset, 0);
494  }
495  else
496  currentline = linebuf;
497  mutt_buffer_reset(err);
498  line_rc = mutt_parse_rc_line(currentline, &token, err);
499  if (line_rc == MUTT_CMD_ERROR)
500  {
501  mutt_error(_("Error in %s, line %d: %s"), rcfile, line, 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, line, 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  FREE(&token.data);
528  FREE(&linebuf);
529  mutt_file_fclose(&fp);
530  if (pid != -1)
531  filter_wait(pid);
532  if (rc)
533  {
534  /* the neomuttrc source keyword */
535  mutt_buffer_reset(err);
536  mutt_buffer_printf(err, (rc >= -MAX_ERRS) ? _("source: errors in %s") : _("source: reading aborted due to too many errors in %s"),
537  rcfile);
538  rc = -1;
539  }
540  else
541  {
542  /* Don't alias errors with warnings */
543  if (warnings > 0)
544  {
545  mutt_buffer_printf(err, ngettext("source: %d warning in %s", "source: %d warnings in %s", warnings),
546  warnings, rcfile);
547  rc = -2;
548  }
549  }
550 
551  if (!ispipe && !STAILQ_EMPTY(&MuttrcStack))
552  {
553  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
554  STAILQ_REMOVE_HEAD(&MuttrcStack, entries);
555  FREE(&np->data);
556  FREE(&np);
557  }
558 
559  return rc;
560 }
#define mutt_warning(...)
Definition: logging.h:82
#define NONULL(x)
Definition: string2.h:37
int mutt_ch_convert_string(char **ps, const char *from, const char *to, int flags)
Convert a string between encodings.
Definition: charset.c:748
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, int flags)
Read a line from a file.
Definition: file.c:667
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:689
#define STAILQ_REMOVE_HEAD(head, field)
Definition: queue.h:419
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define MUTT_CONT
-continuation
Definition: file.h:38
WHERE char * C_ConfigCharset
Config: Character set that the config files are in.
Definition: globals.h:106
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
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:773
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:46
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
char * data
String.
Definition: list.h:35
Warning: Help given to the user.
Definition: mutt_commands.h:36
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
Finish: Stop processing this file.
Definition: mutt_commands.h:38
#define MAX_ERRS
Definition: command_parse.c:71
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
static struct ListHead MuttrcStack
Definition: command_parse.c:69
#define STAILQ_EMPTY(head)
Definition: queue.h:345
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:54
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
int const char int line
Definition: acutest.h:602
A List node for strings.
Definition: list.h:33
FILE * mutt_open_read(const char *path, pid_t *thepid)
Run a command to read from.
Definition: muttlib.c:1393
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
#define STAILQ_FIRST(head)
Definition: queue.h:347
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:991
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_alias()

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

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

Definition at line 565 of file command_parse.c.

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

652 {
653  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
654 
656 
657  do
658  {
660 
661  if (parse_grouplist(&gl, buf, s, err) == -1)
662  goto bail;
663 
664  mutt_regexlist_remove(&UnAlternates, buf->data);
665 
666  if (mutt_regexlist_add(&Alternates, buf->data, REG_ICASE, err) != 0)
667  goto bail;
668 
669  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
670  goto bail;
671  } while (MoreArgs(s));
672 
674  return MUTT_CMD_SUCCESS;
675 
676 bail:
678  return MUTT_CMD_ERROR;
679 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:277
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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:158
#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 684 of file command_parse.c.

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

747 {
748  if (!MoreArgs(s))
749  {
750  mutt_buffer_printf(err, _("%s: too few arguments"), "echo");
751  return MUTT_CMD_WARNING;
752  }
754  OptForceRefresh = true;
755  mutt_message("%s", buf->data);
756  OptForceRefresh = false;
757  mutt_sleep(0);
758 
759  return MUTT_CMD_SUCCESS;
760 }
#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:1535
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:416
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 769 of file command_parse.c.

771 {
772  if (MoreArgs(s))
773  {
774  mutt_buffer_printf(err, _("%s: too many arguments"), "finish");
775  return MUTT_CMD_WARNING;
776  }
777 
778  return MUTT_CMD_FINISH;
779 }
#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 784 of file command_parse.c.

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

882 {
883  struct Buffer token = mutt_buffer_make(0);
884 
886 
887  // is the item defined as:
888  bool res = cs_subset_lookup(NeoMutt->sub, buf->data) // a variable?
889  || feature_enabled(buf->data) // a compiled-in feature?
890  || is_function(buf->data) // a function?
891  || mutt_command_get(buf->data) // a command?
892  || myvar_get(buf->data) // a my_ variable?
893  || mutt_str_getenv(buf->data); // an environment variable?
894 
895  if (!MoreArgs(s))
896  {
897  mutt_buffer_printf(err, _("%s: too few arguments"), (data ? "ifndef" : "ifdef"));
898  return MUTT_CMD_WARNING;
899  }
901 
902  /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
903  if ((res && (data == 0)) || (!res && (data == 1)))
904  {
905  enum CommandResult rc = mutt_parse_rc_line(buf->data, &token, err);
906  if (rc == MUTT_CMD_ERROR)
907  {
908  mutt_error(_("Error: %s"), err->data);
909  FREE(&token.data);
910  return MUTT_CMD_ERROR;
911  }
912  FREE(&token.data);
913  return rc;
914  }
915  return MUTT_CMD_SUCCESS;
916 }
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:562
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
static bool is_function(const char *name)
Is the argument a neomutt function?
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c: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:35
const struct Command * mutt_command_get(const char *s)
Get a Command by its name.
Definition: init.c:385
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1071
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
#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
#define FREE(x)
Definition: memory.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:991
#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 921 of file command_parse.c.

923 {
924  do
925  {
928  add_to_stailq(&Ignore, buf->data);
929  } while (MoreArgs(s));
930 
931  return MUTT_CMD_SUCCESS;
932 }
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:1792
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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:1817
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 937 of file command_parse.c.

939 {
940  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
941 
942  do
943  {
945 
946  if (parse_grouplist(&gl, buf, s, err) == -1)
947  goto bail;
948 
950 
951  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
952  goto bail;
953 
954  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
955  goto bail;
956  } while (MoreArgs(s));
957 
959  return MUTT_CMD_SUCCESS;
960 
961 bail:
963  return MUTT_CMD_ERROR;
964 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:277
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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:158
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: email_globals.c:51
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h: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 971 of file command_parse.c.

973 {
974  while (MoreArgs(s))
975  {
976  struct Mailbox *m = mailbox_new();
977 
978  if (data & MUTT_NAMED)
979  {
981  if (buf->data && (*buf->data != '\0'))
982  {
983  m->name = mutt_str_strdup(buf->data);
984  }
985  else
986  {
987  mailbox_free(&m);
988  continue;
989  }
990  }
991 
993  if (mutt_buffer_is_empty(buf))
994  {
995  /* Skip empty tokens. */
996  mailbox_free(&m);
997  continue;
998  }
999 
1000  mutt_buffer_strcpy(&m->pathbuf, buf->data);
1001  /* int rc = */ mx_path_canon2(m, C_Folder);
1002 
1003  if (m->type <= MUTT_UNKNOWN)
1004  {
1005  mutt_error("Unknown Mailbox: %s", m->realpath);
1006  mailbox_free(&m);
1007  return MUTT_CMD_ERROR;
1008  }
1009 
1010  bool new_account = false;
1011  struct Account *a = mx_ac_find(m);
1012  if (!a)
1013  {
1014  a = account_new(NULL, NeoMutt->sub);
1015  a->type = m->type;
1016  new_account = true;
1017  }
1018 
1019  if (!new_account)
1020  {
1021  struct Mailbox *m_old = mx_mbox_find(a, m->realpath);
1022  if (m_old)
1023  {
1024  if (m_old->flags == MB_HIDDEN)
1025  {
1026  m_old->flags = MB_NORMAL;
1027  mutt_sb_notify_mailbox(m_old, true);
1028  }
1029  mailbox_free(&m);
1030  continue;
1031  }
1032  }
1033 
1034  if (mx_ac_add(a, m) < 0)
1035  {
1036  //error
1037  mailbox_free(&m);
1038  if (new_account)
1039  {
1040  cs_subset_free(&a->sub);
1041  FREE(&a->name);
1042  notify_free(&a->notify);
1043  FREE(&a);
1044  }
1045  continue;
1046  }
1047  if (new_account)
1048  {
1050  }
1051 
1052 #ifdef USE_SIDEBAR
1053  mutt_sb_notify_mailbox(m, true);
1054 #endif
1055 #ifdef USE_INOTIFY
1056  mutt_monitor_add(m);
1057 #endif
1058  }
1059  return MUTT_CMD_SUCCESS;
1060 }
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:1675
int mx_path_canon2(struct Mailbox *m, const char *folder)
Canonicalise the path to realpath.
Definition: mx.c:1459
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
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:1566
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:478
struct Account * mx_ac_find(struct Mailbox *m)
Find the Account owning a Mailbox.
Definition: mx.c:1542
Container for Accounts, Notifications.
Definition: neomutt.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
char * name
A short name for the Mailbox.
Definition: mailbox.h: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:121
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:416
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 Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition: mailbox.c:42
Success: Command worked.
Definition: mutt_commands.h:37
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: account.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
bool neomutt_account_add(struct NeoMutt *n, struct Account *a)
Add an Account to the global list.
Definition: neomutt.c:84
struct Buffer pathbuf
Definition: mailbox.h: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 1065 of file command_parse.c.

1067 {
1068  struct ListNode *n = NULL;
1069  size_t keylen;
1070 
1072  char *p = strpbrk(buf->data, ": \t");
1073  if (!p || (*p != ':'))
1074  {
1075  mutt_buffer_strcpy(err, _("invalid header field"));
1076  return MUTT_CMD_WARNING;
1077  }
1078  keylen = p - buf->data + 1;
1079 
1080  STAILQ_FOREACH(n, &UserHeader, entries)
1081  {
1082  /* see if there is already a field by this name */
1083  if (mutt_str_strncasecmp(buf->data, n->data, keylen) == 0)
1084  {
1085  break;
1086  }
1087  }
1088 
1089  if (!n)
1090  {
1091  /* not found, allocate memory for a new node and add it to the list */
1092  n = mutt_list_insert_tail(&UserHeader, NULL);
1093  }
1094  else
1095  {
1096  /* found, free the existing data */
1097  FREE(&n->data);
1098  }
1099 
1100  n->data = buf->data;
1101  mutt_buffer_init(buf);
1102 
1103  return MUTT_CMD_SUCCESS;
1104 }
#define _(a)
Definition: message.h:28
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:74
int mutt_str_strncasecmp(const char *a, const char *b, size_t l)
Compare two strings ignoring case (to a maximum), safely.
Definition: string.c:679
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
#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:35
Warning: Help given to the user.
Definition: mutt_commands.h:36
int n
Definition: acutest.h:477
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
A List node for strings.
Definition: list.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_path_list()

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

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

Definition at line 1110 of file command_parse.c.

1112 {
1113  struct Buffer *path = mutt_buffer_pool_get();
1114 
1115  do
1116  {
1119  add_to_stailq((struct ListHead *) data, mutt_b2s(path));
1120  } while (MoreArgs(s));
1121  mutt_buffer_pool_release(&path);
1122 
1123  return MUTT_CMD_SUCCESS;
1124 }
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:1792
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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:328
#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 1131 of file command_parse.c.

1133 {
1134  struct Buffer *path = mutt_buffer_pool_get();
1135 
1136  do
1137  {
1139  /* Check for deletion of entire list */
1140  if (mutt_str_strcmp(mutt_b2s(path), "*") == 0)
1141  {
1142  mutt_list_free((struct ListHead *) data);
1143  break;
1144  }
1146  remove_from_stailq((struct ListHead *) data, mutt_b2s(path));
1147  } while (MoreArgs(s));
1148  mutt_buffer_pool_release(&path);
1149 
1150  return MUTT_CMD_SUCCESS;
1151 }
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
#define MoreArgs(buf)
Definition: buffer.h:43
#define mutt_b2s(buf)
Definition: buffer.h:41
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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:1817
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:328
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:78
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
+ Here is the call graph for this function:

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

1161 {
1162  /* The order must match `enum MuttSetCommand` */
1163  static const char *set_commands[] = { "set", "toggle", "unset", "reset" };
1164 
1165  int rc = 0;
1166 
1167  while (MoreArgs(s))
1168  {
1169  bool prefix = false;
1170  bool query = false;
1171  bool inv = (data == MUTT_SET_INV);
1172  bool reset = (data == MUTT_SET_RESET);
1173  bool unset = (data == MUTT_SET_UNSET);
1174 
1175  if (*s->dptr == '?')
1176  {
1177  prefix = true;
1178  query = true;
1179  s->dptr++;
1180  }
1181  else if (mutt_str_startswith(s->dptr, "no", CASE_MATCH))
1182  {
1183  prefix = true;
1184  unset = !unset;
1185  s->dptr += 2;
1186  }
1187  else if (mutt_str_startswith(s->dptr, "inv", CASE_MATCH))
1188  {
1189  prefix = true;
1190  inv = !inv;
1191  s->dptr += 3;
1192  }
1193  else if (*s->dptr == '&')
1194  {
1195  prefix = true;
1196  reset = true;
1197  s->dptr++;
1198  }
1199 
1200  if (prefix && (data != MUTT_SET_SET))
1201  {
1202  mutt_buffer_printf(err, "ERR22 can't use 'inv', 'no', '&' or '?' with the '%s' command",
1203  set_commands[data]);
1204  return MUTT_CMD_WARNING;
1205  }
1206 
1207  /* get the variable name */
1209 
1210  bool bq = false;
1211  bool equals = false;
1212 
1213  struct HashElem *he = NULL;
1214  bool my = mutt_str_startswith(buf->data, "my_", CASE_MATCH);
1215  if (!my)
1216  {
1217  he = cs_subset_lookup(NeoMutt->sub, buf->data);
1218  if (!he)
1219  {
1220  if (reset && (mutt_str_strcmp(buf->data, "all") == 0))
1221  {
1222  struct HashElem **list = get_elem_list(NeoMutt->sub->cs);
1223  if (!list)
1224  return MUTT_CMD_ERROR;
1225 
1226  for (size_t i = 0; list[i]; i++)
1227  cs_subset_he_reset(NeoMutt->sub, list[i], NULL);
1228 
1229  FREE(&list);
1230  break;
1231  }
1232  else
1233  {
1234  mutt_buffer_printf(err, "ERR01 unknown variable: %s", buf->data);
1235  return MUTT_CMD_ERROR;
1236  }
1237  }
1238 
1239  bq = ((DTYPE(he->type) == DT_BOOL) || (DTYPE(he->type) == DT_QUAD));
1240  }
1241 
1242  if (*s->dptr == '?')
1243  {
1244  if (prefix)
1245  {
1246  mutt_buffer_printf(err,
1247  "ERR02 can't use a prefix when querying a variable");
1248  return MUTT_CMD_WARNING;
1249  }
1250 
1251  if (reset || unset || inv)
1252  {
1253  mutt_buffer_printf(err, "ERR03 can't query a variable with the '%s' command",
1254  set_commands[data]);
1255  return MUTT_CMD_WARNING;
1256  }
1257 
1258  query = true;
1259  s->dptr++;
1260  }
1261  else if (*s->dptr == '=')
1262  {
1263  if (prefix)
1264  {
1265  mutt_buffer_printf(err,
1266  "ERR04 can't use prefix when setting a variable");
1267  return MUTT_CMD_WARNING;
1268  }
1269 
1270  if (reset || unset || inv)
1271  {
1272  mutt_buffer_printf(err, "ERR05 can't set a variable with the '%s' command",
1273  set_commands[data]);
1274  return MUTT_CMD_WARNING;
1275  }
1276 
1277  equals = true;
1278  s->dptr++;
1279  }
1280 
1281  if (!bq && (inv || (unset && prefix)))
1282  {
1283  if (data == MUTT_SET_SET)
1284  {
1285  mutt_buffer_printf(err, "ERR06 prefixes 'no' and 'inv' may only be "
1286  "used with bool/quad variables");
1287  }
1288  else
1289  {
1290  mutt_buffer_printf(err, "ERR07 command '%s' can only be used with bool/quad variables",
1291  set_commands[data]);
1292  }
1293  return MUTT_CMD_WARNING;
1294  }
1295 
1296  if (reset)
1297  {
1298  // mutt_buffer_printf(err, "ACT24 reset variable %s", buf->data);
1299  if (he)
1300  {
1301  rc = cs_subset_he_reset(NeoMutt->sub, he, err);
1302  if (CSR_RESULT(rc) != CSR_SUCCESS)
1303  return MUTT_CMD_ERROR;
1304  }
1305  else
1306  {
1307  myvar_del(buf->data);
1308  }
1309  continue;
1310  }
1311 
1312  if ((data == MUTT_SET_SET) && !inv && !unset)
1313  {
1314  if (query)
1315  {
1316  // mutt_buffer_printf(err, "ACT08 query variable %s", buf->data);
1317  if (he)
1318  {
1319  mutt_buffer_addstr(err, buf->data);
1320  mutt_buffer_addch(err, '=');
1321  mutt_buffer_reset(buf);
1322  rc = cs_subset_he_string_get(NeoMutt->sub, he, buf);
1323  if (CSR_RESULT(rc) != CSR_SUCCESS)
1324  {
1325  mutt_buffer_addstr(err, buf->data);
1326  return MUTT_CMD_ERROR;
1327  }
1328  if (DTYPE(he->type) == DT_PATH)
1329  mutt_pretty_mailbox(buf->data, buf->dsize);
1330  pretty_var(buf->data, err);
1331  }
1332  else
1333  {
1334  const char *val = myvar_get(buf->data);
1335  if (val)
1336  {
1337  mutt_buffer_addstr(err, buf->data);
1338  mutt_buffer_addch(err, '=');
1339  pretty_var(val, err);
1340  }
1341  else
1342  {
1343  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1344  return MUTT_CMD_ERROR;
1345  }
1346  }
1347  break;
1348  }
1349  else if (equals)
1350  {
1351  // mutt_buffer_printf(err, "ACT11 set variable %s to ", buf->data);
1352  const char *name = NULL;
1353  if (my)
1354  {
1355  name = mutt_str_strdup(buf->data);
1356  }
1358  if (my)
1359  {
1360  myvar_set(name, buf->data);
1361  FREE(&name);
1362  }
1363  else
1364  {
1365  if (DTYPE(he->type) == DT_PATH)
1366  {
1367  if (he->type & (DT_PATH_DIR | DT_PATH_FILE))
1369  else
1370  mutt_path_tilde(buf->data, buf->dsize, HomeDir);
1371  }
1372  else if (IS_MAILBOX(he))
1373  {
1375  }
1376  else if (IS_COMMAND(he))
1377  {
1378  struct Buffer scratch = mutt_buffer_make(1024);
1379  mutt_buffer_copy(&scratch, buf);
1380 
1381  if (mutt_str_strcmp(buf->data, "builtin") != 0)
1382  {
1383  mutt_buffer_expand_path(&scratch);
1384  }
1385  mutt_buffer_reset(buf);
1386  mutt_buffer_addstr(buf, mutt_b2s(&scratch));
1387  mutt_buffer_dealloc(&scratch);
1388  }
1389 
1390  rc = cs_subset_he_string_set(NeoMutt->sub, he, buf->data, err);
1391  if (CSR_RESULT(rc) != CSR_SUCCESS)
1392  return MUTT_CMD_ERROR;
1393  }
1394  continue;
1395  }
1396  else
1397  {
1398  if (bq)
1399  {
1400  // mutt_buffer_printf(err, "ACT23 set variable %s to 'yes'", buf->data);
1401  rc = cs_subset_he_native_set(NeoMutt->sub, he, true, err);
1402  if (CSR_RESULT(rc) != CSR_SUCCESS)
1403  return MUTT_CMD_ERROR;
1404  continue;
1405  }
1406  else
1407  {
1408  // mutt_buffer_printf(err, "ACT10 query variable %s", buf->data);
1409  if (he)
1410  {
1411  mutt_buffer_addstr(err, buf->data);
1412  mutt_buffer_addch(err, '=');
1413  mutt_buffer_reset(buf);
1414  rc = cs_subset_he_string_get(NeoMutt->sub, he, buf);
1415  if (CSR_RESULT(rc) != CSR_SUCCESS)
1416  {
1417  mutt_buffer_addstr(err, buf->data);
1418  return MUTT_CMD_ERROR;
1419  }
1420  if (DTYPE(he->type) == DT_PATH)
1421  mutt_pretty_mailbox(buf->data, buf->dsize);
1422  pretty_var(buf->data, err);
1423  }
1424  else
1425  {
1426  const char *val = myvar_get(buf->data);
1427  if (val)
1428  {
1429  mutt_buffer_addstr(err, buf->data);
1430  mutt_buffer_addch(err, '=');
1431  pretty_var(val, err);
1432  }
1433  else
1434  {
1435  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1436  return MUTT_CMD_ERROR;
1437  }
1438  }
1439  break;
1440  }
1441  }
1442  }
1443 
1444  if (my)
1445  {
1446  myvar_del(buf->data);
1447  }
1448  else if (bq)
1449  {
1450  if (inv)
1451  {
1452  // mutt_buffer_printf(err, "ACT25 TOGGLE bool/quad variable %s", buf->data);
1453  if (DTYPE(he->type) == DT_BOOL)
1454  bool_he_toggle(NeoMutt->sub, he, err);
1455  else
1456  quad_he_toggle(NeoMutt->sub, he, err);
1457  }
1458  else
1459  {
1460  // mutt_buffer_printf(err, "ACT26 UNSET bool/quad variable %s", buf->data);
1461  rc = cs_subset_he_native_set(NeoMutt->sub, he, false, err);
1462  if (CSR_RESULT(rc) != CSR_SUCCESS)
1463  return MUTT_CMD_ERROR;
1464  }
1465  continue;
1466  }
1467  else
1468  {
1469  rc = cs_subset_he_string_set(NeoMutt->sub, he, NULL, err);
1470  if (CSR_RESULT(rc) != CSR_SUCCESS)
1471  return MUTT_CMD_ERROR;
1472  }
1473  }
1474 
1475  return MUTT_CMD_SUCCESS;
1476 }
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
#define _(a)
Definition: message.h:28
Match case when comparing strings.
Definition: string2.h:67
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c: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:35
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:44
#define DT_PATH_DIR
Path is a directory.
Definition: types.h:53
char * HomeDir
User&#39;s home directory.
Definition: globals.h:49
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
const char * name
Definition: pgpmicalg.c:46
int cs_subset_he_string_set(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Set a config item by string.
Definition: subset.c: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:36
#define DT_PATH_FILE
Path is a file.
Definition: types.h:54
#define mutt_b2s(buf)
Definition: buffer.h:41
#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:416
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
void myvar_set(const char *var, const char *val)
Set the value of a "my_" variable.
Definition: myvar.c:91
default is to unset all vars
Definition: mutt_commands.h:68
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:613
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:240
const char * myvar_get(const char *var)
Get the value of a "my_" variable.
Definition: myvar.c:73
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
void * data
Definition: hash.h:46
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
Definition: dump.c:83
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:328
Warning: Help given to the user.
Definition: mutt_commands.h:36
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
int bool_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:211
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:78
int type
Definition: hash.h:44
#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:228
The item stored in a Hash Table.
Definition: hash.h:42
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:71
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
#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
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
default is to invert all vars
Definition: mutt_commands.h:67
#define MUTT_TOKEN_QUESTION
Treat &#39;?&#39; as a special.
Definition: mutt.h: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 1481 of file command_parse.c.

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

1566 {
1567  char path[PATH_MAX];
1568 
1569  do
1570  {
1571  if (mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS) != 0)
1572  {
1573  mutt_buffer_printf(err, _("source: error at %s"), s->dptr);
1574  return MUTT_CMD_ERROR;
1575  }
1576  mutt_str_strfcpy(path, buf->data, sizeof(path));
1577  mutt_expand_path(path, sizeof(path));
1578 
1579  if (source_rc(path, err) < 0)
1580  {
1581  mutt_buffer_printf(err, _("source: file %s could not be sourced"), path);
1582  return MUTT_CMD_ERROR;
1583  }
1584 
1585  } while (MoreArgs(s));
1586 
1587  return MUTT_CMD_SUCCESS;
1588 }
int source_rc(const char *rcfile_path, struct Buffer *err)
Read an initialization file.
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:133
#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:416
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:773
Success: Command worked.
Definition: mutt_commands.h:37
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h: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 1593 of file command_parse.c.

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

1673 {
1674  do
1675  {
1677  add_to_stailq((struct ListHead *) data, buf->data);
1678  } while (MoreArgs(s));
1679 
1680  return MUTT_CMD_SUCCESS;
1681 }
#define MoreArgs(buf)
Definition: buffer.h:43
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1792
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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 1686 of file command_parse.c.

1688 {
1689  enum CommandResult rc;
1690 
1691  rc = parse_replace_list(buf, s, data, err);
1692  if (rc == MUTT_CMD_SUCCESS)
1694  return rc;
1695 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
static void clear_subject_mods(void)
Clear out all modified email subjects.
static enum CommandResult parse_replace_list(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse a string replacement rule - Implements Command::parse()
+ 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 1700 of file command_parse.c.

1702 {
1703  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
1704 
1705  do
1706  {
1708 
1709  if (parse_grouplist(&gl, buf, s, err) == -1)
1710  goto bail;
1711 
1714 
1715  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
1716  goto bail;
1717  if (mutt_regexlist_add(&SubscribedLists, buf->data, REG_ICASE, err) != 0)
1718  goto bail;
1719  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
1720  goto bail;
1721  } while (MoreArgs(s));
1722 
1724  return MUTT_CMD_SUCCESS;
1725 
1726 bail:
1728  return MUTT_CMD_ERROR;
1729 }
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:226
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:277
static int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:132
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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:158
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: email_globals.c:51
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h: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 1739 of file command_parse.c.

1741 {
1742  if (!buf || !s || !err)
1743  return MUTT_CMD_ERROR;
1744 
1745  mutt_buffer_reset(err);
1746 
1747  if (MoreArgs(s))
1748  {
1750 
1751  if (MoreArgs(s))
1752  {
1753  mutt_buffer_printf(err, _("%s: too many arguments"), "subscribe-to");
1754  return MUTT_CMD_WARNING;
1755  }
1756 
1757  if (buf->data && (*buf->data != '\0'))
1758  {
1759  /* Expand and subscribe */
1760  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), true) == 0)
1761  {
1762  mutt_message(_("Subscribed to %s"), buf->data);
1763  return MUTT_CMD_SUCCESS;
1764  }
1765 
1766  mutt_buffer_printf(err, _("Could not subscribe to %s"), buf->data);
1767  return MUTT_CMD_ERROR;
1768  }
1769 
1770  mutt_debug(LL_DEBUG1, "Corrupted buffer");
1771  return MUTT_CMD_ERROR;
1772  }
1773 
1774  mutt_buffer_addstr(err, _("No folder specified"));
1775  return MUTT_CMD_WARNING;
1776 }
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
size_t dsize
Length of data.
Definition: buffer.h:37
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:133
#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:416
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:1400
+ 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 1782 of file command_parse.c.

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

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

◆ parse_unalias()

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

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

Definition at line 1860 of file command_parse.c.

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

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

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

◆ parse_unignore()

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

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

Definition at line 1991 of file command_parse.c.

1993 {
1994  do
1995  {
1997 
1998  /* don't add "*" to the unignore list */
1999  if (strcmp(buf->data, "*") != 0)
2000  add_to_stailq(&UnIgnore, buf->data);
2001 
2002  remove_from_stailq(&Ignore, buf->data);
2003  } while (MoreArgs(s));
2004 
2005  return MUTT_CMD_SUCCESS;
2006 }
struct ListHead UnIgnore
List of header patterns to unignore (see)
Definition: email_globals.c:46
#define MoreArgs(buf)
Definition: buffer.h:43
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1792
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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:1817
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 2011 of file command_parse.c.

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

2038 {
2039  bool tmp_valid = false;
2040  bool clear_all = false;
2041 
2042  while (!clear_all && MoreArgs(s))
2043  {
2045 
2046  if (mutt_str_strcmp(buf->data, "*") == 0)
2047  {
2048  clear_all = true;
2049  tmp_valid = false;
2050  }
2051  else
2052  {
2054  tmp_valid = true;
2055  }
2056 
2057  struct MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_MAILBOX_ANY);
2058  struct MailboxNode *np = NULL;
2059  struct MailboxNode *nptmp = NULL;
2060  STAILQ_FOREACH_SAFE(np, &ml, entries, nptmp)
2061  {
2062  /* Compare against path or desc? Ensure 'buf' is valid */
2063  if (!clear_all && tmp_valid &&
2064  (mutt_str_strcasecmp(mutt_b2s(buf), mailbox_path(np->mailbox)) != 0) &&
2065  (mutt_str_strcasecmp(mutt_b2s(buf), np->mailbox->name) != 0))
2066  {
2067  continue;
2068  }
2069 
2070 #ifdef USE_SIDEBAR
2071  mutt_sb_notify_mailbox(np->mailbox, false);
2072 #endif
2073 #ifdef USE_INOTIFY
2075 #endif
2076  if (Context && (Context->mailbox == np->mailbox))
2077  {
2078  np->mailbox->flags |= MB_HIDDEN;
2079  }
2080  else
2081  {
2083  mailbox_free(&np->mailbox);
2084  }
2085  }
2087  }
2088  return MUTT_CMD_SUCCESS;
2089 }
The "current" mailbox.
Definition: context.h:37
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:192
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:135
int mutt_monitor_remove(struct Mailbox *m)
Remove a watch for a mailbox.
Definition: monitor.c:523
Match any Mailbox type.
Definition: mailbox.h:45
Container for Accounts, Notifications.
Definition: neomutt.h:35
#define MoreArgs(buf)
Definition: buffer.h:43
char * name
A short name for the Mailbox.
Definition: mailbox.h:85
struct Mailbox * mailbox
Definition: context.h:51
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
#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:416
char * data
Pointer to data.
Definition: buffer.h:35
struct MailboxList neomutt_mailboxlist_get_all(struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Definition: neomutt.c:157
Success: Command worked.
Definition: mutt_commands.h:37
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:328
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
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
List of Mailboxes.
Definition: mailbox.h:145
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h: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 2094 of file command_parse.c.

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

2133 {
2134  do
2135  {
2137  /* Check for deletion of entire list */
2138  if (mutt_str_strcmp(buf->data, "*") == 0)
2139  {
2140  mutt_list_free((struct ListHead *) data);
2141  break;
2142  }
2143  remove_from_stailq((struct ListHead *) data, buf->data);
2144  } while (MoreArgs(s));
2145 
2146  return MUTT_CMD_SUCCESS;
2147 }
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:416
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:1817
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:35
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h: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 2152 of file command_parse.c.

2154 {
2155  enum CommandResult rc;
2156 
2157  rc = parse_unreplace_list(buf, s, data, err);
2158  if (rc == MUTT_CMD_SUCCESS)
2160  return rc;
2161 }
static enum CommandResult parse_unreplace_list(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Remove a string replacement rule - Implements Command::parse()
Definition: command_parse.c:86
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
Success: Command worked.
Definition: mutt_commands.h:37
char * data
String.
Definition: list.h:35
static void clear_subject_mods(void)
Clear out all modified email subjects.
+ 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 2166 of file command_parse.c.

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

2195 {
2196  if (!buf || !s || !err)
2197  return MUTT_CMD_ERROR;
2198 
2199  if (MoreArgs(s))
2200  {
2202 
2203  if (MoreArgs(s))
2204  {
2205  mutt_buffer_printf(err, _("%s: too many arguments"), "unsubscribe-from");
2206  return MUTT_CMD_WARNING;
2207  }
2208 
2209  if (buf->data && (*buf->data != '\0'))
2210  {
2211  /* Expand and subscribe */
2212  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), false) == 0)
2213  {
2214  mutt_message(_("Unsubscribed from %s"), buf->data);
2215  return MUTT_CMD_SUCCESS;
2216  }
2217 
2218  mutt_buffer_printf(err, _("Could not unsubscribe from %s"), buf->data);
2219  return MUTT_CMD_ERROR;
2220  }
2221 
2222  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2223  return MUTT_CMD_ERROR;
2224  }
2225 
2226  mutt_buffer_addstr(err, _("No folder specified"));
2227  return MUTT_CMD_WARNING;
2228 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
size_t dsize
Length of data.
Definition: buffer.h:37
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:133
#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:416
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:1400
+ Here is the call graph for this function:

◆ clear_source_stack()

void clear_source_stack ( void  )

Free memory from the stack used for the souce command.

Definition at line 2234 of file command_parse.c.

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