[Pcsclite-cvs-commit] r3021 - /trunk/PCSC/src/testpcsc.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Tue Jun 24 09:59:35 UTC 2008


Author: rousseau
Date: Tue Jun 24 09:59:35 2008
New Revision: 3021

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3021
Log:
test SCardGetAttrib() with SCARD_AUTOALLOCATE

Modified:
    trunk/PCSC/src/testpcsc.c

Modified: trunk/PCSC/src/testpcsc.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/testpcsc.c?rev=3021&op=diff
==============================================================================
--- trunk/PCSC/src/testpcsc.c (original)
+++ trunk/PCSC/src/testpcsc.c Tue Jun 24 09:59:35 2008
@@ -62,6 +62,8 @@
 	DWORD dwPref, dwReaders = 0;
 	char *pcReaders, *mszReaders;
 	unsigned char pbAtr[MAX_ATR_SIZE];
+	unsigned char *pbAttr = NULL;
+	DWORD pcbAttrLen;
 	char *mszGroups;
 	DWORD dwGroups = 0;
 	long rv;
@@ -251,22 +253,40 @@
 	test_rv(rv, hContext, DONT_PANIC);
 
 	printf("Testing SCardGetAttrib\t\t: ");
-	rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, NULL, &dwAtrLen);
-	test_rv(rv, hContext, DONT_PANIC);
-	if (rv == SCARD_S_SUCCESS)
-		printf("SCARD_ATTR_ATR_STRING length: " GREEN "%ld\n" NORMAL, dwAtrLen);
-
-	printf("Testing SCardGetAttrib\t\t: ");
-	dwAtrLen = sizeof(pbAtr);
-	rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, pbAtr, &dwAtrLen);
-	test_rv(rv, hContext, DONT_PANIC);
-	if (rv == SCARD_S_SUCCESS)
-	{
+#ifdef USE_AUTOALLOCATE
+	pcbAttrLen = SCARD_AUTOALLOCATE;
+	rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, (unsigned char *)&pbAttr,
+		&pcbAttrLen);
+#else
+	rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, NULL, &pcbAttrLen);
+	test_rv(rv, hContext, DONT_PANIC);
+	if (rv == SCARD_S_SUCCESS)
+	{
+		printf("SCARD_ATTR_ATR_STRING length: " GREEN "%ld\n" NORMAL, pcbAttrLen);
+		pbAttr = malloc(pcbAttrLen);
+	}
+
+	printf("Testing SCardGetAttrib\t\t: ");
+	rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, pbAttr, &pcbAttrLen);
+#endif
+	test_rv(rv, hContext, DONT_PANIC);
+	if (rv == SCARD_S_SUCCESS)
+	{
+		printf("SCARD_ATTR_ATR_STRING length: " GREEN "%ld\n" NORMAL, pcbAttrLen);
 		printf("SCARD_ATTR_ATR_STRING: " GREEN);
-		for (i = 0; i < dwAtrLen; i++)
-			printf("%02X ", pbAtr[i]);
+		for (i = 0; i < pcbAttrLen; i++)
+			printf("%02X ", pbAttr[i]);
 		printf("\n" NORMAL);
 	}
+
+#ifdef USE_AUTOALLOCATE
+	printf("Testing SCardFreeMemory\t\t: ");
+	rv = SCardFreeMemory(hContext, pbAttr);
+	test_rv(rv, hContext, PANIC);
+#else
+	if (pbAttr)
+		free(pbAttr);
+#endif
 
 	printf("Testing SCardGetAttrib\t\t: ");
 	dwAtrLen = sizeof(pbAtr);




More information about the Pcsclite-cvs-commit mailing list