globalplatform
debug.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005-2026, Karsten Ohme
3  * This file is part of GlobalPlatform.
4  *
5  * GlobalPlatform is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * GlobalPlatform is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with GlobalPlatform. If not, see <https://www.gnu.org/licenses/>.
17  *
18  * In addition, as a special exception, the copyright holders give
19  * permission to link the code of portions of this program with the
20  * OpenSSL library under certain conditions as described in each
21  * individual source file, and distribute linked combinations
22  * including the two.
23  * You must obey the GNU Lesser General Public License in all respects
24  * for all of the code used other than OpenSSL. If you modify
25  * file(s) with this exception, you may extend this exception to your
26  * version of the file(s), but you are not obligated to do so. If you
27  * do not wish to do so, delete this exception statement from your
28  * version.
29  */
30 
35 #ifndef OPGP_DEBUG_H
36 #define OPGP_DEBUG_H
37 
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #endif
42 
43 #include "types.h"
44 #include "library.h"
45 #include "unicode.h"
46 #include "error.h"
47 
48 #ifdef WIN32
49 #define OPGP_LOG_FILENAME _T("C:\\TEMP\\GlobalPlatform.log")
50 #else
51 #define OPGP_LOG_FILENAME _T("/tmp/GlobalPlatform.log")
52 #endif
53 
54 #ifdef OPGP_DEBUG
55 #define OPGP_LOG_START(msg) OPGP_log_Start(msg, _T(__FILE__), __LINE__)
56 #define OPGP_LOG_MSG(...) OPGP_log_Msg(__VA_ARGS__)
57 #define OPGP_LOG_END(msg, status) OPGP_log_End(msg, _T(__FILE__), __LINE__, status)
58 #define OPGP_LOG_HEX(msg, buffer, bufferLength) OPGP_log_Hex(msg, buffer, bufferLength)
59 #else
60 #define OPGP_LOG_START(msg)
61 #define OPGP_LOG_END(msg,rv)
62 #define OPGP_LOG_HEX(msg, buffer, bufferLength)
63 #define OPGP_LOG_MSG(...)
64 #endif
65 
67 OPGP_API
68 void OPGP_log_Msg(OPGP_STRING msg, ...);
69 
71 OPGP_API
72 void OPGP_log_End(OPGP_STRING func, OPGP_STRING file, int line, OPGP_ERROR_STATUS status);
73 
75 OPGP_API
76 void OPGP_log_Start(OPGP_STRING func, OPGP_STRING file, int line);
77 
79 OPGP_API
80 void OPGP_log_Hex(OPGP_STRING msg, PBYTE buffer, DWORD bufferLength);
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 #endif
OPGP_API void OPGP_log_Start(OPGP_STRING func, OPGP_STRING file, int line)
Logs the start of a function.
Definition: debug.c:56
OPGP_API void OPGP_log_Hex(OPGP_STRING msg, PBYTE buffer, DWORD bufferLength)
Logs a buffer as hex string.
Definition: debug.c:66
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:101
OPGP_API void OPGP_log_Msg(OPGP_STRING msg,...)
Logs something to a file or the syslog.
Definition: debug.c:117
Definition: error.h:58
unsigned char * PBYTE
A Microsoft/Muscle LPBYTE, pointer to unsigned char.
Definition: types.h:64
char * OPGP_STRING
A Microsoft/Muscle LPTSTR.
Definition: types.h:62
unsigned long DWORD
A Microsoft/Muscle DWORD definition.
Definition: types.h:68