aboutsummaryrefslogtreecommitdiffstats
path: root/src/error/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/error/error.c')
-rw-r--r--src/error/error.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/error/error.c b/src/error/error.c
new file mode 100644
index 0000000..c286b46
--- /dev/null
+++ b/src/error/error.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include "error.h"
+
+void error(int err, char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ fprintf(stderr, "error: ");
+ vfprintf(stderr, fmt, args);
+ fprintf(stderr, "\n");
+ va_end(args);
+ if (err != 0)
+ fprintf(stderr, "%s", strerror(err));
+ exit(1);
+}