cepheid

An Aurora 4X clone
Log | Files | Refs | README

commit 8e53b16b8c1c7a09adc939c71527102c0d5408f9
parent cafd1da2e6d4f66916fce569ff2dced29eaecc9a
Author: hhvn <dev@hhvn.uk>
Date:   Tue, 15 Nov 2022 20:10:13 +0000

error() function

Diffstat:
Msrc/main.c | 21+++++++++++++++++++--
Msrc/main.h | 7+++++++
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -2,6 +2,7 @@ #include <time.h> #include <raylib.h> #include <signal.h> +#include <stdlib.h> #include "main.h" #define DEFSAVE "default" @@ -11,6 +12,22 @@ int sigint = 0; int sigterm = 0; void +error(int code, char *fmt, ...) { + va_list ap; + + fprintf(stderr, "error: "); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + +#ifdef DEBUG + raise(SIGTRAP); +#else + exit(code); +#endif /* DEBUG */ +} + +void warning(char *fmt, ...) { va_list ap; @@ -20,8 +37,8 @@ warning(char *fmt, ...) { va_end(ap); #ifdef DEBUG - raise(SIGABRT); -#endif + raise(SIGTRAP); +#endif /* DEBUG */ } static void diff --git a/src/main.h b/src/main.h @@ -20,6 +20,7 @@ extern Save *save; extern int sigint; extern int sigterm; +void error(int code, char *fmt, ...); void warning(char *fmt, ...); /* str.c */ @@ -189,6 +190,12 @@ extern Texture image_settings; void data_load(void); void data_unload(void); +/* bdb.c */ +#define bdset(d, g, ...) _bdset(d, g, __VA_ARGS__, NULL) +#define bdget(d, g, ...) _bdget(d, g, __VA_ARGS__, NULL) +void _bdset(char *dir, char *group, ...); +void _bdget(char *dir, char *group, ...); + /* db.c */ int vdbsetf(char *dir, char *group, char *key, char *fmt, va_list args); int dbsetf(char *dir, char *group, char *key, char *fmt, ...);