*/
struct Hook
{
- int type; ///< Hook type
+ HookFlags type; ///< Hook type
struct Regex regex; ///< Regular expression
char *command; ///< Filename, command or pattern to execute
struct Pattern *pattern; ///< Used for fcc,save,send-hook
};
static TAILQ_HEAD(, Hook) Hooks = TAILQ_HEAD_INITIALIZER(Hooks);
-static int current_hook_type = 0;
+static HookFlags current_hook_type = MUTT_HOOK_NO_FLAGS;
/**
* mutt_parse_hook - Parse the 'hook' family of commands - Implements ::command_t
/**
* mutt_delete_hooks - Delete matching hooks
- * @param type Hook type to delete, e.g. #MUTT_SEND_HOOK
+ * @param type Hook type to delete, see #HookFlags
*
* If 0 is passed, all the hooks will be deleted.
*/
-void mutt_delete_hooks(int type)
+void mutt_delete_hooks(HookFlags type)
{
struct Hook *h = NULL;
struct Hook *tmp = NULL;
/**
* mutt_find_hook - Find a matching hook
- * @param type Type, e.g. #MUTT_FOLDER_HOOK
+ * @param type Hook type, see #HookFlags
* @param pat Pattern to match
* @retval ptr Command string
*
* @note The returned string must not be freed.
*/
-char *mutt_find_hook(int type, const char *pat)
+char *mutt_find_hook(HookFlags type, const char *pat)
{
struct Hook *tmp = NULL;
* mutt_message_hook - Perform a message hook
* @param m Mailbox Context
* @param e Email
- * @param type Hook type, e.g. #MUTT_MESSAGE_HOOK
+ * @param type Hook type, see #HookFlags
*/
-void mutt_message_hook(struct Mailbox *m, struct Email *e, int type)
+void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
{
struct Buffer err, token;
struct Hook *hook = NULL;
* addr_hook - Perform an address hook (get a path)
* @param path Buffer for path
* @param pathlen Length of buffer
- * @param type Type e.g. #MUTT_FCC_HOOK
+ * @param type Hook type, see #HookFlags
* @param ctx Mailbox Context
* @param e Email
* @retval 0 Success
* @retval -1 Failure
*/
-static int addr_hook(char *path, size_t pathlen, int type, struct Context *ctx,
- struct Email *e)
+static int addr_hook(char *path, size_t pathlen, HookFlags type,
+ struct Context *ctx, struct Email *e)
{
struct Hook *hook = NULL;
struct PatternCache cache = { 0 };
* list_hook - Find hook strings matching
* @param[out] matches List of hook strings
* @param[in] match String to match
- * @param[in] hook Hook type, e.g. #MUTT_CRYPT_HOOK
+ * @param[in] hook Hook type, see #HookFlags
*/
-static void list_hook(struct ListHead *matches, const char *match, int hook)
+static void list_hook(struct ListHead *matches, const char *match, HookFlags hook)
{
struct Hook *tmp = NULL;
/**
* mutt_startup_shutdown_hook - Execute any startup/shutdown hooks
- * @param type Hook type: MUTT_STARTUP_HOOK or MUTT_SHUTDOWN_HOOK
+ * @param type Hook type: #MUTT_STARTUP_HOOK or #MUTT_SHUTDOWN_HOOK
*
* The user can configure hooks to be run on startup/shutdown.
* This function finds all the matching hooks and executes them.
*/
-void mutt_startup_shutdown_hook(int type)
+void mutt_startup_shutdown_hook(HookFlags type)
{
struct Hook *hook = NULL;
struct Buffer token = { 0 };
extern bool C_ForceName;
extern bool C_SaveName;
-/* types for mutt_parse_hook() */
+typedef uint32_t HookFlags; ///< Flags for mutt_parse_hook(), e.g. #MUTT_FOLDER_HOOK
+#define MUTT_HOOK_NO_FLAGS 0 ///< No flags are set
#define MUTT_FOLDER_HOOK (1 << 0) ///< folder-hook: when entering a mailbox
#define MUTT_MBOX_HOOK (1 << 1) ///< mbox-hook: move messages after reading them
#define MUTT_SEND_HOOK (1 << 2) ///< send-hook: when composing a new email
void mutt_account_hook(const char *url);
void mutt_crypt_hook(struct ListHead *list, struct Address *addr);
void mutt_default_save(char *path, size_t pathlen, struct Email *e);
-void mutt_delete_hooks(int type);
-char *mutt_find_hook(int type, const char *pat);
+void mutt_delete_hooks(HookFlags type);
+char *mutt_find_hook(HookFlags type, const char *pat);
void mutt_folder_hook(const char *path, const char *desc);
-void mutt_message_hook(struct Mailbox *m, struct Email *e, int type);
+void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type);
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_startup_shutdown_hook(HookFlags type);
void mutt_timeout_hook(void);
#endif /* MUTT_HOOK_H */