[Pcsclite-cvs-commit] r1985 - trunk/Drivers/ccid/examples

Ludovic Rousseau rousseau at costa.debian.org
Mon Mar 27 16:46:59 CEST 2006


Author: rousseau
Date: 2006-03-27 14:46:57 +0000 (Mon, 27 Mar 2006)
New Revision: 1985

Modified:
   trunk/Drivers/ccid/examples/scardcontrol.c
Log:
Modify PIN: use a for() loop instead of 3 fgets() since we will not read
every "PIN" if the command is aborted


Modified: trunk/Drivers/ccid/examples/scardcontrol.c
===================================================================
--- trunk/Drivers/ccid/examples/scardcontrol.c	2006-03-27 14:39:48 UTC (rev 1984)
+++ trunk/Drivers/ccid/examples/scardcontrol.c	2006-03-27 14:46:57 UTC (rev 1985)
@@ -476,30 +476,27 @@
 		fd_set fd;
 #endif
 		struct timeval timeout;
+		int i;
 
-		FD_ZERO(&fd);
-		FD_SET(STDIN_FILENO, &fd);	/* stdin */
-		timeout.tv_sec = 0;			/* timeout = 0 */
-		timeout.tv_usec = 0;
-
-		/* we only try to read stdin if the pinpad is on a keyboard
-		 * we do not read stdin for a SPR 532 for example */
-		if (select(1, &fd, NULL, NULL, &timeout) > 0)
+		/* old PIN, new PIN, confirmation PIN */
+		/* if the command is aborted we will not read every "PIN" */
+		for (i=0; i<3; i++)
 		{
-			/* read the fake digits */
-			char in[40];	/* 4 digits + \n + \0 */
+			FD_ZERO(&fd);
+			FD_SET(STDIN_FILENO, &fd);	/* stdin */
+			timeout.tv_sec = 0;			/* timeout = 0 */
+			timeout.tv_usec = 0;
 
-			/* old PIN */
-			(void)fgets(in, sizeof(in), stdin);
-			printf("keyboard sent: %s", in);
+			/* we only try to read stdin if the pinpad is on a keyboard
+			 * we do not read stdin for a SPR 532 for example */
+			if (select(1, &fd, NULL, NULL, &timeout) > 0)
+			{
+				/* read the fake digits */
+				char in[40];	/* 4 digits + \n + \0 */
 
-			/* new PIN */
-			(void)fgets(in, sizeof(in), stdin);
-			printf("keyboard sent: %s", in);
-
-			/* confirmation PIN */
-			(void)fgets(in, sizeof(in), stdin);
-			printf("keyboard sent: %s", in);
+				(void)fgets(in, sizeof(in), stdin);
+				printf("keyboard sent: %s", in);
+			}
 		}
 	}
 




More information about the Pcsclite-cvs-commit mailing list