aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NK_C_API.cc20
-rw-r--r--NitrokeyManager.cc3
-rw-r--r--include/command.h2
-rw-r--r--libnitrokey.pro76
-rw-r--r--unittest/test_issues.cc4
5 files changed, 91 insertions, 14 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index db87d90..3131db1 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -5,16 +5,16 @@
#include "include/LibraryException.h"
#include "include/cxx_semantics.h"
-#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
+//#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
using namespace nitrokey;
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index 4393682..4b3c7e1 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -14,6 +14,7 @@ namespace nitrokey{
std::mutex mex_dev_com_manager;
+#ifndef strndup
#ifdef _WIN32
#pragma message "Using own strndup"
char * strndup(const char* str, size_t maxlen){
@@ -24,7 +25,7 @@ char * strndup(const char* str, size_t maxlen){
return dup;
}
#endif
-
+#endif
using nitrokey::misc::strcpyT;
diff --git a/include/command.h b/include/command.h
index 3f711c0..279754a 100644
--- a/include/command.h
+++ b/include/command.h
@@ -11,7 +11,7 @@
#define print_to_ss_volatile(x) ( ss << " " << (#x) <<":\t" << "***********" << std::endl );
#endif
#define hexdump_to_ss(x) (ss << #x":\n"\
- << ::nitrokey::misc::hexdump((const char *) (&x), sizeof x, false));
+ << ::nitrokey::misc::hexdump((const uint8_t *) (&x), sizeof x, false));
namespace nitrokey {
namespace proto {
diff --git a/libnitrokey.pro b/libnitrokey.pro
new file mode 100644
index 0000000..621a137
--- /dev/null
+++ b/libnitrokey.pro
@@ -0,0 +1,76 @@
+# Created by and for Qt Creator. This file was created for editing the project sources only.
+# You may attempt to use it for building too, by modifying this file here.
+
+#TARGET = libnitrokey
+
+CONFIG += c++14 staticlib
+#QT =
+
+TEMPLATE = lib
+TARGET = nitrokey
+
+HEADERS = \
+ $$PWD/hidapi/hidapi/hidapi.h \
+# $$PWD/include/hidapi/hidapi.h \
+ $$PWD/include/command.h \
+ $$PWD/include/command_id.h \
+ $$PWD/include/CommandFailedException.h \
+ $$PWD/include/cxx_semantics.h \
+ $$PWD/include/device.h \
+ $$PWD/include/device_proto.h \
+ $$PWD/include/DeviceCommunicationExceptions.h \
+ $$PWD/include/dissect.h \
+ $$PWD/include/inttypes.h \
+ $$PWD/include/LibraryException.h \
+ $$PWD/include/log.h \
+ $$PWD/include/LongOperationInProgressException.h \
+ $$PWD/include/misc.h \
+ $$PWD/include/NitrokeyManager.h \
+ $$PWD/include/stick10_commands.h \
+ $$PWD/include/stick10_commands_0.8.h \
+ $$PWD/include/stick20_commands.h \
+ $$PWD/NK_C_API.h
+
+SOURCES = \
+ $$PWD/command_id.cc \
+ $$PWD/device.cc \
+ $$PWD/DeviceCommunicationExceptions.cpp \
+ $$PWD/log.cc \
+ $$PWD/misc.cc \
+ $$PWD/NitrokeyManager.cc \
+ $$PWD/NK_C_API.cc
+
+
+tests {
+ SOURCES += \
+ $$PWD/unittest/catch_main.cpp \
+ $$PWD/unittest/test.cc \
+ $$PWD/unittest/test2.cc \
+ $$PWD/unittest/test3.cc \
+ $$PWD/unittest/test_C_API.cpp \
+ $$PWD/unittest/test_HOTP.cc
+}
+
+unix:!macx{
+ SOURCES += $$PWD/hidapi/linux/hid.c
+}
+
+unix{
+ SOURCES += $$PWD/hidapi/mac/hid.c
+}
+
+#win32 {
+ SOURCES += $$PWD/hidapi/windows/hid.c
+ LIBS += -lsetupapi
+#}
+
+INCLUDEPATH = \
+ $$PWD/. \
+ $$PWD/hidapi/hidapi \
+ $$PWD/include \
+ $$PWD/include/hidapi \
+ $$PWD/unittest \
+ $$PWD/unittest/Catch/single_include
+
+#DEFINES =
+
diff --git a/unittest/test_issues.cc b/unittest/test_issues.cc
index ec3f933..63ce678 100644
--- a/unittest/test_issues.cc
+++ b/unittest/test_issues.cc
@@ -15,7 +15,7 @@ using namespace nitrokey;
bool test_36(){
auto i = NitrokeyManager::instance();
- i->set_debug(true);
+ i->set_loglevel(3);
REQUIRE(i->connect());
for (int j = 0; j < 200; ++j) {
@@ -28,7 +28,7 @@ bool test_36(){
bool test_31(){
auto i = NitrokeyManager::instance();
- i->set_debug(true);
+ i->set_loglevel(3);
REQUIRE(i->connect());
// i->unlock_encrypted_volume(default_user_pin);