diff options
Diffstat (limited to 'wv_err.h')
| -rw-r--r-- | wv_err.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/wv_err.h b/wv_err.h new file mode 100644 index 0000000..43d5f84 --- /dev/null +++ b/wv_err.h @@ -0,0 +1,38 @@ +#ifndef WV_ERR_H +#define WV_ERR_H + +#ifdef __OpenBSD__ +#include <err.h> +#else +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> + +static void err(int eval, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fprintf(stderr, "wv: "); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ": %s\n", strerror(errno)); + va_end(ap); + exit(eval); +} + +static void errx(int eval, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fprintf(stderr, "wv: "); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); + exit(eval); +} +#endif /* !__OpenBSD__ */ + +#endif /* WV_ERR_H */ |
