home · contact · privacy
866f5e34a577eaba89ccd38b2381f83835a6598b
[plomrogue] / src / command_db.h
1 /* command.h
2  *
3  * The Command DB collects all commands the user can give. It only contains
4  * identifiers and descriptions of commands, not the functions executing these
5  * commands. Coupling with those happens elsewhere.
6  */
7
8 #ifndef COMMAND_DB_H
9 #define COMMAND_DB_H
10
11 #include <stdint.h> /* for uint8_t */
12
13
14
15 struct Command
16 {
17     uint8_t id;       /* unique identifier of command */
18     char * dsc_short; /* short string name of command to be used internally */
19     char * dsc_long;  /* long string description of command for the user */
20 };
21
22 struct CommandDB
23 {
24     uint8_t n;             /* number of Command structs in database*/
25     struct Command * cmds; /* pointer to first Command struct in database */
26 };
27
28
29
30 /* Is "id" the ID of command whose dsc_short is "shortdsc"? Answer in binary. */
31 extern uint8_t is_command_id_shortdsc(uint8_t id, char * shortdsc);
32
33 /* Give short description of command ("dsc_short"), get its ID. */
34 extern uint8_t get_command_id(char * dsc_short);
35
36 /* Give short description of command ("dsc_short"), get long description. */
37 extern char * get_command_longdsc(char * dsc_short);
38
39 /* Read in CommandDB from file "config/commands" to world.cmd_db. */
40 extern void init_command_db();
41
42 /* Free all memory allocated with init_command_db. */
43 extern void free_command_db();
44
45
46
47 #endif