[Pcsclite-cvs-commit] HandlerTest/Host handler_test.c,1.13,1.14

rousseau@haydn.debian.org rousseau@haydn.debian.org


Update of /cvsroot/pcsclite/HandlerTest/Host
In directory haydn:/tmp/cvs-serv6393

Modified Files:
	handler_test.c 
Log Message:
check the version of the IFDHandler and only use IFDHControl() with an
v3.0 API driver


Index: handler_test.c
===================================================================
RCS file: /cvsroot/pcsclite/HandlerTest/Host/handler_test.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- handler_test.c	22 Jun 2004 11:35:12 -0000	1.13
+++ handler_test.c	8 Jul 2004 16:57:24 -0000	1.14
@@ -79,6 +79,7 @@
 	  			   PSCARD_IO_HEADER);
 	RESPONSECODE (*IFDHControl)(DWORD, DWORD, PUCHAR, DWORD, PUCHAR, DWORD, PDWORD);
 	RESPONSECODE (*IFDHICCPresence)(DWORD);
+	int version;
 };
 
 struct f_t f = { NULL, NULL, NULL, NULL, NULL };
@@ -234,12 +235,21 @@
 	DLSYM(IFDHControl)
 
 	f.IFDHCreateChannelByName = dlsym(lib_handle, "IFDHCreateChannelByName");
-	if (f.IFDHCreateChannelByName == NULL && device_name)
+	if (f.IFDHCreateChannelByName == NULL)
 	{
-		printf("IFDHCreateChannelByName not defined by the driver and device_name set\n");
-		return 1;
+		f.version = IFD_HVERSION_2_0;
+
+		/* API v2.0 does not have IFDHCreateChannelByName */
+		if (device_name)
+		{
+			printf("IFDHCreateChannelByName not defined by the driver and device_name set\n");
+			return 1;
+		}
 	}
+	else
+		f.version = IFD_HVERSION_3_0;
 
+	printf("%s:%d\n", __FILE__, __LINE__);
 	ret = handler_test(LUN, channel, device_name);
 	dlclose(lib_handle);
 
@@ -289,6 +299,7 @@
 
 #define IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE     SCARD_CTL_CODE(1)
 
+	if (f.version >= IFD_HVERSION_3_0)
 	{
 		unsigned char cmd[] = "\x02";
 		unsigned char res[100];