globalplatform
debug.h
Go to the documentation of this file.
1 /* Copyright (c) 2009, Karsten Ohme
2  * This file is part of GlobalPlatform.
3  *
4  * GlobalPlatform is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * GlobalPlatform is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with GlobalPlatform. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
22 #ifndef OPGP_DEBUG_H
23 #define OPGP_DEBUG_H
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29 
30 #ifdef WIN32
31 #include "stdafx.h"
32 #endif
33 
34 #include "types.h"
35 #include "library.h"
36 #include "unicode.h"
37 #include "error.h"
38 
39 #ifdef WIN32
40 #define OPGP_LOG_FILENAME _T("C:\\TEMP\\GlobalPlatform.log")
41 #else
42 #define OPGP_LOG_FILENAME _T("/tmp/GlobalPlatform.log")
43 #endif
44 
45 #ifdef OPGP_DEBUG
46 #define OPGP_LOG_START(msg) OPGP_log_Start(msg, _T(__FILE__), __LINE__)
47 #define OPGP_LOG_MSG(...) OPGP_log_Msg(__VA_ARGS__)
48 #define OPGP_LOG_END(msg, status) OPGP_log_End(msg, _T(__FILE__), __LINE__, status)
49 #define OPGP_LOG_HEX(msg, buffer, bufferLength) OPGP_log_Hex(msg, buffer, bufferLength)
50 #else
51 #define OPGP_LOG_START(msg)
52 #define OPGP_LOG_END(msg,rv)
53 #define OPGP_LOG_HEX(msg, buffer, bufferLength)
54 #define OPGP_LOG_MSG(...)
55 #endif
56 
58 OPGP_API
59 void OPGP_log_Msg(OPGP_STRING msg, ...);
60 
62 OPGP_API
63 void OPGP_log_End(OPGP_STRING func, OPGP_STRING file, int line, OPGP_ERROR_STATUS status);
64 
66 OPGP_API
67 void OPGP_log_Start(OPGP_STRING func, OPGP_STRING file, int line);
68 
70 OPGP_API
71 void OPGP_log_Hex(OPGP_STRING msg, PBYTE buffer, DWORD bufferLength);
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 #endif
PBYTE
unsigned char * PBYTE
A Microsoft/Muscle LPBYTE, pointer to unsigned char.
Definition: types.h:48
OPGP_log_End
OPGP_API void OPGP_log_End(OPGP_STRING func, OPGP_STRING file, int line, OPGP_ERROR_STATUS status)
Logs the end of a function and its return code.
Definition: debug.c:85
types.h
OPGP_ERROR_STATUS
Definition: error.h:45
DWORD
unsigned long DWORD
A Microsoft/Muscle DWORD definition.
Definition: types.h:52
error.h
library.h
OPGP_STRING
char * OPGP_STRING
A Microsoft/Muscle LPTSTR.
Definition: types.h:46
OPGP_log_Msg
OPGP_API void OPGP_log_Msg(OPGP_STRING msg,...)
Logs something to a file or the syslog.
Definition: debug.c:100
OPGP_log_Hex
OPGP_API void OPGP_log_Hex(OPGP_STRING msg, PBYTE buffer, DWORD bufferLength)
Logs a buffer as hex string.
Definition: debug.c:53
unicode.h
OPGP_log_Start
OPGP_API void OPGP_log_Start(OPGP_STRING func, OPGP_STRING file, int line)
Logs the start of a function.
Definition: debug.c:43