[Pcsclite-cvs-commit] r1673 - trunk/PCSC/src

Ludovic Rousseau rousseau at costa.debian.org
Mon Sep 26 12:28:30 UTC 2005


Author: rousseau
Date: 2005-09-26 12:28:30 +0000 (Mon, 26 Sep 2005)
New Revision: 1673

Modified:
   trunk/PCSC/src/winscard_clnt.c
Log:
SCardGetStatusChange(): exists if the list of readers changed (one
reader added) so that the application can update its list of readers

Thanks to Najam Siddiqui for a preliminary patch.


Modified: trunk/PCSC/src/winscard_clnt.c
===================================================================
--- trunk/PCSC/src/winscard_clnt.c	2005-09-20 14:06:27 UTC (rev 1672)
+++ trunk/PCSC/src/winscard_clnt.c	2005-09-26 12:28:30 UTC (rev 1673)
@@ -44,6 +44,11 @@
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 #endif
 
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
 /**
  * Represents an Application Context Channel.
  * A channel belongs to an Application Context (\c _psContextMap).
@@ -1517,6 +1522,7 @@
 	DWORD dwBreakFlag = 0;
 	int j;
 	DWORD dwContextIndex;
+	int currentReaderCount = 0;
 
 	if (rgReaderStates == 0 && cReaders > 0)
 		return SCARD_E_INVALID_PARAMETER;
@@ -1632,16 +1638,39 @@
 
 	psContextMap[dwContextIndex].contextBlockStatus = BLOCK_STATUS_BLOCKING;
 
+	/* Get the initial reader count on the system */
+	for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++)
+		if ((readerStates[j])->readerID != 0)
+			currentReaderCount++;
+
 	j = 0;
 
 	do
 	{
+		int newReaderCount = 0;
+		char ReaderCountChanged = FALSE;
+
 		if (SCardCheckDaemonAvailability() != SCARD_S_SUCCESS)
 		{
 			SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex);	
 			return SCARD_E_NO_SERVICE;
 		}
 
+		if (j == 0)
+		{
+			int i;
+
+			for (i=0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
+				if ((readerStates[i])->readerID != 0)
+					newReaderCount++;
+
+			if (newReaderCount != currentReaderCount)
+			{
+				Log1(PCSC_LOG_INFO, "Reader list changed");
+				ReaderCountChanged = TRUE;
+				currentReaderCount = newReaderCount;
+			}
+		}
 		currReader = &rgReaderStates[j];
 
 	/************ Look for IGNORED readers ****************************/
@@ -1905,7 +1934,18 @@
 		 */
 		j = j + 1;
 		if (j == cReaders)
+		{
+			if (!dwBreakFlag)
+			{
+				/* break if the reader count changed,
+				 * so that the calling application can update
+				 * the reader list
+				 */
+				if (ReaderCountChanged)
+					break;
+			}
 			j = 0;
+		}
 
 		/*
 		 * Declare all the break conditions




More information about the Pcsclite-cvs-commit mailing list