aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..9b27512
--- /dev/null
+++ b/util.c
@@ -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
9void
10die(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}