00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #pragma once
00029 #ifndef OSCAP_DEBUG_PRIV_H_
00030 #define OSCAP_DEBUG_PRIV_H_
00031
00032 #include "util.h"
00033
00039 #ifndef OSCAP_DEBUG_FILE
00040 # define OSCAP_DEBUG_FILE "oscap_debug.log"
00041 #endif
00042
00047 #ifndef OSCAP_DEBUG_FILE_ENV
00048 # define OSCAP_DEBUG_FILE_ENV "OSCAP_DEBUG_FILE"
00049 #endif
00050
00057 #ifndef OSCAP_DEBUG_LEVEL_ENV
00058 # define OSCAP_DEBUG_LEVEL_ENV "OSCAP_DEBUG_LEVEL"
00059 #endif
00060
00069 #ifndef OSCAP_DEBUG_PATHSTRIP_ENV
00070 # define OSCAP_DEBUG_PATHSTRIP_ENV "OSCAP_DEBUG_PSTRIP"
00071 #endif
00072
00073
00074 #define OSCAP_DEBUGOBJ_SEXP 1
00075
00076 #include <assert.h>
00077 #ifndef _A
00078 #define _A(x) assert(x)
00079 #endif
00080
00081 #if defined(NDEBUG)
00082 # define oscap_dlprintf(...) while(0)
00083 # define debug(l) if (0)
00084 # define dO(type, obj) while(0)
00085 #else
00086 # include <stdlib.h>
00087 # include <stddef.h>
00088 # include <stdarg.h>
00089
00090 enum {
00091 DBG_E = 1,
00092 DBG_W,
00093 DBG_I
00094 };
00095
00096 # define __dlprintf_wrapper(l, ...) __oscap_dlprintf (l, __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
00097
00098 extern int __debuglog_level;
00099
00113 # define debug(l) if ((__debuglog_level = (__debuglog_level == -1 ? atoi (getenv (OSCAP_DEBUG_LEVEL_ENV) == NULL ? "0" : getenv (OSCAP_DEBUG_LEVEL_ENV)) : __debuglog_level)) && __debuglog_level >= (l))
00114
00125 void __oscap_dlprintf(int level, const char *file, const char *fn, size_t line, const char *fmt, ...);
00126
00132 # define oscap_dlprintf(l, ...) __dlprintf_wrapper (l, __VA_ARGS__)
00133
00134 void __oscap_debuglog_object (const char *file, const char *fn, size_t line, int objtype, void *obj);
00135
00136 # define dO(type, obj) __oscap_debuglog_object(__FILE__, __PRETTY_FUNCTION__, __LINE__, type, obj)
00137
00138 #endif
00139
00140 #define dI(...) oscap_dlprintf(DBG_I, __VA_ARGS__)
00141 #define dW(...) oscap_dlprintf(DBG_W, __VA_ARGS__)
00142 #define dE(...) oscap_dlprintf(DBG_E, __VA_ARGS__)
00143
00144 #endif