home · contact · privacy
459fd29298294dc39ab59fce7a4de4b511684673
[plomrogue] / src / rexit.h
1 /* rexit.h
2  *
3  * Routines to exit the game orderly or on error, with as much cleaning up as is
4  * possible in both cases.
5  */
6
7 #ifndef REXIT_H
8 #define REXIT_H
9
10
11
12 #include <stdint.h> /* for uint8_t */
13 struct World;
14 struct Map;
15
16
17
18 /* set_cleanup_flag() sets any of the flags defined in cleanup_flag to announce
19  * the resources that need cleaning up upon program exit. It is to be called at
20  * the earliest moment possible after resource creation / initialization.
21  */
22 enum cleanup_flag
23 {
24     CLEANUP_NCURSES         = 0x0001,
25     CLEANUP_MAP             = 0x0002,
26     CLEANUP_KEYBINDINGS     = 0x0004,
27     CLEANUP_LOG             = 0x0008,
28     CLEANUP_COMMAND_DB      = 0x0010,
29     CLEANUP_MAP_OBJECTS     = 0x0020,
30     CLEANUP_MAP_OBJECT_DEFS = 0x0040,
31     CLEANUP_WIN_META        = 0x0080,
32     CLEANUP_WINCONFS        = 0x0100,
33     CLEANUP_WINS            = 0x0200
34 };
35 extern void set_cleanup_flag(enum cleanup_flag flag);
36
37
38
39 /* Exit orderly, clean up. */
40 extern void exit_game(struct World * world);
41
42
43
44 /* If "err" == 0, do nothing. Else, clean up and exit with an error message that
45  * consists, first, of "msg" or (if "msg" is a NULL pointer) a generic "Details
46  * unknown", secondly of "err" as the "internal error code", and thirdly of
47  * errno if it is non-zero.
48  */
49 extern void exit_err(uint8_t err, struct World * world, char * msg);
50
51
52
53 #endif