aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp
index f762b4c..874eb41 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -58,6 +58,31 @@ const char *TTY_COLOR_MAGENTA = "\x1b[35m";
const char *TTY_COLOR_CYAN = "\x1b[36m";
const char *TTY_COLOR_RESET = "\x1b[0m";
+extern "C" {
+
+SalticidaeCError salticidae_cerror_normal() {
+ SalticidaeCError res;
+ res.code = SALTI_NORMAL;
+ res.oscode = 0;
+ return res;
+}
+
+SalticidaeCError salticidae_cerror_unknown() {
+ SalticidaeCError res;
+ res.code = SALTI_ERROR_UNKNOWN;
+ res.oscode = 0;
+ return res;
+}
+
+const char *salticidae_strerror(int code) {
+ if (code < 0 ||
+ code >= (int)(sizeof(SALTICIDAE_ERROR_STRINGS) / sizeof(const char *)))
+ return "invalid";
+ return SALTICIDAE_ERROR_STRINGS[code];
+}
+
+}
+
void sec2tv(double t, struct timeval &tv) {
tv.tv_sec = trunc(t);
tv.tv_usec = trunc((t - tv.tv_sec) * 1e6);