diff options
Diffstat (limited to 'util.c')
| -rw-r--r-- | util.c | 23 |
1 files changed, 23 insertions, 0 deletions
| @@ -0,0 +1,23 @@ | |||
| 1 | /* See LICENSE file for copyright and license details. */ | ||
| 2 | #include <stdarg.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | #include <stdlib.h> | ||
| 5 | #include <string.h> | ||
| 6 | |||
| 7 | #include "util.h" | ||
| 8 | |||
| 9 | void | ||
| 10 | die(const char *fmt, ...) { | ||
| 11 | va_list ap; | ||
| 12 | |||
| 13 | va_start(ap, fmt); | ||
| 14 | vfprintf(stderr, fmt, ap); | ||
| 15 | va_end(ap); | ||
| 16 | |||
| 17 | if (fmt[0] && fmt[strlen(fmt)-1] == ':') { | ||
| 18 | fputc(' ', stderr); | ||
| 19 | perror(NULL); | ||
| 20 | } | ||
| 21 | |||
| 22 | exit(1); | ||
| 23 | } | ||
