[Pcsclite-cvs-commit] r6406 - in /trunk/Drivers/ccid/examples: Makefile.am PCSCv2part10.c PCSCv2part10.h scardcontrol.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Aug 7 14:56:20 UTC 2012
Author: rousseau
Date: Tue Aug 7 14:56:20 2012
New Revision: 6406
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6406
Log:
Use helper functions from libPCSCv2part10 project
Added:
trunk/Drivers/ccid/examples/PCSCv2part10.c (with props)
trunk/Drivers/ccid/examples/PCSCv2part10.h (with props)
Modified:
trunk/Drivers/ccid/examples/Makefile.am
trunk/Drivers/ccid/examples/scardcontrol.c
Modified: trunk/Drivers/ccid/examples/Makefile.am
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/examples/Makefile.am?rev=6406&op=diff
==============================================================================
--- trunk/Drivers/ccid/examples/Makefile.am (original)
+++ trunk/Drivers/ccid/examples/Makefile.am Tue Aug 7 14:56:20 2012
@@ -1,7 +1,7 @@
# Process this file with automake to create Makefile.in.
noinst_PROGRAMS = scardcontrol
-scardcontrol_SOURCES = scardcontrol.c
+scardcontrol_SOURCES = scardcontrol.c PCSCv2part10.c
scardcontrol_CFLAGS = $(PCSC_CFLAGS) $(PTHREAD_CFLAGS)
scardcontrol_LDADD = $(PCSC_LIBS) $(PTHREAD_LIBS)
Added: trunk/Drivers/ccid/examples/PCSCv2part10.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/examples/PCSCv2part10.c?rev=6406&op=file
==============================================================================
--- trunk/Drivers/ccid/examples/PCSCv2part10.c (added)
+++ trunk/Drivers/ccid/examples/PCSCv2part10.c Tue Aug 7 14:56:20 2012
@@ -1,0 +1,1 @@
+link ../../../contrib/libPCSCv2part10/PCSCv2part10.c
Propchange: trunk/Drivers/ccid/examples/PCSCv2part10.c
------------------------------------------------------------------------------
svn:special = *
Added: trunk/Drivers/ccid/examples/PCSCv2part10.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/examples/PCSCv2part10.h?rev=6406&op=file
==============================================================================
--- trunk/Drivers/ccid/examples/PCSCv2part10.h (added)
+++ trunk/Drivers/ccid/examples/PCSCv2part10.h Tue Aug 7 14:56:20 2012
@@ -1,0 +1,1 @@
+link ../../../contrib/libPCSCv2part10/PCSCv2part10.h
Propchange: trunk/Drivers/ccid/examples/PCSCv2part10.h
------------------------------------------------------------------------------
svn:special = *
Modified: trunk/Drivers/ccid/examples/scardcontrol.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/examples/scardcontrol.c?rev=6406&op=diff
==============================================================================
--- trunk/Drivers/ccid/examples/scardcontrol.c (original)
+++ trunk/Drivers/ccid/examples/scardcontrol.c Tue Aug 7 14:56:20 2012
@@ -35,6 +35,8 @@
#endif
#include <reader.h>
+#include "PCSCv2part10.h"
+
#undef VERIFY_PIN
#define MODIFY_PIN
#undef GET_GEMPC_FIRMWARE
@@ -75,6 +77,9 @@
#define PRINT_GREEN_DEC(text, value) \
printf("%s: " GREEN "%d\n" NORMAL, text, value)
+#define PRINT_RED_DEC(text, value) \
+ printf("%s: " RED "%d\n" NORMAL, text, value)
+
#define PRINT_GREEN_HEX2(text, value) \
printf("%s: " GREEN "0x%02X\n" NORMAL, text, value)
@@ -161,49 +166,6 @@
p += len;
}
} /* parse_properties */
-
-static int find_property_by_tag(unsigned char *bRecvBuffer, int length,
- int tag_searched)
-{
- unsigned char *p;
- int found = 0, len, value = -1;
-
- p = bRecvBuffer;
- while (p-bRecvBuffer < length)
- {
- if (*p++ == tag_searched)
- {
- found = 1;
- break;
- }
-
- /* go to next tag */
- len = *p++;
- p += len;
- }
-
- if (found)
- {
- len = *p++;
-
- switch(len)
- {
- case 1:
- value = *p;
- break;
- case 2:
- value = *p + (*(p+1)<<8);
- break;
- case 4:
- value = *p + (*(p+1)<<8) + (*(p+2)<<16) + (*(p+3)<<24);
- break;
- default:
- value = -1;
- }
- }
-
- return value;
-} /* find_property_by_tag */
int main(int argc, char *argv[])
{
@@ -397,7 +359,7 @@
ccid_esc_command = ntohl(pcsc_tlv[i].value);
break;
default:
- printf("Can't parse tag: " RED "0x%02X" NORMAL, pcsc_tlv[i].tag);
+ PRINT_RED_DEC("Can't parse tag", pcsc_tlv[i].tag);
}
}
printf("\n");
@@ -405,6 +367,7 @@
if (properties_in_tlv_ioctl)
{
int value;
+ int ret;
rv = SCardControl(hCard, properties_in_tlv_ioctl, NULL, 0,
bRecvBuffer, sizeof(bRecvBuffer), &length);
@@ -419,11 +382,17 @@
parse_properties(bRecvBuffer, length);
printf("\nFind a specific property:\n");
- value = find_property_by_tag(bRecvBuffer, length, PCSCv2_PART10_PROPERTY_bEntryValidationCondition);
- PRINT_GREEN_DEC(" bEntryValidationCondition", value);
-
- value = find_property_by_tag(bRecvBuffer, length, PCSCv2_PART10_PROPERTY_bMaxPINSize);
- PRINT_GREEN_DEC(" bMaxPINSize", value);
+ ret = PCSCv2Part10_find_TLV_property_by_tag_from_buffer(bRecvBuffer, length, PCSCv2_PART10_PROPERTY_wIdVendor, &value);
+ if (ret)
+ PRINT_RED_DEC(" wIdVendor", ret);
+ else
+ PRINT_GREEN_HEX4(" wIdVendor", value);
+
+ ret = PCSCv2Part10_find_TLV_property_by_tag_from_hcard(hCard, PCSCv2_PART10_PROPERTY_wIdProduct, &value);
+ if (ret)
+ PRINT_RED_DEC(" wIdProduct", ret);
+ else
+ PRINT_GREEN_HEX4(" wIdProduct", value);
printf("\n");
}
More information about the Pcsclite-cvs-commit
mailing list