diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2015-03-12 14:02:39 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2015-03-12 14:02:39 +0100 |
commit | 03e9f2891d17643e603f3fd5f88dc61556e38802 (patch) | |
tree | 6dbdbad916543b0ebb95a4da0bf28d5247a26a78 /log.c | |
parent | 9ba3489123c6de58f70fc05379644c2ccedbe870 (diff) | |
download | nldev-03e9f2891d17643e603f3fd5f88dc61556e38802.tar.bz2 nldev-03e9f2891d17643e603f3fd5f88dc61556e38802.tar.xz |
move edie, die and dbg functions to log.c
So it can be reused by the handler.
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -0,0 +1,48 @@ + +#include <stdio.h> +#include <stdlib.h> + +#include "log.h" + +int dodebug = 0; + +void +edie(char *fmt, ...) +{ + va_list fmtargs; + + va_start(fmtargs, fmt); + vfprintf(stderr, fmt, fmtargs); + va_end(fmtargs); + fprintf(stderr, ": "); + + perror(NULL); + + exit(1); +} + +void +die(char *fmt, ...) +{ + va_list fmtargs; + + va_start(fmtargs, fmt); + vfprintf(stderr, fmt, fmtargs); + va_end(fmtargs); + + exit(1); +} + +void +dbg(char *fmt, ...) +{ + va_list fmtargs; + + if (dodebug) { + fprintf(stderr, "%s: ", argv0); + va_start(fmtargs, fmt); + vfprintf(stderr, fmt, fmtargs); + va_end(fmtargs); + fprintf(stderr, "\n"); + } +} |