]> granicus.if.org Git - neomutt/commitdiff
Created enum to group command_t return codes
authorVictor Fernandes <criw@pm.me>
Mon, 24 Dec 2018 00:18:04 +0000 (01:18 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 3 Jan 2019 17:18:09 +0000 (17:18 +0000)
Old return codes have been replaced by the enum ones
in init.c, but other files have functions that must be
changed too.

18 files changed:
color.c
color.h
commands.c
hook.c
hook.h
init.c
init.h
keymap.c
keymap.h
mailbox.c
mailbox.h
main.c
mutt.h
mutt_commands.h
mutt_lua.c
mutt_lua.h
score.c
score.h

diff --git a/color.c b/color.c
index 76b3df8806a6322cfe11c24bf11d00e7daf3663e..910f0683ec560976078fd8356ef8f67424209a2f 100644 (file)
--- a/color.c
+++ b/color.c
@@ -40,6 +40,7 @@
 #include "globals.h"
 #include "keymap.h"
 #include "mailbox.h"
+#include "mutt_commands.h"
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 #include "options.h"
@@ -572,15 +573,14 @@ static void do_uncolor(struct Buffer *buf, struct Buffer *s,
  * @param data          Flags associated with the command
  * @param err           Buffer for error messages
  * @param parse_uncolor If true, 'uncolor', else 'unmono'
- * @retval  0 Success
- * @retval -1 Error
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  *
  * usage:
  * * uncolor index pattern [pattern...]
  * * unmono  index pattern [pattern...]
  */
-static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                         struct Buffer *err, bool parse_uncolor)
+static enum CommandResult parse_uncolor(struct Buffer *buf, struct Buffer *s,
+                                        unsigned long data, struct Buffer *err, bool parse_uncolor)
 {
   int object = 0;
   bool do_cache = false;
@@ -591,14 +591,14 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat
   if (object == -1)
   {
     mutt_buffer_printf(err, _("%s: no such object"), buf->data);
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   if (object > MT_COLOR_INDEX_SUBJECT)
   { /* uncolor index column */
     ColorDefs[object] = 0;
     mutt_menu_set_redraw_full(MENU_MAIN);
-    return 0;
+    return MUTT_CMD_SUCCESS;
   }
 
   if (!mutt_str_startswith(buf->data, "body", CASE_MATCH) &&
@@ -607,13 +607,13 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat
   {
     mutt_buffer_printf(err, _("%s: command valid only for index, body, header objects"),
                        parse_uncolor ? "uncolor" : "unmono");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   if (!MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too few arguments"), parse_uncolor ? "uncolor" : "unmono");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   if (
@@ -634,7 +634,7 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat
       mutt_extract_token(buf, s, 0);
     while (MoreArgs(s));
 
-    return 0;
+    return MUTT_CMD_SUCCESS;
   }
 
   if (object == MT_COLOR_BODY)
@@ -665,7 +665,7 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat
     for (int i = 0; Context && i < Context->mailbox->msg_count; i++)
       Context->mailbox->emails[i]->pair = 0;
   }
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 #ifdef HAVE_COLOR
@@ -673,8 +673,8 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat
 /**
  * mutt_parse_uncolor - Parse the 'uncolor' command - Implements ::command_t
  */
-int mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                       struct Buffer *err)
+enum CommandResult mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s,
+                                      unsigned long data, struct Buffer *err)
 {
   return parse_uncolor(buf, s, data, err, true);
 }
@@ -684,8 +684,8 @@ int mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data,
 /**
  * mutt_parse_unmono - Parse the 'unmono' command - Implements ::command_t
  */
-int mutt_parse_unmono(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                      struct Buffer *err)
+enum CommandResult mutt_parse_unmono(struct Buffer *buf, struct Buffer *s,
+                                     unsigned long data, struct Buffer *err)
 {
   return parse_uncolor(buf, s, data, err, false);
 }
@@ -701,11 +701,11 @@ int mutt_parse_unmono(struct Buffer *buf, struct Buffer *s, unsigned long data,
  * @param err       Buffer for error messages
  * @param is_index  true of this is for the index
  * @param match     Number of regex subexpression to match (0 for entire pattern)
- * @retval  0 Success
- * @retval -1 Error
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  */
-static int add_pattern(struct ColorLineHead *top, const char *s, bool sensitive, int fg,
-                       int bg, int attr, struct Buffer *err, bool is_index, int match)
+static enum CommandResult add_pattern(struct ColorLineHead *top, const char *s,
+                                      bool sensitive, int fg, int bg, int attr,
+                                      struct Buffer *err, bool is_index, int match)
 {
   /* is_index used to store compiled pattern
    * only for `index' color object
@@ -757,7 +757,7 @@ static int add_pattern(struct ColorLineHead *top, const char *s, bool sensitive,
       if (!tmp->color_pattern)
       {
         free_color_line(tmp, true);
-        return -1;
+        return MUTT_CMD_ERROR;
       }
     }
     else
@@ -773,7 +773,7 @@ static int add_pattern(struct ColorLineHead *top, const char *s, bool sensitive,
       {
         regerror(r, &tmp->regex, err->data, err->dsize);
         free_color_line(tmp, true);
-        return -1;
+        return MUTT_CMD_ERROR;
       }
     }
     tmp->pattern = mutt_str_strdup(s);
@@ -797,7 +797,7 @@ static int add_pattern(struct ColorLineHead *top, const char *s, bool sensitive,
       Context->mailbox->emails[i]->pair = 0;
   }
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -977,23 +977,23 @@ static int fgbgattr_to_color(int fg, int bg, int attr)
  * @param callback Function to handle command - Implements ::parser_callback_t
  * @param dry_run  If true, test the command, but don't apply it
  * @param color    If true "color", else "mono"
- * @retval  0 Success
- * @retval -1 Error
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  *
  * usage: color OBJECT FG BG [ REGEX ]
  *        mono  OBJECT ATTR [ REGEX ]
  */
-static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err,
-                       parser_callback_t callback, bool dry_run, bool color)
+static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s,
+                                      struct Buffer *err, parser_callback_t callback,
+                                      bool dry_run, bool color)
 {
-  int object = 0, attr = 0, fg = 0, bg = 0, q_level = 0;
-  int r = 0, match = 0;
+  int object = 0, attr = 0, fg = 0, bg = 0, q_level = 0, match = 0;
+  enum CommandResult r = MUTT_CMD_SUCCESS;
 
   if (parse_object(buf, s, &object, &q_level, err) == -1)
-    return -1;
+    return MUTT_CMD_ERROR;
 
   if (callback(buf, s, &fg, &bg, &attr, err) == -1)
-    return -1;
+    return MUTT_CMD_ERROR;
 
   /* extract a regular expression if needed */
 
@@ -1005,7 +1005,7 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err,
     if (!MoreArgs(s))
     {
       mutt_buffer_printf(err, _("%s: too few arguments"), color ? "color" : "mono");
-      return -1;
+      return MUTT_CMD_ERROR;
     }
 
     mutt_extract_token(buf, s, 0);
@@ -1014,7 +1014,7 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err,
   if (MoreArgs(s) && (object != MT_COLOR_STATUS))
   {
     mutt_buffer_printf(err, _("%s: too many arguments"), color ? "color" : "mono");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   /* dry run? */
@@ -1022,7 +1022,7 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err,
   if (dry_run)
   {
     *s->dptr = '\0'; /* fake that we're done parsing */
-    return 0;
+    return MUTT_CMD_SUCCESS;
   }
 
 #ifdef HAVE_COLOR
@@ -1039,7 +1039,7 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err,
    */
   {
     mutt_buffer_strcpy(err, _("default colors not supported"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 #endif /* HAVE_USE_DEFAULT_COLORS */
 #endif
@@ -1139,8 +1139,8 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err,
 /**
  * mutt_parse_color - Parse the 'color' command - Implements ::command_t
  */
-int mutt_parse_color(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                     struct Buffer *err)
+enum CommandResult mutt_parse_color(struct Buffer *buf, struct Buffer *s,
+                                    unsigned long data, struct Buffer *err)
 {
   bool dry_run = false;
 
@@ -1155,8 +1155,8 @@ int mutt_parse_color(struct Buffer *buf, struct Buffer *s, unsigned long data,
 /**
  * mutt_parse_mono - Parse the 'mono' command - Implements ::command_t
  */
-int mutt_parse_mono(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                    struct Buffer *err)
+enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s,
+                                   unsigned long data, struct Buffer *err)
 {
   bool dry_run = false;
 
diff --git a/color.h b/color.h
index 2fae66e47e4bb19902f7ba661211a4ac3fe64cb0..1c84684049ede859e4bb9576df25657838470b6c 100644 (file)
--- a/color.h
+++ b/color.h
@@ -30,9 +30,9 @@ int  mutt_alloc_color(int fg, int bg);
 int  mutt_combine_color(int fg_attr, int bg_attr);
 void mutt_free_color(int fg, int bg);
 void mutt_free_colors(void);
-int  mutt_parse_color(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-int  mutt_parse_mono(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-int  mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-int  mutt_parse_unmono(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_color(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_unmono(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 
 #endif /* MUTT_COLOR_H */
index 18ec9d9b64950fbce6a672ccf6edd567a59cb774..c8297bfba74caff0c175cf207f3cfeac089774da 100644 (file)
@@ -732,7 +732,7 @@ void mutt_enter_command(void)
 {
   struct Buffer err, token;
   char buffer[LONG_STRING];
-  int r;
+  enum CommandResult r;
 
   buffer[0] = '\0';
   if (mutt_get_field(":", buffer, sizeof(buffer), MUTT_COMMAND) != 0 || !buffer[0])
@@ -749,7 +749,7 @@ void mutt_enter_command(void)
     /* since errbuf could potentially contain printf() sequences in it,
        we must call mutt_error() in this fashion so that vsprintf()
        doesn't expect more arguments that we passed */
-    if (r == 0)
+    if (r == MUTT_CMD_SUCCESS)
       mutt_message("%s", err.data);
     else
       mutt_error("%s", err.data);
diff --git a/hook.c b/hook.c
index 34d8e5e327b7d06f3d0cc69e8bb6571a22d06cd5..402b712bb7b280da09cc6f720eb2acdb3393ff5d 100644 (file)
--- a/hook.c
+++ b/hook.c
@@ -42,6 +42,7 @@
 #include "globals.h"
 #include "hdrline.h"
 #include "mutt_attach.h"
+#include "mutt_commands.h"
 #include "muttlib.h"
 #include "mx.h"
 #include "ncrypt/ncrypt.h"
@@ -77,8 +78,8 @@ static int current_hook_type = 0;
  *
  * This is used by 'account-hook', 'append-hook' and many more.
  */
-int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                    struct Buffer *err)
+enum CommandResult mutt_parse_hook(struct Buffer *buf, struct Buffer *s,
+                                   unsigned long data, struct Buffer *err)
 {
   struct Hook *ptr = NULL;
   struct Buffer command, pattern;
@@ -158,7 +159,7 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data,
     if (mutt_comp_valid_command(command.data) == 0)
     {
       mutt_buffer_strcpy(err, _("badly formatted command string"));
-      return -1;
+      return MUTT_CMD_ERROR;
     }
   }
 #endif
@@ -197,7 +198,7 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data,
       if (mutt_str_strcmp(ptr->command, command.data) == 0)
       {
         FREE(&command.data);
-        return 0;
+        return MUTT_CMD_SUCCESS;
       }
     }
     else if (ptr->type == data &&
@@ -214,7 +215,7 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data,
         {
           FREE(&command.data);
           FREE(&pattern.data);
-          return 0;
+          return MUTT_CMD_SUCCESS;
         }
       }
       else
@@ -227,7 +228,7 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data,
         FREE(&ptr->command);
         ptr->command = command.data;
         FREE(&pattern.data);
-        return 0;
+        return MUTT_CMD_SUCCESS;
       }
     }
   }
@@ -240,7 +241,7 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data,
       goto error;
     FREE(&pattern.data);
     FREE(&command.data);
-    return 0;
+    return MUTT_CMD_SUCCESS;
   }
   else if (data & (MUTT_SEND_HOOK | MUTT_SEND2_HOOK | MUTT_SAVE_HOOK |
                    MUTT_FCC_HOOK | MUTT_MESSAGE_HOOK | MUTT_REPLY_HOOK))
@@ -272,13 +273,13 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data,
   ptr->regex.regex = rx;
   ptr->regex.not = not;
   TAILQ_INSERT_TAIL(&Hooks, ptr, entries);
-  return 0;
+  return MUTT_CMD_SUCCESS;
 
 error:
   if (~data & MUTT_GLOBAL_HOOK) /* NOT a global hook */
     FREE(&pattern.data);
   FREE(&command.data);
-  return -1;
+  return MUTT_CMD_ERROR;
 }
 
 /**
@@ -322,8 +323,8 @@ void mutt_delete_hooks(int type)
 /**
  * mutt_parse_unhook - Parse the 'unhook' command - Implements ::command_t
  */
-int mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                      struct Buffer *err)
+enum CommandResult mutt_parse_unhook(struct Buffer *buf, struct Buffer *s,
+                                     unsigned long data, struct Buffer *err)
 {
   while (MoreArgs(s))
   {
@@ -333,7 +334,7 @@ int mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data,
       if (current_hook_type)
       {
         mutt_buffer_printf(err, "%s", _("unhook: Can't do unhook * from within a hook"));
-        return -1;
+        return MUTT_CMD_ERROR;
       }
       mutt_delete_hooks(0);
       mutt_ch_lookup_remove();
@@ -345,23 +346,23 @@ int mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data,
       if (!type)
       {
         mutt_buffer_printf(err, _("unhook: unknown hook type: %s"), buf->data);
-        return -1;
+        return MUTT_CMD_ERROR;
       }
       if (type & (MUTT_CHARSET_HOOK | MUTT_ICONV_HOOK))
       {
         mutt_ch_lookup_remove();
-        return 0;
+        return MUTT_CMD_SUCCESS;
       }
       if (current_hook_type == type)
       {
         mutt_buffer_printf(err, _("unhook: Can't delete a %s from within a %s"),
                            buf->data, buf->data);
-        return -1;
+        return MUTT_CMD_ERROR;
       }
       mutt_delete_hooks(type);
     }
   }
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -388,7 +389,7 @@ void mutt_folder_hook(const char *path)
     {
       if ((regexec(tmp->regex.regex, path, 0, NULL, 0) == 0) ^ tmp->regex.not)
       {
-        if (mutt_parse_rc_line(tmp->command, &token, &err) == -1)
+        if (mutt_parse_rc_line(tmp->command, &token, &err) == MUTT_CMD_ERROR)
         {
           mutt_error("%s", err.data);
           FREE(&token.data);
@@ -456,7 +457,7 @@ void mutt_message_hook(struct Mailbox *m, struct Email *e, int type)
     {
       if ((mutt_pattern_exec(hook->pattern, 0, m, e, &cache) > 0) ^ hook->regex.not)
       {
-        if (mutt_parse_rc_line(hook->command, &token, &err) == -1)
+        if (mutt_parse_rc_line(hook->command, &token, &err) == MUTT_CMD_ERROR)
         {
           FREE(&token.data);
           mutt_error("%s", err.data);
@@ -638,7 +639,7 @@ void mutt_account_hook(const char *url)
     {
       inhook = true;
 
-      if (mutt_parse_rc_line(hook->command, &token, &err) == -1)
+      if (mutt_parse_rc_line(hook->command, &token, &err) == MUTT_CMD_ERROR)
       {
         FREE(&token.data);
         mutt_error("%s", err.data);
@@ -680,7 +681,7 @@ void mutt_timeout_hook(void)
     if (!(hook->command && (hook->type & MUTT_TIMEOUT_HOOK)))
       continue;
 
-    if (mutt_parse_rc_line(hook->command, &token, &err) == -1)
+    if (mutt_parse_rc_line(hook->command, &token, &err) == MUTT_CMD_ERROR)
     {
       mutt_error("%s", err.data);
       mutt_buffer_reset(&err);
@@ -718,7 +719,7 @@ void mutt_startup_shutdown_hook(int type)
     if (!(hook->command && (hook->type & type)))
       continue;
 
-    if (mutt_parse_rc_line(hook->command, &token, &err) == -1)
+    if (mutt_parse_rc_line(hook->command, &token, &err) == MUTT_CMD_ERROR)
     {
       mutt_error("%s", err.data);
       mutt_buffer_reset(&err);
diff --git a/hook.h b/hook.h
index c60e4e29eb7179e610bb617752225302c3e8dfda..d30c2197e0caa8de77f9b9def68450e23c25f6b8 100644 (file)
--- a/hook.h
+++ b/hook.h
@@ -25,6 +25,7 @@
 
 #include <stdbool.h>
 #include <stdio.h>
+#include "mutt_commands.h"
 
 struct Address;
 struct Buffer;
@@ -67,8 +68,8 @@ void  mutt_delete_hooks(int type);
 char *mutt_find_hook(int type, const char *pat);
 void  mutt_folder_hook(const char *path);
 void  mutt_message_hook(struct Mailbox *m, struct Email *e, int type);
-int   mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-int   mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 void  mutt_select_fcc(char *path, size_t pathlen, struct Email *e);
 void  mutt_startup_shutdown_hook(int type);
 void  mutt_timeout_hook(void);
diff --git a/init.c b/init.c
index 0e88edebeae268fb9a2b8189a366fe4ebd7bf3a8..b55b97557691caf12e588736819613607f1daab7 100644 (file)
--- a/init.c
+++ b/init.c
@@ -288,7 +288,7 @@ static int execute_commands(struct ListHead *p)
   struct ListNode *np = NULL;
   STAILQ_FOREACH(np, p, entries)
   {
-    if (mutt_parse_rc_line(np->data, &token, &err) == -1)
+    if (mutt_parse_rc_line(np->data, &token, &err) == MUTT_CMD_ERROR)
     {
       mutt_error(_("Error in command line: %s"), err.data);
       FREE(&token.data);
@@ -459,11 +459,10 @@ static bool get_hostname(void)
  * @param s    Buffer containing the attachments command
  * @param head List of AttachMatch to add to
  * @param err  Buffer for error messages
- * @retval  0 Success
- * @retval -1 Error
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  */
-static int parse_attach_list(struct Buffer *buf, struct Buffer *s,
-                             struct ListHead *head, struct Buffer *err)
+static enum CommandResult parse_attach_list(struct Buffer *buf, struct Buffer *s,
+                                            struct ListHead *head, struct Buffer *err)
 {
   struct AttachMatch *a = NULL;
   char *p = NULL;
@@ -517,7 +516,7 @@ static int parse_attach_list(struct Buffer *buf, struct Buffer *s,
       regerror(ret, &a->minor_regex, err->data, err->dsize);
       FREE(&a->major);
       FREE(&a);
-      return -1;
+      return MUTT_CMD_ERROR;
     }
 
     mutt_debug(5, "added %s/%s [%d]\n", a->major, a->minor, a->major_int);
@@ -526,7 +525,7 @@ static int parse_attach_list(struct Buffer *buf, struct Buffer *s,
   } while (MoreArgs(s));
 
   attachments_clean();
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -572,8 +571,8 @@ bail:
 /**
  * parse_replace_list - Parse a string replacement rule - Implements ::command_t
  */
-static int parse_replace_list(struct Buffer *buf, struct Buffer *s,
-                              unsigned long data, struct Buffer *err)
+static enum CommandResult parse_replace_list(struct Buffer *buf, struct Buffer *s,
+                                             unsigned long data, struct Buffer *err)
 {
   struct ReplaceList *list = (struct ReplaceList *) data;
   struct Buffer templ = { 0 };
@@ -582,7 +581,7 @@ static int parse_replace_list(struct Buffer *buf, struct Buffer *s,
   if (!MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   mutt_extract_token(buf, s, 0);
 
@@ -590,18 +589,18 @@ static int parse_replace_list(struct Buffer *buf, struct Buffer *s,
   if (!MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too few arguments"), "subjectrx");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   mutt_extract_token(&templ, s, 0);
 
   if (mutt_replacelist_add(list, buf->data, templ.data, err) != 0)
   {
     FREE(&templ.data);
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   FREE(&templ.data);
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -610,10 +609,10 @@ static int parse_replace_list(struct Buffer *buf, struct Buffer *s,
  * @param s    Buffer containing the unattachments command
  * @param head List of AttachMatch to remove from
  * @param err  Buffer for error messages
- * @retval 0 Always
+ * @retval MUTT_CMD_SUCCESS Always
  */
-static int parse_unattach_list(struct Buffer *buf, struct Buffer *s,
-                               struct ListHead *head, struct Buffer *err)
+static enum CommandResult parse_unattach_list(struct Buffer *buf, struct Buffer *s,
+                                              struct ListHead *head, struct Buffer *err)
 {
   struct AttachMatch *a = NULL;
   char *tmp = NULL;
@@ -664,14 +663,14 @@ static int parse_unattach_list(struct Buffer *buf, struct Buffer *s,
 
   FREE(&tmp);
   attachments_clean();
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_unreplace_list - Remove a string replacement rule - Implements ::command_t
  */
-static int parse_unreplace_list(struct Buffer *buf, struct Buffer *s,
-                                unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unreplace_list(struct Buffer *buf, struct Buffer *s,
+                                               unsigned long data, struct Buffer *err)
 {
   struct ReplaceList *list = (struct ReplaceList *) data;
 
@@ -679,7 +678,7 @@ static int parse_unreplace_list(struct Buffer *buf, struct Buffer *s,
   if (!MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too few arguments"), "unsubjectrx");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   mutt_extract_token(buf, s, 0);
@@ -688,11 +687,11 @@ static int parse_unreplace_list(struct Buffer *buf, struct Buffer *s,
   if (mutt_str_strcmp(buf->data, "*") == 0)
   {
     mutt_replacelist_free(list);
-    return 0;
+    return MUTT_CMD_SUCCESS;
   }
 
   mutt_replacelist_remove(list, buf->data);
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -751,7 +750,8 @@ static void remove_from_stailq(struct ListHead *head, const char *str)
 static int source_rc(const char *rcfile_path, struct Buffer *err)
 {
   FILE *f = NULL;
-  int line = 0, rc = 0, line_rc, warnings = 0;
+  int line = 0, rc = 0, warnings = 0;
+  enum CommandResult line_rc;
   struct Buffer token;
   char *linebuf = NULL;
   char *currentline = NULL;
@@ -821,7 +821,7 @@ static int source_rc(const char *rcfile_path, struct Buffer *err)
       currentline = linebuf;
     mutt_buffer_reset(err);
     line_rc = mutt_parse_rc_line(currentline, &token, err);
-    if (line_rc == -1)
+    if (line_rc == MUTT_CMD_ERROR)
     {
       mutt_error(_("Error in %s, line %d: %s"), rcfile, line, err->data);
       if (--rc < -MAXERRS)
@@ -831,13 +831,13 @@ static int source_rc(const char *rcfile_path, struct Buffer *err)
         break;
       }
     }
-    else if (line_rc == -2)
+    else if (line_rc == MUTT_CMD_WARNING)
     {
       /* Warning */
-      mutt_error(_("Warning in %s, line %d: %s"), rcfile, line, err->data);
+      mutt_warning(_("Warning in %s, line %d: %s"), rcfile, line, err->data);
       warnings++;
     }
-    else if (line_rc == 1)
+    else if (line_rc == MUTT_CMD_FINISH)
     {
       break; /* Found "finish" command */
     }
@@ -887,8 +887,8 @@ static int source_rc(const char *rcfile_path, struct Buffer *err)
 /**
  * parse_alias - Parse the 'alias' command - Implements ::command_t
  */
-static int parse_alias(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                       struct Buffer *err)
+static enum CommandResult parse_alias(struct Buffer *buf, struct Buffer *s,
+                                      unsigned long data, struct Buffer *err)
 {
   struct Alias *tmp = NULL;
   char *estr = NULL;
@@ -897,13 +897,13 @@ static int parse_alias(struct Buffer *buf, struct Buffer *s, unsigned long data,
   if (!MoreArgs(s))
   {
     mutt_buffer_strcpy(err, _("alias: no address"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   mutt_extract_token(buf, s, 0);
 
   if (parse_grouplist(&gc, buf, s, data, err) == -1)
-    return -1;
+    return MUTT_CMD_ERROR;
 
   /* check to see if an alias with this name already exists */
   TAILQ_FOREACH(tmp, &Aliases, entries)
@@ -958,18 +958,18 @@ static int parse_alias(struct Buffer *buf, struct Buffer *s, unsigned long data,
     }
   }
   mutt_grouplist_destroy(&gc);
-  return 0;
+  return MUTT_CMD_SUCCESS;
 
 bail:
   mutt_grouplist_destroy(&gc);
-  return -1;
+  return MUTT_CMD_ERROR;
 }
 
 /**
  * parse_alternates - Parse the 'alternates' command - Implements ::command_t
  */
-static int parse_alternates(struct Buffer *buf, struct Buffer *s,
-                            unsigned long data, struct Buffer *err)
+static enum CommandResult parse_alternates(struct Buffer *buf, struct Buffer *s,
+                                           unsigned long data, struct Buffer *err)
 {
   struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
 
@@ -992,18 +992,18 @@ static int parse_alternates(struct Buffer *buf, struct Buffer *s,
   } while (MoreArgs(s));
 
   mutt_grouplist_destroy(&gc);
-  return 0;
+  return MUTT_CMD_SUCCESS;
 
 bail:
   mutt_grouplist_destroy(&gc);
-  return -1;
+  return MUTT_CMD_ERROR;
 }
 
 /**
  * parse_attachments - Parse the 'attachments' command - Implements ::command_t
  */
-static int parse_attachments(struct Buffer *buf, struct Buffer *s,
-                             unsigned long data, struct Buffer *err)
+static enum CommandResult parse_attachments(struct Buffer *buf, struct Buffer *s,
+                                            unsigned long data, struct Buffer *err)
 {
   char op, *category = NULL;
   struct ListHead *head = NULL;
@@ -1012,7 +1012,7 @@ static int parse_attachments(struct Buffer *buf, struct Buffer *s,
   if (!buf->data || *buf->data == '\0')
   {
     mutt_buffer_strcpy(err, _("attachments: no disposition"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   category = buf->data;
@@ -1028,7 +1028,7 @@ static int parse_attachments(struct Buffer *buf, struct Buffer *s,
     print_attach_list(&InlineAllow, '+', "I");
     print_attach_list(&InlineExclude, '-', "I");
     mutt_any_key_to_continue(NULL);
-    return 0;
+    return MUTT_CMD_SUCCESS;
   }
 
   if (op != '+' && op != '-')
@@ -1053,7 +1053,7 @@ static int parse_attachments(struct Buffer *buf, struct Buffer *s,
   else
   {
     mutt_buffer_strcpy(err, _("attachments: invalid disposition"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   return parse_attach_list(buf, s, head, err);
@@ -1062,13 +1062,13 @@ static int parse_attachments(struct Buffer *buf, struct Buffer *s,
 /**
  * parse_echo - Parse the 'echo' command - Implements ::command_t
  */
-static int parse_echo(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                      struct Buffer *err)
+static enum CommandResult parse_echo(struct Buffer *buf, struct Buffer *s,
+                                     unsigned long data, struct Buffer *err)
 {
   if (!MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too few arguments"), "echo");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   mutt_extract_token(buf, s, 0);
   OptForceRefresh = true;
@@ -1076,33 +1076,33 @@ static int parse_echo(struct Buffer *buf, struct Buffer *s, unsigned long data,
   OptForceRefresh = false;
   mutt_sleep(0);
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_finish - Parse the 'finish' command - Implements ::command_t
- * @retval  1 Stop processing the current file
- * @retval -1 Failed
+ * @retval  MUTT_CMD_FINISH Stop processing the current file
+ * @retval  MUTT_CMD_ERROR Failed
  *
  * If the 'finish' command is found, we should stop reading the current file.
  */
-static int parse_finish(struct Buffer *buf, struct Buffer *s,
-                        unsigned long data, struct Buffer *err)
+static enum CommandResult parse_finish(struct Buffer *buf, struct Buffer *s,
+                                       unsigned long data, struct Buffer *err)
 {
   if (MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too many arguments"), "finish");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
-  return 1;
+  return MUTT_CMD_FINISH;
 }
 
 /**
  * parse_group - Parse the 'group' and 'ungroup' commands - Implements ::command_t
  */
-static int parse_group(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                       struct Buffer *err)
+static enum CommandResult parse_group(struct Buffer *buf, struct Buffer *s,
+                                      unsigned long data, struct Buffer *err)
 {
   struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
   enum GroupState state = GS_NONE;
@@ -1170,11 +1170,11 @@ static int parse_group(struct Buffer *buf, struct Buffer *s, unsigned long data,
 
 out:
   mutt_grouplist_destroy(&gc);
-  return 0;
+  return MUTT_CMD_SUCCESS;
 
 bail:
   mutt_grouplist_destroy(&gc);
-  return -1;
+  return MUTT_CMD_ERROR;
 }
 
 /**
@@ -1190,8 +1190,8 @@ bail:
  * e.g.
  *      ifndef imap finish
  */
-static int parse_ifdef(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                       struct Buffer *err)
+static enum CommandResult parse_ifdef(struct Buffer *buf, struct Buffer *s,
+                                      unsigned long data, struct Buffer *err)
 {
   struct Buffer token = { 0 };
 
@@ -1249,31 +1249,31 @@ static int parse_ifdef(struct Buffer *buf, struct Buffer *s, unsigned long data,
   if (!MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too few arguments"), (data ? "ifndef" : "ifdef"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   mutt_extract_token(buf, s, MUTT_TOKEN_SPACE);
 
   /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
   if ((res && (data == 0)) || (!res && (data == 1)))
   {
-    int rc = mutt_parse_rc_line(buf->data, &token, err);
-    if (rc == -1)
+    enum CommandResult rc = mutt_parse_rc_line(buf->data, &token, err);
+    if (rc == MUTT_CMD_ERROR)
     {
       mutt_error(_("Error: %s"), err->data);
       FREE(&token.data);
-      return -1;
+      return MUTT_CMD_ERROR;
     }
     FREE(&token.data);
     return rc;
   }
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_ignore - Parse the 'ignore' command - Implements ::command_t
  */
-static int parse_ignore(struct Buffer *buf, struct Buffer *s,
-                        unsigned long data, struct Buffer *err)
+static enum CommandResult parse_ignore(struct Buffer *buf, struct Buffer *s,
+                                       unsigned long data, struct Buffer *err)
 {
   do
   {
@@ -1282,14 +1282,14 @@ static int parse_ignore(struct Buffer *buf, struct Buffer *s,
     add_to_stailq(&Ignore, buf->data);
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_lists - Parse the 'lists' command - Implements ::command_t
  */
-static int parse_lists(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                       struct Buffer *err)
+static enum CommandResult parse_lists(struct Buffer *buf, struct Buffer *s,
+                                      unsigned long data, struct Buffer *err)
 {
   struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
 
@@ -1310,18 +1310,18 @@ static int parse_lists(struct Buffer *buf, struct Buffer *s, unsigned long data,
   } while (MoreArgs(s));
 
   mutt_grouplist_destroy(&gc);
-  return 0;
+  return MUTT_CMD_SUCCESS;
 
 bail:
   mutt_grouplist_destroy(&gc);
-  return -1;
+  return MUTT_CMD_ERROR;
 }
 
 /**
  * parse_my_hdr - Parse the 'my_hdr' command - Implements ::command_t
  */
-static int parse_my_hdr(struct Buffer *buf, struct Buffer *s,
-                        unsigned long data, struct Buffer *err)
+static enum CommandResult parse_my_hdr(struct Buffer *buf, struct Buffer *s,
+                                       unsigned long data, struct Buffer *err)
 {
   struct ListNode *n = NULL;
   size_t keylen;
@@ -1331,7 +1331,7 @@ static int parse_my_hdr(struct Buffer *buf, struct Buffer *s,
   if (!p || (*p != ':'))
   {
     mutt_buffer_strcpy(err, _("invalid header field"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   keylen = p - buf->data + 1;
 
@@ -1358,15 +1358,15 @@ static int parse_my_hdr(struct Buffer *buf, struct Buffer *s,
   n->data = buf->data;
   mutt_buffer_init(buf);
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 #ifdef USE_SIDEBAR
 /**
  * parse_path_list - Parse the 'sidebar_whitelist' command - Implements ::command_t
  */
-static int parse_path_list(struct Buffer *buf, struct Buffer *s,
-                           unsigned long data, struct Buffer *err)
+static enum CommandResult parse_path_list(struct Buffer *buf, struct Buffer *s,
+                                          unsigned long data, struct Buffer *err)
 {
   char path[PATH_MAX];
 
@@ -1378,7 +1378,7 @@ static int parse_path_list(struct Buffer *buf, struct Buffer *s,
     add_to_stailq((struct ListHead *) data, path);
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 #endif
 
@@ -1386,8 +1386,8 @@ static int parse_path_list(struct Buffer *buf, struct Buffer *s,
 /**
  * parse_path_unlist - Parse the 'unsidebar_whitelist' command - Implements ::command_t
  */
-static int parse_path_unlist(struct Buffer *buf, struct Buffer *s,
-                             unsigned long data, struct Buffer *err)
+static enum CommandResult parse_path_unlist(struct Buffer *buf, struct Buffer *s,
+                                            unsigned long data, struct Buffer *err)
 {
   char path[PATH_MAX];
 
@@ -1405,7 +1405,7 @@ static int parse_path_unlist(struct Buffer *buf, struct Buffer *s,
     remove_from_stailq((struct ListHead *) data, path);
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 #endif
 
@@ -1414,8 +1414,8 @@ static int parse_path_unlist(struct Buffer *buf, struct Buffer *s,
  *
  * This is used by 'reset', 'set', 'toggle' and 'unset'.
  */
-static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                     struct Buffer *err)
+static enum CommandResult parse_set(struct Buffer *buf, struct Buffer *s,
+                                    unsigned long data, struct Buffer *err)
 {
   /* The order must match `enum MuttSetCommand` */
   static const char *set_commands[] = { "set", "toggle", "unset", "reset" };
@@ -1459,7 +1459,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
     {
       mutt_buffer_printf(err, "ERR22 cannot use 'inv', 'no', '&' or '?' with the '%s' command",
                          set_commands[data]);
-      return -1;
+      return MUTT_CMD_ERROR;
     }
 
     /* get the variable name */
@@ -1479,7 +1479,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
         {
           struct HashElem **list = get_elem_list(Config);
           if (!list)
-            return -1;
+            return MUTT_CMD_ERROR;
 
           for (size_t i = 0; list[i]; i++)
             cs_he_reset(Config, list[i], NULL);
@@ -1490,7 +1490,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
         else
         {
           mutt_buffer_printf(err, "ERR01 unknown variable: %s", buf->data);
-          return -1;
+          return MUTT_CMD_ERROR;
         }
       }
 
@@ -1503,14 +1503,14 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
       {
         mutt_buffer_printf(
             err, "ERR02 cannot use a prefix when querying a variable");
-        return -1;
+        return MUTT_CMD_ERROR;
       }
 
       if (reset || unset || inv)
       {
         mutt_buffer_printf(err, "ERR03 cannot query a variable with the '%s' command",
                            set_commands[data]);
-        return -1;
+        return MUTT_CMD_ERROR;
       }
 
       query = true;
@@ -1522,14 +1522,14 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
       {
         mutt_buffer_printf(err,
                            "ERR04 cannot use prefix when setting a variable");
-        return -1;
+        return MUTT_CMD_ERROR;
       }
 
       if (reset || unset || inv)
       {
         mutt_buffer_printf(err, "ERR05 cannot set a variable with the '%s' command",
                            set_commands[data]);
-        return -1;
+        return MUTT_CMD_ERROR;
       }
 
       equals = true;
@@ -1548,7 +1548,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
         mutt_buffer_printf(err, "ERR07 command '%s' can only be used with bool/quad variables",
                            set_commands[data]);
       }
-      return -1;
+      return MUTT_CMD_ERROR;
     }
 
     if (reset)
@@ -1558,7 +1558,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
       {
         rc = cs_he_reset(Config, he, err);
         if (CSR_RESULT(rc) != CSR_SUCCESS)
-          return -1;
+          return MUTT_CMD_ERROR;
       }
       else
       {
@@ -1581,7 +1581,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
           if (CSR_RESULT(rc) != CSR_SUCCESS)
           {
             mutt_buffer_addstr(err, buf->data);
-            return -1;
+            return MUTT_CMD_ERROR;
           }
           pretty_var(buf->data, err);
         }
@@ -1597,7 +1597,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
           else
           {
             mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
-            return -1;
+            return MUTT_CMD_ERROR;
           }
         }
         break;
@@ -1657,7 +1657,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
 
           rc = cs_he_string_set(Config, he, buf->data, err);
           if (CSR_RESULT(rc) != CSR_SUCCESS)
-            return -1;
+            return MUTT_CMD_ERROR;
         }
         continue;
       }
@@ -1668,7 +1668,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
           // mutt_buffer_printf(err, "ACT23 set variable %s to 'yes'", buf->data);
           rc = cs_he_native_set(Config, he, true, err);
           if (CSR_RESULT(rc) != CSR_SUCCESS)
-            return -1;
+            return MUTT_CMD_ERROR;
           continue;
         }
         else
@@ -1683,7 +1683,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
             if (CSR_RESULT(rc) != CSR_SUCCESS)
             {
               mutt_buffer_addstr(err, buf->data);
-              return -1;
+              return MUTT_CMD_ERROR;
             }
             pretty_var(buf->data, err);
           }
@@ -1699,7 +1699,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
             else
             {
               mutt_buffer_printf(err, _("%s: unknown variable"), buf->data);
-              return -1;
+              return MUTT_CMD_ERROR;
             }
           }
           break;
@@ -1726,7 +1726,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
         // mutt_buffer_printf(err, "ACT26 UNSET bool/quad variable %s", buf->data);
         rc = cs_he_native_set(Config, he, false, err);
         if (CSR_RESULT(rc) != CSR_SUCCESS)
-          return -1;
+          return MUTT_CMD_ERROR;
       }
       continue;
     }
@@ -1734,18 +1734,18 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
     {
       rc = cs_he_string_set(Config, he, NULL, err);
       if (CSR_RESULT(rc) != CSR_SUCCESS)
-        return -1;
+        return MUTT_CMD_ERROR;
     }
   }
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_setenv - Parse the 'setenv' and 'unsetenv' commands - Implements ::command_t
  */
-static int parse_setenv(struct Buffer *buf, struct Buffer *s,
-                        unsigned long data, struct Buffer *err)
+static enum CommandResult parse_setenv(struct Buffer *buf, struct Buffer *s,
+                                       unsigned long data, struct Buffer *err)
 {
   char **envp = mutt_envlist_getlist();
 
@@ -1755,7 +1755,7 @@ static int parse_setenv(struct Buffer *buf, struct Buffer *s,
   if (!MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   if (*s->dptr == '?')
@@ -1788,18 +1788,18 @@ static int parse_setenv(struct Buffer *buf, struct Buffer *s,
     if (found)
     {
       mutt_any_key_to_continue(NULL);
-      return 0;
+      return MUTT_CMD_SUCCESS;
     }
 
     mutt_buffer_printf(err, _("%s is unset"), buf->data);
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   if (unset)
   {
     if (mutt_envlist_unset(buf->data))
-      return 0;
-    return -1;
+      return MUTT_CMD_SUCCESS;
+    return MUTT_CMD_ERROR;
   }
 
   /* set variable */
@@ -1813,7 +1813,7 @@ static int parse_setenv(struct Buffer *buf, struct Buffer *s,
   if (!MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too few arguments"), "setenv");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   char *name = mutt_str_strdup(buf->data);
@@ -1821,14 +1821,14 @@ static int parse_setenv(struct Buffer *buf, struct Buffer *s,
   mutt_envlist_set(name, buf->data, true);
   FREE(&name);
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_source - Parse the 'source' command - Implements ::command_t
  */
-static int parse_source(struct Buffer *buf, struct Buffer *s,
-                        unsigned long data, struct Buffer *err)
+static enum CommandResult parse_source(struct Buffer *buf, struct Buffer *s,
+                                       unsigned long data, struct Buffer *err)
 {
   char path[PATH_MAX];
 
@@ -1837,7 +1837,7 @@ static int parse_source(struct Buffer *buf, struct Buffer *s,
     if (mutt_extract_token(buf, s, 0) != 0)
     {
       mutt_buffer_printf(err, _("source: error at %s"), s->dptr);
-      return -1;
+      return MUTT_CMD_ERROR;
     }
     mutt_str_strfcpy(path, buf->data, sizeof(path));
     mutt_expand_path(path, sizeof(path));
@@ -1845,19 +1845,19 @@ static int parse_source(struct Buffer *buf, struct Buffer *s,
     if (source_rc(path, err) < 0)
     {
       mutt_buffer_printf(err, _("source: file %s could not be sourced"), path);
-      return -1;
+      return MUTT_CMD_ERROR;
     }
 
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_spam_list - Parse the 'spam' and 'nospam' commands - Implements ::command_t
  */
-static int parse_spam_list(struct Buffer *buf, struct Buffer *s,
-                           unsigned long data, struct Buffer *err)
+static enum CommandResult parse_spam_list(struct Buffer *buf, struct Buffer *s,
+                                          unsigned long data, struct Buffer *err)
 {
   struct Buffer templ;
 
@@ -1870,7 +1870,7 @@ static int parse_spam_list(struct Buffer *buf, struct Buffer *s,
       mutt_buffer_strcpy(err, _("spam: no matching pattern"));
     else
       mutt_buffer_strcpy(err, _("nospam: no matching pattern"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   /* Extract the first token, a regex */
@@ -1888,7 +1888,7 @@ static int parse_spam_list(struct Buffer *buf, struct Buffer *s,
       if (mutt_replacelist_add(&SpamList, buf->data, templ.data, err) != 0)
       {
         FREE(&templ.data);
-        return -1;
+        return MUTT_CMD_ERROR;
       }
       FREE(&templ.data);
     }
@@ -1898,7 +1898,7 @@ static int parse_spam_list(struct Buffer *buf, struct Buffer *s,
       mutt_regexlist_remove(&NoSpamList, buf->data);
     }
 
-    return 0;
+    return MUTT_CMD_SUCCESS;
   }
   /* MUTT_NOSPAM is for nospam commands. */
   else if (data == MUTT_NOSPAM)
@@ -1910,23 +1910,23 @@ static int parse_spam_list(struct Buffer *buf, struct Buffer *s,
     {
       mutt_replacelist_free(&SpamList);
       mutt_regexlist_free(&NoSpamList);
-      return 0;
+      return MUTT_CMD_SUCCESS;
     }
 
     /* If it's on the spam list, just remove it. */
     if (mutt_replacelist_remove(&SpamList, buf->data) != 0)
-      return 0;
+      return MUTT_CMD_SUCCESS;
 
     /* Otherwise, add it to the nospam list. */
     if (mutt_regexlist_add(&NoSpamList, buf->data, REG_ICASE, err) != 0)
-      return -1;
+      return MUTT_CMD_ERROR;
 
-    return 0;
+    return MUTT_CMD_SUCCESS;
   }
 
   /* This should not happen. */
   mutt_buffer_strcpy(err, "This is no good at all.");
-  return -1;
+  return MUTT_CMD_ERROR;
 }
 
 /**
@@ -1934,8 +1934,8 @@ static int parse_spam_list(struct Buffer *buf, struct Buffer *s,
  *
  * This is used by 'alternative_order', 'auto_view' and several others.
  */
-static int parse_stailq(struct Buffer *buf, struct Buffer *s,
-                        unsigned long data, struct Buffer *err)
+static enum CommandResult parse_stailq(struct Buffer *buf, struct Buffer *s,
+                                       unsigned long data, struct Buffer *err)
 {
   do
   {
@@ -1943,19 +1943,19 @@ static int parse_stailq(struct Buffer *buf, struct Buffer *s,
     add_to_stailq((struct ListHead *) data, buf->data);
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_subjectrx_list - Parse the 'subjectrx' command - Implements ::command_t
  */
-static int parse_subjectrx_list(struct Buffer *buf, struct Buffer *s,
-                                unsigned long data, struct Buffer *err)
+static enum CommandResult parse_subjectrx_list(struct Buffer *buf, struct Buffer *s,
+                                               unsigned long data, struct Buffer *err)
 {
-  int rc;
+  enum CommandResult rc;
 
   rc = parse_replace_list(buf, s, data, err);
-  if (rc == 0)
+  if (rc == MUTT_CMD_SUCCESS)
     clear_subject_mods();
   return rc;
 }
@@ -1963,8 +1963,8 @@ static int parse_subjectrx_list(struct Buffer *buf, struct Buffer *s,
 /**
  * parse_subscribe - Parse the 'subscribe' command - Implements ::command_t
  */
-static int parse_subscribe(struct Buffer *buf, struct Buffer *s,
-                           unsigned long data, struct Buffer *err)
+static enum CommandResult parse_subscribe(struct Buffer *buf, struct Buffer *s,
+                                          unsigned long data, struct Buffer *err)
 {
   struct GroupList gc = STAILQ_HEAD_INITIALIZER(gc);
 
@@ -1987,11 +1987,11 @@ static int parse_subscribe(struct Buffer *buf, struct Buffer *s,
   } while (MoreArgs(s));
 
   mutt_grouplist_destroy(&gc);
-  return 0;
+  return MUTT_CMD_SUCCESS;
 
 bail:
   mutt_grouplist_destroy(&gc);
-  return -1;
+  return MUTT_CMD_ERROR;
 }
 
 #ifdef USE_IMAP
@@ -2002,11 +2002,11 @@ bail:
  * Patterns are not supported.
  * Use it as follows: subscribe-to =folder
  */
-static int parse_subscribe_to(struct Buffer *buf, struct Buffer *s,
-                              unsigned long data, struct Buffer *err)
+static enum CommandResult parse_subscribe_to(struct Buffer *buf, struct Buffer *s,
+                                             unsigned long data, struct Buffer *err)
 {
   if (!buf || !s || !err)
-    return -1;
+    return MUTT_CMD_ERROR;
 
   mutt_buffer_reset(err);
 
@@ -2017,7 +2017,7 @@ static int parse_subscribe_to(struct Buffer *buf, struct Buffer *s,
     if (MoreArgs(s))
     {
       mutt_buffer_printf(err, _("%s: too many arguments"), "subscribe-to");
-      return -1;
+      return MUTT_CMD_ERROR;
     }
 
     if (buf->data && *buf->data)
@@ -2026,34 +2026,34 @@ static int parse_subscribe_to(struct Buffer *buf, struct Buffer *s,
       if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), true) != 0)
       {
         mutt_buffer_printf(err, _("Could not subscribe to %s"), buf->data);
-        return -1;
+        return MUTT_CMD_ERROR;
       }
       else
       {
         mutt_message(_("Subscribed to %s"), buf->data);
-        return 0;
+        return MUTT_CMD_SUCCESS;
       }
     }
     else
     {
       mutt_debug(5, "Corrupted buffer");
-      return -1;
+      return MUTT_CMD_ERROR;
     }
   }
 
   mutt_buffer_addstr(err, _("No folder specified"));
-  return -1;
+  return MUTT_CMD_ERROR;
 }
 #endif
 
 /**
  * parse_tag_formats - Parse the 'tag-formats' command - Implements ::command_t
  */
-static int parse_tag_formats(struct Buffer *buf, struct Buffer *s,
-                             unsigned long data, struct Buffer *err)
+static enum CommandResult parse_tag_formats(struct Buffer *buf, struct Buffer *s,
+                                            unsigned long data, struct Buffer *err)
 {
   if (!buf || !s)
-    return -1;
+    return MUTT_CMD_ERROR;
 
   char *tmp = NULL;
 
@@ -2082,17 +2082,17 @@ static int parse_tag_formats(struct Buffer *buf, struct Buffer *s,
 
     mutt_hash_insert(TagFormats, format, tag);
   }
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_tag_transforms - Parse the 'tag-transforms' command - Implements ::command_t
  */
-static int parse_tag_transforms(struct Buffer *buf, struct Buffer *s,
-                                unsigned long data, struct Buffer *err)
+static enum CommandResult parse_tag_transforms(struct Buffer *buf, struct Buffer *s,
+                                               unsigned long data, struct Buffer *err)
 {
   if (!buf || !s)
-    return -1;
+    return MUTT_CMD_ERROR;
 
   char *tmp = NULL;
 
@@ -2121,14 +2121,14 @@ static int parse_tag_transforms(struct Buffer *buf, struct Buffer *s,
 
     mutt_hash_insert(TagTransforms, tag, transform);
   }
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_unalias - Parse the 'unalias' command - Implements ::command_t
  */
-static int parse_unalias(struct Buffer *buf, struct Buffer *s,
-                         unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unalias(struct Buffer *buf, struct Buffer *s,
+                                        unsigned long data, struct Buffer *err)
 {
   struct Alias *a = NULL;
 
@@ -2171,14 +2171,14 @@ static int parse_unalias(struct Buffer *buf, struct Buffer *s,
       }
     }
   } while (MoreArgs(s));
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_unalternates - Parse the 'unalternates' command - Implements ::command_t
  */
-static int parse_unalternates(struct Buffer *buf, struct Buffer *s,
-                              unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unalternates(struct Buffer *buf, struct Buffer *s,
+                                             unsigned long data, struct Buffer *err)
 {
   alternates_clean();
   do
@@ -2189,19 +2189,19 @@ static int parse_unalternates(struct Buffer *buf, struct Buffer *s,
     if ((mutt_str_strcmp(buf->data, "*") != 0) &&
         mutt_regexlist_add(&UnAlternates, buf->data, REG_ICASE, err) != 0)
     {
-      return -1;
+      return MUTT_CMD_ERROR;
     }
 
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_unattachments - Parse the 'unattachments' command - Implements ::command_t
  */
-static int parse_unattachments(struct Buffer *buf, struct Buffer *s,
-                               unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unattachments(struct Buffer *buf, struct Buffer *s,
+                                              unsigned long data, struct Buffer *err)
 {
   char op, *p = NULL;
   struct ListHead *head = NULL;
@@ -2210,7 +2210,7 @@ static int parse_unattachments(struct Buffer *buf, struct Buffer *s,
   if (!buf->data || *buf->data == '\0')
   {
     mutt_buffer_strcpy(err, _("unattachments: no disposition"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   p = buf->data;
@@ -2237,7 +2237,7 @@ static int parse_unattachments(struct Buffer *buf, struct Buffer *s,
   else
   {
     mutt_buffer_strcpy(err, _("unattachments: invalid disposition"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   return parse_unattach_list(buf, s, head, err);
@@ -2246,8 +2246,8 @@ static int parse_unattachments(struct Buffer *buf, struct Buffer *s,
 /**
  * parse_unignore - Parse the 'unignore' command - Implements ::command_t
  */
-static int parse_unignore(struct Buffer *buf, struct Buffer *s,
-                          unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unignore(struct Buffer *buf, struct Buffer *s,
+                                         unsigned long data, struct Buffer *err)
 {
   do
   {
@@ -2260,14 +2260,14 @@ static int parse_unignore(struct Buffer *buf, struct Buffer *s,
     remove_from_stailq(&Ignore, buf->data);
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_unlists - Parse the 'unlists' command - Implements ::command_t
  */
-static int parse_unlists(struct Buffer *buf, struct Buffer *s,
-                         unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unlists(struct Buffer *buf, struct Buffer *s,
+                                        unsigned long data, struct Buffer *err)
 {
   mutt_hash_free(&AutoSubscribeCache);
   do
@@ -2279,18 +2279,18 @@ static int parse_unlists(struct Buffer *buf, struct Buffer *s,
     if ((mutt_str_strcmp(buf->data, "*") != 0) &&
         mutt_regexlist_add(&UnMailLists, buf->data, REG_ICASE, err) != 0)
     {
-      return -1;
+      return MUTT_CMD_ERROR;
     }
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_unmy_hdr - Parse the 'unmy_hdr' command - Implements ::command_t
  */
-static int parse_unmy_hdr(struct Buffer *buf, struct Buffer *s,
-                          unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unmy_hdr(struct Buffer *buf, struct Buffer *s,
+                                         unsigned long data, struct Buffer *err)
 {
   struct ListNode *np, *tmp;
   size_t l;
@@ -2318,7 +2318,7 @@ static int parse_unmy_hdr(struct Buffer *buf, struct Buffer *s,
       }
     }
   } while (MoreArgs(s));
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -2326,8 +2326,8 @@ static int parse_unmy_hdr(struct Buffer *buf, struct Buffer *s,
  *
  * This is used by 'unalternative_order', 'unauto_view' and several others.
  */
-static int parse_unstailq(struct Buffer *buf, struct Buffer *s,
-                          unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unstailq(struct Buffer *buf, struct Buffer *s,
+                                         unsigned long data, struct Buffer *err)
 {
   do
   {
@@ -2341,19 +2341,19 @@ static int parse_unstailq(struct Buffer *buf, struct Buffer *s,
     remove_from_stailq((struct ListHead *) data, buf->data);
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * parse_unsubjectrx_list - Parse the 'unsubjectrx' command - Implements ::command_t
  */
-static int parse_unsubjectrx_list(struct Buffer *buf, struct Buffer *s,
-                                  unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unsubjectrx_list(struct Buffer *buf, struct Buffer *s,
+                                                 unsigned long data, struct Buffer *err)
 {
-  int rc;
+  enum CommandResult rc;
 
   rc = parse_unreplace_list(buf, s, data, err);
-  if (rc == 0)
+  if (rc == MUTT_CMD_SUCCESS)
     clear_subject_mods();
   return rc;
 }
@@ -2361,8 +2361,8 @@ static int parse_unsubjectrx_list(struct Buffer *buf, struct Buffer *s,
 /**
  * parse_unsubscribe - Parse the 'unsubscribe' command - Implements ::command_t
  */
-static int parse_unsubscribe(struct Buffer *buf, struct Buffer *s,
-                             unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unsubscribe(struct Buffer *buf, struct Buffer *s,
+                                            unsigned long data, struct Buffer *err)
 {
   mutt_hash_free(&AutoSubscribeCache);
   do
@@ -2373,11 +2373,11 @@ static int parse_unsubscribe(struct Buffer *buf, struct Buffer *s,
     if ((mutt_str_strcmp(buf->data, "*") != 0) &&
         mutt_regexlist_add(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0)
     {
-      return -1;
+      return MUTT_CMD_ERROR;
     }
   } while (MoreArgs(s));
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 #ifdef USE_IMAP
@@ -2388,11 +2388,11 @@ static int parse_unsubscribe(struct Buffer *buf, struct Buffer *s,
  * Patterns are not supported.
  * Use it as follows: unsubscribe-from =folder
  */
-static int parse_unsubscribe_from(struct Buffer *buf, struct Buffer *s,
-                                  unsigned long data, struct Buffer *err)
+static enum CommandResult parse_unsubscribe_from(struct Buffer *buf, struct Buffer *s,
+                                                 unsigned long data, struct Buffer *err)
 {
   if (!buf || !s || !err)
-    return -1;
+    return MUTT_CMD_ERROR;
 
   if (MoreArgs(s))
   {
@@ -2401,7 +2401,7 @@ static int parse_unsubscribe_from(struct Buffer *buf, struct Buffer *s,
     if (MoreArgs(s))
     {
       mutt_buffer_printf(err, _("%s: too many arguments"), "unsubscribe-from");
-      return -1;
+      return MUTT_CMD_ERROR;
     }
 
     if (buf->data && *buf->data)
@@ -2410,23 +2410,23 @@ static int parse_unsubscribe_from(struct Buffer *buf, struct Buffer *s,
       if (imap_subscribe(mutt_expand_path(buf->data, buf->dsize), false) != 0)
       {
         mutt_buffer_printf(err, _("Could not unsubscribe from %s"), buf->data);
-        return -1;
+        return MUTT_CMD_ERROR;
       }
       else
       {
         mutt_message(_("Unsubscribed from %s"), buf->data);
-        return 0;
+        return MUTT_CMD_SUCCESS;
       }
     }
     else
     {
       mutt_debug(5, "Corrupted buffer");
-      return -1;
+      return MUTT_CMD_ERROR;
     }
   }
 
   mutt_buffer_addstr(err, _("No folder specified"));
-  return -1;
+  return MUTT_CMD_ERROR;
 }
 #endif
 
@@ -2490,7 +2490,7 @@ int mutt_dump_variables(bool hide_sensitive)
       continue;
     }
     snprintf(command, sizeof(command), "set ?%s\n", MuttVars[i].name);
-    if (mutt_parse_rc_line(command, &token, &err) == -1)
+    if (mutt_parse_rc_line(command, &token, &err) == MUTT_CMD_ERROR)
     {
       mutt_message("%s", err.data);
       FREE(&token.data);
@@ -2844,7 +2844,7 @@ int mutt_get_hook_type(const char *name)
   for (const struct Command *c = Commands; c->name; c++)
     if (c->func == mutt_parse_hook && (mutt_str_strcasecmp(c->name, name) == 0))
       return c->data;
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -3106,17 +3106,18 @@ int mutt_init(bool skip_sys_rc, struct ListHead *commands)
  * @param line  config line to read
  * @param token scratch buffer to be used by parser
  * @param err   where to write error messages
- * @retval  0 Success
- * @retval -1 Failure
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  *
  * Caller should free token->data when finished.  the reason for this variable
  * is to avoid having to allocate and deallocate a lot of memory if we are
  * parsing many lines.  the caller can pass in the memory to use, which avoids
  * having to create new space for every call to this function.
  */
-int mutt_parse_rc_line(/* const */ char *line, struct Buffer *token, struct Buffer *err)
+enum CommandResult mutt_parse_rc_line(/* const */ char *line,
+                                      struct Buffer *token, struct Buffer *err)
 {
-  int i, r = 0;
+  int i;
+  enum CommandResult r = MUTT_CMD_SUCCESS;
   struct Buffer expn;
 
   if (!line || !*line)
@@ -3145,7 +3146,7 @@ int mutt_parse_rc_line(/* const */ char *line, struct Buffer *token, struct Buff
       if (mutt_str_strcmp(token->data, Commands[i].name) == 0)
       {
         r = Commands[i].func(token, &expn, Commands[i].data, err);
-        if (r != 0)
+        if (r != MUTT_CMD_SUCCESS)
         {              /* -1 Error, +1 Finish */
           goto finish; /* Propagate return code */
         }
@@ -3155,7 +3156,7 @@ int mutt_parse_rc_line(/* const */ char *line, struct Buffer *token, struct Buff
     if (!Commands[i].name)
     {
       mutt_buffer_printf(err, _("%s: unknown command"), NONULL(token->data));
-      r = -1;
+      r = MUTT_CMD_ERROR;
       break; /* Ignore the rest of the line */
     }
   }
diff --git a/init.h b/init.h
index f3210269eeeb94c45cdb603ab196e000202908fc..a3bf036ba7f164cc519dbde3c07f512ba79078be 100644 (file)
--- a/init.h
+++ b/init.h
@@ -4681,45 +4681,45 @@ struct ConfigDef MuttVars[] = {
 };
 
 /* functions used to parse commands in a rc file */
-static int parse_alias           (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_alternates      (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_attachments     (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_echo            (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_finish          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_group           (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_ifdef           (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_ignore          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_lists           (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_my_hdr          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_alias           (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_alternates      (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_attachments     (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_echo            (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_finish          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_group           (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_ifdef           (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_ignore          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_lists           (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_my_hdr          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 #ifdef USE_SIDEBAR
-static int parse_path_list       (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_path_unlist     (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_path_list       (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_path_unlist     (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 #endif
-static int parse_replace_list    (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_set             (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_setenv          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_source          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_spam_list       (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_stailq          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_subjectrx_list  (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_subscribe       (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_replace_list    (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_set             (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_setenv          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_source          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_spam_list       (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_stailq          (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_subjectrx_list  (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_subscribe       (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 #ifdef USE_IMAP
-static int parse_subscribe_to    (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_subscribe_to    (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 #endif
-static int parse_tag_formats     (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_tag_transforms  (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unalias         (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unalternates    (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unattachments   (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unignore        (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unlists         (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unmy_hdr        (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unreplace_list  (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unstailq        (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unsubjectrx_list(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-static int parse_unsubscribe     (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_tag_formats     (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_tag_transforms  (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unalias         (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unalternates    (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unattachments   (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unignore        (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unlists         (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unmy_hdr        (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unreplace_list  (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unstailq        (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unsubjectrx_list(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unsubscribe     (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 #ifdef USE_IMAP
-static int parse_unsubscribe_from(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+static enum CommandResult parse_unsubscribe_from(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 #endif
 
 const struct Command Commands[] = {
index fe8bd7b8216a546b3385881601819b03d811a3ce..6f2ee2ca3e94b2694079fa0f9a0d061d2b0ed7bb 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -40,6 +40,7 @@
 #include "curs_lib.h"
 #include "functions.h"
 #include "globals.h"
+#include "mutt_commands.h"
 #include "mutt_curses.h"
 #include "mutt_logging.h"
 #include "mutt_window.h"
@@ -278,16 +279,15 @@ static size_t parsekeys(const char *str, keycode_t *d, size_t max)
  * @param macro Macro string
  * @param desc Description of macro (OPTIONAL)
  * @param err   Buffer for error message
- * @retval  0 Success
- * @retval -2 Error
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  *
  * Insert a key sequence into the specified map.
  * The map is sorted by ASCII value (lowest to highest)
  */
-static int km_bind_err(const char *s, int menu, int op, char *macro, char *desc,
-                       struct Buffer *err)
+static enum CommandResult km_bind_err(const char *s, int menu, int op,
+                                      char *macro, char *desc, struct Buffer *err)
 {
-  int retval = 0;
+  enum CommandResult retval = MUTT_CMD_SUCCESS;
   struct Keymap *last = NULL, *next = NULL;
   keycode_t buf[MAX_SEQ];
   size_t pos = 0, lastpos = 0;
@@ -335,7 +335,7 @@ static int km_bind_err(const char *s, int menu, int op, char *macro, char *desc,
                   "https://neomutt.org/guide/configuration.html#bind-warnings"),
                 old_binding, new_binding, mutt_map_get_name(menu, Menus), new_binding);
           }
-          retval = -2;
+          retval = MUTT_CMD_WARNING;
         }
         len = tmp->eq;
         next = tmp->next;
@@ -387,10 +387,9 @@ static int km_bind_err(const char *s, int menu, int op, char *macro, char *desc,
  * @param op    Operation, e.g. OP_DELETE
  * @param macro Macro string
  * @param desc Description of macro (OPTIONAL)
- * @retval  0 Success
- * @retval -2 Error
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  */
-int km_bind(char *s, int menu, int op, char *macro, char *desc)
+enum CommandResult km_bind(char *s, int menu, int op, char *macro, char *desc)
 {
   return km_bind_err(s, menu, op, macro, desc, NULL);
 }
@@ -401,10 +400,9 @@ int km_bind(char *s, int menu, int op, char *macro, char *desc)
  * @param menu Menu id, e.g. #MENU_PAGER
  * @param op   Operation, e.g. OP_DELETE
  * @param err  Buffer for error message
- * @retval  0 Success
- * @retval -2 Error
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  */
-static int km_bindkey_err(const char *s, int menu, int op, struct Buffer *err)
+static enum CommandResult km_bindkey_err(const char *s, int menu, int op, struct Buffer *err)
 {
   return km_bind_err(s, menu, op, NULL, NULL, err);
 }
@@ -414,10 +412,9 @@ static int km_bindkey_err(const char *s, int menu, int op, struct Buffer *err)
  * @param s    Key string
  * @param menu Menu id, e.g. #MENU_PAGER
  * @param op   Operation, e.g. OP_DELETE
- * @retval  0 Success
- * @retval -2 Error
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  */
-static int km_bindkey(const char *s, int menu, int op)
+static enum CommandResult km_bindkey(const char *s, int menu, int op)
 {
   return km_bindkey_err(s, menu, op, NULL);
 }
@@ -1090,20 +1087,18 @@ void km_error_key(int menu)
 /**
  * mutt_parse_push - Parse the 'push' command - Implements ::command_t
  */
-int mutt_parse_push(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                    struct Buffer *err)
+enum CommandResult mutt_parse_push(struct Buffer *buf, struct Buffer *s,
+                                   unsigned long data, struct Buffer *err)
 {
-  int r = 0;
-
   mutt_extract_token(buf, s, MUTT_TOKEN_CONDENSE);
   if (MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too many arguments"), "push");
-    r = -1;
+    return MUTT_CMD_ERROR;
   }
-  else
-    generic_tokenize_push_string(buf->data, mutt_push_macro_event);
-  return r;
+
+  generic_tokenize_push_string(buf->data, mutt_push_macro_event);
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -1179,12 +1174,10 @@ error:
  * @param func     Function name
  * @param bindings Key bindings table
  * @param err      Buffer for error message
- * @retval  0 Success
- * @retval -1 Unknown function
- * @retval -2 Error
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  */
-static int try_bind(char *key, int menu, char *func,
-                    const struct Binding *bindings, struct Buffer *err)
+static enum CommandResult try_bind(char *key, int menu, char *func,
+                                   const struct Binding *bindings, struct Buffer *err)
 {
   for (int i = 0; bindings[i].name; i++)
   {
@@ -1198,7 +1191,7 @@ static int try_bind(char *key, int menu, char *func,
     mutt_buffer_printf(err, _("Function '%s' not available for menu '%s'"),
                        func, mutt_map_get_name(menu, Menus));
   }
-  return -1; /* Couldn't find an existing function with this name */
+  return MUTT_CMD_ERROR; /* Couldn't find an existing function with this name */
 }
 
 /**
@@ -1251,22 +1244,23 @@ const struct Binding *km_get_table(int menu)
  *
  * bind menu-name `<key_sequence>` function-name
  */
-int mutt_parse_bind(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                    struct Buffer *err)
+enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s,
+                                   unsigned long data, struct Buffer *err)
 {
   const struct Binding *bindings = NULL;
-  int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = 0, nummenus;
+  int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], nummenus;
+  enum CommandResult r = MUTT_CMD_SUCCESS;
 
   char *key = parse_keymap(menu, s, mutt_array_size(menu), &nummenus, err, true);
   if (!key)
-    return -1;
+    return MUTT_CMD_ERROR;
 
   /* function to execute */
   mutt_extract_token(buf, s, 0);
   if (MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too many arguments"), "bind");
-    r = -1;
+    r = MUTT_CMD_ERROR;
   }
   else if (mutt_str_strcasecmp("noop", buf->data) == 0)
   {
@@ -1308,15 +1302,16 @@ int mutt_parse_bind(struct Buffer *buf, struct Buffer *s, unsigned long data,
  *
  * macro `<menu>` `<key>` `<macro>` `<description>`
  */
-int mutt_parse_macro(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                     struct Buffer *err)
+enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s,
+                                    unsigned long data, struct Buffer *err)
 {
-  int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = -1, nummenus;
+  int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], nummenus;
+  enum CommandResult r = MUTT_CMD_ERROR;
   char *seq = NULL;
 
   char *key = parse_keymap(menu, s, mutt_array_size(menu), &nummenus, err, false);
   if (!key)
-    return -1;
+    return MUTT_CMD_ERROR;
 
   mutt_extract_token(buf, s, MUTT_TOKEN_CONDENSE);
   /* make sure the macro sequence is not an empty string */
@@ -1360,8 +1355,8 @@ int mutt_parse_macro(struct Buffer *buf, struct Buffer *s, unsigned long data,
 /**
  * mutt_parse_exec - Parse the 'exec' command - Implements ::command_t
  */
-int mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                    struct Buffer *err)
+enum CommandResult mutt_parse_exec(struct Buffer *buf, struct Buffer *s,
+                                   unsigned long data, struct Buffer *err)
 {
   int ops[128];
   int nops = 0;
@@ -1371,7 +1366,7 @@ int mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data,
   if (!MoreArgs(s))
   {
     mutt_buffer_strcpy(err, _("exec: no arguments"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   do
@@ -1391,7 +1386,7 @@ int mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data,
     {
       mutt_flushinp();
       mutt_error(_("%s: no such function"), function);
-      return -1;
+      return MUTT_CMD_ERROR;
     }
     nops++;
   } while (MoreArgs(s) && nops < mutt_array_size(ops));
@@ -1399,7 +1394,7 @@ int mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data,
   while (nops)
     mutt_push_macro_event(0, ops[--nops]);
 
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
index 2f419b17dcc0276818f7f8f0e737137853cece84..0ad4bf060715e072768155c181b12793da66138c 100644 (file)
--- a/keymap.h
+++ b/keymap.h
@@ -25,6 +25,7 @@
 
 #include <stddef.h>
 #include "mutt/mutt.h"
+#include "mutt_commands.h"
 
 /* maximal length of a key binding sequence used for buffer in km_bindkey */
 #define MAX_SEQ 8
@@ -32,7 +33,7 @@
 /* type for key storage, the rest of neomutt works fine with int type */
 typedef short keycode_t;
 
-int km_bind(char *s, int menu, int op, char *macro, char *desc);
+enum CommandResult km_bind(char *s, int menu, int op, char *macro, char *desc);
 int km_dokey(int menu);
 
 void init_extended_keys(void);
@@ -125,9 +126,9 @@ extern const struct Binding OpMix[];
 
 void mutt_free_keys(void);
 
-int mutt_parse_bind(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-int mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-int mutt_parse_macro(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-int mutt_parse_push(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_push(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 
 #endif /* MUTT_KEYMAP_H */
index f8b468d4414e37662f51a8a668bf20a5ab9830c7..98c27ca9728bf55b890506acecdef1bc1530acc7 100644 (file)
--- a/mailbox.c
+++ b/mailbox.c
@@ -47,6 +47,7 @@
 #include "globals.h"
 #include "maildir/lib.h"
 #include "mbox/mbox.h"
+#include "mutt_commands.h"
 #include "mutt_menu.h"
 #include "mutt_window.h"
 #include "muttlib.h"
@@ -332,8 +333,8 @@ void mutt_update_mailbox(struct Mailbox *m)
  *
  * This is also used by 'virtual-mailboxes'.
  */
-int mutt_parse_mailboxes(struct Buffer *buf, struct Buffer *s,
-                         unsigned long data, struct Buffer *err)
+enum CommandResult mutt_parse_mailboxes(struct Buffer *buf, struct Buffer *s,
+                                        unsigned long data, struct Buffer *err)
 {
   // char canon[PATH_MAX];
   // struct stat sb = { 0 };
@@ -481,7 +482,7 @@ int mutt_parse_mailboxes(struct Buffer *buf, struct Buffer *s,
     mutt_monitor_add(m);
 #endif
   }
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -489,8 +490,8 @@ int mutt_parse_mailboxes(struct Buffer *buf, struct Buffer *s,
  *
  * This is also used by 'unvirtual-mailboxes'
  */
-int mutt_parse_unmailboxes(struct Buffer *buf, struct Buffer *s,
-                           unsigned long data, struct Buffer *err)
+enum CommandResult mutt_parse_unmailboxes(struct Buffer *buf, struct Buffer *s,
+                                          unsigned long data, struct Buffer *err)
 {
   char tmp[PATH_MAX];
   bool tmp_valid = false;
@@ -551,7 +552,7 @@ int mutt_parse_unmailboxes(struct Buffer *buf, struct Buffer *s,
       }
     }
   }
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
index e2baddfd1e748c5c348d1391a387c94d6473a22a..498d25bb754439e1c883669e18cdafc302ddbf63 100644 (file)
--- a/mailbox.h
+++ b/mailbox.h
@@ -29,6 +29,7 @@
 #include <sys/types.h>
 #include <time.h>
 #include "mutt/mutt.h"
+#include "mutt_commands.h"
 #include "where.h"
 
 struct Buffer;
@@ -165,7 +166,7 @@ void mutt_mailbox(char *s, size_t slen);
 bool mutt_mailbox_list(void);
 int mutt_mailbox_check(int force);
 bool mutt_mailbox_notify(void);
-int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s, unsigned long data, struct Buffer *err);
-int mutt_parse_unmailboxes(struct Buffer *path, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_unmailboxes(struct Buffer *path, struct Buffer *s, unsigned long data, struct Buffer *err);
 
 #endif /* MUTT_MAILBOX_H */
diff --git a/main.c b/main.c
index 53cdb65b7b91529c6697c2b403cdc076c96183fb..1cf57b8ca0142bc03054d328dbcd66d1852f02e1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -151,7 +151,7 @@ static void test_parse_set(void)
 
         snprintf(line, sizeof(line), tests[t], commands[c], vars[v]);
         printf("%-26s", line);
-        int rc = mutt_parse_rc_line(line, tmp, err);
+        enum CommandResult rc = mutt_parse_rc_line(line, tmp, err);
         printf("%2d %s\n", rc, err->data);
       }
       printf("\n");
diff --git a/mutt.h b/mutt.h
index d2eb0886227209405ec8bd4d5b4a36f6b0a17d6d..fcce7a5c4389d3aafa163e7147c1d5725280792b 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -29,6 +29,7 @@
 #include <regex.h>
 #include <stdbool.h>
 #include <stdint.h>
+#include "mutt_commands.h"
 
 struct Buffer;
 struct ListHead;
@@ -220,7 +221,7 @@ bool mutt_nm_query_complete(char *buf, size_t buflen, int pos, int numtabs);
 bool mutt_nm_tag_complete(char *buf, size_t buflen, int numtabs);
 int mutt_dump_variables(bool hide_sensitive);
 int mutt_get_hook_type(const char *name);
-int mutt_parse_rc_line(/* const */ char *line, struct Buffer *token, struct Buffer *err);
+enum CommandResult mutt_parse_rc_line(/* const */ char *line, struct Buffer *token, struct Buffer *err);
 int mutt_query_variables(struct ListHead *queries);
 void reset_value(const char *name);
 
index ee35130e3f7ea7d1c89759cf860081d4aa610d86..3e39de2c6439706ee633b1ce587311c92c12962d 100644 (file)
 
 struct Buffer;
 
+/**
+ * enum CommandResult - Error codes for command_t parse functions
+ */
+enum CommandResult
+{
+  MUTT_CMD_ERROR   = -1, ///< Error: Can't help the user
+  MUTT_CMD_WARNING = -2, ///< Warning: Help given to the user
+  MUTT_CMD_SUCCESS =  0, ///< Success: Command worked
+  MUTT_CMD_FINISH  =  1  ///< Finish: Stop processing this file
+};
+
 /**
  * typedef command_t - Prototype for a function to parse a command
  * @param buf  Temporary Buffer space
  * @param s    Buffer containing string to be parsed
  * @param data Flags associated with the command
  * @param err  Buffer for error messages
- * @retval  0 Success
- * @retval -1 Error
- * @retval -2 Warning
+ * @retval enum e.g. #MUTT_CMD_SUCCESS
  */
-typedef int (*command_t)(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+typedef enum CommandResult (*command_t)(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 
 /**
  * struct Command - A user-callable command
index e3dbece078174a15255627573cb852d779e8be8d..fba9901683eb0c4440c2ad0345dd92587d19230f 100644 (file)
@@ -444,7 +444,8 @@ lua_State *Lua = NULL;
 /**
  * mutt_lua_parse - Parse the 'lua' command - Implements ::command_t
  */
-int mutt_lua_parse(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
+enum CommandResult mutt_lua_parse(struct Buffer *buf, struct Buffer *s,
+                                  unsigned long data, struct Buffer *err)
 {
   lua_init(&Lua);
   mutt_debug(2, " * mutt_lua_parse(%s)\n", buf->data);
@@ -455,17 +456,17 @@ int mutt_lua_parse(struct Buffer *buf, struct Buffer *s, unsigned long data, str
     mutt_buffer_printf(err, "%s: %s", s->dptr, lua_tostring(Lua, -1));
     /* pop error message from the stack */
     lua_pop(Lua, 1);
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   mutt_debug(2, " * %s -> success\n", s->dptr);
-  return 2;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
  * mutt_lua_source_file - Parse the 'lua-source' command - Implements ::command_t
  */
-int mutt_lua_source_file(struct Buffer *buf, struct Buffer *s,
-                         unsigned long data, struct Buffer *err)
+enum CommandResult mutt_lua_source_file(struct Buffer *buf, struct Buffer *s,
+                                        unsigned long data, struct Buffer *err)
 {
   mutt_debug(2, " * mutt_lua_source()\n");
 
@@ -476,12 +477,12 @@ int mutt_lua_source_file(struct Buffer *buf, struct Buffer *s,
   if (mutt_extract_token(buf, s, 0) != 0)
   {
     mutt_buffer_printf(err, _("source: error at %s"), s->dptr);
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   if (MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too many arguments"), "source");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   mutt_str_strfcpy(path, buf->data, sizeof(path));
   mutt_expand_path(path, sizeof(path));
@@ -490,7 +491,7 @@ int mutt_lua_source_file(struct Buffer *buf, struct Buffer *s,
   {
     mutt_error(_("Couldn't source lua source: %s"), lua_tostring(Lua, -1));
     lua_pop(Lua, 1);
-    return -1;
+    return MUTT_CMD_ERROR;
   }
-  return 2;
+  return MUTT_CMD_SUCCESS;
 }
index e47e599dba1e1706cd72efc5d35a77d6a406ecbc..4e2b4eb404dfac3253977df79086b17e558b5e81 100644 (file)
 #ifndef MUTT_MUTT_LUA_H
 #define MUTT_MUTT_LUA_H
 
+#include "mutt_commands.h"
+
 struct Buffer;
 
-int mutt_lua_parse(struct Buffer *tmp, struct Buffer *s, unsigned long data, struct Buffer *err);
-int mutt_lua_source_file(struct Buffer *tmp, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_lua_parse(struct Buffer *tmp, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_lua_source_file(struct Buffer *tmp, struct Buffer *s, unsigned long data, struct Buffer *err);
 
 #endif /* MUTT_MUTT_LUA_H */
diff --git a/score.c b/score.c
index 1692943214b6fcc9458a01edaceb1b5c9c9d6b86..217499bdcd0b84d847e9f95016e9109fd36d2354 100644 (file)
--- a/score.c
+++ b/score.c
@@ -38,6 +38,7 @@
 #include "globals.h"
 #include "keymap.h"
 #include "mailbox.h"
+#include "mutt_commands.h"
 #include "mutt_menu.h"
 #include "options.h"
 #include "pattern.h"
@@ -94,8 +95,8 @@ void mutt_check_rescore(struct Mailbox *m)
 /**
  * mutt_parse_score - Parse the 'score' command - Implements ::command_t
  */
-int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                     struct Buffer *err)
+enum CommandResult mutt_parse_score(struct Buffer *buf, struct Buffer *s,
+                                    unsigned long data, struct Buffer *err)
 {
   struct Score *ptr = NULL, *last = NULL;
   char *pattern = NULL, *pc = NULL;
@@ -105,7 +106,7 @@ int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data,
   if (!MoreArgs(s))
   {
     mutt_buffer_printf(err, _("%s: too few arguments"), "score");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   pattern = buf->data;
   mutt_buffer_init(buf);
@@ -114,7 +115,7 @@ int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data,
   {
     FREE(&pattern);
     mutt_buffer_printf(err, _("%s: too many arguments"), "score");
-    return -1;
+    return MUTT_CMD_ERROR;
   }
 
   /* look for an existing entry and update the value, else add it to the end
@@ -128,7 +129,7 @@ int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data,
     if (!pat)
     {
       FREE(&pattern);
-      return -1;
+      return MUTT_CMD_ERROR;
     }
     ptr = mutt_mem_calloc(1, sizeof(struct Score));
     if (last)
@@ -156,10 +157,10 @@ int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data,
   {
     FREE(&pattern);
     mutt_buffer_strcpy(err, _("Error: score: invalid number"));
-    return -1;
+    return MUTT_CMD_ERROR;
   }
   OptNeedRescore = true;
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
 
 /**
@@ -200,8 +201,8 @@ void mutt_score_message(struct Mailbox *m, struct Email *e, bool upd_mbox)
 /**
  * mutt_parse_unscore - Parse the 'unscore' command - Implements ::command_t
  */
-int mutt_parse_unscore(struct Buffer *buf, struct Buffer *s, unsigned long data,
-                       struct Buffer *err)
+enum CommandResult mutt_parse_unscore(struct Buffer *buf, struct Buffer *s,
+                                      unsigned long data, struct Buffer *err)
 {
   struct Score *tmp = NULL, *last = NULL;
 
@@ -238,5 +239,5 @@ int mutt_parse_unscore(struct Buffer *buf, struct Buffer *s, unsigned long data,
     }
   }
   OptNeedRescore = true;
-  return 0;
+  return MUTT_CMD_SUCCESS;
 }
diff --git a/score.h b/score.h
index 2f054cba700a22bc393478f42483f07a0ef9eace..92fa3d74370a2be45ee12335bacf1c0172c9a0f2 100644 (file)
--- a/score.h
+++ b/score.h
@@ -24,6 +24,7 @@
 #define MUTT_SCORE_H
 
 #include <stdbool.h>
+#include "mutt_commands.h"
 
 struct Buffer;
 struct Email;
@@ -35,8 +36,8 @@ extern short ScoreThresholdFlag;
 extern short ScoreThresholdRead;
 
 void mutt_check_rescore(struct Mailbox *m);
-int  mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-int  mutt_parse_unscore(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_unscore(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 void mutt_score_message(struct Mailbox *m, struct Email *e, bool upd_ctx);
 
 #endif /* MUTT_SCORE_H */