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 // 00032 00033 #ifndef UPNP_DEBUG_H 00034 #define UPNP_DEBUG_H 00035 00036 #include "upnpconfig.h" 00037 00038 // Function declarations only if debug compiled into the library 00039 #if UPNP_HAVE_DEBUG 00040 00041 #include <stdio.h> 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 00053 00073 typedef enum Upnp_Module {SSDP,SOAP,GENA,TPOOL,MSERV,DOM,API, HTTP} Dbg_Module; 00075 typedef enum Upnp_LogLevel_e { 00076 UPNP_CRITICAL, 00077 UPNP_PACKET, 00078 UPNP_INFO, 00079 UPNP_ALL 00080 } Upnp_LogLevel; 00082 00083 // for backward compatibility 00084 #define Dbg_Level Upnp_LogLevel 00085 00086 00090 #define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL 00091 00092 00093 00094 /*************************************************************************** 00095 * Function : UpnpInitLog 00096 * 00097 * Parameters: void 00098 * 00099 * Description: 00100 * This functions initializes the log files 00101 * Returns: int 00102 * -1 : If fails 00103 * UPNP_E_SUCCESS : if success 00104 ***************************************************************************/ 00105 int UpnpInitLog(); 00106 00107 // for backward compatibility 00108 #define InitLog UpnpInitLog 00109 00110 00111 /*************************************************************************** 00112 * Function : UpnpSetLogLevel 00113 * 00114 * Parameters: void 00115 * 00116 * Description: 00117 * This functions set the log level (see {\tt Upnp_LogLevel} 00118 * Returns: void 00119 ***************************************************************************/ 00120 void UpnpSetLogLevel (Upnp_LogLevel); 00121 00122 00123 /*************************************************************************** 00124 * Function : UpnpCloseLog 00125 * 00126 * Parameters: void 00127 * 00128 * Description: 00129 * This functions closes the log files 00130 * Returns: void 00131 ***************************************************************************/ 00132 void UpnpCloseLog(); 00133 00134 // for backward compatibility 00135 #define CloseLog UpnpCloseLog 00136 00137 00138 /*************************************************************************** 00139 * Function : UpnpSetLogFileNames 00140 * 00141 * Parameters: 00142 * IN const char* ErrFileName: name of the error file 00143 * IN const char *InfoFileName: name of the information file 00144 * IN int size: Size of the buffer 00145 * IN int starLength: This parameter provides the width of the banner 00146 * 00147 * Description: 00148 * This functions takes the buffer and writes the buffer in the file as 00149 * per the requested banner 00150 * Returns: void 00151 ***************************************************************************/ 00152 void UpnpSetLogFileNames (const char* ErrFileName, const char* InfoFileName); 00153 00154 // for backward compatibility 00155 #define SetLogFileNames UpnpSetLogFileNames 00156 00157 00158 /*************************************************************************** 00159 * Function : UpnpGetDebugFile 00160 * 00161 * Parameters: 00162 * IN Dbg_Level DLevel: The level of the debug logging. It will decide 00163 * whether debug statement will go to standard output, 00164 * or any of the log files. 00165 * IN Dbg_Module Module: debug will go in the name of this module 00166 * 00167 * Description: 00168 * This function checks if the module is turned on for debug 00169 * and returns the file descriptor corresponding to the debug level 00170 * Returns: FILE * 00171 * NULL : if the module is turn off for debug 00172 * else returns the right file descriptor 00173 ***************************************************************************/ 00174 FILE* UpnpGetDebugFile (Upnp_LogLevel level, Dbg_Module module); 00175 00176 // for backward compatibility 00177 #define GetDebugFile UpnpGetDebugFile 00178 00179 00180 /*************************************************************************** 00181 * Function : UpnpPrintf 00182 * 00183 * Parameters: 00184 * IN Dbg_Level DLevel: The level of the debug logging. It will decide 00185 * whether debug statement will go to standard output, 00186 * or any of the log files. 00187 * IN Dbg_Module Module: debug will go in the name of this module 00188 * IN char *DbgFileName: Name of the file from where debug statement is 00189 * coming 00190 * IN int DbgLineNo : Line number of the file from where debug statement 00191 * is coming 00192 * IN char * FmtStr, ...: Variable number of arguments that will go 00193 * in the debug statement 00194 * 00195 * Description: 00196 * This functions prints the debug statement either on the startdard 00197 * output or log file along with the information from where this 00198 * debug statement is coming 00199 * Returns: void 00200 ***************************************************************************/ 00201 void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module, 00202 const char* DbgFileName, int DbgLineNo, 00203 const char* FmtStr, 00204 ...) 00205 #if (__GNUC__ >= 3) 00206 __attribute__((format (__printf__, 5, 6))) 00207 #endif 00208 ; 00209 00210 00211 /*************************************************************************** 00212 * Function : UpnpDisplayBanner 00213 * 00214 * Parameters: 00215 * IN FILE *fd: file descriptor where the banner will be written 00216 * IN char **lines: The buffer that will be written 00217 * IN int size: Size of the buffer 00218 * IN int starLength: This parameter provides the width of the banner 00219 * 00220 * Description: 00221 * This functions takes the buffer and writes the buffer in the file as 00222 * per the requested banner 00223 * Returns: void 00224 ***************************************************************************/ 00225 void UpnpDisplayBanner (FILE *fd, 00226 const char** lines, size_t size, int starlength); 00227 00228 00229 /*************************************************************************** 00230 * Function : UpnpDisplayFileAndLine 00231 * 00232 * Parameters: 00233 * IN FILE *fd: File descriptor where line number and file name will be 00234 * written 00235 * IN char *DbgFileName: Name of the file 00236 * IN int DbgLineNo : Line number of the file 00237 * 00238 * Description: 00239 * This function writes the file name and file number from where 00240 * debug statement is coming to the log file 00241 * Returns: void 00242 ***************************************************************************/ 00243 void UpnpDisplayFileAndLine (FILE *fd, const char *DbgFileName, int DbgLineNo); 00244 00245 00247 00248 00249 #ifdef __cplusplus 00250 } 00251 #endif 00252 00253 #endif // UPNP_HAVE_DEBUG 00254 00255 #endif // UPNP_DEBUG_H
1.6.1