aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJulien Dessaux2019-08-01 17:52:46 +0200
committerJulien Dessaux2019-08-01 17:52:46 +0200
commitc151f2d4c85350b51fcf24ba83b426bf699269d6 (patch)
tree2b5fefac0f30504cc4c55ee09ac531e000b3fa95 /common
downloadrocket-cli-client-c151f2d4c85350b51fcf24ba83b426bf699269d6.tar.gz
rocket-cli-client-c151f2d4c85350b51fcf24ba83b426bf699269d6.tar.bz2
rocket-cli-client-c151f2d4c85350b51fcf24ba83b426bf699269d6.zip
Initial import
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