aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/CMakeLists.txt3
-rw-r--r--common/config.h.in9
-rw-r--r--common/util.c19
-rw-r--r--common/util.h13
4 files changed, 44 insertions, 0 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
new file mode 100644
index 0000000..8636758
--- /dev/null
+++ b/common/CMakeLists.txt
@@ -0,0 +1,3 @@
+file(GLOB_RECURSE SOURCES *.c)
+
+ADD_LIBRARY(common STATIC ${SOURCES})
diff --git a/common/config.h.in b/common/config.h.in
new file mode 100644
index 0000000..2f41d8d
--- /dev/null
+++ b/common/config.h.in
@@ -0,0 +1,9 @@
+#ifndef COMMON_CONFIG_H_
+#define COMMON_CONFIG_H_
+
+#define CONFIG_DIR "@CMAKE_INSTALL_PREFIX@/etc/rocket-cli-client/"
+#define CONFIG_PATH CONFIG_DIR "rocket.conf"
+#define VERSION "@PROJECT_VERSION@"
+#define GIT_HASH "@GIT_HASH@"
+
+#endif
diff --git a/common/util.c b/common/util.c
new file mode 100644
index 0000000..0c85325
--- /dev/null
+++ b/common/util.c
@@ -0,0 +1,19 @@
+#include <string.h>
+
+#include "util.h"
+
+void convert_iso8601(const char *time_string, int ts_len, struct tm *tm_data)
+{
+ tzset();
+
+ char temp[64];
+ memset(temp, 0, sizeof(temp));
+ strncpy(temp, time_string, ts_len);
+
+ struct tm ctime;
+ memset(&ctime, 0, sizeof(struct tm));
+ strptime(temp, "%FT%T%z", &ctime);
+
+ long ts = mktime(&ctime) - timezone;
+ localtime_r(&ts, tm_data);
+}
diff --git a/common/util.h b/common/util.h
new file mode 100644
index 0000000..464e7dc
--- /dev/null
+++ b/common/util.h
@@ -0,0 +1,13 @@
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+#include <features.h>
+#include <time.h>
+
+#ifndef UNUSED
+#define UNUSED __attribute__ ((__unused__))
+#endif
+
+void convert_iso8601(const char *time_string, int ts_len, struct tm *tm_data);
+
+#endif