00001
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #pragma once
00035 #ifndef OSCAP_DEBUG_H
00036 #define OSCAP_DEBUG_H
00037
00038 #ifndef oscap_dprintf
00039 #if defined(NDEBUG)
00040 # define oscap_dprintf(...) while(0)
00041 #else
00042 # include <stddef.h>
00043 # include <stdarg.h>
00044 void __oscap_dprintf(const char *, const char *, size_t, const char *, ...);
00045 # define oscap_dprintf(...) __oscap_dprintf (__FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
00046 #endif
00047 #endif
00048
00049 #ifndef OSCAP_DEBUG_FILE
00050 # define OSCAP_DEBUG_FILE "oscap_debug.log"
00051 #endif
00052
00053 #ifndef OSCAP_DEBUG_FILE_ENV
00054 # define OSCAP_DEBUG_FILE_ENV "OSCAP_DEBUG_FILE"
00055 #endif
00056
00057 #ifndef OSCAP_DEBUG_LEVEL_ENV
00058 # define OSCAP_DEBUG_LEVEL_ENV "OSCAP_DEBUG_LEVEL"
00059 #endif
00060
00061 #ifndef NDEBUG
00062 #include <stdlib.h>
00063 extern int __debuglog_level;
00064 # 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))
00065 #else
00066 # define debug(l) if (0)
00067 #endif
00068
00069 #define oscap_dlprintf(l, ...) do { debug(l) { oscap_dprintf(__VA_ARGS__); }} while(0)
00070
00071 #endif