[Pcsclite-cvs-commit] r6008 - in /trunk/PCSC/src/spy: install_spy.sh pcsc-spy.c uninstall_spy.sh

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Fri Oct 7 09:50:25 UTC 2011


Author: rousseau
Date: Fri Oct  7 09:50:25 2011
New Revision: 6008

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6008
Log:
Allow to replace the real library by the spy one

This is isefull for interpreted languages like Python and Perl with the
PC/SC wrapper.

The scripts install_spy.sh and uninstall_spy.sh do the files changes in
/usr/lib

Added:
    trunk/PCSC/src/spy/install_spy.sh   (with props)
    trunk/PCSC/src/spy/uninstall_spy.sh   (with props)
Modified:
    trunk/PCSC/src/spy/pcsc-spy.c

Added: trunk/PCSC/src/spy/install_spy.sh
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/spy/install_spy.sh?rev=6008&op=file
==============================================================================
--- trunk/PCSC/src/spy/install_spy.sh (added)
+++ trunk/PCSC/src/spy/install_spy.sh Fri Oct  7 09:50:25 2011
@@ -1,0 +1,9 @@
+#!/bin/sh
+
+cd /usr/lib
+
+# backup the real library
+cp libpcsclite.so.1 libpcsclite_nospy.so.1
+
+# link to the spy library
+ln -sf libpcscspy.so.0.0.0 libpcsclite.so.1.0.0

Propchange: trunk/PCSC/src/spy/install_spy.sh
------------------------------------------------------------------------------
    svn:executable = *

Modified: trunk/PCSC/src/spy/pcsc-spy.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/spy/pcsc-spy.c?rev=6008&op=diff
==============================================================================
--- trunk/PCSC/src/spy/pcsc-spy.c (original)
+++ trunk/PCSC/src/spy/pcsc-spy.c Fri Oct  7 09:50:25 2011
@@ -291,12 +291,24 @@
 {
 	void *handle;
 
+#define LIBPCSC_NOSPY "libpcsclite_nospy.so.1"
 #define LIBPCSC "libpcsclite.so.1"
-	handle = dlopen(LIBPCSC, RTLD_LAZY);
+
+	/* first try to load the NOSPY library
+	 * this is used for programs doing an explicit dlopen like
+	 * Perl and Python wrappers */
+	handle = dlopen(LIBPCSC_NOSPY, RTLD_LAZY);
 	if (NULL == handle)
 	{
 		log_line("%s", dlerror());
-		return SCARD_F_INTERNAL_ERROR;
+
+		/* load the normal library */
+		handle = dlopen(LIBPCSC, RTLD_LAZY);
+		if (NULL == handle)
+		{
+			log_line("%s", dlerror());
+			return SCARD_F_INTERNAL_ERROR;
+		}
 	}
 
 #define get_symbol(s) do { spy.s = dlsym(handle, #s); if (NULL == spy.s) { log_line("%s", dlerror()); return SCARD_F_INTERNAL_ERROR; } } while (0)
@@ -643,3 +655,11 @@
 	return rv;
 }
 
+PCSC_API p_pcsc_stringify_error(pcsc_stringify_error)
+{
+	return spy.pcsc_stringify_error(pcscError);
+}
+
+PCSC_API const SCARD_IO_REQUEST g_rgSCardT0Pci = { SCARD_PROTOCOL_T0, sizeof(SCARD_IO_REQUEST) };
+PCSC_API const SCARD_IO_REQUEST g_rgSCardT1Pci = { SCARD_PROTOCOL_T1, sizeof(SCARD_IO_REQUEST) };
+PCSC_API const SCARD_IO_REQUEST g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, sizeof(SCARD_IO_REQUEST) };

Added: trunk/PCSC/src/spy/uninstall_spy.sh
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/spy/uninstall_spy.sh?rev=6008&op=file
==============================================================================
--- trunk/PCSC/src/spy/uninstall_spy.sh (added)
+++ trunk/PCSC/src/spy/uninstall_spy.sh Fri Oct  7 09:50:25 2011
@@ -1,0 +1,6 @@
+#!/bin/sh
+
+cd /usr/lib
+
+# Use the real library again
+mv libpcsclite_nospy.so.1 libpcsclite.so.1.0.0

Propchange: trunk/PCSC/src/spy/uninstall_spy.sh
------------------------------------------------------------------------------
    svn:executable = *




More information about the Pcsclite-cvs-commit mailing list