summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/errstr.c24
-rw-r--r--lib/printf.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/errstr.c b/lib/errstr.c
new file mode 100644
index 0000000..6c4425d
--- /dev/null
+++ b/lib/errstr.c
@@ -0,0 +1,24 @@
+#include "jove.h"
+
+const char*
+errstr(int err)
+{
+ static const char *errstrs[] = {
+ [0] = "OKAY",
+ [EBADOBJ] = "BAD OBJECT",
+ [EOOB] = "OUT OF BOUNDS",
+ [EBADPATH] = "BAD PATH",
+ [ETOOSMALL] = "TOO SMALL",
+ [ETOOBIG] = "TOO BIG",
+ [EBADSIZE] = "BAD SIZE",
+ [ENOMAP] = "NO MAP",
+ [EHASMAP] = "HAS MAP",
+ [EALIGN] = "ALIGNMENT ERROR",
+ [EEXIST] = "ALREADY EXISTS",
+ [EBUSY] = "RESOURCE BUSY"
+ };
+ if(err >= sizeof(errstrs) / sizeof(const char*)) {
+ return "UNKNOWN ERROR";
+ }
+ return errstrs[err];
+}
diff --git a/lib/printf.h b/lib/printf.h
index a132b39..bcee770 100644
--- a/lib/printf.h
+++ b/lib/printf.h
@@ -4,6 +4,8 @@
#include <stdarg.h>
#include <stddef.h>
+#define klogf(fmt, ...) kprintf("%s: " fmt, __func__, __VA_ARGS__)
+
int kprintf(const char *fmt, ...);
int kvprintf(const char *fmt, va_list ap);