libwinpr-smartcard: update PCSC-WinPR instructions (WIP)
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Sun, 27 Apr 2014 21:38:45 +0000 (17:38 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Sun, 27 Apr 2014 21:38:45 +0000 (17:38 -0400)
CMakeLists.txt
winpr/libwinpr/smartcard/smartcard_link.c
winpr/libwinpr/smartcard/smartcard_pcsc.c

index 4bc3e8b..90cdb98 100755 (executable)
@@ -341,7 +341,9 @@ else()
        set(X11_FEATURE_TYPE "DISABLED")
 endif()
 
-find_package(PCSCWinPR)
+if(WITH_PCSC_WINPR)
+       find_package(PCSCWinPR)
+endif()
 
 set(X11_FEATURE_PURPOSE "X11")
 set(X11_FEATURE_DESCRIPTION "X11 client and server")
index 55e39d7..3678ea4 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+#define DISABLE_PCSC_WINPR
+
 /**
- * PCSC-WinPR (only required for Mac OS X):
+ * PCSC-WinPR (optional for Mac OS X):
  *
  * PCSC-WinPR is a static build of libpcsclite with
  * minor modifications meant to avoid an ABI conflict.
  *
+ * At this point, it is only a work in progress, as I was not
+ * yet able to make it work properly. However, if we could make it
+ * work, we might be able to build against a version of pcsc-lite
+ * that doesn't have issues present in Apple's SmartCard Services.
+ *
+ * Patch pcsc-lite/src/PCSC/wintypes.h:
+ * Change "unsigned long" to "unsigned int" for
+ *
+ * typedef unsigned int ULONG;
+ * typedef unsigned int DWORD;
+ *
+ * This is important as ULONG and DWORD are supposed to be 32-bit,
+ * but unsigned long on 64-bit OS X is 64-bit, not 32-bit.
+ * More importantly, Apple's SmartCard Services uses unsigned int,
+ * while vanilla pcsc-lite still uses unsigned long.
+ *
+ * Patch pcsc-lite/src/PCSC/pcsclite.h.in:
+ *
  * Add the WinPR_PCSC_* definitions that follow "#define WinPR_PCSC"
- * in this file to pcsc-lite/src/PCSC/winscard.h
+ * in this source file at the beginning of the pcsclite.h.in.
+ *
+ * Change "unsigned long" to "unsigned int" in the definition
+ * of the SCARD_IO_REQUEST structure:
+ *
+ * unsigned int dwProtocol;
+ * unsigned int cbPciLength;
  *
  * Configure pcsc-lite with the following options (Mac OS X):
  * 
@@ -67,6 +93,7 @@
 
 #if 0
 #define WinPR_PCSC
+
 #define SCardEstablishContext WinPR_PCSC_SCardEstablishContext
 #define SCardReleaseContext WinPR_PCSC_SCardReleaseContext
 #define SCardIsValidContext WinPR_PCSC_SCardIsValidContext
 #define SCardCancel WinPR_PCSC_SCardCancel
 #define SCardGetAttrib WinPR_PCSC_SCardGetAttrib
 #define SCardSetAttrib WinPR_PCSC_SCardSetAttrib
-#define list_size WinPR_PCSC_list_size /* put this line in src/simclist.h */
+
+#define g_rgSCardT0Pci WinPR_PCSC_g_rgSCardT0Pci
+#define g_rgSCardT1Pci WinPR_PCSC_g_rgSCardT1Pci
+#define g_rgSCardRawPci WinPR_PCSC_g_rgSCardRawPci
 #endif
 
 #ifdef WITH_WINPR_PCSC
@@ -138,6 +168,10 @@ int PCSC_InitializeSCardApi_Link(void)
 {
        int status = -1;
        
+#ifdef DISABLE_PCSC_WINPR
+       return -1;
+#endif
+       
 #ifdef WITH_WINPR_PCSC
        g_PCSC_Link.pfnSCardEstablishContext = (void*) WinPR_PCSC_SCardEstablishContext;
        g_PCSC_Link.pfnSCardReleaseContext = (void*) WinPR_PCSC_SCardReleaseContext;
index 9d88fbd..0799af2 100644 (file)
@@ -2157,7 +2157,7 @@ extern int PCSC_InitializeSCardApi_Link(void);
 
 int PCSC_InitializeSCardApi(void)
 {
-#if 0
+#ifndef DISABLE_PCSC_LINK
        if (PCSC_InitializeSCardApi_Link() >= 0)
        {
                g_PCSC.pfnSCardEstablishContext = g_PCSC_Link.pfnSCardEstablishContext;