libUPnP
1.6.17
|
00001 /******************************************************************************* 00002 * 00003 * Copyright (c) 2000-2003 Intel Corporation 00004 * Copyright (c) 2006 Rémi Turboult <r3mi@users.sourceforge.net> 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are met: 00009 * 00010 * - Redistributions of source code must retain the above copyright notice, 00011 * this list of conditions and the following disclaimer. 00012 * - Redistributions in binary form must reproduce the above copyright notice, 00013 * this list of conditions and the following disclaimer in the documentation 00014 * and/or other materials provided with the distribution. 00015 * - Neither name of Intel Corporation nor the names of its contributors 00016 * may be used to endorse or promote products derived from this software 00017 * without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00021 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00022 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 00023 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00024 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00025 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00026 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00027 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00028 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 * 00031 ******************************************************************************/ 00032 00033 #ifndef UPNP_DEBUG_H 00034 #define UPNP_DEBUG_H 00035 00040 #include "ThreadPool.h" 00041 #include "upnpconfig.h" 00042 #include "UpnpGlobal.h" /* for UPNP_INLINE */ 00043 00044 #include <stdio.h> 00045 00046 #ifdef __cplusplus 00047 extern "C" { 00048 #endif 00049 00055 00072 typedef enum Upnp_Module { 00073 SSDP, 00074 SOAP, 00075 GENA, 00076 TPOOL, 00077 MSERV, 00078 DOM, 00079 API, 00080 HTTP 00081 } Dbg_Module; 00082 00084 typedef enum Upnp_LogLevel_e { 00085 UPNP_CRITICAL, 00086 UPNP_PACKET, 00087 UPNP_INFO, 00088 UPNP_ALL 00089 } Upnp_LogLevel; 00095 #define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL 00096 00102 #ifdef DEBUG 00103 int UpnpInitLog(void); 00104 #else 00105 static UPNP_INLINE int UpnpInitLog(void) 00106 { 00107 return UPNP_E_SUCCESS; 00108 } 00109 #endif 00110 00113 #ifdef DEBUG 00114 void UpnpSetLogLevel( 00116 Upnp_LogLevel log_level); 00117 #else 00118 static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) 00119 { 00120 return; 00121 log_level = log_level; 00122 } 00123 #endif 00124 00128 #ifdef DEBUG 00129 void UpnpCloseLog(void); 00130 #else 00131 static UPNP_INLINE void UpnpCloseLog(void) 00132 { 00133 } 00134 #endif 00135 00139 #ifdef DEBUG 00140 void UpnpSetLogFileNames( 00142 const char *ErrFileName, 00144 const char *InfoFileName); 00145 #else 00146 static UPNP_INLINE void UpnpSetLogFileNames(const char *ErrFileName, 00147 const char *InfoFileName) 00148 { 00149 return; 00150 ErrFileName = ErrFileName; 00151 InfoFileName = InfoFileName; 00152 } 00153 #endif 00154 00162 #ifdef DEBUG 00163 FILE *UpnpGetDebugFile( 00166 Upnp_LogLevel level, 00168 Dbg_Module module); 00169 #else 00170 static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module) 00171 { 00172 return NULL; 00173 level = level; 00174 module = module; 00175 } 00176 #endif 00177 00183 #ifdef DEBUG 00184 int DebugAtThisLevel( 00187 Upnp_LogLevel DLevel, 00189 Dbg_Module Module); 00190 #else 00191 static UPNP_INLINE int DebugAtThisLevel(Upnp_LogLevel DLevel, Dbg_Module Module) 00192 { 00193 return 0; 00194 DLevel = DLevel; 00195 Module = Module; 00196 } 00197 #endif 00198 00203 #ifdef DEBUG 00204 void UpnpPrintf( 00207 Upnp_LogLevel DLevel, 00209 Dbg_Module Module, 00211 const char *DbgFileName, 00213 int DbgLineNo, 00215 const char *FmtStr, 00218 ...) 00219 #if (__GNUC__ >= 3) 00220 /* This enables printf like format checking by the compiler. */ 00221 __attribute__ ((format(__printf__, 5, 6))) 00222 #endif 00223 ; 00224 #else /* DEBUG */ 00225 static UPNP_INLINE void UpnpPrintf(Upnp_LogLevel DLevel, Dbg_Module Module, 00226 const char *DbgFileName, int DbgLineNo, const char *FmtStr, ...) 00227 { 00228 return; 00229 DLevel = DLevel; 00230 Module = Module; 00231 DbgFileName = DbgFileName; 00232 DbgLineNo = DbgLineNo; 00233 FmtStr = FmtStr; 00234 } 00235 #endif /* DEBUG */ 00236 00241 #ifdef DEBUG 00242 void UpnpDisplayFileAndLine( 00245 FILE * fd, 00247 const char *DbgFileName, 00249 int DbgLineNo); 00250 #else 00251 static UPNP_INLINE void UpnpDisplayFileAndLine(FILE *fd, 00252 const char *DbgFileName, int DbgLineNo) 00253 { 00254 return; 00255 fd = fd; 00256 DbgFileName = DbgFileName; 00257 DbgLineNo = DbgLineNo; 00258 } 00259 #endif 00260 00264 #ifdef DEBUG 00265 void UpnpDisplayBanner( 00267 FILE * fd, 00269 const char **lines, 00271 size_t size, 00273 size_t starlength); 00274 #else 00275 static UPNP_INLINE void UpnpDisplayBanner(FILE *fd, const char **lines, 00276 size_t size, int starlength) 00277 { 00278 return; 00279 fd = fd; 00280 lines = lines; 00281 size = size; 00282 starlength = starlength; 00283 } 00284 #endif 00285 00288 #ifdef __cplusplus 00289 } 00290 #endif 00291 00292 #endif /* UPNP_DEBUG_H */