[Pcsclite-cvs-commit] PCSC/src ifdwrapper.h,1.7,1.8 ifdwrapper.c,1.19,1.20

rousseau@haydn.debian.org rousseau@haydn.debian.org


Update of /cvsroot/pcsclite/PCSC/src
In directory haydn:/tmp/cvs-serv16851/src

Modified Files:
	ifdwrapper.h ifdwrapper.c 
Log Message:
in IFDStatusICC() the argument pdwProtocol was set as:
  *pdwProtocol = rContext->dwProtocol;
and rContext was an input argument.

So IFDStatusICC() had _no_ action on pdwProtocol expect make a copy form
an IN parameter to an OUT parameter. This was useless and misleading.
PDWORD pdwProtocol is now removed.


Index: ifdwrapper.h
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/ifdwrapper.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ifdwrapper.h	19 Apr 2004 14:59:59 -0000	1.7
+++ ifdwrapper.h	18 Jun 2004 08:32:01 -0000	1.8
@@ -6,6 +6,7 @@
  *
  * Copyright (C) 1999-2004
  *  David Corcoran <corcoran@linuxnet.com>
+ *  Ludovic Rousseau <ludovic.rouseau@free.fr>
  *
  * $Id$
  */
@@ -21,7 +22,7 @@
 	LONG IFDOpenIFD(PREADER_CONTEXT);
 	LONG IFDCloseIFD(PREADER_CONTEXT);
 	LONG IFDPowerICC(PREADER_CONTEXT, DWORD, PUCHAR, PDWORD);
-	LONG IFDStatusICC(PREADER_CONTEXT, PDWORD, PDWORD, PUCHAR, PDWORD);
+	LONG IFDStatusICC(PREADER_CONTEXT, PDWORD, PUCHAR, PDWORD);
 	LONG IFDControl_v2(PREADER_CONTEXT, PUCHAR, DWORD, PUCHAR, PDWORD);
 	LONG IFDControl(PREADER_CONTEXT, DWORD, LPCVOID, DWORD, LPVOID,
 		DWORD, LPDWORD);

Index: ifdwrapper.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/ifdwrapper.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- ifdwrapper.c	17 Jun 2004 08:14:56 -0000	1.19
+++ ifdwrapper.c	18 Jun 2004 08:32:01 -0000	1.20
@@ -414,7 +414,7 @@
 	RESPONSECODE rv, ret;
 	LPVOID vFunction;
 	SMARTCARD_EXTENSION sSmartCard;
-	DWORD dwStatus, dwProtocol;
+	DWORD dwStatus;
 	UCHAR ucValue[1];
 
 #ifndef PCSCLITE_STATIC_DRIVER
@@ -428,13 +428,12 @@
 	rv = 0;
 	vFunction = NULL;
 	dwStatus = 0;
-	dwProtocol = 0;
 	ucValue[0] = 0;
 
 	/*
 	 * Check that the card is inserted first 
 	 */
-	IFDStatusICC(rContext, &dwStatus, &dwProtocol, pucAtr, pdwAtrLen);
+	IFDStatusICC(rContext, &dwStatus, pucAtr, pdwAtrLen);
 
 	if (dwStatus & SCARD_ABSENT)
 		return SCARD_W_REMOVED_CARD;
@@ -451,7 +450,7 @@
 		IFD_power_icc = (RESPONSECODE(*)(DWORD)) vFunction;
 	else
 		IFDH_power_icc = (RESPONSECODE(*)(DWORD, DWORD, PUCHAR,
-				PDWORD)) vFunction;
+			PDWORD)) vFunction;
 #endif
 
 	/*
@@ -463,8 +462,8 @@
 #ifndef PCSCLITE_STATIC_DRIVER
 	if (rContext->dwVersion == IFD_HVERSION_1_0)
 	{
-	        ucValue[0] = rContext->dwSlot;
-	        IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
+		ucValue[0] = rContext->dwSlot;
+		IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
 		rv = (*IFD_power_icc) (dwAction);
 	}
 	else
@@ -477,8 +476,8 @@
 #else
 	if (rContext->dwVersion == IFD_HVERSION_1_0)
 	{
-	        ucValue[0] = rContext->dwSlot;
-	        IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
+		ucValue[0] = rContext->dwSlot;
+		IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
 		rv = IFD_Power_ICC(dwAction);
 	}
 	else
@@ -490,11 +489,18 @@
 	 * END OF LOCKED REGION 
 	 */
 
+	/* use clean values in case of error */
+	if (rv != IFD_SUCCESS)
+	{
+		*pdwAtrLen = 0;
+		pucAtr[0] = '\0';
+	}
+
 	/*
 	 * Get the ATR and it's length 
 	 */
 	if (rContext->dwVersion == IFD_HVERSION_1_0)
-		IFDStatusICC(rContext, &dwStatus, &dwProtocol, pucAtr, pdwAtrLen);
+		IFDStatusICC(rContext, &dwStatus, pucAtr, pdwAtrLen);
 
 	return rv;
 }
@@ -506,7 +512,7 @@
  */
 
 LONG IFDStatusICC(PREADER_CONTEXT rContext, PDWORD pdwStatus,
-	PDWORD pdwProtocol, PUCHAR pucAtr, PDWORD pdwAtrLen)
+	PUCHAR pucAtr, PDWORD pdwAtrLen)
 {
 	RESPONSECODE rv, rv1;
 	LPVOID vFunctionA, vFunctionB;
@@ -563,8 +569,8 @@
 #ifndef PCSCLITE_STATIC_DRIVER
 	if (rContext->dwVersion == IFD_HVERSION_1_0)
 	{
-	        ucValue[0] = rContext->dwSlot;
-	        IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
+		ucValue[0] = rContext->dwSlot;
+		IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
 		rv = (*IFD_is_icc_present) ();
 	}
 	else
@@ -572,8 +578,8 @@
 #else
 	if (rContext->dwVersion == IFD_HVERSION_1_0)
 	{
-	        ucValue[0] = rContext->dwSlot;
-	        IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
+		ucValue[0] = rContext->dwSlot;
+		IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
 		rv = IFD_Is_ICC_Present();
 	}
 	else
@@ -653,7 +659,6 @@
 	}
 
 	*pdwStatus = dwCardStatus;
-	*pdwProtocol = rContext->dwProtocol;
 
 	return SCARD_S_SUCCESS;
 }