[Pcsclite-cvs-commit] r2081 - trunk/libmusclecard/src

Karsten Ohme ohme-guest at costa.debian.org
Wed Jun 28 16:51:23 UTC 2006


Author: ohme-guest
Date: 2006-06-28 16:51:12 +0000 (Wed, 28 Jun 2006)
New Revision: 2081

Modified:
   trunk/libmusclecard/src/musclecard.c
Log:
cached context was released in MSCReleaseContext() - fixed

Modified: trunk/libmusclecard/src/musclecard.c
===================================================================
--- trunk/libmusclecard/src/musclecard.c	2006-06-15 08:53:14 UTC (rev 2080)
+++ trunk/libmusclecard/src/musclecard.c	2006-06-28 16:51:12 UTC (rev 2081)
@@ -42,7 +42,7 @@
 static SCARDCONTEXT localHContext = 0;
 
 /*
- * internal function 
+ * internal function
  */
 MSC_RV pcscToMSC(MSCLong32);
 MSC_RV MSCReEstablishConnection(MSCLPTokenConnection);
@@ -125,7 +125,7 @@
 	mscUnLockThread();
 
 	/*
-	 * Get the reader list size 
+	 * Get the reader list size
 	 */
 	rv = SCardListReaders(localHContext, NULL, readerList, &readerLength);
 
@@ -140,7 +140,7 @@
 	rv = SCardListReaders(localHContext, NULL, readerList, &readerLength);
 
 	/*
-	 * Now that we have the readers, lets check their status 
+	 * Now that we have the readers, lets check their status
 	 */
 	for (i = 0; i < readerLength - 1; i++)
 	{
@@ -158,7 +158,7 @@
 		}
 
 		/*
-		 * We only care about slots with a token unless stated 
+		 * We only care about slots with a token unless stated
 		 */
 		if ((rgReaderStates.dwEventState & SCARD_STATE_PRESENT) ||
 			(listScope == MSC_LIST_SLOTS))
@@ -167,21 +167,21 @@
 			if (rgReaderStates.dwEventState & SCARD_STATE_PRESENT)
 			{
 				/*
-				 * We only care about supported tokens 
+				 * We only care about supported tokens
 				 */
 				rv = TPSearchBundlesForAtr(rgReaderStates.rgbAtr,
 					rgReaderStates.cbAtr, &tokenInfo);
 			}
 
 			/*
-			 * Success for this function 
+			 * Success for this function
 			 */
 			if ((rv == 0) || (listScope == MSC_LIST_SLOTS) ||
 				(listScope == MSC_LIST_ALL))
 			{
 
 				/*
-				 * We found something interesting to the application 
+				 * We found something interesting to the application
 				 */
 				tokensFound += 1;
 
@@ -245,11 +245,11 @@
 				}
 			}
 			/*
-			 * End of TPSearch success 
+			 * End of TPSearch success
 			 */
 		}
 		/*
-		 * End of if token present 
+		 * End of if token present
 		 */
 		while (readerList[++i] != 0);
 	}	/* End of for .. readers */
@@ -258,7 +258,7 @@
 		free(readerList);
 
 	/*
-	 * Application provides null requesting length 
+	 * Application provides null requesting length
 	 */
 	if (tokenArray == NULL)
 	{
@@ -267,7 +267,7 @@
 	}
 
 	/*
-	 * Provided length is too small 
+	 * Provided length is too small
 	 */
 	if (*arrayLength < tokensFound)
 	{
@@ -323,7 +323,7 @@
 	pConnection->shareMode = 0;
 
 	/*
-	 * Check the token name strings 
+	 * Check the token name strings
 	 */
 	if (sharingMode != MSC_SHARE_DIRECT)
 	{
@@ -335,7 +335,7 @@
 	}
 
 	/*
-	 * Set up the initial connection to the resource manager 
+	 * Set up the initial connection to the resource manager
 	 */
 
 	mscLockThread();
@@ -380,7 +380,7 @@
 	pConnection->shareMode = sharingMode;
 
 	/*
-	 * Set the sendPCI value based on the ActiveProtocol 
+	 * Set the sendPCI value based on the ActiveProtocol
 	 */
 	switch (dwActiveProtocol)
 	{
@@ -396,8 +396,8 @@
 	}
 
 	/*
-	 * Call SCardStatus, make sure the card information matches if it does 
-	 * not return an error.  If it does, copy it 
+	 * Call SCardStatus, make sure the card information matches if it does
+	 * not return an error.  If it does, copy it
 	 */
 
 	rv = SCardStatus(pConnection->hCard, slotName,
@@ -418,7 +418,7 @@
 	{
 		/*
 		 * They asked for direct mode and no card is inserted so we are
-		 * done with this 
+		 * done with this
 		 */
 		return MSC_SUCCESS;
 	}
@@ -441,7 +441,7 @@
 		MSC_MAXSIZE_TOKENAME);
 
 	/*
-	 * Load the library for the token 
+	 * Load the library for the token
 	 */
 	rv = TPLoadToken(pConnection);
 
@@ -457,7 +457,7 @@
 	}
 
 	/*
-	 * Select the AID or initialization routine for the card 
+	 * Select the AID or initialization routine for the card
 	 */
 	vInitFunction = pConnection->libPointers.pvfInitializePlugin;
 	vIdFunction = pConnection->libPointers.pvfIdentifyToken;
@@ -505,7 +505,7 @@
 		if ((applicationName == 0) || (nameSize == 0))
 		{
 			/*
-			 * Use the default AID given by the Info.plist 
+			 * Use the default AID given by the Info.plist
 			 */
 
 			rv = (*libPL_MSCIdentifyToken) (pConnection);
@@ -562,7 +562,7 @@
 	}
 
 	/*
-	 * Select finalization routine for the token plugin 
+	 * Select finalization routine for the token plugin
 	 */
 	vFunction = pConnection->libPointers.pvfFinalizePlugin;
 
@@ -576,12 +576,12 @@
 	libPL_MSCFinalizePlugin = (MSCLong32(*)(MSCLPTokenConnection)) vFunction;
 
 	/*
-	 * Stop and clean up the plugin 
+	 * Stop and clean up the plugin
 	 */
 	rv = (*libPL_MSCFinalizePlugin) (pConnection);
 
 	/*
-	 * Disconnect from the token 
+	 * Disconnect from the token
 	 */
 	if (pConnection->hCard != 0)
 	{
@@ -591,7 +591,7 @@
 	}
 
 	/*
-	 * Unload the token driver 
+	 * Unload the token driver
 	 */
 	if (pConnection->tokenLibHandle != 0)
 	{
@@ -599,16 +599,6 @@
 		pConnection->tokenLibHandle = 0;
 	}
 
-	/*
-	 * Release Context
-	 */
-	if (pConnection->hContext != 0)
-	{
-		rv = SCardReleaseContext(pConnection->hContext);
-		if (pcscToMSC(rv) != MSC_SUCCESS)
-			return pcscToMSC(rv);
-	}
-
 	pConnection->tokenLibHandle = 0;
 	pConnection->hCard = 0;
 	pConnection->hContext = 0;
@@ -630,7 +620,7 @@
 	/*
 	 * Allocate array of SCARD_READERSTATE_A structures, set UNAWARE on
 	 * all of the structures to get the current status and then send them
-	 * to GetStatusChange for blocking event 
+	 * to GetStatusChange for blocking event
 	 */
 
 	if (arraySize == 0)
@@ -640,7 +630,7 @@
 			return MSC_INSUFFICIENT_BUFFER;
 
 	/*
-	 * Set up the initial connection to the resource manager 
+	 * Set up the initial connection to the resource manager
 	 */
 
 	mscLockThread();
@@ -665,7 +655,7 @@
 	for (i = 0; i < arraySize; i++)
 	{
 		/*
-		 * Make sure they don't pass an empty structure 
+		 * Make sure they don't pass an empty structure
 		 */
 		if (strlen(tokenArray[i].slotName) == 0)
 		{
@@ -710,7 +700,7 @@
 		if (tokenArray[i].tokenState & MSC_STATE_CHANGED)
 		{
 			/*
-			 * If it is removed, we need to update the names/etc 
+			 * If it is removed, we need to update the names/etc
 			 */
 			if (tokenArray[i].tokenState & MSC_STATE_EMPTY)
 			{
@@ -729,7 +719,7 @@
 				rt = TPSearchBundlesForAtr(rgReaderStates[i].rgbAtr,
 					rgReaderStates[i].cbAtr, &tokenInfo);
 				/*
-				 * Successfully found 
+				 * Successfully found
 				 */
 				if (rt == 0)
 				{
@@ -809,7 +799,7 @@
 	MSCULong32 curToken;
 
 	/*
-	 * Create the event wait list 
+	 * Create the event wait list
 	 */
 	evlist = (MSCLPEventWaitInfo) malloc(sizeof(MSCEventWaitInfo));
 
@@ -831,7 +821,7 @@
 	memcpy(evlist->tokenArray, tokenArray, sizeof(MSCTokenInfo) * arraySize);
 
 	/*
-	 * Copy the "extra" data 
+	 * Copy the "extra" data
 	 */
 	for (curToken = 0; curToken < arraySize; curToken++)
 	{
@@ -969,7 +959,7 @@
 }
 
 /*
- * Real MSC functions 
+ * Real MSC functions
  */
 
 MSC_RV MSCGetStatus(MSCLPTokenConnection pConnection,
@@ -1482,7 +1472,7 @@
 
 	/*
 	 * Figure out the number of steps total and present this in a percent
-	 * step basis 
+	 * step basis
 	 */
 
 	totalSteps = objectSize / MSC_SIZEOF_KEYPACKET + 1;
@@ -1554,7 +1544,7 @@
 
 	/*
 	 * Figure out the number of steps total and present this in a percent
-	 * step basis 
+	 * step basis
 	 */
 
 	totalSteps = objectSize / MSC_SIZEOF_KEYPACKET + 1;
@@ -1807,7 +1797,7 @@
     MSCObjectInfo objInfo;
     MSCULong32 objectSize;
     MSCPUChar8  data = NULL;
-    
+
     if (pConnection == NULL)
         return MSC_INVALID_PARAMETER;
      if (localHContext == 0)
@@ -1822,7 +1812,7 @@
     *pOutputData = 0;
 
     rv = MSCGetObjectAttributes(pConnection, objectID, &objInfo);
-    if (rv == MSC_SUCCESS) 
+    if (rv == MSC_SUCCESS)
     {
         objectSize = objInfo.objectSize;
         data = (MSCPUChar8) malloc(sizeof(MSCUChar8) * objectSize);
@@ -1830,7 +1820,7 @@
         {
             rv =  MSCReadObject(pConnection, objectID, 0, data,
                      objectSize, rwCallback, addParams);
-            
+
             if (rv == MSC_SUCCESS)
             {
                 *dataSize = objectSize;
@@ -2008,7 +1998,7 @@
 	vIdFunction = NULL;
 
 	/*
-	 * Select the AID or initialization routine for the card 
+	 * Select the AID or initialization routine for the card
 	 */
 	vInitFunction = pConnection->libPointers.pvfInitializePlugin;
 	vFinFunction = pConnection->libPointers.pvfFinalizePlugin;
@@ -2051,17 +2041,17 @@
 		return pcscToMSC(rv);
 
 	/*
-	 * Stop the plugin and start it up again 
+	 * Stop the plugin and start it up again
 	 */
 	rv = (*libPL_MSCFinalizePlugin) (pConnection);
 
 	/*
-	 * Use the default AID given by the Info.plist 
+	 * Use the default AID given by the Info.plist
 	 */
 	rv = (*libPL_MSCInitializePlugin) (pConnection);
 
-	/* 
-	 * Use the default AID given by the Info.plist 
+	/*
+	 * Use the default AID given by the Info.plist
 	 */
 	rv = (*libPL_MSCIdentifyToken) (pConnection);
 
@@ -2138,4 +2128,3 @@
 	else
 		return 0;
 }
-




More information about the Pcsclite-cvs-commit mailing list