3 * Routines to exit the game orderly or on error, with as much cleaning up as is
4 * possible in both cases.
10 #include <stdint.h> /* for uint8_t */
14 /* set_cleanup_flag() sets any of the flags defined in cleanup_flag to announce
15 * the resources that need cleaning up upon program exit. It is to be called at
16 * the earliest moment possible after resource creation / initialization.
21 CLEANUP_COMMAND_DB = 0x0002,
23 CLEANUP_MAP_OBJECTS = 0x0008,
24 CLEANUP_MAP_OBJECT_DEFS = 0x0010,
25 CLEANUP_MAP_OBJECT_ACTS = 0x0020,
26 CLEANUP_INTERFACE = 0x0040,
27 CLEANUP_NCURSES = 0x0080
29 extern void set_cleanup_flag(enum cleanup_flag flag);
33 /* Exit orderly, clean up in an order respecting resource dependencies. */
34 extern void exit_game();
36 /* If "err" == 0, do nothing. Else, clean up and exit with an error message that
37 * consists, first, of "msg" or (if "msg" is a NULL pointer) a generic "Details
38 * unknown", secondly of "err" as the "internal error code", and thirdly of
39 * errno if it is non-zero.
41 extern void exit_err(uint8_t err, char * msg);
43 /* Do exit_err() with "msg" as: "Trouble in ".parent." with ".child."." */
44 extern void exit_trouble(uint8_t err, char * parent, char * child);