[Pcsclite-cvs-commit] PCSC/src ifdwrapper.c,1.25,1.26 readerfactory.c,1.61,1.62
rousseau@haydn.debian.org
rousseau@haydn.debian.org
Update of /cvsroot/pcsclite/PCSC/src
In directory haydn:/tmp/cvs-serv16689
Modified Files:
ifdwrapper.c readerfactory.c
Log Message:
use the new psFunctions C union
Index: ifdwrapper.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/ifdwrapper.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- ifdwrapper.c 6 Aug 2004 12:12:20 -0000 1.25
+++ ifdwrapper.c 13 Aug 2004 20:28:35 -0000 1.26
@@ -35,31 +35,27 @@
UCHAR ucValue[1];
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunction;
RESPONSECODE(*IFD_set_protocol_parameters) (DWORD, UCHAR, UCHAR,
UCHAR, UCHAR) = NULL;
RESPONSECODE(*IFDH_set_protocol_parameters) (DWORD, DWORD, UCHAR,
UCHAR, UCHAR, UCHAR) = NULL;
- /*
- * Make sure the symbol exists in the driver
- */
- vFunction = rContext->psFunctions.pvfSetProtocolParameters;
-
- if (vFunction == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
if (rContext->dwVersion == IFD_HVERSION_1_0)
{
- IFD_set_protocol_parameters = (RESPONSECODE(*)(DWORD, UCHAR,
- UCHAR, UCHAR,
- UCHAR))
- vFunction;
- } else
+ IFD_set_protocol_parameters = (RESPONSECODE(*)(DWORD, UCHAR, UCHAR,
+ UCHAR, UCHAR)) rContext->psFunctions.psFunctions_v1.pvfSetProtocolParameters;
+
+ if (NULL == IFD_set_protocol_parameters)
+ return SCARD_E_UNSUPPORTED_FEATURE;
+ }
+ else
{
- IFDH_set_protocol_parameters =
- (RESPONSECODE(*)(DWORD, DWORD, UCHAR, UCHAR, UCHAR,
- UCHAR)) vFunction;
+ IFDH_set_protocol_parameters = (RESPONSECODE(*)(DWORD, DWORD, UCHAR,
+ UCHAR, UCHAR, UCHAR))
+ rContext->psFunctions.psFunctions_v2.pvfSetProtocolParameters;
+
+ if (NULL == IFDH_set_protocol_parameters)
+ return SCARD_E_UNSUPPORTED_FEATURE;
}
#endif
@@ -118,33 +114,24 @@
RESPONSECODE rv = 0;
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunction;
- LPVOID vFunction1;
RESPONSECODE(*IO_create_channel) (DWORD) = NULL;
RESPONSECODE(*IFDH_create_channel) (DWORD, DWORD) = NULL;
RESPONSECODE(*IFDH_create_channel_by_name) (DWORD, LPTSTR) = NULL;
- /*
- * Make sure the symbol exists in the driver
- */
- vFunction = rContext->psFunctions.pvfCreateChannel;
- vFunction1 = rContext->psFunctions.pvfCreateChannelByName;
-
- if (vFunction == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
if (rContext->dwVersion == IFD_HVERSION_1_0)
- {
- IO_create_channel = (RESPONSECODE(*)(DWORD)) vFunction;
- } else if (rContext->dwVersion == IFD_HVERSION_2_0)
- {
- IFDH_create_channel = (RESPONSECODE(*)(DWORD, DWORD)) vFunction;
- }
+ IO_create_channel =
+ rContext->psFunctions.psFunctions_v1.pvfCreateChannel;
else
- {
- IFDH_create_channel = (RESPONSECODE(*)(DWORD, DWORD)) vFunction;
- IFDH_create_channel_by_name = (RESPONSECODE(*)(DWORD, LPTSTR)) vFunction1;
- }
+ if (rContext->dwVersion == IFD_HVERSION_2_0)
+ IFDH_create_channel =
+ rContext->psFunctions.psFunctions_v2.pvfCreateChannel;
+ else
+ {
+ IFDH_create_channel =
+ rContext->psFunctions.psFunctions_v3.pvfCreateChannel;
+ IFDH_create_channel_by_name =
+ rContext->psFunctions.psFunctions_v3.pvfCreateChannelByName;
+ }
#endif
/*
@@ -161,11 +148,13 @@
rv = (*IFDH_create_channel) (rContext->dwSlot, rContext->dwPort);
} else
{
+ DebugLogA("POUET");
/* use device name only if defined */
if (rContext->lpcDevice[0] != '\0')
rv = (*IFDH_create_channel_by_name) (rContext->dwSlot, rContext->lpcDevice);
else
rv = (*IFDH_create_channel) (rContext->dwSlot, rContext->dwPort);
+ DebugLogA("POUET");
}
#else
if (rContext->dwVersion == IFD_HVERSION_1_0)
@@ -202,22 +191,13 @@
RESPONSECODE rv = 0;
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunction;
RESPONSECODE(*IO_close_channel) () = NULL;
RESPONSECODE(*IFDH_close_channel) (DWORD) = NULL;
- /*
- * Make sure the symbol exists in the driver
- */
- vFunction = rContext->psFunctions.pvfCloseChannel;
-
- if (vFunction == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
if (rContext->dwVersion == IFD_HVERSION_1_0)
- IO_close_channel = (RESPONSECODE(*)())vFunction;
+ IO_close_channel = rContext->psFunctions.psFunctions_v1.pvfCloseChannel;
else
- IFDH_close_channel = (RESPONSECODE(*)(DWORD)) vFunction;
+ IFDH_close_channel = rContext->psFunctions.psFunctions_v2.pvfCloseChannel;
#endif
/*
@@ -257,23 +237,13 @@
LONG rv = 0;
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunction;
RESPONSECODE(*IFD_set_capabilities) (DWORD, PUCHAR) = NULL;
RESPONSECODE(*IFDH_set_capabilities) (DWORD, DWORD, DWORD, PUCHAR) = NULL;
- /*
- * Make sure the symbol exists in the driver
- */
- vFunction = rContext->psFunctions.pvfSetCapabilities;
-
- if (vFunction == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
if (rContext->dwVersion == IFD_HVERSION_1_0)
- IFD_set_capabilities = (RESPONSECODE(*)(DWORD, PUCHAR)) vFunction;
+ IFD_set_capabilities = rContext->psFunctions.psFunctions_v1.pvfSetCapabilities;
else
- IFDH_set_capabilities = (RESPONSECODE(*)(DWORD, DWORD, DWORD,
- PUCHAR)) vFunction;
+ IFDH_set_capabilities = rContext->psFunctions.psFunctions_v2.pvfSetCapabilities;
#endif
/*
@@ -310,24 +280,15 @@
LONG rv = 0;
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunction;
RESPONSECODE(*IFD_get_capabilities) (DWORD, PUCHAR) = NULL;
RESPONSECODE(*IFDH_get_capabilities) (DWORD, DWORD, PDWORD, PUCHAR) = NULL;
- /*
- * Make sure the symbol exists in the driver
- */
- vFunction = rContext->psFunctions.pvfGetCapabilities;
-
- if (vFunction == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
if (rContext->dwVersion == IFD_HVERSION_1_0)
- IFD_get_capabilities = (RESPONSECODE(*)(DWORD, PUCHAR))
- vFunction;
+ IFD_get_capabilities =
+ rContext->psFunctions.psFunctions_v1.pvfGetCapabilities;
else
- IFDH_get_capabilities = (RESPONSECODE(*)(DWORD, DWORD, PDWORD,
- PUCHAR)) vFunction;
+ IFDH_get_capabilities =
+ rContext->psFunctions.psFunctions_v2.pvfGetCapabilities;
#endif
/*
@@ -373,7 +334,6 @@
UCHAR ucValue[1];
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunction;
RESPONSECODE(*IFD_power_icc) (DWORD) = NULL;
RESPONSECODE(*IFDH_power_icc) (DWORD, DWORD, PUCHAR, PDWORD) = NULL;
#endif
@@ -393,19 +353,10 @@
if (dwStatus & SCARD_ABSENT)
return SCARD_W_REMOVED_CARD;
#ifndef PCSCLITE_STATIC_DRIVER
- /*
- * Make sure the symbol exists in the driver
- */
- vFunction = rContext->psFunctions.pvfPowerICC;
-
- if (vFunction == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
if (rContext->dwVersion == IFD_HVERSION_1_0)
- IFD_power_icc = (RESPONSECODE(*)(DWORD)) vFunction;
+ IFD_power_icc = rContext->psFunctions.psFunctions_v1.pvfPowerICC;
else
- IFDH_power_icc = (RESPONSECODE(*)(DWORD, DWORD, PUCHAR,
- PDWORD)) vFunction;
+ IFDH_power_icc = rContext->psFunctions.psFunctions_v2.pvfPowerICC;
#endif
/*
@@ -475,31 +426,19 @@
UCHAR ucValue[1] = "\x00";
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunctionA, vFunctionB;
RESPONSECODE(*IFD_is_icc_present) () = NULL;
RESPONSECODE(*IFDH_icc_presence) (DWORD) = NULL;
RESPONSECODE(*IFD_get_capabilities) (DWORD, PUCHAR) = NULL;
- /*
- * Make sure the symbol exists in the driver
- */
- vFunctionA = rContext->psFunctions.pvfICCPresence;
- vFunctionB = rContext->psFunctions.pvfGetCapabilities;
-
- if (vFunctionA == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
- if ((vFunctionB == NULL) && (rContext->dwVersion == IFD_HVERSION_1_0))
- return SCARD_E_UNSUPPORTED_FEATURE;
-
if (rContext->dwVersion == IFD_HVERSION_1_0)
{
- IFD_is_icc_present = (RESPONSECODE(*)())vFunctionA;
- IFD_get_capabilities = (RESPONSECODE(*)(DWORD, PUCHAR))
- vFunctionB;
+ IFD_is_icc_present =
+ rContext->psFunctions.psFunctions_v1.pvfICCPresence;
+ IFD_get_capabilities =
+ rContext->psFunctions.psFunctions_v1.pvfGetCapabilities;
}
else
- IFDH_icc_presence = (RESPONSECODE(*)(DWORD)) vFunctionA;
+ IFDH_icc_presence = rContext->psFunctions.psFunctions_v2.pvfICCPresence;
#endif
/*
@@ -621,24 +560,15 @@
RESPONSECODE rv = 0;
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunction;
RESPONSECODE(*IFDH_control_v2) (DWORD, PUCHAR, DWORD, PUCHAR, PDWORD);
#endif
+ DebugLogA("POUET");
if (rContext->dwVersion != IFD_HVERSION_2_0)
return SCARD_E_UNSUPPORTED_FEATURE;
#ifndef PCSCLITE_STATIC_DRIVER
- /*
- * Make sure the symbol exists in the driver
- */
- vFunction = rContext->psFunctions.pvfControl;
-
- if (vFunction == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
- IFDH_control_v2 = (RESPONSECODE(*)(DWORD, PUCHAR, DWORD,
- PUCHAR, PDWORD)) vFunction;
+ IFDH_control_v2 = rContext->psFunctions.psFunctions_v2.pvfControl;
#endif
/*
@@ -681,24 +611,15 @@
RESPONSECODE rv = 0;
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunction;
RESPONSECODE(*IFDH_control) (DWORD, DWORD, LPCVOID, DWORD, LPVOID, DWORD, LPDWORD);
#endif
+ DebugLogA("POUET");
if (rContext->dwVersion < IFD_HVERSION_3_0)
return SCARD_E_UNSUPPORTED_FEATURE;
#ifndef PCSCLITE_STATIC_DRIVER
- /*
- * Make sure the symbol exists in the driver
- */
- vFunction = rContext->psFunctions.pvfControl;
-
- if (vFunction == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
- IFDH_control = (RESPONSECODE(*)(DWORD, DWORD, LPCVOID, DWORD,
- LPVOID, DWORD, LPDWORD)) vFunction;
+ IFDH_control = rContext->psFunctions.psFunctions_v3.pvfControl;
#endif
/*
@@ -739,9 +660,8 @@
UCHAR ucValue[1] = "\x00";
#ifndef PCSCLITE_STATIC_DRIVER
- LPVOID vFunction;
RESPONSECODE(*IFD_transmit_to_icc) (SCARD_IO_HEADER, PUCHAR, DWORD,
- PUCHAR, DWORD *, PSCARD_IO_HEADER) = NULL;
+ PUCHAR, PDWORD, PSCARD_IO_HEADER) = NULL;
RESPONSECODE(*IFDH_transmit_to_icc) (DWORD, SCARD_IO_HEADER, PUCHAR,
DWORD, PUCHAR, PDWORD, PSCARD_IO_HEADER) = NULL;
#endif
@@ -750,23 +670,12 @@
DebugLogCategory(DEBUG_CATEGORY_APDU, pucTxBuffer, dwTxLength);
#ifndef PCSCLITE_STATIC_DRIVER
- /*
- * Make sure the symbol exists in the driver
- */
- vFunction = rContext->psFunctions.pvfTransmitToICC;
-
- if (vFunction == NULL)
- return SCARD_E_UNSUPPORTED_FEATURE;
-
if (rContext->dwVersion == IFD_HVERSION_1_0)
- IFD_transmit_to_icc = (RESPONSECODE(*)(SCARD_IO_HEADER, PUCHAR,
- DWORD, PUCHAR, DWORD *,
- PSCARD_IO_HEADER)) vFunction;
+ IFD_transmit_to_icc =
+ rContext->psFunctions.psFunctions_v1.pvfTransmitToICC;
else
IFDH_transmit_to_icc =
- (RESPONSECODE(*)(DWORD, SCARD_IO_HEADER, PUCHAR,
- DWORD, PUCHAR, DWORD *,
- PSCARD_IO_HEADER)) vFunction;
+ rContext->psFunctions.psFunctions_v2.pvfTransmitToICC;
#endif
/*
Index: readerfactory.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/readerfactory.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- readerfactory.c 6 Aug 2004 12:12:20 -0000 1.61
+++ readerfactory.c 13 Aug 2004 20:28:35 -0000 1.62
@@ -789,13 +789,16 @@
DebugLogSuppress(DEBUGLOG_IGNORE_ENTRIES);
rv1 = DYN_GetAddress(rContext->vHandle,
- &rContext->psFunctions.pvfCreateChannel, "IO_Create_Channel");
+ (void **)&rContext->psFunctions.psFunctions_v1.pvfCreateChannel,
+ "IO_Create_Channel");
rv2 = DYN_GetAddress(rContext->vHandle,
- &rContext->psFunctions.pvfCreateChannel, "IFDHCreateChannel");
+ (void **)&rContext->psFunctions.psFunctions_v2.pvfCreateChannel,
+ "IFDHCreateChannel");
rv3 = DYN_GetAddress(rContext->vHandle,
- &rContext->psFunctions.pvfCreateChannelByName, "IFDHCreateChannelByName");
+ (void **)&rContext->psFunctions.psFunctions_v3.pvfCreateChannelByName,
+ "IFDHCreateChannelByName");
DebugLogSuppress(DEBUGLOG_LOG_ENTRIES);
@@ -804,8 +807,6 @@
/*
* Neither version of the IFD Handler was found - exit
*/
- rContext->psFunctions.pvfCreateChannel = NULL;
-
DebugLogA("IFDHandler functions missing");
exit(1);
@@ -815,11 +816,6 @@
* Ifd Handler 1.0 found
*/
rContext->dwVersion = IFD_HVERSION_1_0;
- /*
- * Re bind the function since it was lost in the second
- */
- DYN_GetAddress(rContext->vHandle,
- &rContext->psFunctions.pvfCreateChannel, "IO_Create_Channel");
} else if (rv3 == SCARD_S_SUCCESS)
{
/*
@@ -845,9 +841,9 @@
#define GET_ADDRESS_OPTIONALv1(field, function, code) \
{ \
- if (SCARD_S_SUCCESS != DYN_GetAddress(rContext->vHandle, &rContext->psFunctions.pvf ## field, "IFD_" #function)) \
+ if (SCARD_S_SUCCESS != DYN_GetAddress(rContext->vHandle, (void **)&rContext->psFunctions.psFunctions_v1.pvf ## field, "IFD_" #function)) \
{ \
- rContext->psFunctions.pvf ## field = NULL; \
+ rContext->psFunctions.psFunctions_v1.pvf ## field = NULL; \
code \
} \
}
@@ -857,10 +853,15 @@
DebugLogA("IFDHandler functions missing: " #function ); \
exit(1); )
+ DYN_GetAddress(rContext->vHandle,
+ (void **)&rContext->psFunctions.psFunctions_v1.pvfCreateChannel,
+ "IO_Create_Channel");
+
if (SCARD_S_SUCCESS != DYN_GetAddress(rContext->vHandle,
- &rContext->psFunctions.pvfCloseChannel, "IO_Close_Channel"))
+ (void **)&rContext->psFunctions.psFunctions_v1.pvfCloseChannel,
+ "IO_Close_Channel"))
{
- rContext->psFunctions.pvfCloseChannel = NULL;
+ rContext->psFunctions.psFunctions_v1.pvfCloseChannel = NULL;
DebugLogA("IFDHandler functions missing");
exit(1);
}
@@ -877,17 +878,49 @@
GET_ADDRESS_OPTIONALv1(SetProtocolParameters, Set_Protocol_Parameters, )
GET_ADDRESS_OPTIONALv1(ICCAbsent, Is_ICC_Absent, )
}
- else if ((rContext->dwVersion == IFD_HVERSION_2_0) || (rContext->dwVersion == IFD_HVERSION_3_0))
+ else if (rContext->dwVersion == IFD_HVERSION_2_0)
{
/*
- * The following binds version 2.0/3.0 of the IFD Handler specs
+ * The following binds version 2.0 of the IFD Handler specs
+ */
+
+#define GET_ADDRESS_OPTIONALv2(s, code) \
+{ \
+ if (SCARD_S_SUCCESS != DYN_GetAddress(rContext->vHandle, (void **)&rContext->psFunctions.psFunctions_v2.pvf ## s, "IFDH" #s)) \
+ { \
+ rContext->psFunctions.psFunctions_v2.pvf ## s = NULL; \
+ code \
+ } \
+}
+
+#define GET_ADDRESSv2(s) \
+ GET_ADDRESS_OPTIONALv2(s, \
+ DebugLogA("IFDHandler functions missing: " #s ); \
+ exit(1); )
+
+ DebugLogA("Loading IFD Handler 2.0");
+
+ GET_ADDRESSv2(CloseChannel)
+ GET_ADDRESSv2(GetCapabilities)
+ GET_ADDRESSv2(SetCapabilities)
+ GET_ADDRESSv2(PowerICC)
+ GET_ADDRESSv2(TransmitToICC)
+ GET_ADDRESSv2(ICCPresence)
+ GET_ADDRESS_OPTIONALv2(SetProtocolParameters, )
+
+ GET_ADDRESSv2(Control)
+ }
+ else if (rContext->dwVersion == IFD_HVERSION_3_0)
+ {
+ /*
+ * The following binds version 3.0 of the IFD Handler specs
*/
#define GET_ADDRESS_OPTIONALv3(s, code) \
{ \
- if (SCARD_S_SUCCESS != DYN_GetAddress(rContext->vHandle, &rContext->psFunctions.pvf ## s, "IFDH" #s)) \
+ if (SCARD_S_SUCCESS != DYN_GetAddress(rContext->vHandle, (void **)&rContext->psFunctions.psFunctions_v3.pvf ## s, "IFDH" #s)) \
{ \
- rContext->psFunctions.pvf ## s = NULL; \
+ rContext->psFunctions.psFunctions_v3.pvf ## s = NULL; \
code \
} \
}
@@ -897,20 +930,17 @@
DebugLogA("IFDHandler functions missing: " #s ); \
exit(1); )
- if (rContext->dwVersion == IFD_HVERSION_2_0)
- DebugLogA("Loading IFD Handler 2.0");
- else
- DebugLogA("Loading IFD Handler 3.0");
+ DebugLogA("Loading IFD Handler 3.0");
- GET_ADDRESSv3(CloseChannel)
- GET_ADDRESSv3(GetCapabilities)
- GET_ADDRESSv3(SetCapabilities)
- GET_ADDRESSv3(PowerICC)
- GET_ADDRESSv3(TransmitToICC)
- GET_ADDRESSv3(Control)
- GET_ADDRESSv3(ICCPresence)
+ GET_ADDRESSv2(CloseChannel)
+ GET_ADDRESSv2(GetCapabilities)
+ GET_ADDRESSv2(SetCapabilities)
+ GET_ADDRESSv2(PowerICC)
+ GET_ADDRESSv2(TransmitToICC)
+ GET_ADDRESSv2(ICCPresence)
+ GET_ADDRESS_OPTIONALv2(SetProtocolParameters, )
- GET_ADDRESS_OPTIONALv3(SetProtocolParameters, )
+ GET_ADDRESSv3(Control)
}
else
{
@@ -930,19 +960,7 @@
* Zero out everything
*/
- rContext->psFunctions.pvfCreateChannel = NULL;
- rContext->psFunctions.pvfCreateChannelByName = NULL;
- rContext->psFunctions.pvfCloseChannel = NULL;
- rContext->psFunctions.pvfGetCapabilities = NULL;
- rContext->psFunctions.pvfSetCapabilities = NULL;
- rContext->psFunctions.pvfSetProtocolParameters = NULL;
- rContext->psFunctions.pvfPowerICC = NULL;
- rContext->psFunctions.pvfSwallowICC = NULL;
- rContext->psFunctions.pvfEjectICC = NULL;
- rContext->psFunctions.pvfConfiscateICC = NULL;
- rContext->psFunctions.pvfTransmitToICC = NULL;
- rContext->psFunctions.pvfICCPresence = NULL;
- rContext->psFunctions.pvfICCAbsent = NULL;
+ memset(&rContext->psFunctions, 0, sizeof(rContext->psFunctions));
return SCARD_S_SUCCESS;
}