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 #include "public/debug.h"
00034
00035 #if defined(NDEBUG)
00036 # define oscap_dprintf(...) while(0)
00037 # define oscap_dlprintf(...) while(0)
00038 # define debug(l) if (0)
00039 #else
00040 # include <stdlib.h>
00041 # include <stddef.h>
00042 # include <stdarg.h>
00043
00044 enum {
00045 DBG_E = 1,
00046 DBG_W,
00047 DBG_I
00048 };
00049
00050 # define __dlprintf_wrapper(l, ...) __oscap_dlprintf (l, __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
00051
00061 void __oscap_dprintf(const char *file, const char *fn, size_t line, const char *fmt, ...);
00062
00068 # define oscap_dprintf(...) __dlprintf_wrapper (0, __VA_ARGS__)
00069
00070 extern int __debuglog_level;
00084 # 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))
00085
00096 void __oscap_dlprintf(int level, const char *file, const char *fn, size_t line, const char *fmt, ...);
00097
00103 # define oscap_dlprintf(l, ...) __dlprintf_wrapper (l, __VA_ARGS__)
00104 #endif
00105
00106 #define dI(...) oscap_dlprintf(DBG_I, __VA_ARGS__)
00107 #define dW(...) oscap_dlprintf(DBG_W, __VA_ARGS__)
00108 #define dE(...) oscap_dlprintf(DBG_E, __VA_ARGS__)
00109
00110 #endif