[Pcsclite-cvs-commit] CVS PCSC/src

CVS User rousseau ludovic.rousseau@free.fr
Mon, 28 Feb 2005 05:44:25 -0700


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

Modified Files:
	debuglog.c 
Log Message:
simplify the debug output switch


--- /cvsroot/pcsclite/PCSC/src/debuglog.c	2005/02/28 12:35:18	1.32
+++ /cvsroot/pcsclite/PCSC/src/debuglog.c	2005/02/28 12:44:25	1.33
@@ -7,7 +7,7 @@
  *  David Corcoran <corcoran@linuxnet.com>
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: debuglog.c,v 1.32 2005/02/28 12:35:18 rousseau Exp $
+ * $Id: debuglog.c,v 1.33 2005/02/28 12:44:25 rousseau Exp $
  */
 
 #include "config.h"
@@ -43,11 +43,9 @@
 	char DebugBuffer[DEBUG_BUF_SIZE];
 	va_list argptr;
 
-	if (lSuppress != DEBUGLOG_LOG_ENTRIES)
-		return;
-
-	/* log priority lower than threshold? */
-	if (priority < log_level)
+	if ((lSuppress != DEBUGLOG_LOG_ENTRIES)
+		|| (priority < log_level) /* log priority lower than threshold? */
+		|| (DEBUGLOG_NO_DEBUG == debug_msg_type))
 		return;
 
 	va_start(argptr, fmt);
@@ -62,29 +60,12 @@
 #endif
 	va_end(argptr);
 
-	switch(debug_msg_type) {
-		case DEBUGLOG_NO_DEBUG:
-		/*
-		 * Do nothing, it hasn't been set 
-		 */
-		break;
-
-		case DEBUGLOG_SYSLOG_DEBUG:
 #ifndef WIN32
-			syslog(LOG_INFO, "%s", DebugBuffer);
-#else
-			fprintf(stderr, "%s\n", DebugBuffer);
+	if (DEBUGLOG_SYSLOG_DEBUG == debug_msg_type)
+		syslog(LOG_INFO, "%s", DebugBuffer);
+	else
 #endif
-			break;
-
-		case DEBUGLOG_STDERR_DEBUG:
-			fprintf(stderr, "%s\n", DebugBuffer);
-			break;
-
-		default:
-			/* Unknown type. Do nothing. */
-			assert(0);
-	}
+		fprintf(stderr, "%s\n", DebugBuffer);
 } /* log_msg */
 
 void log_xxd(const int priority, const char *msg, const unsigned char *buffer,
@@ -93,13 +74,11 @@
 	char DebugBuffer[DEBUG_BUF_SIZE];
 	int i;
 	char *c;
-        char *debug_buf_end;
-
-	if (lSuppress != DEBUGLOG_LOG_ENTRIES)
-		return;
+	char *debug_buf_end;
 
-	/* log priority lower than threshold? */
-	if (priority <= log_level)
+	if ((lSuppress != DEBUGLOG_LOG_ENTRIES)
+		|| (priority < log_level) /* log priority lower than threshold? */
+		|| (DEBUGLOG_NO_DEBUG == debug_msg_type))
 		return;
 
 	debug_buf_end = DebugBuffer + DEBUG_BUF_SIZE - 5;
@@ -113,29 +92,12 @@
 		c += strlen(c);
 	}
 
-	switch( debug_msg_type ) {
-		case DEBUGLOG_NO_DEBUG:
-		/*
-		 * Do nothing, it hasn't been set 
-		 */
-		break;
-
-		case DEBUGLOG_SYSLOG_DEBUG:
 #ifndef WIN32
+	if (DEBUGLOG_SYSLOG_DEBUG == debug_msg_type)
 		syslog(LOG_INFO, "%s", DebugBuffer);
-#else
-		fprintf(stderr, "%s\n", DebugBuffer);
+	else
 #endif
-		break;
-
-		case DEBUGLOG_STDERR_DEBUG:
 		fprintf(stderr, "%s\n", DebugBuffer);
-		break;
-
-		default:
-			/* Unknown type - do nothing */
-			assert(0);
-	}
 } /* log_xxd */
 
 void DebugLogSuppress(const int lSType)
@@ -359,7 +321,8 @@
 	char DebugBuffer[DEBUG_BUF_SIZE];
 	va_list argptr;
 
-	if (lSuppress != DEBUGLOG_LOG_ENTRIES)
+	if ((lSuppress != DEBUGLOG_LOG_ENTRIES)
+		|| (DEBUGLOG_NO_DEBUG == debug_msg_type))
 		return;
 
 	va_start(argptr, fmt);
@@ -374,29 +337,12 @@
 #endif
 	va_end(argptr);
 
-	switch(debug_msg_type) {
-		case DEBUGLOG_NO_DEBUG:
-		/*
-		 * Do nothing, it hasn't been set 
-		 */
-		break;
-
-		case DEBUGLOG_SYSLOG_DEBUG:
 #ifndef WIN32
-			syslog(LOG_INFO, "%s", DebugBuffer);
-#else
-			fprintf(stderr, "%s\n", DebugBuffer);
+	if (DEBUGLOG_SYSLOG_DEBUG == debug_msg_type)
+		syslog(LOG_INFO, "%s", DebugBuffer);
+	else
 #endif
-			break;
-
-		case DEBUGLOG_STDERR_DEBUG:
-			fprintf(stderr, "%s\n", DebugBuffer);
-			break;
-
-		default:
-			/* Unknown type. Do nothing. */
-			assert(0);
-	}
+		fprintf(stderr, "%s\n", DebugBuffer);
 } /* debug_msg */
 
 void debug_xxd(const char *msg, const unsigned char *buffer, const int len)