Hi all,

I'm back with a smaller and reworked winscard patch.

In respond to Vitaly Margolen (http://www.winehq.org/pipermail/wine-devel/2010-September/087017.html)
1. I used configure to get the so name of the library.
2. I removed trailing spaces.
3. When this patch is approved, I will make a new patch for SCardListReadersA.

Is this patch ready for wine-patch ?

Thanks for your help.

Vincent.
>From 5045344418419168536fcea320115ee45618fa77 Mon Sep 17 00:00:00 2001
From: Vincent Hardy <vincent.hardy...@gmail.com>
Date: Fri, 21 Jan 2011 09:36:29 +0100
Subject: Loading PCSC-Lite library

---
 configure.ac             |    3 +++
 dlls/winscard/winscard.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4d049b6..c6a1714 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1638,6 +1638,9 @@ fi
 dnl **** Check for libodbc ****
 WINE_CHECK_SONAME(odbc,SQLConnect,,[AC_DEFINE_UNQUOTED(SONAME_LIBODBC,["libodbc.$LIBEXT"])])
 
+dnl **** Check for libpcsclite ****
+WINE_CHECK_SONAME(pcsclite,SCardEstablishContext,,[AC_DEFINE_UNQUOTED(SONAME_LIBPCSCLITE,["libpcsclite.$LIBEXT"])])
+
 dnl **** Check for any sound system ****
 if test "x$ALSALIBS$COREAUDIO$NASLIBS$ESDLIBS$ac_cv_lib_soname_jack" = "x" -a \
         "$ac_cv_header_sys_soundcard_h" != "yes" -a \
diff --git a/dlls/winscard/winscard.c b/dlls/winscard/winscard.c
index 412299c..4dac49e 100644
--- a/dlls/winscard/winscard.c
+++ b/dlls/winscard/winscard.c
@@ -17,16 +17,22 @@
  */
 
 #include "config.h"
+#include "wine/port.h"
 #include <stdarg.h>
 #include "windef.h"
 #include "winbase.h"
 #include "wine/debug.h"
+#include "wine/library.h"
 #include "winscard.h"
 #include "winternl.h"
 
+static BOOL PCSCLite_loadlib(void);
+static BOOL PCSCLite_loadfunctions(void);
+
 WINE_DEFAULT_DEBUG_CHANNEL(winscard);
 
 static HMODULE WINSCARD_hModule;
+static void *g_pcscliteHandle = NULL;
 static HANDLE g_startedEvent = NULL;
 
 const SCARD_IO_REQUEST g_rgSCardT0Pci = { SCARD_PROTOCOL_T0, 8 };
@@ -44,13 +50,24 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
         {
             DisableThreadLibraryCalls(hinstDLL);
             WINSCARD_hModule = hinstDLL;
+
+            if (PCSCLite_loadlib())
+                PCSCLite_loadfunctions();
+
             /* FIXME: for now, we act as if the pcsc daemon is always started */
             g_startedEvent = CreateEventA(NULL,TRUE,TRUE,NULL);
+
             break;
         }
         case DLL_PROCESS_DETACH:
         {
             CloseHandle(g_startedEvent);
+
+            if (g_pcscliteHandle)
+            {
+                wine_dlclose(g_pcscliteHandle,NULL,0);
+                g_pcscliteHandle = NULL;
+            }
             break;
         }
     }
@@ -58,6 +75,31 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
     return TRUE;
 }
 
+static BOOL PCSCLite_loadlib(void)
+{
+    char error[256];
+
+    if (g_pcscliteHandle)
+        return TRUE; /*already loaded*/
+    else
+    {
+        g_pcscliteHandle = wine_dlopen(SONAME_LIBPCSCLITE, RTLD_LAZY | RTLD_GLOBAL, error, sizeof(error));
+        if (g_pcscliteHandle)
+            return TRUE;
+        else
+        {
+            WARN("Failed to open library %s : %s\n", debugstr_a(SONAME_LIBPCSCLITE), error);
+            return FALSE;
+        }
+    }
+}
+
+static BOOL PCSCLite_loadfunctions(void)
+{
+    FIXME("%s\n", SONAME_LIBPCSCLITE);
+    return TRUE;
+}
+
 HANDLE WINAPI SCardAccessStartedEvent(void)
 {
     return g_startedEvent;
-- 
1.7.3.4



Reply via email to