Open SCAP Library
|
00001 00005 /* 00006 * Copyright 2011 Red Hat Inc., Durham, North Carolina. 00007 * All Rights Reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 * 00023 * Authors: 00024 * Daniel Kopecek <dkopecek@redhat.com> 00025 * Peter Vrabec <pvrabec@redhat.com> 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 #define OSCAP_DEBUGOBJ_SEXP 1 00036 00037 #if defined(NDEBUG) 00038 # define oscap_dlprintf(...) while(0) 00039 # define debug(l) if (0) 00040 # define dO(type, obj) while(0) 00041 #else 00042 # include <stdlib.h> 00043 # include <stddef.h> 00044 # include <stdarg.h> 00045 00046 enum { 00047 DBG_E = 1, 00048 DBG_W, 00049 DBG_I 00050 }; 00051 00052 # define __dlprintf_wrapper(l, ...) __oscap_dlprintf (l, __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) 00053 00054 extern int __debuglog_level; 00055 00069 # 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)) 00070 00081 void __oscap_dlprintf(int level, const char *file, const char *fn, size_t line, const char *fmt, ...); 00082 00088 # define oscap_dlprintf(l, ...) __dlprintf_wrapper (l, __VA_ARGS__) 00089 00090 void __oscap_debuglog_object (const char *file, const char *fn, size_t line, int objtype, void *obj); 00091 00092 # define dO(type, obj) __oscap_debuglog_object(__FILE__, __PRETTY_FUNCTION__, __LINE__, type, obj) 00093 00094 #endif /* NDEBUG */ 00095 00096 #define dI(...) oscap_dlprintf(DBG_I, __VA_ARGS__) 00097 #define dW(...) oscap_dlprintf(DBG_W, __VA_ARGS__) 00098 #define dE(...) oscap_dlprintf(DBG_E, __VA_ARGS__) 00099 00100 #endif