diff options
Diffstat (limited to 'global.c')
-rw-r--r-- | global.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/global.c b/global.c new file mode 100644 index 0000000..bf5bf2e --- /dev/null +++ b/global.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <errno.h> +#include "global.h" + +__attribute__((noreturn, format(printf, 1, 2))) +void die(const char *format,...){ + fprintf(stderr,"DIE: "); + va_list ap; + va_start(ap,format); + vfprintf(stderr,format,ap); + va_end(ap); + fputc('\n',stderr); + exit(1); +} + +__attribute__((noreturn)) +void die_perror(const char *func){ + fprintf(stderr,"DIE: %s: %s\n",func,strerror(errno)); + exit(1); +} + +__attribute__((format (printf, 1, 2))) +void debug(const char *format,...){ + fprintf(stderr,"DEBUG: "); + va_list ap; + va_start(ap,format); + vfprintf(stderr,format,ap); + va_end(ap); + fputc('\n',stderr); +} |