[Pcsclite-cvs-commit] PCSC/src hotplug_libusb.c,1.16,1.17 hotplug_linux.c,1.20,1.21 hotplug_macosx.c,1.13,1.14

aet-guest@quantz.debian.org aet-guest@quantz.debian.org
Tue, 21 Oct 2003 22:47:24 +0200


Update of /cvsroot/pcsclite/PCSC/src
In directory quantz:/tmp/cvs-serv13630

Modified Files:
	hotplug_libusb.c hotplug_linux.c hotplug_macosx.c 
Log Message:
- More merging between the hotplug implementations
- Get rid of some internal limitation defines, there
  seems to be more than enough of these things in
  pcsclite.h already


Index: hotplug_libusb.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/hotplug_libusb.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- hotplug_libusb.c	21 Oct 2003 20:00:53 -0000	1.16
+++ hotplug_libusb.c	21 Oct 2003 20:47:22 -0000	1.17
@@ -35,18 +35,15 @@
 #include "parser.h"
 #include "hotplug.h"
 
-/* PCSCLITE_MAX_READERS_CONTEXTS is defined in pcsclite.h */
-#define PCSCLITE_MAX_DRIVERS			16
-#define BUS_DEVICE_STRSIZE			256
+#undef DEBUG_HOTPLUG
 
-#define READER_ABSENT	0
-#define READER_PRESENT	1
+#define BUS_DEVICE_STRSIZE	256
 
-#define FALSE 0
-#define TRUE 1
+#define READER_ABSENT		0
+#define READER_PRESENT		1
 
-/* set to 1 if you want to see USB hotplug debug messages */
-#define DEBUG_USB_HOTPLUG 0
+#define FALSE			0
+#define TRUE			1
 
 extern PCSCLITE_MUTEX usbNotifierMutex;
 
@@ -54,7 +51,7 @@
 static int driverSize = -1;
 
 /*
- * keep track of PCSCLITE_MAX_DRIVERS simultaneous drivers
+ * keep track of PCSCLITE_MAX_READERS_CONTEXTS simultaneous drivers
  */
 static struct _driverTracker
 {
@@ -64,7 +61,7 @@
 	char *bundleName;
 	char *libraryPath;
 	char *readerName;
-} driverTracker[PCSCLITE_MAX_DRIVERS];
+} driverTracker[PCSCLITE_MAX_READERS_CONTEXTS];
 
 /*
  * keep track of PCSCLITE_MAX_READERS_CONTEXTS simultaneous readers
@@ -152,7 +149,7 @@
 					driverTracker[listCount].libraryPath = strdup(fullLibPath);
 				}
 
-#if DEBUG_USB_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 					DebugLogB("Found driver for: %s",
 						driverTracker[listCount].readerName);
 #endif
@@ -199,7 +196,7 @@
 			for (dev = bus->devices; dev; dev = dev->next)
 			{
 				/* check if the device is supported by one driver */
-				for (i=0; i<PCSCLITE_MAX_DRIVERS; i++)
+				for (i=0; i<PCSCLITE_MAX_READERS_CONTEXTS; i++)
 				{
 					if (driverTracker[i].libraryPath != NULL &&
 						dev->descriptor.idVendor == driverTracker[i].manuID &&
@@ -211,7 +208,7 @@
 						snprintf(bus_device, BUS_DEVICE_STRSIZE, "%s:%s",
 							bus->dirname, dev->filename);
 						bus_device[BUS_DEVICE_STRSIZE - 1] = '\0';
-#if DEBUG_USB_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 						DebugLogB("Found matching USB device: %s", bus_device);
 #endif
 						newreader = TRUE;
@@ -225,7 +222,7 @@
 								/* The reader is already known */
 								readerTracker[j].status = READER_PRESENT;
 								newreader = FALSE;
-#if DEBUG_USB_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 								DebugLogB("Refresh USB device: %s", bus_device);
 #endif
 								break;
@@ -268,12 +265,12 @@
 				if (errno == EBUSY)
 				{
 					/* The device is present */
-#ifdef DEBUG_USB_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 					DebugLogB("BSD: EBUSY on %s", filename);
 #endif
 					readerTracker[i].status = READER_PRESENT;
 				}
-#ifdef DEBUG_USB_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 				else
 					DebugLogC("BSD: %s error: %s", filename,
 						strerror(errno));
@@ -281,7 +278,7 @@
 			}
 			else
 			{
-#ifdef DEBUG_USB_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 				DebugLogB("BSD: %s still present", filename);
 #endif
 				readerTracker[i].status = READER_PRESENT;
@@ -302,7 +299,7 @@
 {
 	int i;
 
-	for (i=0; i < PCSCLITE_MAX_DRIVERS; i++)
+	for (i=0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
 		driverTracker[i].productID  = 0;
 		driverTracker[i].manuID     = 0;

Index: hotplug_linux.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/hotplug_linux.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- hotplug_linux.c	21 Oct 2003 20:00:53 -0000	1.20
+++ hotplug_linux.c	21 Oct 2003 20:47:22 -0000	1.21
@@ -33,12 +33,7 @@
 #include "parser.h"
 #include "hotplug.h"
 
-#define PCSCLITE_USB_PATH                       "/proc/bus/usb"
-
-/* PCSCLITE_MAX_READERS_CONTEXTS is defined in pcsclite.h */
-#define PCSCLITE_HP_MAX_IDENTICAL_READERS	16
-#define PCSCLITE_HP_MAX_SIMUL_READERS		04
-#define PCSCLITE_HP_MAX_DRIVERS			20
+#define PCSCLITE_USB_PATH		"/proc/bus/usb"
 
 extern PCSCLITE_MUTEX usbNotifierMutex;
 
@@ -80,13 +75,13 @@
 	struct _deviceNumber {
 		int  id;
 		char status;
-	} deviceNumber[PCSCLITE_HP_MAX_SIMUL_READERS];
+	} deviceNumber[PCSCLITE_MAX_READERS_CONTEXTS];
 
 	char *bundleName;
 	char *libraryPath;
 	char *readerName;
 }
-bundleTracker[PCSCLITE_HP_MAX_DRIVERS];
+bundleTracker[PCSCLITE_MAX_READERS_CONTEXTS];
 
 LONG HPReadBundleValues()
 {
@@ -200,7 +195,7 @@
 			usbDeviceStatus     = 0;
 			suspectDeviceNumber = 0;
 
-			for (j=0; j < PCSCLITE_HP_MAX_SIMUL_READERS; j++)
+			for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++)
 				/* clear rollcall */
 				bundleTracker[i].deviceNumber[j].status = 0;
 
@@ -273,7 +268,7 @@
 						usbDescriptor.idVendor !=0 &&
 						usbDescriptor.idProduct != 0)
 					{
-						for (j=0; j < PCSCLITE_HP_MAX_SIMUL_READERS; j++)
+						for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++)
 						{
 							if (bundleTracker[i].deviceNumber[j].id == deviceNumber &&
 								bundleTracker[i].deviceNumber[j].id != 0)
@@ -283,7 +278,7 @@
 							}
 						}
 
-						if (j == PCSCLITE_HP_MAX_SIMUL_READERS)
+						if (j == PCSCLITE_MAX_READERS_CONTEXTS)
 						{
 							usbDeviceStatus = 1;
 							suspectDeviceNumber = deviceNumber;
@@ -301,13 +296,13 @@
 			{
 				SYS_MutexLock(&usbNotifierMutex);
 
-				for (j=0; j < PCSCLITE_HP_MAX_SIMUL_READERS; j++)
+				for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++)
 				{
 					if (bundleTracker[i].deviceNumber[j].id == 0)
 						break;
 				}
 
-				if (j == PCSCLITE_HP_MAX_SIMUL_READERS)
+				if (j == PCSCLITE_MAX_READERS_CONTEXTS)
 					DebugLogA("Too many identical readers plugged in");
 				else
 				{
@@ -321,7 +316,7 @@
 				if (usbDeviceStatus == 0)
 				{
 
-					for (j=0; j < PCSCLITE_HP_MAX_SIMUL_READERS; j++)
+					for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++)
 					{
 						if (bundleTracker[i].deviceNumber[j].id != 0 &&
 							bundleTracker[i].deviceNumber[j].status == 0)
@@ -354,12 +349,12 @@
 {
 	int i, j;
 
-	for (i = 0; i < PCSCLITE_HP_MAX_DRIVERS; i++)
+	for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
 		bundleTracker[i].productID  = 0;
 		bundleTracker[i].manuID     = 0;
 
-		for (j=0; j < PCSCLITE_HP_MAX_SIMUL_READERS; j++)
+		for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++)
 			 bundleTracker[i].deviceNumber[j].id = 0;
 	}
 

Index: hotplug_macosx.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/hotplug_macosx.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- hotplug_macosx.c	21 Oct 2003 20:00:53 -0000	1.13
+++ hotplug_macosx.c	21 Oct 2003 20:47:22 -0000	1.14
@@ -29,7 +29,7 @@
 #include "parser.h"
 #include "hotplug.h"
 
-#define DEBUG_MACOS_HOTPLUG
+#undef DEBUG_HOTPLUG
 
 /*
  * An aggregation of useful information on a driver bundle in the
@@ -103,7 +103,7 @@
 static HPDriverVector HPDriversGetFromDirectory(const char *driverBundlePath)
 {
 	int i;
-#ifdef DEBUG_MACOS_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 	DebugLogB("Entering HPDriversGetFromDirectory: %s", driverBundlePath);
 #endif
 
@@ -161,7 +161,7 @@
 			/* No alias, only one reader supported */
 			readersNumber++;
 	}
-#ifdef DEBUG_MACOS_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 	DebugLogB("Total of %d readers supported", readersNumber);
 #endif
 
@@ -201,7 +201,7 @@
 			CFArrayRef friendlyNameArray;
 			char *libPath = driverBundle->m_libPath;
 
-#ifdef DEBUG_MACOS_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 			DebugLogB("Driver with aliases: %s", libPath);
 #endif
 			/* get list of ProductID */
@@ -258,7 +258,7 @@
 				if (!driverBundle->m_libPath)
 					driverBundle->m_libPath = strdup(libPath);
 
-#ifdef DEBUG_MACOS_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 				DebugLogB("VendorID: 0x%04X", driverBundle->m_vendorId);
 				DebugLogB("ProductID: 0x%04X", driverBundle->m_productId);
 				DebugLogB("Friendly name: %s", driverBundle->m_friendlyName);
@@ -273,7 +273,7 @@
 		{
 			CFStringRef strValue = blobValue;
 
-#ifdef DEBUG_MACOS_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 			DebugLogC("Driver without alias: %s", driverBundle, driverBundle->m_libPath);
 #endif
 
@@ -304,7 +304,7 @@
 
 				driverBundle->m_friendlyName = strdup(cstr);
 			}
-#ifdef DEBUG_MACOS_HOTPLUG
+#ifdef DEBUG_HOTPLUG
 			DebugLogB("VendorID: 0x%04X", driverBundle->m_vendorId);
 			DebugLogB("ProductID: 0x%04X", driverBundle->m_productId);
 			DebugLogB("Friendly name: %s", driverBundle->m_friendlyName);