[Pcsclite-cvs-commit] CVS PCSC/src

CVS User rousseau ludovic.rousseau@free.fr
Tue, 22 Feb 2005 07:40:26 -0700


Update of /cvsroot/pcsclite/PCSC/src
In directory haydn:/tmp/cvs-serv14877

Modified Files:
	atrhandler.c configfile.l dyn_hpux.c dyn_macosx.c dyn_unix.c 
	dyn_win32.c eventhandler.c hotplug_libusb.c hotplug_linux.c 
	hotplug_macosx.c ifdwrapper.c powermgt_macosx.c prothandler.c 
	readerfactory.c sys_unix.c tokenparser.l winscard.c 
	winscard_clnt.c winscard_msg.c winscard_svc.c 
Log Message:
Use dynamic level logging using LogX() instead of DebugLogX()


--- /cvsroot/pcsclite/PCSC/src/atrhandler.c	2004/08/13 14:09:39	1.15
+++ /cvsroot/pcsclite/PCSC/src/atrhandler.c	2005/02/22 14:40:25	1.16
@@ -8,7 +8,7 @@
  *  David Corcoran <corcoran@linuxnet.com>
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: atrhandler.c,v 1.15 2004/08/13 14:09:39 rousseau Exp $
+ * $Id: atrhandler.c,v 1.16 2005/02/22 14:40:25 rousseau Exp $
  */
 
 #include "config.h"
@@ -40,7 +40,7 @@
 
 #ifdef ATR_DEBUG
 	if (dwLength > 0)
-		DebugXxd("ATR: ", pucAtr, dwLength);
+		LogXxd(PCSC_LOG_DEBUG, "ATR: ", pucAtr, dwLength);
 #endif
 
 	if (dwLength < 2)
@@ -135,7 +135,7 @@
 			}
 
 #ifdef ATR_DEBUG
-			DebugLogB("T=%d Protocol Found", T);
+			Log2(PCSC_LOG_DEBUG, "T=%d Protocol Found", T);
 #endif
 			if (0 == T)
 			{
@@ -177,7 +177,7 @@
 			{
 				T = TAi & 0x0F;
 #ifdef ATR_DEBUG
-				DebugLogB("Specific mode: T=%d", T);
+				Log2(PCSC_LOG_DEBUG, "Specific mode: T=%d", T);
 #endif
 				switch (T)
 				{
@@ -239,7 +239,7 @@
 	psExtension->ATR.Length = p;	/* modified from p-1 */
 
 #ifdef ATR_DEBUG
-	DebugLogC("CurrentProtocol: %d, AvailableProtocols: %d",
+	Log3(PCSC_LOG_DEBUG, "CurrentProtocol: %d, AvailableProtocols: %d",
 		psExtension->CardCapabilities.CurrentProtocol,
 		psExtension->CardCapabilities.AvailableProtocols);
 #endif
--- /cvsroot/pcsclite/PCSC/src/configfile.l	2004/09/21 18:33:54	1.18
+++ /cvsroot/pcsclite/PCSC/src/configfile.l	2005/02/22 14:40:25	1.19
@@ -8,7 +8,7 @@
  *  Damien Sauveron <damien.sauveron@labri.fr>
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: configfile.l,v 1.18 2004/09/21 18:33:54 rousseau Exp $
+ * $Id: configfile.l,v 1.19 2005/02/22 14:40:25 rousseau Exp $
  */
 
 %{
@@ -93,9 +93,9 @@
 				if ((NULL == strchr(pcDevicename, ':'))
 					&& (SYS_Stat(pcDevicename, &fStatBuf) != 0))
 				{
-					DebugLogC("Error with device %s: %s",
+					Log3(PCSC_LOG_CRITICAL, "Error with device %s: %s",
 						pcDevicename, strerror(errno));
-					DebugLogA("You should use 'DEVICENAME /dev/null' if your driver does not use this field");
+					Log1(PCSC_LOG_CRITICAL, "You should use 'DEVICENAME /dev/null' if your driver does not use this field");
 					badError = 1;
 				}
 			}
@@ -114,16 +114,16 @@
 				pcLibpath = strdup(pcCurrent);
 				if (SYS_Stat(pcLibpath, &fStatBuf) != 0)
 				{
-					DebugLogC("Error with library %s: %s",
+					Log3(PCSC_LOG_CRITICAL, "Error with library %s: %s",
 						pcLibpath, strerror(errno));
 					badError = 1;
 				}
 
 				if (strstr(pcLibpath, ".bundle") != NULL)
 				{
-					DebugLogA("WARNING *************************************");
-					DebugLogB("WARNING: USB drivers SHOULD NOT be declared in reader.conf: %s", pcLibpath);
-					DebugLogA("WARNING *************************************");
+					Log1(PCSC_LOG_ERROR, "WARNING *************************************");
+					Log2(PCSC_LOG_ERROR, "WARNING: USB drivers SHOULD NOT be declared in reader.conf: %s", pcLibpath);
+					Log1(PCSC_LOG_ERROR, "WARNING *************************************");
 				}
 			}
 			else
@@ -174,7 +174,8 @@
 
 void tok_error(char *token_error)
 {
-	DebugLogB("tok_error: invalid value in reader.conf: %s", token_error);
+	Log2(PCSC_LOG_ERROR, "tok_error: invalid value in reader.conf: %s",
+		token_error);
 	badError = 1;
 }
 
--- /cvsroot/pcsclite/PCSC/src/dyn_hpux.c	2004/08/06 12:12:20	1.10
+++ /cvsroot/pcsclite/PCSC/src/dyn_hpux.c	2005/02/22 14:40:25	1.11
@@ -8,7 +8,7 @@
  * Copyright (C) 2004
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: dyn_hpux.c,v 1.10 2004/08/06 12:12:20 rousseau Exp $
+ * $Id: dyn_hpux.c,v 1.11 2005/02/22 14:40:25 rousseau Exp $
  */
 
 #include "config.h"
@@ -33,7 +33,7 @@
 
 	if (myHandle == 0)
 	{
-		DebugLogC("%s: %s", pcLibrary, strerror(errno));
+		Log3(PCSC_LOG_ERROR, "%s: %s", pcLibrary, strerror(errno));
 		return SCARD_F_UNKNOWN_ERROR;
 	}
 
@@ -51,7 +51,7 @@
 
 	if (rv == -1)
 	{
-		DebugLogB("%s", strerror(errno));
+		Log2(PCSC_LOG_ERROR, "%s", strerror(errno));
 		return SCARD_F_UNKNOWN_ERROR;
 	}
 
@@ -69,7 +69,7 @@
 
 	if (rv == -1)
 	{
-		DebugLogC("%s: %s", pcFunction, strerror(errno));
+		Log3(PCSC_LOG_ERROR, "%s: %s", pcFunction, strerror(errno));
 		rv = SCARD_F_UNKNOWN_ERROR;
 	}
 	else
--- /cvsroot/pcsclite/PCSC/src/dyn_macosx.c	2004/08/06 12:12:20	1.9
+++ /cvsroot/pcsclite/PCSC/src/dyn_macosx.c	2005/02/22 14:40:26	1.10
@@ -6,7 +6,7 @@
  * Copyright (C) 2000
  *  David Corcoran <corcoran@linuxnet.com>
  *
- * $Id: dyn_macosx.c,v 1.9 2004/08/06 12:12:20 rousseau Exp $
+ * $Id: dyn_macosx.c,v 1.10 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -74,7 +74,7 @@
 		CFRelease(bundle);
 	}
 	else
-		DebugLogA("Cannot unload library.");
+		Log1(PCSC_LOG_ERROR, "Cannot unload library.");
 
 	*pvLHandle = 0;
 	return SCARD_S_SUCCESS;
--- /cvsroot/pcsclite/PCSC/src/dyn_unix.c	2004/08/06 12:12:20	1.12
+++ /cvsroot/pcsclite/PCSC/src/dyn_unix.c	2005/02/22 14:40:26	1.13
@@ -8,7 +8,7 @@
  * Copyright (C) 2004
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: dyn_unix.c,v 1.12 2004/08/06 12:12:20 rousseau Exp $
+ * $Id: dyn_unix.c,v 1.13 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -29,7 +29,7 @@
 
 	if (*pvLHandle == NULL)
 	{
-		DebugLogC("%s: %s", pcLibrary, dlerror());
+		Log3(PCSC_LOG_CRITICAL, "%s: %s", pcLibrary, dlerror());
 		return SCARD_F_UNKNOWN_ERROR;
 	}
 
@@ -45,7 +45,7 @@
 
 	if (ret)
 	{
-		DebugLogB("%s", dlerror());
+		Log2(PCSC_LOG_CRITICAL, "%s", dlerror());
 		return SCARD_F_UNKNOWN_ERROR;
 	}
 
@@ -69,7 +69,7 @@
 
 	if (*pvFHandle == NULL)
 	{
-		DebugLogC("%s: %s", pcFunction, dlerror());
+		Log3(PCSC_LOG_CRITICAL, "%s: %s", pcFunction, dlerror());
 		rv = SCARD_F_UNKNOWN_ERROR;
 	} else
 		rv = SCARD_S_SUCCESS;
--- /cvsroot/pcsclite/PCSC/src/dyn_win32.c	2003/11/18 15:57:20	1.8
+++ /cvsroot/pcsclite/PCSC/src/dyn_win32.c	2005/02/22 14:40:26	1.9
@@ -6,7 +6,7 @@
  * Copyright (C) 1999
  *  David Corcoran <corcoran@linuxnet.com>
  *
- * $Id: dyn_win32.c,v 1.8 2003/11/18 15:57:20 rousseau Exp $
+ * $Id: dyn_win32.c,v 1.9 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -26,7 +26,7 @@
 	if (*pvLHandle == NULL)
 	{
 #if 0
-		DebugLogB("DYN_LoadLibrary: dlerror() reports %s", dlerror());
+		Log2(PCSC_LOG_ERROR, "DYN_LoadLibrary: dlerror() reports %s", dlerror());
 #endif
 		return SCARD_F_UNKNOWN_ERROR;
 	}
@@ -46,7 +46,7 @@
 	if (ret == 0)
 	{
 #if 0
-		DebugLogB("DYN_CloseLibrary: dlerror() reports %s", dlerror());
+		Log2(PCSC_LOG_ERROR, "DYN_CloseLibrary: dlerror() reports %s", dlerror());
 #endif
 		return SCARD_F_UNKNOWN_ERROR;
 	}
@@ -73,7 +73,7 @@
 	if (*pvFHandle == NULL)
 	{
 #if 0
-		DebugLogB("DYN_GetAddress: dlerror() reports %s", dlerror());
+		Log2(PCSC_LOG_ERROR, "DYN_GetAddress: dlerror() reports %s", dlerror());
 #endif
 		rv = SCARD_F_UNKNOWN_ERROR;
 	}
--- /cvsroot/pcsclite/PCSC/src/eventhandler.c	2004/09/14 07:09:07	1.30
+++ /cvsroot/pcsclite/PCSC/src/eventhandler.c	2005/02/22 14:40:26	1.31
@@ -9,7 +9,7 @@
  * Copyright (C) 2004
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: eventhandler.c,v 1.30 2004/09/14 07:09:07 rousseau Exp $
+ * $Id: eventhandler.c,v 1.31 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -49,7 +49,7 @@
 	fd = SYS_OpenFile(PCSCLITE_PUBSHM_FILE, O_RDWR | O_CREAT, 00644);
 	if (fd < 0)
 	{
-		DebugLogC("Cannot create public shared file %s: %s",
+		Log3(PCSC_LOG_CRITICAL, "Cannot create public shared file %s: %s",
 			PCSCLITE_PUBSHM_FILE, strerror(errno));
 		exit(1);
 	}
@@ -74,7 +74,7 @@
 			SYS_MemoryMap(sizeof(READER_STATE), fd, (i * pageSize));
 		if (readerStates[i] == 0)
 		{
-			DebugLogC("Cannot memory map public shared file %s: %s",
+			Log3(PCSC_LOG_CRITICAL, "Cannot memory map public shared file %s: %s",
 				PCSCLITE_PUBSHM_FILE, strerror(errno));
 			exit(1);
 		}
@@ -99,13 +99,13 @@
 {
 	if (NULL == rContext->readerState)
 	{
-		DebugLogA("Thread never started (reader init failed?)");
+		Log1(PCSC_LOG_ERROR, "Thread never started (reader init failed?)");
 		return SCARD_S_SUCCESS;
 	}
 
 	if ('\0' == rContext->readerState->readerName[0])
 	{
-		DebugLogA("Thread already stomped.");
+		Log1(PCSC_LOG_INFO, "Thread already stomped.");
 		return SCARD_S_SUCCESS;
 	}
 
@@ -114,7 +114,7 @@
 	 */
 	rContext->dwLockId = 0xFFFF;
 
-	DebugLogA("Stomping thread.");
+	Log1(PCSC_LOG_INFO, "Stomping thread.");
 
 	do
 	{
@@ -143,7 +143,7 @@
 	/* Zero the thread */
 	rContext->pthThread = 0;
 
-	DebugLogA("Thread stomped.");
+	Log1(PCSC_LOG_INFO, "Thread stomped.");
 
 	return SCARD_S_SUCCESS;
 }
@@ -159,7 +159,7 @@
 	rv = IFDStatusICC(rContext, &dwStatus, ucAtr, &dwAtrLen);
 	if (rv != SCARD_S_SUCCESS)
 	{
-		DebugLogB("Initial Check Failed on %s", rContext->lpcReader);
+		Log2(PCSC_LOG_ERROR, "Initial Check Failed on %s", rContext->lpcReader);
 		return SCARD_F_UNKNOWN_ERROR;
 	}
 
@@ -238,12 +238,12 @@
 
 			if (rContext->readerState->cardAtrLength > 0)
 			{
-				DebugXxd("Card ATR: ",
+				LogXxd(PCSC_LOG_INFO, "Card ATR: ",
 					rContext->readerState->cardAtr,
 					rContext->readerState->cardAtrLength);
 			}
 			else
-				DebugLogA("Card ATR: (NULL)");
+				Log1(PCSC_LOG_INFO, "Card ATR: (NULL)");
 		}
 		else
 		{
@@ -254,7 +254,7 @@
 			dwStatus &= ~SCARD_NEGOTIABLE;
 			dwStatus &= ~SCARD_SPECIFIC;
 			dwStatus &= ~SCARD_UNKNOWN;
-			DebugLogA("Error powering up card.");
+			Log1(PCSC_LOG_ERROR, "Error powering up card.");
 		}
 
 		dwCurrentState = SCARD_PRESENT;
@@ -293,7 +293,7 @@
 
 		if (rv != SCARD_S_SUCCESS)
 		{
-			DebugLogB("Error communicating to: %s", lpcReader);
+			Log2(PCSC_LOG_ERROR, "Error communicating to: %s", lpcReader);
 
 			/*
 			 * Set error status on this reader while errors occur 
@@ -342,7 +342,7 @@
 				/*
 				 * Change the status structure 
 				 */
-				DebugLogB("Card Removed From %s", lpcReader);
+				Log2(PCSC_LOG_INFO, "Card Removed From %s", lpcReader);
 				/*
 				 * Notify the card has been removed 
 				 */
@@ -410,21 +410,21 @@
 
 				SYS_MMapSynchronize((void *) rContext->readerState, pageSize);
 
-				DebugLogB("Card inserted into %s", lpcReader);
+				Log2(PCSC_LOG_INFO, "Card inserted into %s", lpcReader);
 
 				if (rv == IFD_SUCCESS)
 				{
 					if (rContext->readerState->cardAtrLength > 0)
 					{
-						DebugXxd("Card ATR: ",
+						LogXxd(PCSC_LOG_INFO, "Card ATR: ",
 							rContext->readerState->cardAtr,
 							rContext->readerState->cardAtrLength);
 					}
 					else
-						DebugLogA("Card ATR: (NULL)");
+						Log1(PCSC_LOG_INFO, "Card ATR: (NULL)");
 				}
 				else
-					DebugLogA("Error powering up card.");
+					Log1(PCSC_LOG_ERROR,"Error powering up card.");
 			}
 		}
 
--- /cvsroot/pcsclite/PCSC/src/hotplug_libusb.c	2004/08/06 12:12:20	1.32
+++ /cvsroot/pcsclite/PCSC/src/hotplug_libusb.c	2005/02/22 14:40:26	1.33
@@ -9,7 +9,7 @@
  *  Toni Andjelkovic <toni@soth.at>
  *  Damien Sauveron <damien.sauveron@labri.fr>
  *
- * $Id: hotplug_libusb.c,v 1.32 2004/08/06 12:12:20 rousseau Exp $
+ * $Id: hotplug_libusb.c,v 1.33 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -95,8 +95,8 @@
 
 	if (hpDir == NULL)
 	{
-		DebugLogA("Cannot open PC/SC drivers directory: " PCSCLITE_HP_DROPDIR);
-		DebugLogA("Disabling USB support for pcscd.");
+		Log1(PCSC_LOG_ERROR, "Cannot open PC/SC drivers directory: " PCSCLITE_HP_DROPDIR);
+		Log1(PCSC_LOG_ERROR, "Disabling USB support for pcscd.");
 		return -1;
 	}
 
@@ -104,7 +104,7 @@
 	driverTracker = calloc(DRIVER_TRACKER_SIZE_STEP, sizeof(*driverTracker));
 	if (NULL == driverTracker)
 	{
-		DebugLogA("Not enough memory");
+		Log1(PCSC_LOG_CRITICAL, "Not enough memory");
 		return -1;
 	}
 	driverSize = DRIVER_TRACKER_SIZE_STEP;
@@ -161,7 +161,7 @@
 				}
 
 #ifdef DEBUG_HOTPLUG
-					DebugLogB("Found driver for: %s",
+					Log2(PCSC_LOG_INFO, "Found driver for: %s",
 						driverTracker[listCount].readerName);
 #endif
 
@@ -173,14 +173,14 @@
 					/* increase the array size */
 					driverSize += DRIVER_TRACKER_SIZE_STEP;
 #ifdef DEBUG_HOTPLUG
-					DebugLogB("Increase driverTracker to %d entries",
-						driverSize);
+					Log2(PCSC_LOG_INFO,
+						"Increase driverTracker to %d entries", driverSize);
 #endif
 					driverTracker = realloc(driverTracker,
 						driverSize * sizeof(*driverTracker));
 					if (NULL == driverTracker)
 					{
-						DebugLogA("Not enough memory");
+						Log1(PCSC_LOG_CRITICAL, "Not enough memory");
 						return -1;
 					}
 				}
@@ -193,12 +193,12 @@
 
 	if (driverSize == 0)
 	{
-		DebugLogA("No bundle files in pcsc drivers directory: " PCSCLITE_HP_DROPDIR);
-		DebugLogA("Disabling USB support for pcscd");
+		Log1(PCSC_LOG_INFO, "No bundle files in pcsc drivers directory: " PCSCLITE_HP_DROPDIR);
+		Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd");
 	}
 #ifdef DEBUG_HOTPLUG
 	else
-		DebugLogB("Found drivers for %d readers", listCount);
+		Log2(PCSC_LOG_INFO, "Found drivers for %d readers", listCount);
 #endif
 
 	return 0;
@@ -241,7 +241,7 @@
 							bus->dirname, dev->filename);
 						bus_device[BUS_DEVICE_STRSIZE - 1] = '\0';
 #ifdef DEBUG_HOTPLUG
-						DebugLogB("Found matching USB device: %s", bus_device);
+						Log2(PCSC_LOG_DEBUG, "Found matching USB device: %s", bus_device);
 #endif
 						newreader = TRUE;
 
@@ -255,7 +255,7 @@
 								readerTracker[j].status = READER_PRESENT;
 								newreader = FALSE;
 #ifdef DEBUG_HOTPLUG
-								DebugLogB("Refresh USB device: %s", bus_device);
+								Log2(PCSC_LOG_DEBUG, "Refresh USB device: %s", bus_device);
 #endif
 								break;
 							}
@@ -298,20 +298,20 @@
 				{
 					/* The device is present */
 #ifdef DEBUG_HOTPLUG
-					DebugLogB("BSD: EBUSY on %s", filename);
+					Log2(PCSC_LOG_DEBUG, "BSD: EBUSY on %s", filename);
 #endif
 					readerTracker[i].status = READER_PRESENT;
 				}
 #ifdef DEBUG_HOTPLUG
 				else
-					DebugLogC("BSD: %s error: %s", filename,
+					Log3(PCSC_LOG_DEBUG, "BSD: %s error: %s", filename,
 						strerror(errno));
 #endif
 			}
 			else
 			{
 #ifdef DEBUG_HOTPLUG
-				DebugLogB("BSD: %s still present", filename);
+				Log2(PCSC_LOG_DEBUG, "BSD: %s still present", filename);
 #endif
 				readerTracker[i].status = READER_PRESENT;
 				close(fd);
@@ -327,7 +327,7 @@
 		{
 			int retval;
 
-			DebugLogA("Hotplug stopped");
+			Log1(PCSC_LOG_INFO, "Hotplug stopped");
 			pthread_exit(&retval);
 		}
 
@@ -368,7 +368,7 @@
 
 	SYS_MutexLock(&usbNotifierMutex);
 
-	DebugLogB("Adding USB device: %s", bus_device);
+	Log2(PCSC_LOG_INFO, "Adding USB device: %s", bus_device);
 
 	snprintf(deviceName, sizeof(deviceName), "usb:%04x/%04x:libusb:%s",
 		dev->descriptor.idVendor, dev->descriptor.idProduct, bus_device);
@@ -383,7 +383,8 @@
 
 	if (i==PCSCLITE_MAX_READERS_CONTEXTS)
 	{
-		DebugLogB("Not enough reader entries. Already found %d readers", i);
+		Log2(PCSC_LOG_ERROR,
+			"Not enough reader entries. Already found %d readers", i);
 		return 0;
 	}
 
@@ -407,7 +408,8 @@
 {
 	SYS_MutexLock(&usbNotifierMutex);
 
-	DebugLogC("Removing USB device[%d]: %s", index, readerTracker[index].bus_device);
+	Log3(PCSC_LOG_INFO, "Removing USB device[%d]: %s", index,
+		readerTracker[index].bus_device);
 
 	RFRemoveReader(readerTracker[index].driver->readerName,
 		PCSCLITE_HP_BASE_PORT + index);
--- /cvsroot/pcsclite/PCSC/src/hotplug_linux.c	2004/08/06 12:12:20	1.31
+++ /cvsroot/pcsclite/PCSC/src/hotplug_linux.c	2005/02/22 14:40:26	1.32
@@ -10,7 +10,7 @@
  * The USB code was based partly on Johannes Erdfelt
  * libusb code found at libusb.sourceforge.net
  *
- * $Id: hotplug_linux.c,v 1.31 2004/08/06 12:12:20 rousseau Exp $
+ * $Id: hotplug_linux.c,v 1.32 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -102,8 +102,9 @@
 
 	if (hpDir == NULL)
 	{
-		DebugLogA("Cannot open PC/SC drivers directory: " PCSCLITE_HP_DROPDIR);
-		DebugLogA("Disabling USB support for pcscd.");
+		Log1(PCSC_LOG_INFO,
+			"Cannot open PC/SC drivers directory: " PCSCLITE_HP_DROPDIR);
+		Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd.");
 		return -1;
 	}
 
@@ -168,8 +169,9 @@
 
 	if (bundleSize == 0)
 	{
-		DebugLogA("No bundle files in pcsc drivers directory: " PCSCLITE_HP_DROPDIR);
-		DebugLogA("Disabling USB support for pcscd");
+		Log1(PCSC_LOG_INFO,
+			"No bundle files in pcsc drivers directory: " PCSCLITE_HP_DROPDIR);
+		Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd");
 	}
 
 	closedir(hpDir);
@@ -207,7 +209,8 @@
 			dir = opendir(PCSCLITE_USB_PATH);
 			if (dir == NULL)
 			{
-				DebugLogA("Cannot open USB path directory: " PCSCLITE_USB_PATH);
+				Log1(PCSC_LOG_ERROR,
+					"Cannot open USB path directory: " PCSCLITE_USB_PATH);
 				return;
 			}
 
@@ -232,8 +235,8 @@
 
 				if (dirB == NULL)
 				{
-					DebugLogB("USB path seems to have disappeared %s",
-						dirpath);
+					Log2(PCSC_LOG_ERROR,
+						"USB path seems to have disappeared %s", dirpath);
 					closedir(dir);
 					return;
 				}
@@ -307,7 +310,8 @@
 				}
 
 				if (j == PCSCLITE_MAX_READERS_CONTEXTS)
-					DebugLogA("Too many identical readers plugged in");
+					Log1(PCSC_LOG_ERROR,
+						"Too many identical readers plugged in");
 				else
 				{
 					HPAddHotPluggable(i, j+1);
@@ -349,7 +353,7 @@
 		{
 			int retval;
 
-			DebugLogA("Hotplug stopped");
+			Log1(PCSC_LOG_INFO, "Hotplug stopped");
 			pthread_exit(&retval);
 		}
 
--- /cvsroot/pcsclite/PCSC/src/hotplug_macosx.c	2004/08/06 12:12:20	1.22
+++ /cvsroot/pcsclite/PCSC/src/hotplug_macosx.c	2005/02/22 14:40:26	1.23
@@ -8,7 +8,7 @@
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *  David Corcoran <corcoran@linuxnet.com>
  *
- * $Id: hotplug_macosx.c,v 1.22 2004/08/06 12:12:20 rousseau Exp $
+ * $Id: hotplug_macosx.c,v 1.23 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -102,7 +102,8 @@
 {
 	int i;
 #ifdef DEBUG_HOTPLUG
-	DebugLogB("Entering HPDriversGetFromDirectory: %s", driverBundlePath);
+	Log2(PCSC_LOG_DEBUG, "Entering HPDriversGetFromDirectory: %s",
+		driverBundlePath);
 #endif
 
 	int readersNumber = 0;
@@ -119,14 +120,14 @@
 	CFRelease(driverBundlePathString);
 	if (!pluginUrl)
 	{
-		DebugLogA("error getting plugin directory URL");
+		Log1(PCSC_LOG_ERROR, "error getting plugin directory URL");
 		return NULL;
 	}
 	bundleArray = CFBundleCreateBundlesFromDirectory(kCFAllocatorDefault,
 		pluginUrl, NULL);
 	if (!bundleArray)
 	{
-		DebugLogA("error getting plugin directory bundles");
+		Log1(PCSC_LOG_ERROR, "error getting plugin directory bundles");
 		return NULL;
 	}
 	CFRelease(pluginUrl);
@@ -145,7 +146,7 @@
 
 		if (!blobValue)
 		{
-			DebugLogA("error getting vendor ID from bundle");
+			Log1(PCSC_LOG_ERROR, "error getting vendor ID from bundle");
 			return NULL;
 		}
 
@@ -160,7 +161,7 @@
 			readersNumber++;
 	}
 #ifdef DEBUG_HOTPLUG
-	DebugLogB("Total of %d readers supported", readersNumber);
+	Log2(PCSC_LOG_DEBUG, "Total of %d readers supported", readersNumber);
 #endif
 
 	/* The last entry is an end marker (m_vendorId = 0)
@@ -171,7 +172,7 @@
 	bundleVector = (HPDriver *) calloc(readersNumber, sizeof(HPDriver));
 	if (!bundleVector)
 	{
-		DebugLogA("memory allocation failure");
+		Log1(PCSC_LOG_ERROR, "memory allocation failure");
 		return NULL;
 	}
 
@@ -193,7 +194,7 @@
 
 		if (!blobValue)
 		{
-			DebugLogA("error getting vendor ID from bundle");
+			Log1(PCSC_LOG_ERROR, "error getting vendor ID from bundle");
 			return bundleVector;
 		}
 
@@ -205,14 +206,14 @@
 			char *libPath = driverBundle->m_libPath;
 
 #ifdef DEBUG_HOTPLUG
-			DebugLogB("Driver with aliases: %s", libPath);
+			Log2(PCSC_LOG_DEBUG, "Driver with aliases: %s", libPath);
 #endif
 			/* get list of ProductID */
 			productArray = CFDictionaryGetValue(dict,
 				 CFSTR(PCSCLITE_HP_PRODKEY_NAME));
 			if (!productArray)
 			{
-				DebugLogA("error getting product ID from bundle");
+				Log1(PCSC_LOG_ERROR, "error getting product ID from bundle");
 				return bundleVector;
 			}
 
@@ -221,7 +222,7 @@
 				 CFSTR(PCSCLITE_HP_NAMEKEY_NAME));
 			if (!friendlyNameArray)
 			{
-				DebugLogA("error getting product ID from bundle");
+				Log1(PCSC_LOG_ERROR, "error getting product ID from bundle");
 				return bundleVector;
 			}
 
@@ -229,14 +230,16 @@
 
 			if (reader_nb != CFArrayGetCount(productArray))
 			{
-				DebugLogC("Malformed Info.plist: %d vendors and %d products",
+				Log3(PCSC_LOG_ERROR,
+					"Malformed Info.plist: %d vendors and %d products",
 					reader_nb, CFArrayGetCount(productArray));
 				return bundleVector;
 			}
 
 			if (reader_nb != CFArrayGetCount(friendlyNameArray))
 			{
-				DebugLogC("Malformed Info.plist: %d vendors and %d friendlynames",
+				Log3(PCSC_LOG_ERROR,
+					"Malformed Info.plist: %d vendors and %d friendlynames",
 					reader_nb, CFArrayGetCount(friendlyNameArray));
 				return bundleVector;
 			}
@@ -262,10 +265,13 @@
 					driverBundle->m_libPath = strdup(libPath);
 
 #ifdef DEBUG_HOTPLUG
-				DebugLogB("VendorID: 0x%04X", driverBundle->m_vendorId);
-				DebugLogB("ProductID: 0x%04X", driverBundle->m_productId);
-				DebugLogB("Friendly name: %s", driverBundle->m_friendlyName);
-				DebugLogB("Driver: %s", driverBundle->m_libPath);
+				Log2(PCSC_LOG_DEBUG, "VendorID: 0x%04X",
+					driverBundle->m_vendorId);
+				Log2(PCSC_LOG_DEBUG, "ProductID: 0x%04X",
+					driverBundle->m_productId);
+				Log2(PCSC_LOG_DEBUG, "Friendly name: %s",
+					driverBundle->m_friendlyName);
+				Log2(PCSC_LOG_DEBUG, "Driver: %s", driverBundle->m_libPath);
 #endif
 
 				/* go to next bundle in the vector */
@@ -277,7 +283,8 @@
 			CFStringRef strValue = blobValue;
 
 #ifdef DEBUG_HOTPLUG
-			DebugLogC("Driver without alias: %s", driverBundle, driverBundle->m_libPath);
+			Log3(PCSC_LOG_DEBUG, "Driver without alias: %s",
+				driverBundle, driverBundle->m_libPath);
 #endif
 
 			driverBundle->m_vendorId = strtoul(CFStringGetCStringPtr(strValue,
@@ -287,7 +294,7 @@
 				CFSTR(PCSCLITE_HP_PRODKEY_NAME));
 			if (!strValue)
 			{
-				DebugLogA("error getting product ID from bundle");
+				Log1(PCSC_LOG_ERROR, "error getting product ID from bundle");
 				return bundleVector;
 			}
 			driverBundle->m_productId = strtoul(CFStringGetCStringPtr(strValue,
@@ -297,7 +304,7 @@
 				CFSTR(PCSCLITE_HP_NAMEKEY_NAME));
 			if (!strValue)
 			{
-				DebugLogA("error getting product friendly name from bundle");
+				Log1(PCSC_LOG_ERROR, "error getting product friendly name from bundle");
 				driverBundle->m_friendlyName = strdup("unnamed device");
 			}
 			else
@@ -308,10 +315,10 @@
 				driverBundle->m_friendlyName = strdup(cstr);
 			}
 #ifdef DEBUG_HOTPLUG
-			DebugLogB("VendorID: 0x%04X", driverBundle->m_vendorId);
-			DebugLogB("ProductID: 0x%04X", driverBundle->m_productId);
-			DebugLogB("Friendly name: %s", driverBundle->m_friendlyName);
-			DebugLogB("Driver: %s", driverBundle->m_libPath);
+			Log2(PCSC_LOG_DEBUG, "VendorID: 0x%04X", driverBundle->m_vendorId);
+			Log2(PCSC_LOG_DEBUG, "ProductID: 0x%04X", driverBundle->m_productId);
+			Log2(PCSC_LOG_DEBUG, "Friendly name: %s", driverBundle->m_friendlyName);
+			Log2(PCSC_LOG_DEBUG, "Driver: %s", driverBundle->m_libPath);
 #endif
 
 			/* go to next bundle in the vector */
@@ -381,7 +388,7 @@
 
 	if (!newReader)
 	{
-		DebugLogA("memory allocation failure");
+		Log1(PCSC_LOG_ERROR, "memory allocation failure");
 		return list;
 	}
 
@@ -425,7 +432,8 @@
 
 	if (0 == usbMatch)
 	{
-		DebugLogA("error getting USB match from IOServiceMatching()");
+		Log1(PCSC_LOG_ERROR,
+			"error getting USB match from IOServiceMatching()");
 		return 1;
 	}
 
@@ -435,8 +443,8 @@
 
 	if (kret != 0)
 	{
-		DebugLogA
-			("error getting iterator from IOServiceGetMatchingServices()");
+		Log1(PCSC_LOG_ERROR,
+			"error getting iterator from IOServiceGetMatchingServices()");
 		return 1;
 	}
 
@@ -450,8 +458,8 @@
 		kret = IORegistryEntryGetName(usbDevice, namebuf);
 		if (kret != 0)
 		{
-			DebugLogA
-				("error getting device name from IORegistryEntryGetName()");
+			Log1(PCSC_LOG_ERROR,
+				"error getting device name from IORegistryEntryGetName()");
 			return 1;
 		}
 
@@ -463,8 +471,7 @@
 			kIOCFPlugInInterfaceID, &iodev, &score);
 		if (kret != 0)
 		{
-			DebugLogA
-				("error getting plugin interface from IOCreatePlugInInterfaceForService()");
+			Log1(PCSC_LOG_ERROR, "error getting plugin interface from IOCreatePlugInInterfaceForService()");
 			return 1;
 		}
 		IOObjectRelease(usbDevice);
@@ -477,7 +484,8 @@
 		(*iodev)->Release(iodev);
 		if (hres)
 		{
-			DebugLogA("error querying interface in QueryInterface()");
+			Log1(PCSC_LOG_ERROR,
+				"error querying interface in QueryInterface()");
 			return 1;
 		}
 
@@ -518,7 +526,8 @@
 
 	if (pccMatch == NULL)
 	{
-		DebugLogA("error getting PCCard match from IOServiceMatching()");
+		Log1(PCSC_LOG_ERROR,
+			"error getting PCCard match from IOServiceMatching()");
 		return 1;
 	}
 
@@ -528,7 +537,8 @@
 		&pccIter);
 	if (kret != 0)
 	{
-		DebugLogA("error getting iterator from IOServiceGetMatchingServices()");
+		Log1(PCSC_LOG_ERROR,
+			"error getting iterator from IOServiceGetMatchingServices()");
 		return 1;
 	}
 
@@ -542,7 +552,7 @@
 		kret = IORegistryEntryGetName(pccDevice, namebuf);
 		if (kret != 0)
 		{
-			DebugLogA("error getting plugin interface from IOCreatePlugInInterfaceForService()");
+			Log1(PCSC_LOG_ERROR, "error getting plugin interface from IOCreatePlugInInterfaceForService()");
 			return 1;
 		}
 		UInt32 vendorId = 0;
@@ -554,7 +564,7 @@
 
 		if (!valueRef)
 		{
-			DebugLogA("error getting vendor");
+			Log1(PCSC_LOG_ERROR, "error getting vendor");
 		}
 		else
 		{
@@ -566,7 +576,7 @@
 			kCFAllocatorDefault, NULL);
 		if (!valueRef)
 		{
-			DebugLogA("error getting device");
+			Log1(PCSC_LOG_ERROR, "error getting device");
 		}
 		else
 		{
@@ -578,7 +588,7 @@
 			kCFAllocatorDefault, NULL);
 		if (!valueRef)
 		{
-			DebugLogA("error getting PC Card socket");
+			Log1(PCSC_LOG_ERROR, "error getting PC Card socket");
 		}
 		else
 		{
@@ -618,7 +628,7 @@
 	matchingDictionary = IOServiceMatching("IOUSBDevice");
 	if (!matchingDictionary)
 	{
-		DebugLogB("IOServiceMatching() failed", 0);
+		Log1(PCSC_LOG_ERROR, "IOServiceMatching() failed");
 	}
 	matchingDictionary =
 		(CFMutableDictionaryRef) CFRetain(matchingDictionary);
@@ -628,8 +638,8 @@
 		matchingDictionary, HPDeviceAppeared, NULL, &deviceAddedIterator);
 	if (kret)
 	{
-		DebugLogB("IOServiceAddMatchingNotification()-1 failed with code %d",
-			kret);
+		Log2(PCSC_LOG_ERROR,
+			"IOServiceAddMatchingNotification()-1 failed with code %d", kret);
 	}
 	HPDeviceAppeared(NULL, deviceAddedIterator);
 
@@ -639,8 +649,8 @@
 		HPDeviceDisappeared, NULL, &deviceRemovedIterator);
 	if (kret)
 	{
-		DebugLogB("IOServiceAddMatchingNotification()-2 failed with code %d",
-			kret);
+		Log2(PCSC_LOG_ERROR,
+			"IOServiceAddMatchingNotification()-2 failed with code %d", kret);
 	}
 	HPDeviceDisappeared(NULL, deviceRemovedIterator);
 }
@@ -661,7 +671,7 @@
 	matchingDictionary = IOServiceMatching("IOPCCard16Device");
 	if (!matchingDictionary)
 	{
-		DebugLogB("IOServiceMatching() failed", 0);
+		Log1(PCSC_LOG_ERROR, "IOServiceMatching() failed");
 	}
 	matchingDictionary =
 		(CFMutableDictionaryRef) CFRetain(matchingDictionary);
@@ -671,8 +681,8 @@
 		matchingDictionary, HPDeviceAppeared, NULL, &deviceAddedIterator);
 	if (kret)
 	{
-		DebugLogB("IOServiceAddMatchingNotification()-1 failed with code %d",
-			kret);
+		Log2(PCSC_LOG_ERROR,
+			"IOServiceAddMatchingNotification()-1 failed with code %d", kret);
 	}
 	HPDeviceAppeared(NULL, deviceAddedIterator);
 
@@ -682,8 +692,8 @@
 		HPDeviceDisappeared, NULL, &deviceRemovedIterator);
 	if (kret)
 	{
-		DebugLogB("IOServiceAddMatchingNotification()-2 failed with code %d",
-			kret);
+		Log2(PCSC_LOG_ERROR,
+			"IOServiceAddMatchingNotification()-2 failed with code %d", kret);
 	}
 	HPDeviceDisappeared(NULL, deviceRemovedIterator);
 }
--- /cvsroot/pcsclite/PCSC/src/ifdwrapper.c	2004/09/14 22:51:17	1.28
+++ /cvsroot/pcsclite/PCSC/src/ifdwrapper.c	2005/02/22 14:40:26	1.29
@@ -8,7 +8,7 @@
  *  Damien Sauveron <damien.sauveron@labri.fr>
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: ifdwrapper.c,v 1.28 2004/09/14 22:51:17 rousseau Exp $
+ * $Id: ifdwrapper.c,v 1.29 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -477,7 +477,7 @@
 			dwCardStatus |= SCARD_ABSENT;
 		else
 		{
-			DebugLogB("Card not transacted: %ld", rv);
+			Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
 			return SCARD_E_NOT_TRANSACTED;
 		}
 
@@ -592,7 +592,7 @@
 		return SCARD_S_SUCCESS;
 	else
 	{
-		DebugLogB("Card not transacted: %ld", rv);
+		Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
 		return SCARD_E_NOT_TRANSACTED;
 	}
 }
@@ -647,7 +647,7 @@
 		return SCARD_S_SUCCESS;
 	else
 	{
-		DebugLogB("Card not transacted: %ld", rv);
+		Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
 		return SCARD_E_NOT_TRANSACTED;
 	}
 }
@@ -728,7 +728,7 @@
 		return SCARD_S_SUCCESS;
 	else
 	{
-		DebugLogB("Card not transacted: %ld", rv);
+		Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
 		return SCARD_E_NOT_TRANSACTED;
 	}
 }
--- /cvsroot/pcsclite/PCSC/src/powermgt_macosx.c	2004/08/06 12:12:20	1.16
+++ /cvsroot/pcsclite/PCSC/src/powermgt_macosx.c	2005/02/22 14:40:26	1.17
@@ -57,14 +57,14 @@
           IOAllowPowerChange(root_port,(long)messageArgument);
           break;
     case kIOMessageSystemWillSleep:
-          DebugLogA("system going into sleep");
+          Log1(PCSC_LOG_INFO, "system going into sleep");
           SYS_MutexLock(&usbNotifierMutex);
           RFSuspendAllReaders();
           IOAllowPowerChange(root_port,(long)messageArgument);
-          DebugLogA("system allowed to sleep");
+          Log1(PCSC_LOG_INFO, "system allowed to sleep");
           break;
     case kIOMessageSystemHasPoweredOn: 
-        DebugLogA("system coming out of sleep");
+        Log1(PCSC_LOG_INFO, "system coming out of sleep");
         HPSearchHotPluggables();
         RFAwakeAllReaders();
         SYS_MutexUnLock(&usbNotifierMutex);
@@ -78,7 +78,7 @@
     root_port = IORegisterForSystemPower (0,&notify,PMPowerEventCallback,&anIterator);
   
     if ( root_port == NULL ) {
-            DebugLogA("IORegisterForSystemPower failed");
+            Log1(PCSC_LOG_ERROR, "IORegisterForSystemPower failed");
             return;
     }
     
--- /cvsroot/pcsclite/PCSC/src/prothandler.c	2004/09/03 19:45:40	1.16
+++ /cvsroot/pcsclite/PCSC/src/prothandler.c	2005/02/22 14:40:26	1.17
@@ -8,7 +8,7 @@
  * Copyright (C) 2004
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: prothandler.c,v 1.16 2004/09/03 19:45:40 rousseau Exp $
+ * $Id: prothandler.c,v 1.17 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -101,7 +101,7 @@
 		 * and the case ucAvailable == 0 should never occur (the card is at
 		 * least T=0 or T=1)
 		 */
-		DebugLogB("Protocol T=%d requested but unsupported by the card",
+		Log2(PCSC_LOG_ERROR, "Protocol T=%d requested but unsupported by the card",
 			(SCARD_PROTOCOL_T0 == dwPreferred) ? 0 : 1);
 		return SET_PROTOCOL_WRONG_ARGUMENT;
 	}
@@ -122,7 +122,7 @@
 			/* App wants unsupported protocol */
 			return SET_PROTOCOL_WRONG_ARGUMENT;
 
-	DebugLogB("Attempting PTS to T=%d",
+	Log2(PCSC_LOG_INFO, "Attempting PTS to T=%d",
 		(SCARD_PROTOCOL_T0 == ucChosen ? 0 : 1));
 	rv = IFDSetPTS(rContext, ucChosen, 0x00, 0x00, 0x00, 0x00);
 
@@ -130,11 +130,11 @@
 		protocol = ucChosen;
 	else
 		if (IFD_NOT_SUPPORTED == rv)
-			DebugLogB("PTS not supported by driver, using T=%d",
+			Log2(PCSC_LOG_INFO, "PTS not supported by driver, using T=%d",
 				(SCARD_PROTOCOL_T0 == protocol) ? 0 : 1);
 		else
 		{
-			DebugLogC("PTS failed (%d), using T=%d", rv,
+			Log3(PCSC_LOG_INFO, "PTS failed (%d), using T=%d", rv,
 				(SCARD_PROTOCOL_T0 == protocol) ? 0 : 1);
 
  			/* ISO 7816-3:1997 ch. 7.2 PPS protocol page 14
--- /cvsroot/pcsclite/PCSC/src/readerfactory.c	2005/01/11 20:45:45	1.67
+++ /cvsroot/pcsclite/PCSC/src/readerfactory.c	2005/02/22 14:40:26	1.68
@@ -8,7 +8,7 @@
  *  Damien Sauveron <damien.sauveron@labri.fr>
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: readerfactory.c,v 1.67 2005/01/11 20:45:45 rousseau Exp $
+ * $Id: readerfactory.c,v 1.68 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -92,7 +92,7 @@
 				if ((strcmp(lpcReader, lpcStripReader) == 0) &&
 					(dwPort == (sReadersContexts[i])->dwPort))
 				{
-					DebugLogA("Duplicate reader found.");
+					Log1(PCSC_LOG_ERROR, "Duplicate reader found.");
 					return SCARD_E_DUPLICATE_READER;
 				}
 			}
@@ -169,7 +169,7 @@
 
 		if (rv == IFD_SUCCESS && dwGetSize == 1 && ucThread[0] == 1)
 		{
-			DebugLogA("Driver is thread safe");
+			Log1(PCSC_LOG_INFO, "Driver is thread safe");
 			(sReadersContexts[dwContext])->mMutex = 0;
 			(sReadersContexts[dwContext])->pdwMutex = 0;
 		}
@@ -216,7 +216,7 @@
 		/*
 		 * Clean up so it is not using needed space 
 		 */
-		DebugLogB("%s init failed.", lpcReader);
+		Log2(PCSC_LOG_ERROR, "%s init failed.", lpcReader);
 
 		(sReadersContexts[dwContext])->dwVersion = 0;
 		(sReadersContexts[dwContext])->dwPort = 0;
@@ -393,7 +393,7 @@
 			/*
 			 * Clean up so it is not using needed space 
 			 */
-			DebugLogB("%s init failed.", lpcReader);
+			Log2(PCSC_LOG_ERROR, "%s init failed.", lpcReader);
 
 			(sReadersContexts[dwContextB])->dwVersion = 0;
 			(sReadersContexts[dwContextB])->dwPort = 0;
@@ -464,7 +464,8 @@
 		 */
 		if ((NULL == sContext->pdwMutex) || (NULL == sContext->pdwFeeds))
 		{
-			DebugLogA("Trying to remove an already removed driver");
+			Log1(PCSC_LOG_ERROR,
+				"Trying to remove an already removed driver");
 			return SCARD_E_INVALID_VALUE;
 		}
 
@@ -552,8 +553,8 @@
 						(tagValue[0] > 1))
 					{
 						supportedChannels = tagValue[0];
-						DebugLogB("Support %d simultaneous readers",
-							tagValue[0]);
+						Log2(PCSC_LOG_INFO,
+							"Support %d simultaneous readers", tagValue[0]);
 					}
 					else
 						supportedChannels = -1;
@@ -776,7 +777,7 @@
 {
 	if (rContext->vHandle != 0)
 	{
-		DebugLogA("Warning library pointer not NULL");
+		Log1(PCSC_LOG_ERROR, "Warning library pointer not NULL");
 		/*
 		 * Another reader exists with this library loaded 
 		 */
@@ -817,7 +818,7 @@
 		/*
 		 * Neither version of the IFD Handler was found - exit 
 		 */
-		DebugLogA("IFDHandler functions missing");
+		Log1(PCSC_LOG_CRITICAL, "IFDHandler functions missing");
 
 		exit(1);
 	} else if (rv1 == SCARD_S_SUCCESS)
@@ -847,7 +848,7 @@
 
 	if (rContext->dwVersion == IFD_HVERSION_1_0)
 	{
-		DebugLogA("Loading IFD Handler 1.0");
+		Log1(PCSC_LOG_INFO, "Loading IFD Handler 1.0");
 
 #define GET_ADDRESS_OPTIONALv1(field, function, code) \
 { \
@@ -860,7 +861,7 @@
 
 #define GET_ADDRESSv1(field, function) \
 	GET_ADDRESS_OPTIONALv1(field, function, \
-		DebugLogA("IFDHandler functions missing: " #function ); \
+		Log1(PCSC_LOG_CRITICAL, "IFDHandler functions missing: " #function ); \
 		exit(1); )
 
 		DYN_GetAddress(rContext->vHandle,
@@ -872,7 +873,7 @@
 			"IO_Close_Channel"))
 		{
 			rContext->psFunctions.psFunctions_v1.pvfCloseChannel = NULL;
-			DebugLogA("IFDHandler functions missing");
+			Log1(PCSC_LOG_CRITICAL, "IFDHandler functions missing");
 			exit(1);
 		}
 
@@ -901,10 +902,10 @@
 
 #define GET_ADDRESSv2(s) \
 	GET_ADDRESS_OPTIONALv2(s, \
-		DebugLogA("IFDHandler functions missing: " #s ); \
+		Log1(PCSC_LOG_CRITICAL, "IFDHandler functions missing: " #s ); \
 		exit(1); )
 
-		DebugLogA("Loading IFD Handler 2.0");
+		Log1(PCSC_LOG_INFO, "Loading IFD Handler 2.0");
 
 		GET_ADDRESSv2(CloseChannel)
 		GET_ADDRESSv2(GetCapabilities)
@@ -933,10 +934,10 @@
 
 #define GET_ADDRESSv3(s) \
 	GET_ADDRESS_OPTIONALv3(s, \
-		DebugLogA("IFDHandler functions missing: " #s ); \
+		Log1(PCSC_LOG_CRITICAL, "IFDHandler functions missing: " #s ); \
 		exit(1); )
 
-		DebugLogA("Loading IFD Handler 3.0");
+		Log1(PCSC_LOG_INFO, "Loading IFD Handler 3.0");
 
 		GET_ADDRESSv2(CloseChannel)
 		GET_ADDRESSv2(GetCapabilities)
@@ -953,7 +954,7 @@
 		/*
 		 * Who knows what could have happenned for it to get here. 
 		 */
-		DebugLogA("IFD Handler not 1.0/2.0 or 3.0");
+		Log1(PCSC_LOG_CRITICAL, "IFD Handler not 1.0/2.0 or 3.0");
 		exit(1);
 	}
 
@@ -979,7 +980,7 @@
 
 	if (*rContext->pdwFeeds == 1)
 	{
-		DebugLogA("Unloading reader driver.");
+		Log1(PCSC_LOG_INFO, "Unloading reader driver.");
 		DYN_CloseLibrary(&rContext->vHandle);
 	}
 
@@ -1062,7 +1063,7 @@
 	/*
 	 * Spawn the event handler thread 
 	 */
-	DebugLogB("Attempting startup of %s.", rContext->lpcReader);
+	Log2(PCSC_LOG_INFO, "Attempting startup of %s.", rContext->lpcReader);
 
   /******************************************/
 	/*
@@ -1096,7 +1097,7 @@
 
 	if (rv != IFD_SUCCESS)
 	{
-		DebugLogC("Open Port %X Failed (%s)",
+		Log3(PCSC_LOG_CRITICAL, "Open Port %X Failed (%s)",
 			rContext->dwPort, rContext->lpcDevice);
 		RFUnBindFunctions(rContext);
 		RFUnloadReader(rContext);
@@ -1108,7 +1109,7 @@
 
 LONG RFUnInitializeReader(PREADER_CONTEXT rContext)
 {
-	DebugLogB("Attempting shutdown of %s.",
+	Log2(PCSC_LOG_INFO, "Attempting shutdown of %s.",
 		rContext->lpcReader);
 
 	/*
@@ -1317,7 +1318,7 @@
 {
 	int i;
 
-	DebugLogA("entering cleaning function");
+	Log1(PCSC_LOG_INFO, "entering cleaning function");
 	for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
 		if (sReadersContexts[i]->vHandle != 0)
@@ -1325,7 +1326,8 @@
 			LONG rv;
 			char lpcStripReader[MAX_READERNAME];
 
-			DebugLogB("Stopping reader: %s", sReadersContexts[i]->lpcReader);
+			Log2(PCSC_LOG_INFO, "Stopping reader: %s",
+				sReadersContexts[i]->lpcReader);
 
 			strncpy(lpcStripReader, (sReadersContexts[i])->lpcReader,
 				sizeof(lpcStripReader));
@@ -1337,7 +1339,7 @@
 			rv = RFRemoveReader(lpcStripReader, sReadersContexts[i]->dwPort);
 
 			if (rv != SCARD_S_SUCCESS)
-				DebugLogB("RFRemoveReader error: %s",
+				Log2(PCSC_LOG_ERROR, "RFRemoveReader error: %s",
 					pcsc_stringify_error(rv));
 		}
 	}
@@ -1397,7 +1399,7 @@
 
 			if (rv != IFD_SUCCESS)
 			{
-				DebugLogC("Open Port %X Failed (%s)",
+				Log3(PCSC_LOG_ERROR, "Open Port %X Failed (%s)",
 					(sReadersContexts[i])->dwPort, (sReadersContexts[i])->lpcDevice);
 			}
 
--- /cvsroot/pcsclite/PCSC/src/sys_unix.c	2005/01/11 20:44:54	1.14
+++ /cvsroot/pcsclite/PCSC/src/sys_unix.c	2005/02/22 14:40:26	1.15
@@ -6,7 +6,7 @@
  * Copyright (C) 1999
  *  David Corcoran <corcoran@linuxnet.com>
  *
- * $Id: sys_unix.c,v 1.14 2005/01/11 20:44:54 rousseau Exp $
+ * $Id: sys_unix.c,v 1.15 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -259,17 +259,17 @@
 
 	if (!noclose) {
 		if (SYS_CloseFile(0))
-			DebugLogB("SYS_CloseFile(0) failed: %s", strerror(errno));
+			Log2("SYS_CloseFile(0) failed: %s", strerror(errno));
 
 		if (SYS_CloseFile(1))
-			DebugLogB("SYS_CloseFile(1) failed: %s", strerror(errno));
+			Log2("SYS_CloseFile(1) failed: %s", strerror(errno));
 
 		if (SYS_CloseFile(2))
-			DebugLogB("SYS_CloseFile(2) failed: %s", strerror(errno));
+			Log2("SYS_CloseFile(2) failed: %s", strerror(errno));
 	}
 	if (!nochdir) {
 		if (SYS_Chdir("/"))
-			DebugLogB("SYS_Chdir() failed: %s", strerror(errno));
+			Log2("SYS_Chdir() failed: %s", strerror(errno));
 	}
 	return 0;
 #endif
--- /cvsroot/pcsclite/PCSC/src/tokenparser.l	2004/09/21 18:33:54	1.17
+++ /cvsroot/pcsclite/PCSC/src/tokenparser.l	2005/02/22 14:40:26	1.18
@@ -7,7 +7,7 @@
  *  David Corcoran <corcoran@linuxnet.com>
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: tokenparser.l,v 1.17 2004/09/21 18:33:54 rousseau Exp $
+ * $Id: tokenparser.l,v 1.18 2005/02/22 14:40:26 rousseau Exp $
  */
 
 %{
@@ -113,8 +113,8 @@
 
 	if (!file)
 	{
-		DebugLogC("Could not open bundle file %s: %s", fileName,
-			strerror(errno));
+		Log3(PCSC_LOG_CRITICAL, "Could not open bundle file %s: %s",
+			fileName, strerror(errno));
 		return 1;
 	}
 
@@ -130,7 +130,7 @@
 		if (tokenIndice == 0)
 		{
 			/* Not defined at all */
-			DebugLogC("Value/Key not defined for: %s in %s",
+			Log3(PCSC_LOG_CRITICAL, "Value/Key not defined for: %s in %s",
 				tokenKey, fileName);
 		}
 		ret = -1;
--- /cvsroot/pcsclite/PCSC/src/winscard.c	2005/01/11 20:45:45	1.47
+++ /cvsroot/pcsclite/PCSC/src/winscard.c	2005/02/22 14:40:26	1.48
@@ -8,7 +8,7 @@
  *  David Corcoran <corcoran@linuxnet.com>
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: winscard.c,v 1.47 2005/01/11 20:45:45 rousseau Exp $
+ * $Id: winscard.c,v 1.48 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -66,7 +66,7 @@
 
 	*phContext = (PCSCLITE_SVC_IDENTITY + SYS_RandomInt(1, 65535));
 
-	DebugLogB("Establishing Context: %d", *phContext);
+	Log2(PCSC_LOG_DEBUG, "Establishing Context: %d", *phContext);
 
 	return SCARD_S_SUCCESS;
 }
@@ -77,7 +77,7 @@
 	 * Nothing to do here RPC layer will handle this
 	 */
 
-	DebugLogB("Releasing Context: %d", hContext);
+	Log2(PCSC_LOG_DEBUG, "Releasing Context: %d", hContext);
 
 	return SCARD_S_SUCCESS;
 }
@@ -119,13 +119,14 @@
 			dwShareMode != SCARD_SHARE_DIRECT)
 		return SCARD_E_INVALID_VALUE;
 
-	DebugLogC("Attempting Connect to %s %d", szReader, dwPreferredProtocols);
+	Log3(PCSC_LOG_DEBUG, "Attempting Connect to %s %d", szReader,
+		dwPreferredProtocols);
 
 	rv = RFReaderInfo((LPTSTR) szReader, &rContext);
 
 	if (rv != SCARD_S_SUCCESS)
 	{
-		DebugLogB("Reader %s Not Found", szReader);
+		Log2(PCSC_LOG_ERROR, "Reader %s Not Found", szReader);
 		return rv;
 	}
 
@@ -147,7 +148,7 @@
 	 */
 	if (rContext->dwContexts == SCARD_EXCLUSIVE_CONTEXT)
 	{
-		DebugLogA("Error Reader Exclusive");
+		Log1(PCSC_LOG_ERROR, "Error Reader Exclusive");
 		return SCARD_E_SHARING_VIOLATION;
 	}
 
@@ -163,7 +164,7 @@
 	{
 		if (!(dwStatus & SCARD_PRESENT))
 		{
-			DebugLogA("Card Not Inserted");
+			Log1(PCSC_LOG_ERROR, "Card Not Inserted");
 			return SCARD_E_NO_SMARTCARD;
 		}
 	}
@@ -223,9 +224,10 @@
 
 	if ((*pdwActiveProtocol != SCARD_PROTOCOL_T0)
 		&& (*pdwActiveProtocol != SCARD_PROTOCOL_T1))
-		DebugLogB("Active Protocol: unknown %d", *pdwActiveProtocol);
+		Log2(PCSC_LOG_ERROR, "Active Protocol: unknown %d",
+			*pdwActiveProtocol);
 	else
-		DebugLogB("Active Protocol: T=%d",
+		Log2(PCSC_LOG_DEBUG, "Active Protocol: T=%d",
 			(*pdwActiveProtocol == SCARD_PROTOCOL_T0) ? 0 : 1);
 
 	/*
@@ -233,7 +235,7 @@
 	 */
 	*phCard = RFCreateReaderHandle(rContext);
 
-	DebugLogB("hCard Identity: %x", *phCard);
+	Log2(PCSC_LOG_DEBUG, "hCard Identity: %x", *phCard);
 
 	/*******************************************
 	 *
@@ -300,7 +302,7 @@
 	LONG rv;
 	PREADER_CONTEXT rContext = NULL;
 
-	DebugLogA("Attempting reconnect to token.");
+	Log1(PCSC_LOG_DEBUG, "Attempting reconnect to token.");
 
 	if (hCard == 0)
 		return SCARD_E_INVALID_HANDLE;
@@ -392,17 +394,17 @@
 				break;
 
 			case SCARD_W_REMOVED_CARD:
-				DebugLogA("card removed");
+				Log1(PCSC_LOG_ERROR, "card removed");
 				return SCARD_W_REMOVED_CARD;
 
 			/* invalid EventStatus */
 			case SCARD_E_INVALID_VALUE:
-				DebugLogA("invalid EventStatus");
+				Log1(PCSC_LOG_ERROR, "invalid EventStatus");
 				return SCARD_F_INTERNAL_ERROR;
 
 			/* invalid hCard, but hCard was widely used some lines above :( */
 			case SCARD_E_INVALID_HANDLE:
-				DebugLogA("invalid handle");
+				Log1(PCSC_LOG_ERROR, "invalid handle");
 				return SCARD_F_INTERNAL_ERROR;
 
 			case SCARD_S_SUCCESS:
@@ -438,8 +440,9 @@
 
 				if (rContext->readerState->cardAtrLength > 0)
 				{
-					DebugLogA("Reset complete.");
-					DebugXxd("Card ATR: ", rContext->readerState->cardAtr,
+					Log1(PCSC_LOG_DEBUG, "Reset complete.");
+					LogXxd(PCSC_LOG_DEBUG, "Card ATR: ",
+						rContext->readerState->cardAtr,
 						rContext->readerState->cardAtrLength);
 				}
 				else
@@ -447,7 +450,7 @@
 					DWORD dwStatus, dwAtrLen;
 					UCHAR ucAtr[MAX_ATR_SIZE];
 
-					DebugLogA("Error resetting card.");
+					Log1(PCSC_LOG_ERROR, "Error resetting card.");
 					IFDStatusICC(rContext, &dwStatus, ucAtr, &dwAtrLen);
 					if (dwStatus & SCARD_PRESENT)
 						return SCARD_W_UNRESPONSIVE_CARD;
@@ -457,7 +460,8 @@
 				break;
 
 			default:
-				DebugLogB("invalid retcode from RFCheckReaderEventState (%X)", rv);
+				Log2(PCSC_LOG_ERROR,
+					"invalid retcode from RFCheckReaderEventState (%X)", rv);
 				return SCARD_F_INTERNAL_ERROR;
 				break;
 		}
@@ -613,7 +617,7 @@
 	 */
 	RFUnlockSharing(hCard);
 
-	DebugLogB("Active Contexts: %d", rContext->dwContexts);
+	Log2(PCSC_LOG_DEBUG, "Active Contexts: %d", rContext->dwContexts);
 
 	if (dwDisposition == SCARD_RESET_CARD ||
 		dwDisposition == SCARD_UNPOWER_CARD)
@@ -672,9 +676,9 @@
 		}
 
 		if (rContext->readerState->cardAtrLength > 0)
-			DebugLogA("Reset complete.");
+			Log1(PCSC_LOG_DEBUG, "Reset complete.");
 		else
-			DebugLogA("Error resetting card.");
+			Log1(PCSC_LOG_ERROR, "Error resetting card.");
 
 	}
 	else if (dwDisposition == SCARD_EJECT_CARD)
@@ -699,16 +703,16 @@
 		{
 			if (receiveLength == 2 && receiveBuffer[0] == 0x90)
 			{
-				DebugLogA("Card ejected successfully.");
+				Log1(PCSC_LOG_DEBUG, "Card ejected successfully.");
 				/*
 				 * Successful
 				 */
 			}
 			else
-				DebugLogA("Error ejecting card.");
+				Log1(PCSC_LOG_ERROR, "Error ejecting card.");
 		}
 		else
-			DebugLogA("Error ejecting card.");
+			Log1(PCSC_LOG_ERROR, "Error ejecting card.");
 
 	}
 	else if (dwDisposition == SCARD_LEAVE_CARD)
@@ -784,7 +788,7 @@
 
 	rv = RFLockSharing(hCard);
 
-	DebugLogB("Status: %d.", rv);
+	Log2(PCSC_LOG_DEBUG, "Status: %d.", rv);
 
 	return rv;
 }
@@ -881,9 +885,9 @@
 		}
 
 		if (rContext->readerState->cardAtrLength > 0)
-			DebugLogA("Reset complete.");
+			Log1(PCSC_LOG_DEBUG, "Reset complete.");
 		else
-			DebugLogA("Error resetting card.");
+			Log1(PCSC_LOG_ERROR, "Error resetting card.");
 
 	}
 	else if (dwDisposition == SCARD_EJECT_CARD)
@@ -908,16 +912,16 @@
 		{
 			if (receiveLength == 2 && receiveBuffer[0] == 0x90)
 			{
-				DebugLogA("Card ejected successfully.");
+				Log1(PCSC_LOG_DEBUG, "Card ejected successfully.");
 				/*
 				 * Successful
 				 */
 			}
 			else
-				DebugLogA("Error ejecting card.");
+				Log1(PCSC_LOG_ERROR, "Error ejecting card.");
 		}
 		else
-			DebugLogA("Error ejecting card.");
+			Log1(PCSC_LOG_ERROR, "Error ejecting card.");
 
 	}
 	else if (dwDisposition == SCARD_LEAVE_CARD)
@@ -932,7 +936,7 @@
 	 */
 	RFUnlockSharing(hCard);
 
-	DebugLogB("Status: %d.", rv);
+	Log2(PCSC_LOG_DEBUG, "Status: %d.", rv);
 
 	return rv;
 }
@@ -968,7 +972,7 @@
 
 	rv = RFUnlockSharing(hCard);
 
-	DebugLogB("Status: %d.", rv);
+	Log2(PCSC_LOG_DEBUG, "Status: %d.", rv);
 
 	return rv;
 }
@@ -1367,7 +1371,7 @@
 	sSendPci.Length = pioSendPci->cbPciLength;
 
 	/* the protocol number is decoded a few lines above */
-	DebugLogB("Send Protocol: T=%d", sSendPci.Protocol);
+	Log2(PCSC_LOG_DEBUG, "Send Protocol: T=%d", sSendPci.Protocol);
 
 	tempRxLength = dwRxLength;
 
@@ -1394,7 +1398,7 @@
 	if (rv != SCARD_S_SUCCESS)
 	{
 		*pcbRecvLength = 0;
-		DebugLogB("Card not transacted: %ld", rv);
+		Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
 		return SCARD_E_NOT_TRANSACTED;
 	}
 
--- /cvsroot/pcsclite/PCSC/src/winscard_clnt.c	2005/01/11 20:45:45	1.51
+++ /cvsroot/pcsclite/PCSC/src/winscard_clnt.c	2005/02/22 14:40:26	1.52
@@ -9,7 +9,7 @@
  *  Damien Sauveron <damien.sauveron@labri.fr>
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: winscard_clnt.c,v 1.51 2005/01/11 20:45:45 rousseau Exp $
+ * $Id: winscard_clnt.c,v 1.52 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -145,7 +145,7 @@
 		mapAddr = SYS_OpenFile(PCSCLITE_PUBSHM_FILE, O_RDONLY, 0);
 		if (mapAddr < 0)
 		{
-			DebugLogB("ERROR: Cannot open public shared file: %s",
+			Log2(PCSC_LOG_CRITICAL, "Cannot open public shared file: %s",
 				PCSCLITE_PUBSHM_FILE);
 			return SCARD_E_NO_SERVICE;
 		}
@@ -162,7 +162,7 @@
 				mapAddr, (i * pageSize));
 			if (readerStates[i] == NULL)
 			{
-				DebugLogA("ERROR: Cannot public memory map");
+				Log1(PCSC_LOG_CRITICAL, "Cannot public memory map");
 				SYS_CloseFile(mapAddr);	/* Close the memory map file */
 				return SCARD_F_INTERNAL_ERROR;
 			}
@@ -238,11 +238,11 @@
 		if (-1 == SHMMessageReceive(&msgStruct, dwClientID,
 			PCSCLITE_CLIENT_ATTEMPTS))
 		{
-			DebugLogA("Your pcscd is too old and does not support CMD_VERSION");
+			Log1(PCSC_LOG_CRITICAL, "Your pcscd is too old and does not support CMD_VERSION");
 			return SCARD_F_COMM_ERROR;
 		}
 
-		DebugLogC("Server is protocol version %d:%d",
+		Log3(PCSC_LOG_INFO, "Server is protocol version %d:%d",
 			veStr->major, veStr->minor);
 
 		isExecuted = 1;
@@ -1132,9 +1132,7 @@
 	 * Now is where we start our event checking loop
 	 */
 
-	/*
-	 * DebugLogA("Event Loop Start"_);
-	 */
+	Log1(PCSC_LOG_DEBUG, "Event Loop Start");
 
 	psContextMap[dwContextIndex].contextBlockStatus = BLOCK_STATUS_BLOCKING;
 
@@ -1452,9 +1450,7 @@
 	}
 	while (1);
 
-	/*
-	 * DebugLogA("Event Loop End");
-	 */
+	Log1(PCSC_LOG_DEBUG, "Event Loop End");
 
 	if (psContextMap[dwContextIndex].contextBlockStatus ==
 			BLOCK_STATUS_RESUME)
@@ -2135,7 +2131,7 @@
 
 	if (rv != 0)
 	{
-		DebugLogA("PCSC Not Running");
+		Log1(PCSC_LOG_ERROR, "PCSC Not Running");
 		return SCARD_E_NO_SERVICE;
 	}
 
--- /cvsroot/pcsclite/PCSC/src/winscard_msg.c	2005/01/11 20:28:31	1.25
+++ /cvsroot/pcsclite/PCSC/src/winscard_msg.c	2005/02/22 14:40:26	1.26
@@ -8,7 +8,7 @@
  *  Damien Sauveron <damien.sauveron@labri.fr>
  *  Ludoic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: winscard_msg.c,v 1.25 2005/01/11 20:28:31 rousseau Exp $
+ * $Id: winscard_msg.c,v 1.26 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -48,7 +48,7 @@
 
 	if ((*pdwClientID = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
 	{
-		DebugLogB("Error: create on client socket: %s",
+		Log2(PCSC_LOG_CRITICAL, "Error: create on client socket: %s",
 			strerror(errno));
 		return -1;
 	}
@@ -60,7 +60,7 @@
 	if (connect(*pdwClientID, (struct sockaddr *) &svc_addr,
 			sizeof(svc_addr.sun_family) + strlen(svc_addr.sun_path) + 1) < 0)
 	{
-		DebugLogB("Error: connect to client socket: %s",
+		Log2(PCSC_LOG_CRITICAL, "Error: connect to client socket: %s",
 			strerror(errno));
 		SYS_CloseFile(*pdwClientID);
 		return -1;
@@ -69,7 +69,7 @@
 	one = 1;
 	if (ioctl(*pdwClientID, FIONBIO, &one) < 0)
 	{
-		DebugLogB("Error: cannot set socket nonblocking: %s",
+		Log2(PCSC_LOG_CRITICAL, "Error: cannot set socket nonblocking: %s",
 			strerror(errno));
 		SYS_CloseFile(*pdwClientID);
 		return -1;
@@ -93,7 +93,8 @@
 	 */
 	if ((commonSocket = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
 	{
-		DebugLogB("Unable to create common socket: %s", strerror(errno));
+		Log2(PCSC_LOG_CRITICAL, "Unable to create common socket: %s",
+			strerror(errno));
 		return -1;
 	}
 
@@ -105,14 +106,16 @@
 	if (bind(commonSocket, (struct sockaddr *) &serv_adr,
 			sizeof(serv_adr.sun_family) + strlen(serv_adr.sun_path) + 1) < 0)
 	{
-		DebugLogB("Unable to bind common socket: %s", strerror(errno));
+		Log2(PCSC_LOG_CRITICAL, "Unable to bind common socket: %s",
+			strerror(errno));
 		SHMCleanupSharedSegment(commonSocket, PCSCLITE_CSOCK_NAME);
 		return -1;
 	}
 
 	if (listen(commonSocket, 1) < 0)
 	{
-		DebugLogB("Unable to listen common socket: %s", strerror(errno));
+		Log2(PCSC_LOG_CRITICAL, "Unable to listen common socket: %s",
+			strerror(errno));
 		SHMCleanupSharedSegment(commonSocket, PCSCLITE_CSOCK_NAME);
 		return -1;
 	}
@@ -137,7 +140,8 @@
 	if ((new_sock = accept(commonSocket, (struct sockaddr *) &clnt_addr,
 				&clnt_len)) < 0)
 	{
-		DebugLogB("ER: Accept on common socket: %s", strerror(errno));
+		Log2(PCSC_LOG_CRITICAL, "Accept on common socket: %s",
+			strerror(errno));
 		return -1;
 	}
 
@@ -146,7 +150,8 @@
 	one = 1;
 	if (ioctl(*pdwClientID, FIONBIO, &one) < 0)
 	{
-		DebugLogB("Error: cannot set socket nonblocking: %s", strerror(errno));
+		Log2(PCSC_LOG_CRITICAL, "Error: cannot set socket nonblocking: %s",
+			strerror(errno));
 		SYS_CloseFile(*pdwClientID);
 		*pdwClientID = -1;
 		return -1;
@@ -176,7 +181,8 @@
 
 	if (selret < 0)
 	{
-		DebugLogB("Select returns with failure: %s", strerror(errno));
+		Log2(PCSC_LOG_CRITICAL, "Select returns with failure: %s",
+			strerror(errno));
 		return -1;
 	}
 
@@ -188,14 +194,16 @@
 	 */
 	if (FD_ISSET(commonSocket, &read_fd))
 	{
-		DebugLogA("Common channel packet arrival");
+		Log1(PCSC_LOG_DEBUG, "Common channel packet arrival");
 		if (SHMProcessCommonChannelRequest(pdwClientID) == -1)
 		{
-			DebugLogB("error in SHMProcessCommonChannelRequest: %d", *pdwClientID);
+			Log2(PCSC_LOG_ERROR,
+				"error in SHMProcessCommonChannelRequest: %d", *pdwClientID);
 			return -1;
 		} else
 		{
-			DebugLogB("SHMProcessCommonChannelRequest detects: %d", *pdwClientID);
+			Log2(PCSC_LOG_DEBUG,
+				"SHMProcessCommonChannelRequest detects: %d", *pdwClientID);
 			return 0;
 		}
 	}
@@ -220,7 +228,8 @@
 
 	if (selret < 0)
 	{
-		DebugLogB("Select returns with failure: %s", strerror(errno));
+		Log2(PCSC_LOG_ERROR, "select returns with failure: %s",
+			strerror(errno));
 		return -1;
 	}
 
@@ -238,7 +247,8 @@
 		
 		if (rv == -1)
 		{	/* The client has died */
-			DebugLogB("Client has disappeared: %d", *pdwClientID);
+			Log2(PCSC_LOG_DEBUG, "Client has disappeared: %d",
+				*pdwClientID);
 			msgStruct->mtype = CMD_CLIENT_DIED;
 			msgStruct->command = 0;
 			SYS_CloseFile(*pdwClientID);
@@ -249,7 +259,8 @@
 		/*
 		 * Set the identifier handle 
 		 */
-		DebugLogB("correctly processed client: %d", *pdwClientID);
+		Log2(PCSC_LOG_DEBUG, "correctly processed client: %d",
+			*pdwClientID);
 		return 1;
 	}
 	
@@ -358,7 +369,8 @@
 			 */
 			if (errno != EINTR)
 			{
-				DebugLogB("Select returns with failure: %s", strerror(errno));
+				Log2(PCSC_LOG_ERROR, "select returns with failure: %s",
+					strerror(errno));
 				retval = -1;
 				break;
 			}
@@ -469,7 +481,8 @@
 			 */
 			if (errno != EINTR)
 			{
-				DebugLogB("Select returns with failure: %s", strerror(errno));
+				Log2(PCSC_LOG_ERROR, "select returns with failure: %s",
+					strerror(errno));
 				retval = -1;
 				break;
 			}
--- /cvsroot/pcsclite/PCSC/src/winscard_svc.c	2004/08/06 12:12:19	1.30
+++ /cvsroot/pcsclite/PCSC/src/winscard_svc.c	2005/02/22 14:40:26	1.31
@@ -9,7 +9,7 @@
  *  Damien Sauveron <damien.sauveron@labri.fr>
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: winscard_svc.c,v 1.30 2004/08/06 12:12:19 rousseau Exp $
+ * $Id: winscard_svc.c,v 1.31 2005/02/22 14:40:26 rousseau Exp $
  */
 
 #include "config.h"
@@ -99,7 +99,8 @@
 	sharedSegmentMsg msgStruct;
 	DWORD dwContextIndex = *pdwIndex;
 
-	DebugLogB("Thread is started: %d", psContext[dwContextIndex].dwClientID);
+	Log2(PCSC_LOG_DEBUG, "Thread is started: %d",
+		psContext[dwContextIndex].dwClientID);
 	
 	while (1)
 	{
@@ -111,7 +112,8 @@
 				/*
 				 * Clean up the dead client
 				 */
-				DebugLogB("Client die: %d", psContext[dwContextIndex].dwClientID);
+				Log2(PCSC_LOG_DEBUG, "Client die: %d",
+					psContext[dwContextIndex].dwClientID);
 				MSGCleanupClient(dwContextIndex);
 				SYS_ThreadExit((LPVOID) NULL);
 			} 
@@ -138,7 +140,8 @@
 					psContext[dwContextIndex].protocol_major = veStr->major;
 					psContext[dwContextIndex].protocol_minor = veStr->minor;
 
-					DebugLogC("Client is protocol version %d:%d",
+					Log3(PCSC_LOG_DEBUG,
+						"Client is protocol version %d:%d",
 						veStr->major, veStr->minor);
 
 					/* set the server protocol version */
@@ -165,12 +168,12 @@
 			break;
 			
 		case -1:
-			DebugLogA("Error in SHMProcessEventsContext");
+			Log1(PCSC_LOG_ERROR, "Error in SHMProcessEventsContext");
 			break;
 			
 		default:
-			DebugLogB("SHMProcessEventsContext unknown retval: %d",
-				  rv);
+			Log2(PCSC_LOG_ERROR,
+				"SHMProcessEventsContext unknown retval: %d", rv);
 			break;
 		}
 	}
@@ -440,7 +443,7 @@
 	}
 	
 	/* Must be a rogue client, debug log and sleep a couple of seconds */
-	DebugLogA("Client failed to authenticate");
+	Log1(PCSC_LOG_ERROR, "Client failed to authenticate");
 	SYS_Sleep(2);
 
 	return -1;