summaryrefslogtreecommitdiff
path: root/repo/kbd/error.h
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-09-10 23:00:02 +0100
committerdavidovski <david@davidovski.xyz>2022-09-10 23:00:02 +0100
commit24998e21676efbd0801bb9a56d167eaf273d44d7 (patch)
treebd5c13247a9e3d25211f41f358718f2d7447a60c /repo/kbd/error.h
parentc38dfe6188112ca490090966a63faefe5ec7e9a0 (diff)
Added cmatrix and updated a few
Diffstat (limited to 'repo/kbd/error.h')
-rw-r--r--repo/kbd/error.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/repo/kbd/error.h b/repo/kbd/error.h
new file mode 100644
index 0000000..5eb8ed5
--- /dev/null
+++ b/repo/kbd/error.h
@@ -0,0 +1,20 @@
+#ifndef ERROR_H
+#define ERROR_H
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <err.h>
+
+static inline void error(int status, int errnum, const char *fmt, ...)
+{
+ va_list ap;
+ void (*errfunc[2])(int, const char *, va_list) = { &verr, &verrx };
+ void (*warnfunc[2])(const char *, va_list) = { &vwarn, &vwarnx };
+ fflush(stdout);
+ va_start(ap, fmt);
+ if (status != 0)
+ errfunc[errnum==0](status, fmt, ap); /* does not return */
+ warnfunc[errnum==0](fmt, ap);
+ va_end(ap);
+}
+#endif