UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
upnpdebug.hpp
Go to the documentation of this file.
1#ifndef COMPA_DEBUG_HPP
2#define COMPA_DEBUG_HPP
3/*******************************************************************************
4 *
5 * Copyright (c) 2000-2003 Intel Corporation
6 * Copyright (c) 2006 Rémi Turboult <r3mi@users.sourceforge.net>
7 * All rights reserved.
8 * Copyright (C) 2022+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
9 * Redistribution only with this Copyright remark. Last modified: 2025-06-12
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * - Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * - Neither name of Intel Corporation nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
31 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36// Last compare with pupnp original source file on 2023-08-19, ver 1.14.17
42#include <upnp.hpp> // for UPNP_E_SUCCESS
44#include <stdio.h>
46
47#ifdef __cplusplus
48extern "C" {
49#endif /* __cplusplus */
50
51/* ! \name Other debugging features
52 *
53 * The UPnP SDK contains other features to aid in debugging.
54 * @{
55 */
56
59typedef enum Upnp_Module {
60 SSDP,
61 SOAP,
62 GENA,
63 TPOOL,
64 MSERV,
65 DOM,
66 API,
67 HTTP
70
72
88typedef enum Upnp_LogLevel_e {
89 UPNP_CRITICAL,
90 UPNP_ERROR,
91 UPNP_INFO,
92 UPNP_ALL
95
99#define UPNP_PACKET UPNP_ERROR
100
102#define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL
103
109UPnPsdk_VIS int UpnpInitLog(void);
110
111#if defined NDEBUG && !defined UPNP_DEBUG_C
112#define UpnpInitLog UpnpInitLog_Inlined
113static inline int UpnpInitLog_Inlined(void) { return UPNP_E_SUCCESS; }
114#endif
120 Upnp_LogLevel log_level);
121
122#if defined NDEBUG && !defined UPNP_DEBUG_C
123#define UpnpSetLogLevel UpnpSetLogLevel_Inlined
124static inline void UpnpSetLogLevel_Inlined(Upnp_LogLevel log_level) {
125 (void)log_level;
126 return;
127}
128#endif
129
133UPnPsdk_VIS void UpnpCloseLog(void);
134
135#if defined NDEBUG && !defined UPNP_DEBUG_C
136#define UpnpCloseLog UpnpCloseLog_Inlined
137static inline void UpnpCloseLog_Inlined(void) {}
138#endif
139
147 const char* fileName,
149 const char* Ignored);
150
151#if defined NDEBUG && !defined UPNP_DEBUG_C
152#define UpnpSetLogFileNames UpnpSetLogFileNames_Inlined
153static inline void UpnpSetLogFileNames_Inlined(const char* ErrFileName,
154 const char* ignored) {
155 (void)ErrFileName;
156 (void)ignored;
157 return;
158}
159#endif
160
172 Upnp_LogLevel DLevel,
174 Dbg_Module Module);
175
177#if (defined NDEBUG && !defined UPNP_DEBUG_C)
178#define UpnpGetDebugFile UpnpGetDebugFile_Inlined
179static inline FILE* UpnpGetDebugFile_Inlined(Upnp_LogLevel level,
180 Dbg_Module module) {
181 (void)level, (void)module;
182 return NULL;
183}
184#endif
186
198 Upnp_LogLevel DLevel,
200 Dbg_Module Module,
202 const char* DbgFileName,
205 int DbgLineNo,
207 const char* FmtStr,
210 ...)
211#if (__GNUC__ >= 3)
212 /* This enables printf like format checking by the compiler. */
213 __attribute__((format(__printf__, 5, 6)))
214#endif
215 ;
216
217#if defined NDEBUG && !defined UPNP_DEBUG_C
218#define UpnpPrintf UpnpPrintf_Inlined
219// static inline void UpnpPrintf_Inlined(Upnp_LogLevel DLevel,
220// Dbg_Module Module,
221// const char *DbgFileName,
222// int DbgLineNo,
223// const char *FmtStr,
224// ...)
225// #if (__GNUC__ >= 3)
226// /* This enables printf like format checking by the compiler. */
227// __attribute__((format(__printf__, 5, 6)))
228// #endif
229// ;
230static inline void UpnpPrintf_Inlined(Upnp_LogLevel DLevel, Dbg_Module Module,
231 const char* DbgFileName, int DbgLineNo,
232 const char* FmtStr, ...) {
233 (void)DLevel;
234 (void)Module;
235 (void)DbgFileName;
236 (void)DbgLineNo;
237 (void)FmtStr;
238 return;
239}
240#endif /* DEBUG */
241
242#ifdef __cplusplus
243}
244#endif /* __cplusplus */
245
246#endif // COMPA_DEBUG_HPP
#define UPNP_E_SUCCESS
The operation completed successfully.
Definition messages.hpp:27
static char * fileName
Definition upnpdebug.cpp:71
enum Upnp_Module Dbg_Module
Only debug messages from this program module.
Upnp_Module
Only debug messages from this program module.
Definition upnpdebug.hpp:59
UPnPsdk_VIS FILE * UpnpGetDebugFile(Upnp_LogLevel DLevel, Dbg_Module Module)
Check if the module is turned on for debug and returns the file descriptor corresponding to the debug...
UPnPsdk_VIS void UpnpSetLogFileNames(const char *fileName, const char *Ignored)
Set the name for the log file. There used to be 2 separate files. The second parameter has been kept ...
UPnPsdk_VIS void UpnpPrintf(Upnp_LogLevel DLevel, Dbg_Module Module, const char *DbgFileName, int DbgLineNo, const char *FmtStr,...)
Prints the debug statement.
UPnPsdk_VIS int UpnpInitLog(void)
Initialize the log files.
Definition upnpdebug.cpp:77
UPnPsdk_VIS void UpnpSetLogLevel(Upnp_LogLevel log_level)
Set the log level (see Upnp_LogLevel).
Upnp_LogLevel_e
Upnp_LogLevel.
Definition upnpdebug.hpp:88
UPnPsdk_VIS void UpnpCloseLog(void)
Closes the log files.
enum Upnp_LogLevel_e Upnp_LogLevel
Upnp_LogLevel.
#define UPnPsdk_VIS
Prefix to export symbol for external use.