[Pcsclite-cvs-commit] PCSC/src prothandler.c,1.9,1.10

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


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

Modified Files:
	prothandler.c 
Log Message:
PHSetProtocol() correctly return the selected protocol


Index: prothandler.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/prothandler.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- prothandler.c	10 Jun 2004 14:57:47 -0000	1.9
+++ prothandler.c	16 Jun 2004 14:03:45 -0000	1.10
@@ -76,11 +76,7 @@
 	DWORD dwPreferred, UCHAR ucAvailable)
 {
 	LONG rv;
-
-	/*
-	 * Zero out everything 
-	 */
-	rv = 0;
+	DWORD protocol = rContext->dwProtocol;
 
 	if (dwPreferred == 0)
 	{
@@ -103,11 +99,12 @@
 			 *
 			 * Action: Change to T=0 protocol.  
 			 */
-			rv = IFDSetPTS(rContext, SCARD_PROTOCOL_T0, 0x00,
-				0x00, 0x00, 0x00);
+			rv = IFDSetPTS(rContext, SCARD_PROTOCOL_T0, 0x00, 0x00, 0x00, 0x00);
 
-			if (rv != SCARD_S_SUCCESS)
-				return SCARD_PROTOCOL_T1;
+			if (rv != IFD_SUCCESS)
+				protocol = SCARD_PROTOCOL_T1;
+			else
+				protocol = SCARD_PROTOCOL_T0;
 		}
 		else
 		{
@@ -136,9 +133,9 @@
 				0x00, 0x00, 0x00);
 
 			if (rv != SCARD_S_SUCCESS)
-				return SCARD_PROTOCOL_T0;
+				protocol = SCARD_PROTOCOL_T0;
 			else
-				return SCARD_PROTOCOL_T1;
+				protocol = SCARD_PROTOCOL_T1;
 		}
 		else
 		{
@@ -157,9 +154,8 @@
 		 *
 		 * Action: No need to change protocols 
 		 */
-		return rContext->dwProtocol;
 	}
 
-	return rContext->dwProtocol;
+	return protocol;
 }