From: Richard Russon Date: Sun, 21 Apr 2019 23:40:14 +0000 (+0100) Subject: flags: clear up HookFlags usage X-Git-Tag: 2019-10-25~245^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02575848bfafa0e3cce536f2c330814773e9e51c;p=neomutt flags: clear up HookFlags usage --- diff --git a/hook.c b/hook.c index fdd880db6..90df28eb4 100644 --- a/hook.c +++ b/hook.c @@ -317,7 +317,7 @@ void mutt_delete_hooks(HookFlags type) TAILQ_FOREACH_SAFE(h, &Hooks, entries, tmp) { - if ((type == 0) || (type == h->type)) + if ((type == MUTT_HOOK_NO_FLAGS) || (type == h->type)) { TAILQ_REMOVE(&Hooks, h, entries); delete_hook(h); @@ -471,7 +471,7 @@ enum CommandResult mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS); if (mutt_str_strcmp("*", buf->data) == 0) { - if (current_hook_type) + if (current_hook_type != MUTT_TOKEN_NO_FLAGS) { mutt_buffer_printf(err, "%s", _("unhook: Can't do unhook * from within a hook")); return MUTT_CMD_WARNING; @@ -482,9 +482,9 @@ enum CommandResult mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, } else { - int type = mutt_get_hook_type(buf->data); + HookFlags type = mutt_get_hook_type(buf->data); - if (!type) + if (type == MUTT_HOOK_NO_FLAGS) { mutt_buffer_printf(err, _("unhook: unknown hook type: %s"), buf->data); return MUTT_CMD_ERROR; @@ -546,7 +546,7 @@ void mutt_folder_hook(const char *path, const char *desc) mutt_buffer_pool_release(&token); mutt_buffer_pool_release(&err); - current_hook_type = 0; + current_hook_type = MUTT_HOOK_NO_FLAGS; } /** @@ -601,7 +601,7 @@ void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type) { mutt_buffer_pool_release(&token); mutt_error("%s", mutt_b2s(err)); - current_hook_type = 0; + current_hook_type = MUTT_HOOK_NO_FLAGS; mutt_buffer_pool_release(&err); return; @@ -615,7 +615,7 @@ void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type) mutt_buffer_pool_release(&token); mutt_buffer_pool_release(&err); - current_hook_type = 0; + current_hook_type = MUTT_HOOK_NO_FLAGS; } /** diff --git a/init.c b/init.c index 8d87246b2..1694f0570 100644 --- a/init.c +++ b/init.c @@ -2969,10 +2969,10 @@ void mutt_free_opts(void) /** * mutt_get_hook_type - Find a hook by name * @param name Name to find - * @retval num Data associated with the hook - * @retval 0 Error, no matching hook + * @retval num Hook ID, e.g. #MUTT_FOLDER_HOOK + * @retval #MUTT_HOOK_NO_FLAGS Error, no matching hook */ -int mutt_get_hook_type(const char *name) +HookFlags mutt_get_hook_type(const char *name) { for (const struct Command *c = Commands; c->name; c++) { @@ -2982,7 +2982,7 @@ int mutt_get_hook_type(const char *name) return c->data; } } - return MUTT_CMD_SUCCESS; + return MUTT_HOOK_NO_FLAGS; } /** diff --git a/mutt.h b/mutt.h index a525dde90..ff8458556 100644 --- a/mutt.h +++ b/mutt.h @@ -30,6 +30,7 @@ #include #include #include "config/lib.h" +#include "hook.h" #include "mutt_commands.h" struct Buffer; @@ -146,7 +147,7 @@ void myvar_set(const char *var, const char *val); 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); +HookFlags mutt_get_hook_type(const char *name); 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);