[Pcsclite-cvs-commit] Drivers/ccid/src utils.c,1.5,1.6 utils.h,1.1.1.1,1.2

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


Update of /cvsroot/pcsclite/Drivers/ccid/src
In directory haydn:/tmp/cvs-serv22300/src

Modified Files:
	utils.c utils.h 
Log Message:
use a more complex Lun -> reader transformation
(Lun>>16) is not usable for multi-slots readers


Index: utils.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/utils.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- utils.c	16 Jul 2004 06:53:25 -0000	1.5
+++ utils.c	28 Jul 2004 08:30:30 -0000	1.6
@@ -28,14 +28,40 @@
 #include "ccid_ifdhandler.h"
 #include "utils.h"
 
-/* Check if the Lun is not to large for the pgSlots table
- * returns TRUE in case of error */
-int CheckLun(DWORD Lun)
+int ReaderIndex[CCID_DRIVER_MAX_READERS];
+
+void InitReaderIndex(void)
 {
-	if ((LunToReaderIndex(Lun) >= CCID_DRIVER_MAX_READERS) ||
-		LunToReaderIndex(Lun) < 0)
-		return TRUE;
+	int i;
 
-	return FALSE;
-} /* CheckLun */
+	for (i=0; i<CCID_DRIVER_MAX_READERS; i++)
+		ReaderIndex[i] = -1;
+} /* InitReaderIndex */
+
+int GetNewReaderIndex(const DWORD Lun)
+{
+	int i;
+
+	for (i=0; i<CCID_DRIVER_MAX_READERS; i++)
+		if (-1 == ReaderIndex[i])
+			return i;
+
+	return -1;
+} /* GetReaderIndex */
+
+int LunToReaderIndex(const DWORD Lun)
+{
+	int i;
+
+	for (i=0; i<CCID_DRIVER_MAX_READERS; i++)
+		if (Lun == ReaderIndex[i])
+			return i;
+
+	return -1;
+} /* LunToReaderIndex */
+
+int ReleaseReaderIndex(const int index)
+{
+	ReaderIndex[index] = -1;
+} /* ReleaseReaderIndex */
 

Index: utils.h
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/utils.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- utils.h	12 Aug 2003 12:40:24 -0000	1.1.1.1
+++ utils.h	28 Jul 2004 08:30:30 -0000	1.2
@@ -1,6 +1,6 @@
 /*
     utils.c:
-    Copyright (C) 2003   Ludovic Rousseau
+    Copyright (C) 2003-2004   Ludovic Rousseau
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -21,12 +21,13 @@
  * $Id$
  */
 
-#define LunToReaderIndex(Lun) (Lun>>16)
-
 #ifndef TRUE
 #define FALSE 0
 #define TRUE 1
 #endif
 
-int CheckLun(DWORD Lun);
+void InitReaderIndex(void);
+int GetNewReaderIndex(const DWORD Lun);
+int LunToReaderIndex(DWORD Lun);
+int ReleaseReaderIndex(const int index);