diff options
| -rw-r--r-- | CMakeLists.txt | 10 | ||||
| -rw-r--r-- | NK_C_API.cc | 4 | ||||
| -rw-r--r-- | NitrokeyManager.cc | 12 | ||||
| m--------- | hidapi | 0 | ||||
| -rw-r--r-- | include/device.h | 2 | ||||
| -rw-r--r-- | include/log.h | 4 | 
6 files changed, 18 insertions, 14 deletions
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<GetSlotName>();          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<GetPasswordSafeSlotName>();          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<GetPasswordSafeSlotLogin>();          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<GetPasswordSafeSlotPassword>();          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 -Subproject a6a622ffb680c55da0de787ff93b80280498330 +Subproject 69c45b083821037667a9409b952282f9cb4dcca 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 <chrono> -#include <hidapi/hidapi.h> +#include "hidapi/hidapi.h"  #include <cstdint>  #include <string> 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 {  | 
