Fixed a bug in my own code: in the Windows DllMain() in PCSC.cpp break; was missing in the swicth statement. So everytime the Conext was released.

Hello,

The aim of this is to have a working CVS version which is both usable
under Windows and Linux in addition to the missing call to SCardRelease().

I have checked out today April, 11, 2005 the CVS version of
libmusclecard made a diff with my version and appended some necessary
files to compile it under Windows.

Under http://www.inf.tu-dresden.de/~ko189283/MuscleCard/ is a diff file
and a complete package with the missing files.

The SCardRelease() is now called at destruction time. For Windows this
is when the DLL is unloaded (DllMain() in PCSC.cpp), for Unix this is

+/* Library constructor and deconstructor function for UNIX */
+#ifndef WIN32
+
+void __attribute__ ((constructor)) musclecard_init(void) {
+}
+
+void __attribute__ ((destructor)) musclecard_fini(void) {
+    if (localHContext != 0) {
+        SCardReleaseContext(localHContext);
+    }
+}
+
+#endif
+

Never tested, but could work or is a good starting point.

Some remarks:

I have included some files and header files, which are part of the the
Unix PC/SC implementation but missing under Windows.

I have changed the include

-#include <winscard.h>
+#include "pcsclite.h"

winscard.h is included in windows and the Windows version should be used
if compiling under Windows, not the pcsclite version. So the pcsclite.h
includes the windows winscard.h if compiling under windows and defines a
few thing, else under some Unix the winscard.h of the Unix subdirectory
is included.

Under Unix this file is generated from pcsclite.h.in, but the make
process is not usable under Windows.

I have removed the conditional inclusion of the pthread headers. Pthread
is also available for Windows, so the differentiation is not necessary.
libmusclecard works with the native Windows mutex functions, but in the
PKCS#11 I have problems. And because PKCS#11 uses the same headers, I
removed it also from libmusclecard.

I have removed some debug code. There were only five places with debug
code and no continuous and exhausting use of it.

A file install.w32 is included instructing the build process.

Bye, Karsten
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle

_______________________________________________ Muscle mailing list [email protected] http://lists.drizzle.com/mailman/listinfo/muscle

Reply via email to