Skip to content

Commit

Permalink
Fix PCSC compilation under windows /monero#3844
Browse files Browse the repository at this point in the history
PR3843 based on release-v0.12 => rebased on master
  • Loading branch information
cslashm authored and stoffu committed Jun 26, 2018
1 parent 89ade95 commit 06cd28c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -467,9 +467,12 @@ link_directories(${LIBUNWIND_LIBRARY_DIRS})

# Final setup for libpcsc
if (PCSC_FOUND)
message(STATUS "Using PCSC include dir at ${PCSC_INCLUDE_DIR}")
add_definitions(-DHAVE_PCSC)
include_directories(${PCSC_INCLUDE_DIR})
link_directories(${LIBPCSC_LIBRARY_DIRS})
else (PCSC_FOUND)
message(STATUS "Could not find PCSC")
endif()

if(MSVC)
Expand Down
6 changes: 6 additions & 0 deletions cmake/FindPCSC.cmake
Expand Up @@ -18,6 +18,9 @@ ENDIF (NOT WIN32)

FIND_PATH(PCSC_INCLUDE_DIR winscard.h
HINTS
IF (WIN32)
${MSYS2_FOLDER}/mingw64/x86_64-w64-mingw32/include
ENDIF (WIN32)
/usr/include/PCSC
${PC_PCSC_INCLUDEDIR}
${PC_PCSC_INCLUDE_DIRS}
Expand All @@ -26,6 +29,9 @@ FIND_PATH(PCSC_INCLUDE_DIR winscard.h

FIND_LIBRARY(PCSC_LIBRARY NAMES pcsclite libpcsclite WinSCard PCSC
HINTS
IF (WIN32)
${MSYS2_FOLDER}/mingw64/x86_64-w64-mingw32/lib
ENDIF (WIN32)
${PC_PCSC_LIBDIR}
${PC_PCSC_LIBRARY_DIRS}
)
Expand Down
9 changes: 9 additions & 0 deletions src/device/device_ledger.cpp
Expand Up @@ -48,6 +48,15 @@ namespace hw {
/* ===================================================================== */
/* === Debug ==== */
/* ===================================================================== */
#ifdef WIN32
static char *pcsc_stringify_error(LONG rv) {
static __thread char out[20];
sprintf_s(out, sizeof(out), "0x%08lX", rv);

return out;
}
#endif

void set_apdu_verbose(bool verbose) {
apdu_verbose = verbose;
}
Expand Down
5 changes: 5 additions & 0 deletions src/device/device_ledger.hpp
Expand Up @@ -33,8 +33,13 @@
#include <cstddef>
#include <string>
#include "device.hpp"
#ifdef WIN32
#include <winscard.h>
#define MAX_ATR_SIZE 33
#else
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
#endif
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>

Expand Down

0 comments on commit 06cd28c

Please sign in to comment.