NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
command_parse.h File Reference

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

#include "config.h"
#include <stdint.h>
#include "mutt_commands.h"
+ Include dependency graph for command_parse.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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_cd (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'cd' 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_set (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'set' family of commands - Implements Command::parse() More...
 
enum CommandResult parse_setenv (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'setenv' and 'unsetenv' commands - Implements Command::parse() More...
 
enum CommandResult parse_source (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'source' command - Implements Command::parse() More...
 
enum CommandResult parse_spam_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'spam' and 'nospam' commands - Implements Command::parse() More...
 
enum CommandResult parse_stailq (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse a list command - Implements Command::parse() More...
 
enum CommandResult parse_subjectrx_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subjectrx' command - Implements Command::parse() More...
 
enum CommandResult parse_subscribe (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subscribe' command - Implements Command::parse() More...
 
enum CommandResult parse_subscribe_to (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subscribe-to' command - Implements Command::parse() More...
 
enum CommandResult parse_tag_formats (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'tag-formats' command - Implements Command::parse() More...
 
enum CommandResult parse_tag_transforms (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'tag-transforms' command - Implements Command::parse() More...
 
enum CommandResult parse_unalternates (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unalternates' command - Implements Command::parse() More...
 
enum CommandResult parse_unattachments (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unattachments' command - Implements Command::parse() More...
 
enum CommandResult parse_unignore (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unignore' command - Implements Command::parse() More...
 
enum CommandResult parse_unlists (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unlists' command - Implements Command::parse() More...
 
enum CommandResult parse_unmailboxes (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unmailboxes' command - Implements Command::parse() More...
 
enum CommandResult parse_unmy_hdr (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unmy_hdr' command - Implements Command::parse() More...
 
enum CommandResult parse_unstailq (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse an unlist command - Implements Command::parse() More...
 
enum CommandResult parse_unsubjectrx_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubjectrx' command - Implements Command::parse() More...
 
enum CommandResult parse_unsubscribe (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubscribe' command - Implements Command::parse() More...
 
enum CommandResult parse_unsubscribe_from (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubscribe-from' command - Implements Command::parse() More...
 
int parse_grouplist (struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
 Parse a group context. More...
 
void clear_source_stack (void)
 Free memory from the stack used for the souce command. More...
 
int source_rc (const char *rcfile_path, struct Buffer *err)
 Read an initialization file. More...
 

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.h.

Function Documentation

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

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

◆ parse_attachments()

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

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

Definition at line 601 of file command_parse.c.

603 {
604  char op;
605  char *category = NULL;
606  struct ListHead *head = NULL;
607 
609  if (!buf->data || (*buf->data == '\0'))
610  {
611  mutt_buffer_strcpy(err, _("attachments: no disposition"));
612  return MUTT_CMD_WARNING;
613  }
614 
615  category = buf->data;
616  op = *category++;
617 
618  if (op == '?')
619  {
620  mutt_endwin();
621  fflush(stdout);
622  printf("\n%s\n\n", _("Current attachments settings:"));
623  print_attach_list(&AttachAllow, '+', "A");
624  print_attach_list(&AttachExclude, '-', "A");
625  print_attach_list(&InlineAllow, '+', "I");
626  print_attach_list(&InlineExclude, '-', "I");
628  return MUTT_CMD_SUCCESS;
629  }
630 
631  if ((op != '+') && (op != '-'))
632  {
633  op = '+';
634  category--;
635  }
636  if (mutt_istr_startswith("attachment", category))
637  {
638  if (op == '+')
639  head = &AttachAllow;
640  else
641  head = &AttachExclude;
642  }
643  else if (mutt_istr_startswith("inline", category))
644  {
645  if (op == '+')
646  head = &InlineAllow;
647  else
648  head = &InlineExclude;
649  }
650  else
651  {
652  mutt_buffer_strcpy(err, _("attachments: invalid disposition"));
653  return MUTT_CMD_ERROR;
654  }
655 
656  return parse_attach_list(buf, s, head, err);
657 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
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:571
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:172
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:604
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: mutt_parse.c:40
Success: Command worked.
Definition: mutt_commands.h:38
Warning: Help given to the user.
Definition: mutt_commands.h:37
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_cd()

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

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

Definition at line 662 of file command_parse.c.

664 {
667  if (mutt_buffer_len(buf) == 0)
668  {
669  if (HomeDir)
671  else
672  {
673  mutt_buffer_printf(err, _("%s: too few arguments"), "cd");
674  return MUTT_CMD_ERROR;
675  }
676  }
677 
678  if (chdir(mutt_b2s(buf)) != 0)
679  {
680  mutt_buffer_printf(err, "cd: %s", strerror(errno));
681  return MUTT_CMD_ERROR;
682  }
683 
684  return MUTT_CMD_SUCCESS;
685 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
#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 * HomeDir
User&#39;s home directory.
Definition: mutt_globals.h:49
#define mutt_b2s(buf)
Definition: buffer.h:41
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:356
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
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:38
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
#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 690 of file command_parse.c.

692 {
693  if (!MoreArgs(s))
694  {
695  mutt_buffer_printf(err, _("%s: too few arguments"), "echo");
696  return MUTT_CMD_WARNING;
697  }
699  OptForceRefresh = true;
700  mutt_message("%s", buf->data);
701  OptForceRefresh = false;
702  mutt_sleep(0);
703 
704  return MUTT_CMD_SUCCESS;
705 }
#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:1446
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:394
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
Warning: Help given to the user.
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_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 714 of file command_parse.c.

716 {
717  if (MoreArgs(s))
718  {
719  mutt_buffer_printf(err, _("%s: too many arguments"), "finish");
720  return MUTT_CMD_WARNING;
721  }
722 
723  return MUTT_CMD_FINISH;
724 }
#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:37
Finish: Stop processing this file.
Definition: mutt_commands.h:39
+ 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 729 of file command_parse.c.

731 {
732  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
733  enum GroupState state = GS_NONE;
734 
735  do
736  {
738  if (parse_grouplist(&gl, buf, s, err) == -1)
739  goto bail;
740 
741  if ((data == MUTT_UNGROUP) && mutt_istr_equal(buf->data, "*"))
742  {
744  goto out;
745  }
746 
747  if (mutt_istr_equal(buf->data, "-rx"))
748  state = GS_RX;
749  else if (mutt_istr_equal(buf->data, "-addr"))
750  state = GS_ADDR;
751  else
752  {
753  switch (state)
754  {
755  case GS_NONE:
756  mutt_buffer_printf(err, _("%sgroup: missing -rx or -addr"),
757  (data == MUTT_UNGROUP) ? "un" : "");
758  goto warn;
759 
760  case GS_RX:
761  if ((data == MUTT_GROUP) &&
762  (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0))
763  {
764  goto bail;
765  }
766  else if ((data == MUTT_UNGROUP) &&
767  (mutt_grouplist_remove_regex(&gl, buf->data) < 0))
768  {
769  goto bail;
770  }
771  break;
772 
773  case GS_ADDR:
774  {
775  char *estr = NULL;
776  struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
777  mutt_addrlist_parse2(&al, buf->data);
778  if (TAILQ_EMPTY(&al))
779  goto bail;
780  if (mutt_addrlist_to_intl(&al, &estr))
781  {
782  mutt_buffer_printf(err, _("%sgroup: warning: bad IDN '%s'"),
783  (data == 1) ? "un" : "", estr);
784  mutt_addrlist_clear(&al);
785  FREE(&estr);
786  goto bail;
787  }
788  if (data == MUTT_GROUP)
789  mutt_grouplist_add_addrlist(&gl, &al);
790  else if (data == MUTT_UNGROUP)
792  mutt_addrlist_clear(&al);
793  break;
794  }
795  }
796  }
797  } while (MoreArgs(s));
798 
799 out:
801  return MUTT_CMD_SUCCESS;
802 
803 bail:
805  return MUTT_CMD_ERROR;
806 
807 warn:
809  return MUTT_CMD_WARNING;
810 }
int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
#define MUTT_UNGROUP
&#39;ungroup&#39; config command
Definition: group.h:33
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
void mutt_grouplist_clear(struct GroupList *gl)
Clear a GroupList.
Definition: group.c:103
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1468
#define _(a)
Definition: message.h:28
void mutt_grouplist_add_addrlist(struct GroupList *gl, struct AddressList *al)
Add Address list to a GroupList.
Definition: group.c:226
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:616
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:276
int mutt_grouplist_remove_regex(struct GroupList *gl, const char *s)
Remove matching addresses from a GroupList.
Definition: group.c:300
GroupState
Type of email address group.
Definition: command_parse.c:74
int mutt_grouplist_remove_addrlist(struct GroupList *gl, struct AddressList *al)
Remove an AddressList from a GroupList.
Definition: group.c:245
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
Entry is an address.
Definition: command_parse.c:78
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
char * data
Pointer to data.
Definition: buffer.h:35
Group is missing an argument.
Definition: command_parse.c:76
Success: Command worked.
Definition: mutt_commands.h:38
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1304
Warning: Help given to the user.
Definition: mutt_commands.h:37
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#define FREE(x)
Definition: memory.h:40
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
#define TAILQ_EMPTY(head)
Definition: queue.h:714
Entry is a regular expression.
Definition: command_parse.c:77
#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 825 of file command_parse.c.

827 {
829 
830  // is the item defined as:
831  bool res = cs_subset_lookup(NeoMutt->sub, buf->data) // a variable?
832  || feature_enabled(buf->data) // a compiled-in feature?
833  || is_function(buf->data) // a function?
834  || mutt_command_get(buf->data) // a command?
835  || myvar_get(buf->data) // a my_ variable?
836  || mutt_str_getenv(buf->data); // an environment variable?
837 
838  if (!MoreArgs(s))
839  {
840  mutt_buffer_printf(err, _("%s: too few arguments"), (data ? "ifndef" : "ifdef"));
841  return MUTT_CMD_WARNING;
842  }
844 
845  /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
846  if ((res && (data == 0)) || (!res && (data == 1)))
847  {
848  enum CommandResult rc = mutt_parse_rc_line(buf->data, err);
849  if (rc == MUTT_CMD_ERROR)
850  {
851  mutt_error(_("Error: %s"), err->data);
852  return MUTT_CMD_ERROR;
853  }
854  return rc;
855  }
856  return MUTT_CMD_SUCCESS;
857 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:34
bool feature_enabled(const char *name)
Test if a compile-time feature is enabled.
Definition: version.c:565
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
enum CommandResult mutt_parse_rc_line(const char *line, struct Buffer *err)
Parse a line of user config.
Definition: init.c:1039
#define _(a)
Definition: message.h:28
static bool is_function(const char *name)
Is the argument a neomutt function?
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:168
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
Container for Accounts, Notifications.
Definition: neomutt.h:36
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:991
#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:394
#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
struct Command * mutt_command_get(const char *s)
Get a Command by its name.
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:38
Warning: Help given to the user.
Definition: mutt_commands.h:37
#define mutt_error(...)
Definition: logging.h:84
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_ignore()

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

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

Definition at line 862 of file command_parse.c.

864 {
865  do
866  {
869  add_to_stailq(&Ignore, buf->data);
870  } while (MoreArgs(s));
871 
872  return MUTT_CMD_SUCCESS;
873 }
#define MoreArgs(buf)
Definition: buffer.h:43
struct ListHead Ignore
List of header patterns to ignore.
Definition: globals.c:45
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1700
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
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:1725
Success: Command worked.
Definition: mutt_commands.h:38
struct ListHead UnIgnore
List of header patterns to unignore (see)
Definition: globals.c:46
#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 878 of file command_parse.c.

880 {
881  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
882 
883  do
884  {
886 
887  if (parse_grouplist(&gl, buf, s, err) == -1)
888  goto bail;
889 
891 
892  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
893  goto bail;
894 
895  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
896  goto bail;
897  } while (MoreArgs(s));
898 
900  return MUTT_CMD_SUCCESS;
901 
902 bail:
904  return MUTT_CMD_ERROR;
905 }
int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: globals.c:50
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:276
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: globals.c:51
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

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

914 {
915  while (MoreArgs(s))
916  {
917  struct Mailbox *m = mailbox_new();
918 
919  if (data & MUTT_NAMED)
920  {
921  // This may be empty, e.g. `named-mailboxes "" +inbox`
923  m->name = mutt_buffer_strdup(buf);
924  }
925 
927  if (mutt_buffer_is_empty(buf))
928  {
929  /* Skip empty tokens. */
930  mailbox_free(&m);
931  continue;
932  }
933 
934  mutt_buffer_strcpy(&m->pathbuf, buf->data);
935  /* int rc = */ mx_path_canon2(m, C_Folder);
936 
937  if (m->type <= MUTT_UNKNOWN)
938  {
939  mutt_error("Unknown Mailbox: %s", m->realpath);
940  mailbox_free(&m);
941  return MUTT_CMD_ERROR;
942  }
943 
944  bool new_account = false;
945  struct Account *a = mx_ac_find(m);
946  if (!a)
947  {
948  a = account_new(NULL, NeoMutt->sub);
949  a->type = m->type;
950  new_account = true;
951  }
952 
953  if (!new_account)
954  {
955  struct Mailbox *m_old = mx_mbox_find(a, m->realpath);
956  if (m_old)
957  {
958  const bool show = (m_old->flags == MB_HIDDEN);
959  if (show)
960  {
961  m_old->flags = MB_NORMAL;
962  }
963 
964  const bool rename = (data & MUTT_NAMED) && !mutt_str_equal(m_old->name, m->name);
965  if (rename)
966  {
967  mutt_str_replace(&m_old->name, m->name);
968  }
969 
970  mailbox_free(&m);
971  continue;
972  }
973  }
974 
975  if (mx_ac_add(a, m) < 0)
976  {
977  //error
978  mailbox_free(&m);
979  if (new_account)
980  {
981  cs_subset_free(&a->sub);
982  FREE(&a->name);
983  notify_free(&a->notify);
984  FREE(&a);
985  }
986  continue;
987  }
988  if (new_account)
989  {
991  }
992 
993 #ifdef USE_INOTIFY
994  mutt_monitor_add(m);
995 #endif
996  }
997  return MUTT_CMD_SUCCESS;
998 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
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:36
int mx_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Wrapper for MxOps::ac_add()
Definition: mx.c:1768
int mx_path_canon2(struct Mailbox *m, const char *folder)
Canonicalise the path to realpath.
Definition: mx.c:1482
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer&#39;s string.
Definition: buffer.c:432
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:74
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
Find a Mailbox on an Account.
Definition: mx.c:1592
void cs_subset_free(struct ConfigSubset **ptr)
Free a Config Subset.
Definition: subset.c:93
enum MailboxType type
Type of Mailboxes this Account contains.
Definition: account.h:38
int mutt_monitor_add(struct Mailbox *m)
Add a watch for a mailbox.
Definition: monitor.c:479
struct Account * mx_ac_find(struct Mailbox *m)
Find the Account owning a Mailbox.
Definition: mx.c:1568
Container for Accounts, Notifications.
Definition: neomutt.h:36
#define MoreArgs(buf)
Definition: buffer.h:43
char * name
A short name for the Mailbox.
Definition: mailbox.h:85
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:63
int flags
e.g. MB_NORMAL
Definition: mailbox.h:134
#define MB_HIDDEN
Definition: mailbox.h:38
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:394
char * data
Pointer to data.
Definition: buffer.h:35
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
Definition: mutt_globals.h:96
struct Account * account_new(const char *name, struct ConfigSubset *sub)
Create a new Account.
Definition: account.c:43
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:38
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: account.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
bool neomutt_account_add(struct NeoMutt *n, struct Account *a)
Add an Account to the global list.
Definition: neomutt.c:84
struct Buffer pathbuf
Definition: mailbox.h:83
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
#define MB_NORMAL
Definition: mailbox.h:37
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_my_hdr()

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

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

Definition at line 1003 of file command_parse.c.

1005 {
1007  char *p = strpbrk(buf->data, ": \t");
1008  if (!p || (*p != ':'))
1009  {
1010  mutt_buffer_strcpy(err, _("invalid header field"));
1011  return MUTT_CMD_WARNING;
1012  }
1013 
1014  struct EventHeader event = { buf->data };
1015  struct ListNode *n = header_find(&UserHeader, buf->data);
1016 
1017  if (n)
1018  {
1019  header_update(n, buf->data);
1021  }
1022  else
1023  {
1024  header_add(&UserHeader, buf->data);
1026  }
1027 
1028  return MUTT_CMD_SUCCESS;
1029 }
An existing header has been changed.
Definition: email.h:160
struct ListNode * header_add(struct ListHead *hdrlist, const char *header)
Add a header to a list.
Definition: email.c:195
An event that happened to a header.
Definition: email.h:167
#define _(a)
Definition: message.h:28
Container for Accounts, Notifications.
Definition: neomutt.h:36
struct ListNode * header_update(struct ListNode *hdr, const char *header)
Update an existing header.
Definition: email.c:209
A new header has been added.
Definition: email.h:159
#define MUTT_TOKEN_QUOTE
Don&#39;t interpret quotes.
Definition: mutt.h:74
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
#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
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
A header has changed, NotifyHeader EventHeader.
Definition: notify_type.h:41
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:38
Warning: Help given to the user.
Definition: mutt_commands.h:37
struct ListNode * header_find(const struct ListHead *hdrlist, const char *header)
Find a header, matching on its field, in a list of headers.
Definition: email.c:172
A List node for strings.
Definition: list.h:34
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:152
+ Here is the call graph for this function:
+ Here is the caller 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 1036 of file command_parse.c.

1038 {
1039  /* The order must match `enum MuttSetCommand` */
1040  static const char *set_commands[] = { "set", "toggle", "unset", "reset" };
1041 
1042  int rc = 0;
1043 
1044  while (MoreArgs(s))
1045  {
1046  bool prefix = false;
1047  bool query = false;
1048  bool inv = (data == MUTT_SET_INV);
1049  bool reset = (data == MUTT_SET_RESET);
1050  bool unset = (data == MUTT_SET_UNSET);
1051 
1052  if (*s->dptr == '?')
1053  {
1054  prefix = true;
1055  query = true;
1056  s->dptr++;
1057  }
1058  else if (mutt_str_startswith(s->dptr, "no"))
1059  {
1060  prefix = true;
1061  unset = !unset;
1062  s->dptr += 2;
1063  }
1064  else if (mutt_str_startswith(s->dptr, "inv"))
1065  {
1066  prefix = true;
1067  inv = !inv;
1068  s->dptr += 3;
1069  }
1070  else if (*s->dptr == '&')
1071  {
1072  prefix = true;
1073  reset = true;
1074  s->dptr++;
1075  }
1076 
1077  if (prefix && (data != MUTT_SET_SET))
1078  {
1079  mutt_buffer_printf(err, _("Can't use 'inv', 'no', '&' or '?' with the '%s' command"),
1080  set_commands[data]);
1081  return MUTT_CMD_WARNING;
1082  }
1083 
1084  /* get the variable name */
1086 
1087  bool bq = false;
1088  bool equals = false;
1089  bool increment = false;
1090  bool decrement = false;
1091 
1092  struct HashElem *he = NULL;
1093  bool my = mutt_str_startswith(buf->data, "my_");
1094  if (!my)
1095  {
1096  he = cs_subset_lookup(NeoMutt->sub, buf->data);
1097  if (!he)
1098  {
1099  if (reset && mutt_str_equal(buf->data, "all"))
1100  {
1101  struct HashElem **list = get_elem_list(NeoMutt->sub->cs);
1102  if (!list)
1103  return MUTT_CMD_ERROR;
1104 
1105  for (size_t i = 0; list[i]; i++)
1106  cs_subset_he_reset(NeoMutt->sub, list[i], NULL);
1107 
1108  FREE(&list);
1109  break;
1110  }
1111  else
1112  {
1113  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1114  return MUTT_CMD_ERROR;
1115  }
1116  }
1117 
1118  bq = ((DTYPE(he->type) == DT_BOOL) || (DTYPE(he->type) == DT_QUAD));
1119  }
1120 
1121  if (*s->dptr == '?')
1122  {
1123  if (prefix)
1124  {
1125  mutt_buffer_printf(err,
1126  _("Can't use a prefix when querying a variable"));
1127  return MUTT_CMD_WARNING;
1128  }
1129 
1130  if (reset || unset || inv)
1131  {
1132  mutt_buffer_printf(err, _("Can't query a variable with the '%s' command"),
1133  set_commands[data]);
1134  return MUTT_CMD_WARNING;
1135  }
1136 
1137  query = true;
1138  s->dptr++;
1139  }
1140  else if (*s->dptr == '+' || *s->dptr == '-')
1141  {
1142  if (prefix)
1143  {
1145  err,
1146  _("Can't use prefix when incrementing or decrementing a variable"));
1147  return MUTT_CMD_WARNING;
1148  }
1149 
1150  if (reset || unset || inv)
1151  {
1152  mutt_buffer_printf(err, _("Can't set a variable with the '%s' command"),
1153  set_commands[data]);
1154  return MUTT_CMD_WARNING;
1155  }
1156  if (*s->dptr == '+')
1157  increment = true;
1158  else
1159  decrement = true;
1160 
1161  s->dptr++;
1162  if (*s->dptr == '=')
1163  {
1164  equals = true;
1165  s->dptr++;
1166  }
1167  }
1168  else if (*s->dptr == '=')
1169  {
1170  if (prefix)
1171  {
1172  mutt_buffer_printf(err, _("Can't use prefix when setting a variable"));
1173  return MUTT_CMD_WARNING;
1174  }
1175 
1176  if (reset || unset || inv)
1177  {
1178  mutt_buffer_printf(err, _("Can't set a variable with the '%s' command"),
1179  set_commands[data]);
1180  return MUTT_CMD_WARNING;
1181  }
1182 
1183  equals = true;
1184  s->dptr++;
1185  }
1186 
1187  if (!bq && (inv || (unset && prefix)))
1188  {
1189  if (data == MUTT_SET_SET)
1190  {
1191  mutt_buffer_printf(err, _("Prefixes 'no' and 'inv' may only be used "
1192  "with bool/quad variables"));
1193  }
1194  else
1195  {
1196  mutt_buffer_printf(err, _("Command '%s' can only be used with bool/quad variables"),
1197  set_commands[data]);
1198  }
1199  return MUTT_CMD_WARNING;
1200  }
1201 
1202  if (reset)
1203  {
1204  // mutt_buffer_printf(err, "ACT24 reset variable %s", buf->data);
1205  if (he)
1206  {
1207  rc = cs_subset_he_reset(NeoMutt->sub, he, err);
1208  if (CSR_RESULT(rc) != CSR_SUCCESS)
1209  return MUTT_CMD_ERROR;
1210  }
1211  else
1212  {
1213  myvar_del(buf->data);
1214  }
1215  continue;
1216  }
1217 
1218  if ((data == MUTT_SET_SET) && !inv && !unset)
1219  {
1220  if (query)
1221  {
1222  // mutt_buffer_printf(err, "ACT08 query variable %s", buf->data);
1223  if (he)
1224  {
1225  mutt_buffer_addstr(err, buf->data);
1226  mutt_buffer_addch(err, '=');
1227  mutt_buffer_reset(buf);
1228  rc = cs_subset_he_string_get(NeoMutt->sub, he, buf);
1229  if (CSR_RESULT(rc) != CSR_SUCCESS)
1230  {
1231  mutt_buffer_addstr(err, buf->data);
1232  return MUTT_CMD_ERROR;
1233  }
1234  if (DTYPE(he->type) == DT_PATH)
1235  mutt_pretty_mailbox(buf->data, buf->dsize);
1236  pretty_var(buf->data, err);
1237  }
1238  else
1239  {
1240  const char *val = myvar_get(buf->data);
1241  if (val)
1242  {
1243  mutt_buffer_addstr(err, buf->data);
1244  mutt_buffer_addch(err, '=');
1245  pretty_var(val, err);
1246  }
1247  else
1248  {
1249  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1250  return MUTT_CMD_ERROR;
1251  }
1252  }
1253  break;
1254  }
1255  else if (equals)
1256  {
1257  // mutt_buffer_printf(err, "ACT11 set variable %s to ", buf->data);
1258  const char *name = NULL;
1259  if (my)
1260  {
1261  name = mutt_str_dup(buf->data);
1262  }
1264  if (my)
1265  {
1266  myvar_set(name, buf->data);
1267  FREE(&name);
1268  }
1269  else
1270  {
1271  if (DTYPE(he->type) == DT_PATH)
1272  {
1273  if (he->type & (DT_PATH_DIR | DT_PATH_FILE))
1275  else
1276  mutt_path_tilde(buf->data, buf->dsize, HomeDir);
1277  }
1278  else if (IS_MAILBOX(he))
1279  {
1281  }
1282  else if (IS_COMMAND(he))
1283  {
1284  struct Buffer scratch = mutt_buffer_make(1024);
1285  mutt_buffer_copy(&scratch, buf);
1286 
1287  if (!mutt_str_equal(buf->data, "builtin"))
1288  {
1289  mutt_buffer_expand_path(&scratch);
1290  }
1291  mutt_buffer_reset(buf);
1292  mutt_buffer_addstr(buf, mutt_b2s(&scratch));
1293  mutt_buffer_dealloc(&scratch);
1294  }
1295  if (increment)
1296  {
1297  rc = cs_subset_he_string_plus_equals(NeoMutt->sub, he, buf->data, err);
1298  }
1299  else if (decrement)
1300  {
1301  rc = cs_subset_he_string_minus_equals(NeoMutt->sub, he, buf->data, err);
1302  }
1303  else
1304  {
1305  rc = cs_subset_he_string_set(NeoMutt->sub, he, buf->data, err);
1306  }
1307  if (CSR_RESULT(rc) != CSR_SUCCESS)
1308  return MUTT_CMD_ERROR;
1309  }
1310  continue;
1311  }
1312  else
1313  {
1314  if (bq)
1315  {
1316  // mutt_buffer_printf(err, "ACT23 set variable %s to 'yes'", buf->data);
1317  rc = cs_subset_he_native_set(NeoMutt->sub, he, true, err);
1318  if (CSR_RESULT(rc) != CSR_SUCCESS)
1319  return MUTT_CMD_ERROR;
1320  continue;
1321  }
1322  else
1323  {
1324  // mutt_buffer_printf(err, "ACT10 query variable %s", buf->data);
1325  if (he)
1326  {
1327  mutt_buffer_addstr(err, buf->data);
1328  mutt_buffer_addch(err, '=');
1329  mutt_buffer_reset(buf);
1330  rc = cs_subset_he_string_get(NeoMutt->sub, he, buf);
1331  if (CSR_RESULT(rc) != CSR_SUCCESS)
1332  {
1333  mutt_buffer_addstr(err, buf->data);
1334  return MUTT_CMD_ERROR;
1335  }
1336  if (DTYPE(he->type) == DT_PATH)
1337  mutt_pretty_mailbox(buf->data, buf->dsize);
1338  pretty_var(buf->data, err);
1339  }
1340  else
1341  {
1342  const char *val = myvar_get(buf->data);
1343  if (val)
1344  {
1345  mutt_buffer_addstr(err, buf->data);
1346  mutt_buffer_addch(err, '=');
1347  pretty_var(val, err);
1348  }
1349  else
1350  {
1351  mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
1352  return MUTT_CMD_ERROR;
1353  }
1354  }
1355  break;
1356  }
1357  }
1358  }
1359 
1360  if (my)
1361  {
1362  myvar_del(buf->data);
1363  }
1364  else if (bq)
1365  {
1366  if (inv)
1367  {
1368  // mutt_buffer_printf(err, "ACT25 TOGGLE bool/quad variable %s", buf->data);
1369  if (DTYPE(he->type) == DT_BOOL)
1370  bool_he_toggle(NeoMutt->sub, he, err);
1371  else
1372  quad_he_toggle(NeoMutt->sub, he, err);
1373  }
1374  else
1375  {
1376  // mutt_buffer_printf(err, "ACT26 UNSET bool/quad variable %s", buf->data);
1377  rc = cs_subset_he_native_set(NeoMutt->sub, he, false, err);
1378  if (CSR_RESULT(rc) != CSR_SUCCESS)
1379  return MUTT_CMD_ERROR;
1380  }
1381  continue;
1382  }
1383  else
1384  {
1385  rc = cs_subset_he_string_set(NeoMutt->sub, he, NULL, err);
1386  if (CSR_RESULT(rc) != CSR_SUCCESS)
1387  return MUTT_CMD_ERROR;
1388  }
1389  }
1390 
1391  return MUTT_CMD_SUCCESS;
1392 }
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:522
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:36
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
int bool_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:185
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
Definition: dump.c:83
int quad_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a quad.
Definition: quad.c:202
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
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
#define _(a)
Definition: message.h:28
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:168
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
int cs_subset_he_string_minus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Remove from a config item by string.
Definition: subset.c:449
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:37
Container for Accounts, Notifications.
Definition: neomutt.h:36
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:44
struct HashElem ** get_elem_list(struct ConfigSet *cs)
Create a sorted list of all config items.
Definition: subset.c:64
#define DT_PATH_DIR
Path is a directory.
Definition: types.h:53
#define CSR_RESULT(x)
Definition: set.h:52
char * HomeDir
User&#39;s home directory.
Definition: mutt_globals.h:49
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
default is to reset all vars to default
Definition: mutt_commands.h:70
size_t dsize
Length of data.
Definition: buffer.h:37
#define MoreArgs(buf)
Definition: buffer.h:43
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:51
int cs_subset_he_reset(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Reset a config item to its initial value.
Definition: subset.c:307
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
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 DT_PATH_FILE
Path is a file.
Definition: types.h:54
#define mutt_b2s(buf)
Definition: buffer.h:41
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:160
#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:394
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
void myvar_set(const char *var, const char *val)
Set the value of a "my_" variable.
Definition: myvar.c:91
#define MUTT_TOKEN_PLUS
Treat &#39;+&#39; as a special.
Definition: mutt.h:81
default is to unset all vars
Definition: mutt_commands.h:69
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:240
const char * myvar_get(const char *var)
Get the value of a "my_" variable.
Definition: myvar.c:73
void * data
User-supplied data.
Definition: hash.h:47
Success: Command worked.
Definition: mutt_commands.h:38
char * data
String.
Definition: list.h:36
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
Warning: Help given to the user.
Definition: mutt_commands.h:37
int cs_subset_he_string_plus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Add to a config item by string.
Definition: subset.c:411
#define MUTT_TOKEN_MINUS
Treat &#39;-&#39; as a special.
Definition: mutt.h:82
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:78
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition: hash.h:45
#define FREE(x)
Definition: memory.h:40
The item stored in a Hash Table.
Definition: hash.h:43
#define MUTT_TOKEN_EQUAL
Treat &#39;=&#39; as a special.
Definition: mutt.h:71
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
#define IS_COMMAND(x)
Definition: types.h:58
default is to set all vars
Definition: mutt_commands.h:67
#define DT_BOOL
boolean option
Definition: types.h:30
default is to invert all vars
Definition: mutt_commands.h:68
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
#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 1397 of file command_parse.c.

1399 {
1400  char **envp = mutt_envlist_getlist();
1401 
1402  bool query = false;
1403  bool prefix = false;
1404  bool unset = (data == MUTT_SET_UNSET);
1405 
1406  if (!MoreArgs(s))
1407  {
1408  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1409  return MUTT_CMD_WARNING;
1410  }
1411 
1412  if (*s->dptr == '?')
1413  {
1414  query = true;
1415  prefix = true;
1416 
1417  if (unset)
1418  {
1419  mutt_buffer_printf(err, _("Can't query a variable with the '%s' command"), "unsetenv");
1420  return MUTT_CMD_WARNING;
1421  }
1422 
1423  s->dptr++;
1424  }
1425 
1426  /* get variable name */
1428 
1429  if (*s->dptr == '?')
1430  {
1431  if (unset)
1432  {
1433  mutt_buffer_printf(err, _("Can't query a variable with the '%s' command"), "unsetenv");
1434  return MUTT_CMD_WARNING;
1435  }
1436 
1437  if (prefix)
1438  {
1439  mutt_buffer_printf(err, _("Can't use a prefix when querying a variable"));
1440  return MUTT_CMD_WARNING;
1441  }
1442 
1443  query = true;
1444  s->dptr++;
1445  }
1446 
1447  if (query)
1448  {
1449  bool found = false;
1450  while (envp && *envp)
1451  {
1452  /* This will display all matches for "^QUERY" */
1453  if (mutt_str_startswith(*envp, buf->data))
1454  {
1455  if (!found)
1456  {
1457  mutt_endwin();
1458  found = true;
1459  }
1460  puts(*envp);
1461  }
1462  envp++;
1463  }
1464 
1465  if (found)
1466  {
1468  return MUTT_CMD_SUCCESS;
1469  }
1470 
1471  mutt_buffer_printf(err, _("%s is unset"), buf->data);
1472  return MUTT_CMD_WARNING;
1473  }
1474 
1475  if (unset)
1476  {
1477  if (mutt_envlist_unset(buf->data))
1478  return MUTT_CMD_SUCCESS;
1479  return MUTT_CMD_ERROR;
1480  }
1481 
1482  /* set variable */
1483 
1484  if (*s->dptr == '=')
1485  {
1486  s->dptr++;
1487  SKIPWS(s->dptr);
1488  }
1489 
1490  if (!MoreArgs(s))
1491  {
1492  mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
1493  return MUTT_CMD_WARNING;
1494  }
1495 
1496  char *name = mutt_str_dup(buf->data);
1498  mutt_envlist_set(name, buf->data, true);
1499  FREE(&name);
1500 
1501  return MUTT_CMD_SUCCESS;
1502 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define MoreArgs(buf)
Definition: buffer.h:43
#define SKIPWS(ch)
Definition: string2.h:46
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:160
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:571
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:394
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:69
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:604
Success: Command worked.
Definition: mutt_commands.h:38
Warning: Help given to the user.
Definition: mutt_commands.h:37
#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
#define MUTT_TOKEN_QUESTION
Treat &#39;?&#39; as a special.
Definition: mutt.h:80
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 1507 of file command_parse.c.

1509 {
1510  char path[PATH_MAX];
1511 
1512  do
1513  {
1514  if (mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS) != 0)
1515  {
1516  mutt_buffer_printf(err, _("source: error at %s"), s->dptr);
1517  return MUTT_CMD_ERROR;
1518  }
1519  mutt_str_copy(path, buf->data, sizeof(path));
1520  mutt_expand_path(path, sizeof(path));
1521 
1522  if (source_rc(path, err) < 0)
1523  {
1524  mutt_buffer_printf(err, _("source: file %s could not be sourced"), path);
1525  return MUTT_CMD_ERROR;
1526  }
1527 
1528  } while (MoreArgs(s));
1529 
1530  return MUTT_CMD_SUCCESS;
1531 }
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:36
#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:128
#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:394
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716
#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 1536 of file command_parse.c.

1538 {
1539  struct Buffer templ;
1540 
1541  mutt_buffer_init(&templ);
1542 
1543  /* Insist on at least one parameter */
1544  if (!MoreArgs(s))
1545  {
1546  if (data == MUTT_SPAM)
1547  mutt_buffer_strcpy(err, _("spam: no matching pattern"));
1548  else
1549  mutt_buffer_strcpy(err, _("nospam: no matching pattern"));
1550  return MUTT_CMD_ERROR;
1551  }
1552 
1553  /* Extract the first token, a regex */
1555 
1556  /* data should be either MUTT_SPAM or MUTT_NOSPAM. MUTT_SPAM is for spam commands. */
1557  if (data == MUTT_SPAM)
1558  {
1559  /* If there's a second parameter, it's a template for the spam tag. */
1560  if (MoreArgs(s))
1561  {
1563 
1564  /* Add to the spam list. */
1565  if (mutt_replacelist_add(&SpamList, buf->data, templ.data, err) != 0)
1566  {
1567  FREE(&templ.data);
1568  return MUTT_CMD_ERROR;
1569  }
1570  FREE(&templ.data);
1571  }
1572  /* If not, try to remove from the nospam list. */
1573  else
1574  {
1576  }
1577 
1578  return MUTT_CMD_SUCCESS;
1579  }
1580  /* MUTT_NOSPAM is for nospam commands. */
1581  else if (data == MUTT_NOSPAM)
1582  {
1583  /* nospam only ever has one parameter. */
1584 
1585  /* "*" is a special case. */
1586  if (mutt_str_equal(buf->data, "*"))
1587  {
1590  return MUTT_CMD_SUCCESS;
1591  }
1592 
1593  /* If it's on the spam list, just remove it. */
1594  if (mutt_replacelist_remove(&SpamList, buf->data) != 0)
1595  return MUTT_CMD_SUCCESS;
1596 
1597  /* Otherwise, add it to the nospam list. */
1598  if (mutt_regexlist_add(&NoSpamList, buf->data, REG_ICASE, err) != 0)
1599  return MUTT_CMD_ERROR;
1600 
1601  return MUTT_CMD_SUCCESS;
1602  }
1603 
1604  /* This should not happen. */
1605  mutt_buffer_strcpy(err, "This is no good at all.");
1606  return MUTT_CMD_ERROR;
1607 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, const char *templ, struct Buffer *err)
Add a pattern and a template to a list.
Definition: regex.c:261
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
#define MUTT_NOSPAM
Definition: mutt.h:115
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:446
#define MoreArgs(buf)
Definition: buffer.h:43
#define MUTT_SPAM
Definition: mutt.h:114
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
struct RegexList NoSpamList
List of regexes to whitelist non-spam emails.
Definition: globals.c:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
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 ReplaceList SpamList
List of regexes and patterns to match spam emails.
Definition: globals.c:44
Success: Command worked.
Definition: mutt_commands.h:38
int mutt_replacelist_remove(struct ReplaceList *rl, const char *pat)
Remove a pattern from a list.
Definition: regex.c:563
#define FREE(x)
Definition: memory.h:40
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
Definition: buffer.c:46
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition: regex.c:169
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_stailq()

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

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

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

Definition at line 1614 of file command_parse.c.

1616 {
1617  do
1618  {
1620  add_to_stailq((struct ListHead *) data, buf->data);
1621  } while (MoreArgs(s));
1622 
1623  return MUTT_CMD_SUCCESS;
1624 }
#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:1700
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
#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 1629 of file command_parse.c.

1631 {
1632  enum CommandResult rc;
1633 
1634  rc = parse_replace_list(buf, s, &SubjectRegexList, err);
1635  if (rc == MUTT_CMD_SUCCESS)
1637  return rc;
1638 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:34
struct ReplaceList SubjectRegexList
List of regexes to tidy the view of the email&#39;s subject.
Definition: globals.c:53
static enum CommandResult parse_replace_list(struct Buffer *buf, struct Buffer *s, struct ReplaceList *list, struct Buffer *err)
Parse a string replacement rule - Implements Command::parse()
Success: Command worked.
Definition: mutt_commands.h:38
static void clear_subject_mods(void)
Clear out all modified email subjects.
+ Here is the call graph for this function:

◆ parse_subscribe()

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

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

Definition at line 1643 of file command_parse.c.

1645 {
1646  struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
1647 
1648  do
1649  {
1651 
1652  if (parse_grouplist(&gl, buf, s, err) == -1)
1653  goto bail;
1654 
1657 
1658  if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0)
1659  goto bail;
1660  if (mutt_regexlist_add(&SubscribedLists, buf->data, REG_ICASE, err) != 0)
1661  goto bail;
1662  if (mutt_grouplist_add_regex(&gl, buf->data, REG_ICASE, err) != 0)
1663  goto bail;
1664  } while (MoreArgs(s));
1665 
1667  return MUTT_CMD_SUCCESS;
1668 
1669 bail:
1671  return MUTT_CMD_ERROR;
1672 }
int parse_grouplist(struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
Parse a group context.
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: globals.c:52
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: globals.c:49
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: globals.c:50
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_grouplist_add_regex(struct GroupList *gl, const char *s, int flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition: group.c:276
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: globals.c:51
void mutt_grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition: group.c:157
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

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

1684 {
1685  if (!buf || !s || !err)
1686  return MUTT_CMD_ERROR;
1687 
1688  mutt_buffer_reset(err);
1689 
1690  if (MoreArgs(s))
1691  {
1693 
1694  if (MoreArgs(s))
1695  {
1696  mutt_buffer_printf(err, _("%s: too many arguments"), "subscribe-to");
1697  return MUTT_CMD_WARNING;
1698  }
1699 
1700  if (buf->data && (*buf->data != '\0'))
1701  {
1702  /* Expand and subscribe */
1703  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), true) == 0)
1704  {
1705  mutt_message(_("Subscribed to %s"), buf->data);
1706  return MUTT_CMD_SUCCESS;
1707  }
1708 
1709  mutt_buffer_printf(err, _("Could not subscribe to %s"), buf->data);
1710  return MUTT_CMD_ERROR;
1711  }
1712 
1713  mutt_debug(LL_DEBUG1, "Corrupted buffer");
1714  return MUTT_CMD_ERROR;
1715  }
1716 
1717  mutt_buffer_addstr(err, _("No folder specified"));
1718  return MUTT_CMD_WARNING;
1719 }
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:36
#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:128
#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:394
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
Log at debug level 1.
Definition: logging.h:40
Warning: Help given to the user.
Definition: mutt_commands.h:37
#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:1261
+ 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 1725 of file command_parse.c.

1727 {
1728  if (!buf || !s)
1729  return MUTT_CMD_ERROR;
1730 
1731  char *tmp = NULL;
1732 
1733  while (MoreArgs(s))
1734  {
1735  char *tag = NULL, *format = NULL;
1736 
1738  if (buf->data && (*buf->data != '\0'))
1739  tag = mutt_str_dup(buf->data);
1740  else
1741  continue;
1742 
1744  format = mutt_str_dup(buf->data);
1745 
1746  /* avoid duplicates */
1747  tmp = mutt_hash_find(TagFormats, format);
1748  if (tmp)
1749  {
1750  mutt_debug(LL_DEBUG3, "tag format '%s' already registered as '%s'\n", format, tmp);
1751  FREE(&tag);
1752  FREE(&format);
1753  continue;
1754  }
1755 
1756  mutt_hash_insert(TagFormats, format, tag);
1757  }
1758  return MUTT_CMD_SUCCESS;
1759 }
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:354
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
Definition: hash.c:327
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
#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:394
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
WHERE struct HashTable * TagFormats
Hash Table of tag-formats (tag -> format string)
Definition: mutt_globals.h:59
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 1764 of file command_parse.c.

1766 {
1767  if (!buf || !s)
1768  return MUTT_CMD_ERROR;
1769 
1770  char *tmp = NULL;
1771 
1772  while (MoreArgs(s))
1773  {
1774  char *tag = NULL, *transform = NULL;
1775 
1777  if (buf->data && (*buf->data != '\0'))
1778  tag = mutt_str_dup(buf->data);
1779  else
1780  continue;
1781 
1783  transform = mutt_str_dup(buf->data);
1784 
1785  /* avoid duplicates */
1786  tmp = mutt_hash_find(TagTransforms, tag);
1787  if (tmp)
1788  {
1789  mutt_debug(LL_DEBUG3, "tag transform '%s' already registered as '%s'\n", tag, tmp);
1790  FREE(&tag);
1791  FREE(&transform);
1792  continue;
1793  }
1794 
1795  mutt_hash_insert(TagTransforms, tag, transform);
1796  }
1797  return MUTT_CMD_SUCCESS;
1798 }
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:354
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
Definition: hash.c:327
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
#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:394
char * data
Pointer to data.
Definition: buffer.h:35
struct HashTable * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:38
Success: Command worked.
Definition: mutt_commands.h:38
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Log at debug level 3.
Definition: logging.h:42
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_unalternates()

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

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

Definition at line 1803 of file command_parse.c.

1805 {
1806  alternates_clean();
1807  do
1808  {
1810  mutt_regexlist_remove(&Alternates, buf->data);
1811 
1812  if (!mutt_str_equal(buf->data, "*") &&
1813  (mutt_regexlist_add(&UnAlternates, buf->data, REG_ICASE, err) != 0))
1814  {
1815  return MUTT_CMD_ERROR;
1816  }
1817 
1818  } while (MoreArgs(s));
1819 
1820  return MUTT_CMD_SUCCESS;
1821 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition: regex.c:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
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:38
#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 1826 of file command_parse.c.

1828 {
1829  char op;
1830  char *p = NULL;
1831  struct ListHead *head = NULL;
1832 
1834  if (!buf->data || (*buf->data == '\0'))
1835  {
1836  mutt_buffer_strcpy(err, _("unattachments: no disposition"));
1837  return MUTT_CMD_WARNING;
1838  }
1839 
1840  p = buf->data;
1841  op = *p++;
1842 
1843  if (op == '*')
1844  {
1850  return 0;
1851  }
1852 
1853  if ((op != '+') && (op != '-'))
1854  {
1855  op = '+';
1856  p--;
1857  }
1858  if (mutt_istr_startswith("attachment", p))
1859  {
1860  if (op == '+')
1861  head = &AttachAllow;
1862  else
1863  head = &AttachExclude;
1864  }
1865  else if (mutt_istr_startswith("inline", p))
1866  {
1867  if (op == '+')
1868  head = &InlineAllow;
1869  else
1870  head = &InlineExclude;
1871  }
1872  else
1873  {
1874  mutt_buffer_strcpy(err, _("unattachments: invalid disposition"));
1875  return MUTT_CMD_ERROR;
1876  }
1877 
1878  return parse_unattach_list(buf, s, head, err);
1879 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
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:144
#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:394
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:172
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: mutt_parse.c:40
Warning: Help given to the user.
Definition: mutt_commands.h:37
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:45
+ Here is the call graph for this function:

◆ parse_unignore()

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

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

Definition at line 1884 of file command_parse.c.

1886 {
1887  do
1888  {
1890 
1891  /* don't add "*" to the unignore list */
1892  if (strcmp(buf->data, "*") != 0)
1893  add_to_stailq(&UnIgnore, buf->data);
1894 
1895  remove_from_stailq(&Ignore, buf->data);
1896  } while (MoreArgs(s));
1897 
1898  return MUTT_CMD_SUCCESS;
1899 }
#define MoreArgs(buf)
Definition: buffer.h:43
struct ListHead Ignore
List of header patterns to ignore.
Definition: globals.c:45
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1700
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
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:1725
Success: Command worked.
Definition: mutt_commands.h:38
struct ListHead UnIgnore
List of header patterns to unignore (see)
Definition: globals.c:46
#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 1904 of file command_parse.c.

1906 {
1908  do
1909  {
1913 
1914  if (!mutt_str_equal(buf->data, "*") &&
1915  (mutt_regexlist_add(&UnMailLists, buf->data, REG_ICASE, err) != 0))
1916  {
1917  return MUTT_CMD_ERROR;
1918  }
1919  } while (MoreArgs(s));
1920 
1921  return MUTT_CMD_SUCCESS;
1922 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: globals.c:52
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition: hash.c:447
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: globals.c:50
struct HashTable * AutoSubscribeCache
Hash Table of auto-subscribed mailing lists.
Definition: 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:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: globals.c:51
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:

◆ parse_unmailboxes()

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

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

This is also used by 'unvirtual-mailboxes'

Definition at line 1967 of file command_parse.c.

1969 {
1970  while (MoreArgs(s))
1971  {
1973 
1974  if (mutt_str_equal(buf->data, "*"))
1975  {
1977  return MUTT_CMD_SUCCESS;
1978  }
1979 
1981 
1982  struct Account *a = NULL;
1983  TAILQ_FOREACH(a, &NeoMutt->accounts, entries)
1984  {
1985  struct Mailbox *m = mx_mbox_find(a, mutt_b2s(buf));
1986  if (m)
1987  {
1988  do_unmailboxes(m);
1989  break;
1990  }
1991  }
1992  }
1993  return MUTT_CMD_SUCCESS;
1994 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
struct AccountList accounts
List of all Accounts.
Definition: neomutt.h:40
A group of associated Mailboxes.
Definition: account.h:36
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
Find a Mailbox on an Account.
Definition: mx.c:1592
Container for Accounts, Notifications.
Definition: neomutt.h:36
#define MoreArgs(buf)
Definition: buffer.h:43
#define mutt_b2s(buf)
Definition: buffer.h:41
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:394
char * data
Pointer to data.
Definition: buffer.h:35
static void do_unmailboxes_star(void)
Remove all Mailboxes from the Sidebar/notifications.
static void do_unmailboxes(struct Mailbox *m)
Remove a Mailbox from the Sidebar/notifications.
Success: Command worked.
Definition: mutt_commands.h:38
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ 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 1999 of file command_parse.c.

2001 {
2002  struct ListNode *np = NULL, *tmp = NULL;
2003  size_t l;
2004 
2005  do
2006  {
2008  if (mutt_str_equal("*", buf->data))
2009  {
2010  /* Clear all headers, send a notification for each header */
2011  STAILQ_FOREACH(np, &UserHeader, entries)
2012  {
2013  struct EventHeader event = { np->data };
2015  }
2016  mutt_list_free(&UserHeader);
2017  continue;
2018  }
2019 
2020  l = mutt_str_len(buf->data);
2021  if (buf->data[l - 1] == ':')
2022  l--;
2023 
2024  STAILQ_FOREACH_SAFE(np, &UserHeader, entries, tmp)
2025  {
2026  if (mutt_istrn_equal(buf->data, np->data, l) && (np->data[l] == ':'))
2027  {
2028  struct EventHeader event = { np->data };
2030 
2031  header_free(&UserHeader, np);
2032  }
2033  }
2034  } while (MoreArgs(s));
2035  return MUTT_CMD_SUCCESS;
2036 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
An event that happened to a header.
Definition: email.h:167
Container for Accounts, Notifications.
Definition: neomutt.h:36
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
bool mutt_istrn_equal(const char *a, const char *b, size_t l)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition: string.c:621
#define MoreArgs(buf)
Definition: buffer.h:43
A header is about to be removed.
Definition: email.h:161
#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:394
char * data
Pointer to data.
Definition: buffer.h:35
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
A header has changed, NotifyHeader EventHeader.
Definition: notify_type.h:41
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
void header_free(struct ListHead *hdrlist, struct ListNode *target)
Free and remove a header from a header list.
Definition: email.c:237
Success: Command worked.
Definition: mutt_commands.h:38
char * data
String.
Definition: list.h:36
A List node for strings.
Definition: list.h:34
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:152
+ 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 2043 of file command_parse.c.

2045 {
2046  do
2047  {
2049  /* Check for deletion of entire list */
2050  if (mutt_str_equal(buf->data, "*"))
2051  {
2052  mutt_list_free((struct ListHead *) data);
2053  break;
2054  }
2055  remove_from_stailq((struct ListHead *) data, buf->data);
2056  } while (MoreArgs(s));
2057 
2058  return MUTT_CMD_SUCCESS;
2059 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
#define MoreArgs(buf)
Definition: buffer.h:43
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
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:1725
Success: Command worked.
Definition: mutt_commands.h:38
#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 2064 of file command_parse.c.

2066 {
2067  enum CommandResult rc;
2068 
2069  rc = parse_unreplace_list(buf, s, &SubjectRegexList, err);
2070  if (rc == MUTT_CMD_SUCCESS)
2072  return rc;
2073 }
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:34
struct ReplaceList SubjectRegexList
List of regexes to tidy the view of the email&#39;s subject.
Definition: globals.c:53
static enum CommandResult parse_unreplace_list(struct Buffer *buf, struct Buffer *s, struct ReplaceList *list, struct Buffer *err)
Remove a string replacement rule - Implements Command::parse()
Definition: command_parse.c:84
Success: Command worked.
Definition: mutt_commands.h:38
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 2078 of file command_parse.c.

2080 {
2082  do
2083  {
2086 
2087  if (!mutt_str_equal(buf->data, "*") &&
2088  (mutt_regexlist_add(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0))
2089  {
2090  return MUTT_CMD_ERROR;
2091  }
2092  } while (MoreArgs(s));
2093 
2094  return MUTT_CMD_SUCCESS;
2095 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: globals.c:52
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition: regex.c:225
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition: hash.c:447
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: globals.c:49
struct HashTable * AutoSubscribeCache
Hash Table of auto-subscribed mailing lists.
Definition: 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:131
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ 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 2105 of file command_parse.c.

2107 {
2108  if (!buf || !s || !err)
2109  return MUTT_CMD_ERROR;
2110 
2111  if (MoreArgs(s))
2112  {
2114 
2115  if (MoreArgs(s))
2116  {
2117  mutt_buffer_printf(err, _("%s: too many arguments"), "unsubscribe-from");
2118  return MUTT_CMD_WARNING;
2119  }
2120 
2121  if (buf->data && (*buf->data != '\0'))
2122  {
2123  /* Expand and subscribe */
2124  if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), false) == 0)
2125  {
2126  mutt_message(_("Unsubscribed from %s"), buf->data);
2127  return MUTT_CMD_SUCCESS;
2128  }
2129 
2130  mutt_buffer_printf(err, _("Could not unsubscribe from %s"), buf->data);
2131  return MUTT_CMD_ERROR;
2132  }
2133 
2134  mutt_debug(LL_DEBUG1, "Corrupted buffer");
2135  return MUTT_CMD_ERROR;
2136  }
2137 
2138  mutt_buffer_addstr(err, _("No folder specified"));
2139  return MUTT_CMD_WARNING;
2140 }
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
#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:128
#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:394
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:38
Log at debug level 1.
Definition: logging.h:40
Warning: Help given to the user.
Definition: mutt_commands.h:37
#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:1261
+ Here is the call graph for this function:

◆ parse_grouplist()

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

Parse a group context.

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

Definition at line 392 of file command_parse.c.

394 {
395  while (mutt_istr_equal(buf->data, "-group"))
396  {
397  if (!MoreArgs(s))
398  {
399  mutt_buffer_strcpy(err, _("-group: no group name"));
400  return -1;
401  }
402 
404 
406 
407  if (!MoreArgs(s))
408  {
409  mutt_buffer_strcpy(err, _("out of arguments"));
410  return -1;
411  }
412 
414  }
415 
416  return 0;
417 }
void mutt_grouplist_add(struct GroupList *gl, struct Group *group)
Add a Group to a GroupList.
Definition: group.c:137
#define _(a)
Definition: message.h:28
#define MoreArgs(buf)
Definition: buffer.h:43
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
char * data
Pointer to data.
Definition: buffer.h:35
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
struct Group * mutt_pattern_group(const char *pat)
Match a pattern to a Group.
Definition: group.c:65
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear_source_stack()

void clear_source_stack ( void  )

Free memory from the stack used for the souce command.

Definition at line 2146 of file command_parse.c.

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

426 {
427  int lineno = 0, rc = 0, warnings = 0;
428  enum CommandResult line_rc;
429  struct Buffer *token = NULL, *linebuf = NULL;
430  char *line = NULL;
431  char *currentline = NULL;
432  char rcfile[PATH_MAX];
433  size_t linelen = 0;
434  pid_t pid;
435 
436  mutt_str_copy(rcfile, rcfile_path, sizeof(rcfile));
437 
438  size_t rcfilelen = mutt_str_len(rcfile);
439  if (rcfilelen == 0)
440  return -1;
441 
442  bool ispipe = rcfile[rcfilelen - 1] == '|';
443 
444  if (!ispipe)
445  {
446  struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
447  if (!mutt_path_to_absolute(rcfile, np ? NONULL(np->data) : ""))
448  {
449  mutt_error(_("Error: Can't build path of '%s'"), rcfile_path);
450  return -1;
451  }
452 
453  STAILQ_FOREACH(np, &MuttrcStack, entries)
454  {
455  if (mutt_str_equal(np->data, rcfile))
456  {
457  break;
458  }
459  }
460  if (np)
461  {
462  mutt_error(_("Error: Cyclic sourcing of configuration file '%s'"), rcfile);
463  return -1;
464  }
465 
467  }
468 
469  mutt_debug(LL_DEBUG2, "Reading configuration file '%s'\n", rcfile);
470 
471  FILE *fp = mutt_open_read(rcfile, &pid);
472  if (!fp)
473  {
474  mutt_buffer_printf(err, "%s: %s", rcfile, strerror(errno));
475  return -1;
476  }
477 
478  token = mutt_buffer_pool_get();
479  linebuf = mutt_buffer_pool_get();
480 
481  while ((line = mutt_file_read_line(line, &linelen, fp, &lineno, MUTT_CONT)) != NULL)
482  {
483  const bool conv = C_ConfigCharset && C_Charset;
484  if (conv)
485  {
486  currentline = mutt_str_dup(line);
487  if (!currentline)
488  continue;
489  mutt_ch_convert_string(&currentline, C_ConfigCharset, C_Charset, 0);
490  }
491  else
492  currentline = line;
493 
494  mutt_buffer_strcpy(linebuf, currentline);
495 
496  mutt_buffer_reset(err);
497  line_rc = mutt_parse_rc_buffer(linebuf, token, err);
498  if (line_rc == MUTT_CMD_ERROR)
499  {
500  mutt_error(_("Error in %s, line %d: %s"), rcfile, lineno, err->data);
501  if (--rc < -MAX_ERRS)
502  {
503  if (conv)
504  FREE(&currentline);
505  break;
506  }
507  }
508  else if (line_rc == MUTT_CMD_WARNING)
509  {
510  /* Warning */
511  mutt_warning(_("Warning in %s, line %d: %s"), rcfile, lineno, err->data);
512  warnings++;
513  }
514  else if (line_rc == MUTT_CMD_FINISH)
515  {
516  break; /* Found "finish" command */
517  }
518  else
519  {
520  if (rc < 0)
521  rc = -1;
522  }
523  if (conv)
524  FREE(&currentline);
525  }
526 
527  FREE(&line);
528  mutt_file_fclose(&fp);
529  if (pid != -1)
530  filter_wait(pid);
531 
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  mutt_buffer_pool_release(&token);
560  mutt_buffer_pool_release(&linebuf);
561  return rc;
562 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
#define mutt_warning(...)
Definition: logging.h:82
#define NONULL(x)
Definition: string2.h:37
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:34
Error: Can&#39;t help the user.
Definition: mutt_commands.h:36
int mutt_ch_convert_string(char **ps, const char *from, const char *to, int flags)
Convert a string between encodings.
Definition: charset.c:754
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
#define _(a)
Definition: message.h:28
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, int flags)
Read a line from a file.
Definition: file.c:667
#define STAILQ_REMOVE_HEAD(head, field)
Definition: queue.h:419
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define MUTT_CONT
-continuation
Definition: file.h:37
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
WHERE char * C_ConfigCharset
Config: Character set that the config files are in.
Definition: mutt_globals.h:88
char * data
Pointer to data.
Definition: buffer.h:35
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
Definition: path.c:397
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition: list.c:45
enum CommandResult mutt_parse_rc_buffer(struct Buffer *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:981
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
char * data
String.
Definition: list.h:36
Warning: Help given to the user.
Definition: mutt_commands.h:37
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716
Finish: Stop processing this file.
Definition: mutt_commands.h:39
#define MAX_ERRS
Definition: command_parse.c:69
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
static struct ListHead MuttrcStack
Definition: command_parse.c:67
#define STAILQ_EMPTY(head)
Definition: queue.h:345
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
A List node for strings.
Definition: list.h:34
FILE * mutt_open_read(const char *path, pid_t *thepid)
Run a command to read from.
Definition: muttlib.c:1304
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:53
#define STAILQ_FIRST(head)
Definition: queue.h:347
+ Here is the call graph for this function:
+ Here is the caller graph for this function: