1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
* This handles debugging.
*
* MUSCLE SmartCard Development ( http://www.linuxnet.com )
*
* Copyright (C) 1999-2002
* David Corcoran <corcoran@linuxnet.com>
* Ludovic Rousseau <ludovic.rousseau@free.fr>
*
* $Id: debuglog.h,v 1.11 2004/04/21 21:40:19 rousseau Exp $
*/
/*
* log message is sent to syslog, stdout or stderr depending on --debug
* command line argument
*
* DebugLogA("text");
* log "text"
*
* DebugLogB("text: %d", 1234);
* log "text: 1234"
* the format string can be anything printf() can understand
*
* DebugLogC("text: %d %d", 1234, 5678);
* log "text: 1234 5678"
* the format string can be anything printf() can understand
*
* DebugXxd(msg, buffer, size);
* log "msg" + a hex dump of size bytes of buffer[]
*
*/
#ifndef __debuglog_h__
#define __debuglog_h__
#ifdef __cplusplus
extern "C"
{
#endif
#define DEBUGLOG_LOG_ENTRIES 1
#define DEBUGLOG_IGNORE_ENTRIES 2
typedef enum {
DEBUGLOG_NO_DEBUG = 0,
DEBUGLOG_SYSLOG_DEBUG,
DEBUGLOG_STDERR_DEBUG,
DEBUGLOG_STDOUT_DEBUG,
} DebugLogType;
#define DEBUG_CATEGORY_NOTHING 0
#define DEBUG_CATEGORY_APDU 1
#define DEBUG_CATEGORY_SW 2
/* You can't do #ifndef __FUNCTION__ */
#if !defined(__GNUC__) && !defined(__IBMC__)
#define __FUNCTION__ ""
#endif
#ifdef PCSC_DEBUG
#define DebugLogA(fmt) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__)
#define DebugLogB(fmt, data) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data)
#define DebugLogC(fmt, data1, data2) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2)
#define DebugXxd(msg, buffer, size) debug_xxd(msg, buffer, size)
#else
#define DebugLogA(fmt)
#define DebugLogB(fmt, data)
#define DebugLogC(fmt, data1, data2)
#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 DebugLogSuppress(const int);
void DebugLogSetLogType(const int);
int DebugLogSetCategory(const int);
void DebugLogCategory(const int, const char *, const int);
char *pcsc_stringify_error(long);
#ifdef __cplusplus
}
#endif
#endif /* __debuglog_h__ */
|