summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorsinanmohd <sinan@firemail.cc>2023-05-22 15:25:25 +0530
committersinanmohd <sinan@firemail.cc>2023-06-26 12:59:10 +0530
commitd7ce046606ce05dd8a37e83fc48667bbe4c20093 (patch)
tree7e8d44431998e8c9d80f39165b6525866ddb5856 /util.c
initial commitHEADmaster
Diffstat (limited to 'util.c')
-rw-r--r--util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..d8c65b8
--- /dev/null
+++ b/util.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+#include "util.h"
+
+void die(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ fprintf(stderr, "error: ");
+ vfprintf(stderr, fmt, ap);
+ if (errno)
+ fprintf(stderr, " (%d): %s\n", errno, strerror(errno));
+ else
+ fputc('\n', stderr);;
+ va_end(ap);
+
+ exit(errno);
+}