From c69604e8ba099b1421af86c34d904b0b380f996c Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 9 Mar 2017 18:49:02 +0100 Subject: Test compilation under windows --- hidapi | 1 + 1 file changed, 1 insertion(+) create mode 160000 hidapi (limited to 'hidapi') diff --git a/hidapi b/hidapi new file mode 160000 index 0000000..a6a622f --- /dev/null +++ b/hidapi @@ -0,0 +1 @@ +Subproject commit a6a622ffb680c55da0de787ff93b80280498330f -- cgit v1.2.3 From 6ee68fa294d1d9ab8fa8e61a009845dc31a9b771 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 14 Feb 2017 11:53:25 +0100 Subject: Compiles on MXE, but not working on Windows Signed-off-by: Szczepan Zalega --- CMakeLists.txt | 10 +++++----- NK_C_API.cc | 4 ++-- NitrokeyManager.cc | 12 ++++++------ hidapi | 2 +- include/device.h | 2 +- include/log.h | 4 ++++ 6 files changed, 19 insertions(+), 15 deletions(-) (limited to 'hidapi') diff --git a/CMakeLists.txt b/CMakeLists.txt index e77de6e..89ab66d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,13 +61,13 @@ set(SOURCE_FILES NK_C_API.cc ) -#IF(UNIX) +IF(UNIX) # add_library(hidapi-libusb STATIC hidapi/libusb/hid.c ) -#ELSE() +ELSEIF(WIN32) include_directories(hidapi/hidapi) - add_library(hidapi-libusb SHARED hidapi/windows/hid.c ) - target_link_libraries(hidapi-libusb setupapi setupapi kernel32 user32 gdi32 winspool comdlg32 advapi32 shell32 ole32 oleaut32 uuid odbc32 odbccp32) -#ENDIF() + add_library(hidapi-libusb STATIC hidapi/windows/hid.c ) + target_link_libraries(hidapi-libusb setupapi) +ENDIF() IF (NOT LIBNITROKEY_STATIC) add_library(nitrokey SHARED ${SOURCE_FILES}) diff --git a/NK_C_API.cc b/NK_C_API.cc index 4e53cd1..6d18e52 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -169,7 +169,7 @@ extern const char * NK_status() { auto m = NitrokeyManager::instance(); return get_with_string_result([&](){ string && s = m->get_status_as_string(); - char * rs = _strdup(s.c_str()); + char * rs = strdup(s.c_str()); clear_string(s); return rs; }); @@ -179,7 +179,7 @@ extern const char * NK_device_serial_number(){ auto m = NitrokeyManager::instance(); return get_with_string_result([&](){ string && s = m->get_serial_number(); - char * rs = _strdup(s.c_str()); + char * rs = strdup(s.c_str()); clear_string(s); return rs; }); diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index a120085..6ce9910 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -397,7 +397,7 @@ namespace nitrokey{ auto payload = get_payload(); payload.slot_number = slot_number; auto resp = GetSlotName::CommandTransaction::run(device, payload); - return _strdup((const char *) resp.data().slot_name); + return strdup((const char *) resp.data().slot_name); } bool NitrokeyManager::first_authenticate(const char *pin, const char *temporary_password) { @@ -504,7 +504,7 @@ namespace nitrokey{ auto p = get_payload(); p.slot_number = slot_number; auto response = GetPasswordSafeSlotName::CommandTransaction::run(device, p); - return _strdup((const char *) response.data().slot_name); + return strdup((const char *) response.data().slot_name); } bool NitrokeyManager::is_valid_password_safe_slot_number(uint8_t slot_number) const { return slot_number < 16; } @@ -514,7 +514,7 @@ namespace nitrokey{ auto p = get_payload(); p.slot_number = slot_number; auto response = GetPasswordSafeSlotLogin::CommandTransaction::run(device, p); - return _strdup((const char *) response.data().slot_login); + return strdup((const char *) response.data().slot_login); } const char *NitrokeyManager::get_password_safe_slot_password(uint8_t slot_number) { @@ -522,7 +522,7 @@ namespace nitrokey{ auto p = get_payload(); p.slot_number = slot_number; auto response = GetPasswordSafeSlotPassword::CommandTransaction::run(device, p); - return _strdup((const char *) response.data().slot_password); //FIXME use secure way + return strdup((const char *) response.data().slot_password); //FIXME use secure way } void NitrokeyManager::write_password_safe_slot(uint8_t slot_number, const char *slot_name, const char *slot_login, @@ -724,7 +724,7 @@ namespace nitrokey{ const char * NitrokeyManager::get_status_storage_as_string(){ auto p = stick20::GetDeviceStatus::CommandTransaction::run(device); - return _strdup(p.data().dissect().c_str()); + return strdup(p.data().dissect().c_str()); } stick20::DeviceConfigurationResponsePacket::ResponsePayload NitrokeyManager::get_status_storage(){ @@ -734,7 +734,7 @@ namespace nitrokey{ const char * NitrokeyManager::get_SD_usage_data_as_string(){ auto p = stick20::GetSDCardOccupancy::CommandTransaction::run(device); - return _strdup(p.data().dissect().c_str()); + return strdup(p.data().dissect().c_str()); } int NitrokeyManager::get_progress_bar_value(){ diff --git a/hidapi b/hidapi index a6a622f..69c45b0 160000 --- a/hidapi +++ b/hidapi @@ -1 +1 @@ -Subproject commit a6a622ffb680c55da0de787ff93b80280498330f +Subproject commit 69c45b083821037667a9409b952282f9cb4dcca2 diff --git a/include/device.h b/include/device.h index a23e1b3..281c4d9 100644 --- a/include/device.h +++ b/include/device.h @@ -1,7 +1,7 @@ #ifndef DEVICE_H #define DEVICE_H #include -#include +#include "hidapi/hidapi.h" #include #include diff --git a/include/log.h b/include/log.h index 8eda4fb..0b0df8c 100644 --- a/include/log.h +++ b/include/log.h @@ -6,6 +6,10 @@ namespace nitrokey { namespace log { +#ifdef ERROR +#undef ERROR +#endif + enum class Loglevel : int { DEBUG_L2, DEBUG, INFO, WARNING, ERROR }; class LogHandler { -- cgit v1.2.3