]> granicus.if.org Git - neomutt/blob - mutt_commands.h
Fix mutt_write_mime_body() application/pgp-encrypted handling
[neomutt] / mutt_commands.h
1 /**
2  * @file
3  * Mapping from user command name to function
4  *
5  * @authors
6  * Copyright (C) 2016 Bernard Pratz <z+mutt+pub@m0g.net>
7  *
8  * @copyright
9  * This program is free software: you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License as published by the Free Software
11  * Foundation, either version 2 of the License, or (at your option) any later
12  * version.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License along with
20  * this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef MUTT_MUTT_COMMANDS_H
24 #define MUTT_MUTT_COMMANDS_H
25
26 #include <stdint.h>
27
28 struct Buffer;
29
30 /**
31  * enum CommandResult - Error codes for command_t parse functions
32  */
33 enum CommandResult
34 {
35   MUTT_CMD_ERROR   = -1, ///< Error: Can't help the user
36   MUTT_CMD_WARNING = -2, ///< Warning: Help given to the user
37   MUTT_CMD_SUCCESS =  0, ///< Success: Command worked
38   MUTT_CMD_FINISH  =  1  ///< Finish: Stop processing this file
39 };
40
41 /**
42  * typedef command_t - Prototype for a function to parse a command
43  * @param buf  Temporary Buffer space
44  * @param s    Buffer containing string to be parsed
45  * @param data Flags associated with the command
46  * @param err  Buffer for error messages
47  * @retval #CommandResult Result e.g. #MUTT_CMD_SUCCESS
48  */
49 typedef enum CommandResult (*command_t)(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
50
51 /**
52  * struct Command - A user-callable command
53  */
54 struct Command
55 {
56   const char *name; ///< Name of the command
57   command_t func;   ///< Function to parse the command
58   intptr_t data;    ///< Data or flags to pass to the command
59 };
60
61 const struct Command *mutt_command_get(const char *s);
62 void mutt_commands_apply(void *data, void (*application)(void *, const struct Command *));
63
64 #endif /* MUTT_MUTT_COMMANDS_H */