3 * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
4 * or any later version. For details on its copyright, license, and warranties,
5 * see the file NOTICE in the root directory of the PlomRogue source package.
9 #include <errno.h> /* global errno */
10 #include <stdint.h> /* uint16_t */
11 #include <stdio.h> /* printf(), perror(), sprintf() */
12 #include <stdlib.h> /* exit(), free(), EXIT_FAILURE */
13 #include <string.h> /* strlen() */
14 #include "try_malloc.h" /* try_malloc() */
18 void (* cleanup_func) ();
22 extern void set_cleanup_func(void (* f)())
29 extern void exit_err(int err, const char * msg)
38 msg = "Details unknown.";
40 printf("Aborted program due to error. %s\n", msg);
43 perror("errno states");
50 extern void exit_trouble(int err, const char * parent, const char * child)
52 char * p1 = "Trouble in ";
55 uint16_t size = strlen(p1) + strlen(parent) + strlen(p2) + strlen(child)
57 char * msg = try_malloc(size, __func__);
58 int test = sprintf(msg, "%s%s%s%s%s", p1, parent, p2, child, p3);
59 exit_err(test < 0, "Trouble in exit_trouble with sprintf.");