summaryrefslogtreecommitdiff
path: root/src/kiterror.c
diff options
context:
space:
mode:
authorTuomas Virtanen <katajakasa@gmail.com>2016-01-04 04:33:59 +0200
committerTuomas Virtanen <katajakasa@gmail.com>2016-01-04 04:33:59 +0200
commit537ca31915603d7ed47ab4374a74058e340125c7 (patch)
treeb3c19e8dae778385021ea08be596022d952ccab5 /src/kiterror.c
Initial commit; Not done yet though, needs more work.
Diffstat (limited to 'src/kiterror.c')
-rw-r--r--src/kiterror.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/kiterror.c b/src/kiterror.c
new file mode 100644
index 0000000..948fda9
--- /dev/null
+++ b/src/kiterror.c
@@ -0,0 +1,30 @@
+#include "kitchensink/kitchensink.h"
+
+#include <stdarg.h>
+#include <stdbool.h>
+
+#define KIT_ERRBUFSIZE 1024
+
+static char _error_available = false;
+static char _error_message[KIT_ERRBUFSIZE] = "\0";
+
+const char* Kit_GetError() {
+ if(_error_available) {
+ _error_available = false;
+ return _error_message;
+ }
+ return NULL;
+}
+
+void Kit_SetError(const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(_error_message, KIT_ERRBUFSIZE, (char*)fmt, args);
+ va_end(args);
+ _error_available = true;
+}
+
+void Kit_ClearError() {
+ _error_message[0] = 0;
+ _error_available = false;
+}