[Pcsclite-cvs-commit] PCSC/src debuglog.h,1.9,1.10 debuglog.c,1.17,1.18
rousseau@quantz.debian.org
rousseau@quantz.debian.org
Thu, 30 Oct 2003 18:02:33 +0100
Update of /cvsroot/pcsclite/PCSC/src
In directory quantz:/tmp/cvs-serv26796
Modified Files:
debuglog.h debuglog.c
Log Message:
remove log to a file service since it was not used.
Index: debuglog.h
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/debuglog.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- debuglog.h 18 Oct 2003 17:19:36 -0000 1.9
+++ debuglog.h 30 Oct 2003 17:02:30 -0000 1.10
@@ -41,13 +41,12 @@
#define DEBUGLOG_LOG_ENTRIES 1
#define DEBUGLOG_IGNORE_ENTRIES 2
- typedef enum {
+typedef enum {
DEBUGLOG_NO_DEBUG = 0,
DEBUGLOG_SYSLOG_DEBUG,
DEBUGLOG_STDERR_DEBUG,
DEBUGLOG_STDOUT_DEBUG,
- DEBUGLOG_FILE_DEBUG,
- } DebugLogType;
+} DebugLogType;
#define DEBUG_CATEGORY_NOTHING 0
#define DEBUG_CATEGORY_APDU 1
@@ -65,16 +64,15 @@
#define DebugXxd(msg, buffer, size)
#endif
- void debug_msg(const char *fmt, ...);
- void debug_xxd(const char *msg, const unsigned char *buffer,
- const int size);
+void debug_msg(const char *fmt, ...);
+void debug_xxd(const char *msg, const unsigned char *buffer, const int size);
- void DebugLogSuppress(const int);
- void DebugLogSetLogType(const int);
- int DebugLogSetCategory(const int);
- void DebugLogCategory(const int, const char *, const int);
+void DebugLogSuppress(const int);
+void DebugLogSetLogType(const int);
+int DebugLogSetCategory(const int);
+void DebugLogCategory(const int, const char *, const int);
- char *pcsc_stringify_error(long);
+char *pcsc_stringify_error(long);
#ifdef __cplusplus
}
Index: debuglog.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/debuglog.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- debuglog.c 18 Oct 2003 17:19:36 -0000 1.17
+++ debuglog.c 30 Oct 2003 17:02:31 -0000 1.18
@@ -27,13 +27,13 @@
#include "debuglog.h"
#include "sys_generic.h"
-/* Max string size when dumping a 256 bytes longs APDU */
-#define DEBUG_BUF_SIZE (256*3+30)
+/* Max string size when dumping a 256 bytes longs APDU
+ * Should be bigger than 256*3+30 */
+#define DEBUG_BUF_SIZE 2048
static int lSuppress = DEBUGLOG_LOG_ENTRIES;
static int debug_msg_type = DEBUGLOG_NO_DEBUG;
static int debug_category = DEBUG_CATEGORY_NOTHING;
-static FILE *debug_file = NULL;
void debug_msg(const char *fmt, ...)
{
@@ -64,28 +64,18 @@
case DEBUGLOG_SYSLOG_DEBUG:
#ifndef WIN32
- syslog(LOG_INFO, "%s", DebugBuffer);
+ syslog(LOG_INFO, "%s", DebugBuffer);
#else
- fprintf(stderr, "%s\n", DebugBuffer);
+ fprintf(stderr, "%s\n", DebugBuffer);
#endif
- break;
+ break;
case DEBUGLOG_STDERR_DEBUG:
- fprintf(stderr, "%s\n", DebugBuffer);
- break;
+ fprintf(stderr, "%s\n", DebugBuffer);
+ break;
case DEBUGLOG_STDOUT_DEBUG:
- fprintf(stdout, "%s\n", DebugBuffer);
- break;
-
- case DEBUGLOG_FILE_DEBUG:
- if (debug_file) {
- fprintf(debug_file, "%s\n", DebugBuffer);
- } else {
- /* File not setup, do nothing. But assert to catch this in debug
- * builds */
- assert(0);
- }
+ fprintf(stdout, "%s\n", DebugBuffer);
break;
default:
@@ -137,16 +127,6 @@
fprintf(stdout, "%s\n", DebugBuffer);
break;
- case DEBUGLOG_FILE_DEBUG:
- if (debug_file) {
- fprintf(debug_file, "%s\n", DebugBuffer);
- } else {
- /* File not setup, do nothing. But assert to catch this in debug
- * builds. */
- assert(0);
- }
- break;
-
default:
/* Unknown type - do nothing */
assert(0);
@@ -318,6 +298,9 @@
};
+ /* add a null byte */
+ strError[sizeof(strError)] = '\0';
+
return strError;
}
@@ -327,28 +310,3 @@
}
#endif
-void DebugLogSetupLogFile(const char* filename_base) {
- char *filename = NULL;
- int bufsize;
-
- bufsize = strlen(filename_base) + 22;
- filename = (char *)malloc(bufsize);
- if (filename == NULL) {
- goto finish;
- }
-
- if ( debug_file != NULL ) {
- fclose(debug_file);
- debug_file = NULL;
- }
-
- sprintf(filename, "%s.%20d", filename_base, SYS_GetPID());
- debug_file = fopen(filename, "a");
-
- /* In debug mode, catch the case where we couldn't open the file */
- assert(debug_file);
-
-finish:
- free(filename);
-
-}