[Pcsclite-cvs-commit] r4338 - /trunk/Drivers/ccid/examples/scardcontrol.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Jul 21 17:26:15 UTC 2009
Author: rousseau
Date: Tue Jul 21 17:26:14 2009
New Revision: 4338
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4338
Log:
check a card is present only _after_
SCardControl(CM_IOCTL_GET_FEATURE_REQUEST)
Modified:
trunk/Drivers/ccid/examples/scardcontrol.c
Modified: trunk/Drivers/ccid/examples/scardcontrol.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/examples/scardcontrol.c?rev=4338&op=diff
==============================================================================
--- trunk/Drivers/ccid/examples/scardcontrol.c (original)
+++ trunk/Drivers/ccid/examples/scardcontrol.c Tue Jul 21 17:26:14 2009
@@ -199,6 +199,43 @@
PCSC_ERROR_CONT(rv, "SCardControl")
#endif
+ /* does the reader support PIN verification? */
+ rv = SCardControl(hCard, CM_IOCTL_GET_FEATURE_REQUEST, NULL, 0,
+ bRecvBuffer, sizeof(bRecvBuffer), &length);
+ PCSC_ERROR_EXIT(rv, "SCardControl")
+
+ printf(" TLV (%ld): ", length);
+ for (i=0; i<length; i++)
+ printf("%02X ", bRecvBuffer[i]);
+ printf("\n");
+
+ PCSC_ERROR_CONT(rv, "SCardControl(CM_IOCTL_GET_FEATURE_REQUEST)")
+
+ if (length % sizeof(PCSC_TLV_STRUCTURE))
+ {
+ printf("Inconsistent result! Bad TLV values!\n");
+ goto end;
+ }
+
+ /* get the number of elements instead of the complete size */
+ length /= sizeof(PCSC_TLV_STRUCTURE);
+
+ pcsc_tlv = (PCSC_TLV_STRUCTURE *)bRecvBuffer;
+ for (i = 0; i < length; i++)
+ {
+ if (pcsc_tlv[i].tag == FEATURE_VERIFY_PIN_DIRECT)
+ verify_ioctl = ntohl(pcsc_tlv[i].value);
+ if (pcsc_tlv[i].tag == FEATURE_MODIFY_PIN_DIRECT)
+ modify_ioctl = ntohl(pcsc_tlv[i].value);
+ }
+
+ if (0 == verify_ioctl)
+ {
+ printf("Reader %s does not support PIN verification\n",
+ readers[reader_nb]);
+ goto end;
+ }
+
/* get card status */
dwAtrLen = sizeof(pbAtr);
dwReaderLen = sizeof(pbReader);
@@ -216,43 +253,6 @@
if (dwState & SCARD_ABSENT)
{
printf("No card inserted\n");
- goto end;
- }
-
- /* does the reader support PIN verification? */
- rv = SCardControl(hCard, CM_IOCTL_GET_FEATURE_REQUEST, NULL, 0,
- bRecvBuffer, sizeof(bRecvBuffer), &length);
- PCSC_ERROR_EXIT(rv, "SCardControl")
-
- printf(" TLV (%ld): ", length);
- for (i=0; i<length; i++)
- printf("%02X ", bRecvBuffer[i]);
- printf("\n");
-
- PCSC_ERROR_CONT(rv, "SCardControl(CM_IOCTL_GET_FEATURE_REQUEST)")
-
- if (length % sizeof(PCSC_TLV_STRUCTURE))
- {
- printf("Inconsistent result! Bad TLV values!\n");
- goto end;
- }
-
- /* get the number of elements instead of the complete size */
- length /= sizeof(PCSC_TLV_STRUCTURE);
-
- pcsc_tlv = (PCSC_TLV_STRUCTURE *)bRecvBuffer;
- for (i = 0; i < length; i++)
- {
- if (pcsc_tlv[i].tag == FEATURE_VERIFY_PIN_DIRECT)
- verify_ioctl = ntohl(pcsc_tlv[i].value);
- if (pcsc_tlv[i].tag == FEATURE_MODIFY_PIN_DIRECT)
- modify_ioctl = ntohl(pcsc_tlv[i].value);
- }
-
- if (0 == verify_ioctl)
- {
- printf("Reader %s does not support PIN verification\n",
- readers[reader_nb]);
goto end;
}
More information about the Pcsclite-cvs-commit
mailing list