aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NitrokeyManager.cc12
-rw-r--r--include/NitrokeyManager.h5
2 files changed, 17 insertions, 0 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index 60c1a24..5939cbf 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -14,6 +14,18 @@ namespace nitrokey{
std::mutex mex_dev_com;
+#ifdef __WIN32
+#pragma message "Using own strndup"
+char * strndup(const char* str, size_t maxlen){
+ size_t len = strnlen(str, maxlen);
+ char* dup = (char *) malloc(len + 1);
+ memcpy(dup, str, len);
+ dup[len] = 0;
+ return dup;
+}
+#endif
+
+
/**
* Copies string from pointer to fixed size C-style array. Src needs to be a valid C-string - eg. ended with '\0'.
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index 51cd966..e3dcc45 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -18,6 +18,11 @@ namespace nitrokey {
using namespace nitrokey::proto;
using namespace nitrokey::log;
+
+#ifdef __WIN32
+char * strndup(const char* str, size_t maxlen);
+#endif
+
class NitrokeyManager {
public:
static shared_ptr <NitrokeyManager> instance();