summaryrefslogtreecommitdiff
path: root/lib/util.c
diff options
context:
space:
mode:
authorawy <awy@awy.one>2025-08-25 19:38:44 +0300
committerawy <awy@awy.one>2025-08-25 19:38:44 +0300
commit4300e4022314514c982ef401b36f3061aa926ca1 (patch)
treed50da7fcb7775b0e2da9751091714c681a0610e8 /lib/util.c
parentda3ed11be83694d32285f1773de5232cd51d8b4b (diff)
updates
Diffstat (limited to 'lib/util.c')
-rw-r--r--lib/util.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/util.c b/lib/util.c
new file mode 100644
index 0000000..1fe30da
--- /dev/null
+++ b/lib/util.c
@@ -0,0 +1,25 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "util.h"
+
+void
+die(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+
+ if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
+ fputc(' ', stderr);
+ perror(NULL);
+ } else {
+ fputc('\n', stderr);
+ }
+
+ exit(1);
+}