2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
9 * $Id: debug.h,v 1.15 2001/03/08 03:23:07 ca Exp $
13 ** libsm debugging and tracing
14 ** See libsm/debug.html for documentation.
24 ** abstractions for printing trace messages
28 sm_debug_file
__P((void));
31 sm_debug_setfile
__P((
34 extern void PRINTFLIKE(1, 2)
40 sm_dflush
__P((void));
43 ** abstractions for setting and testing debug activation levels
47 sm_debug_addsettings_x
__P((
51 sm_debug_addsetting_x
__P((
55 # define SM_DEBUG_UNKNOWN ((SM_ATOMIC_UINT_T)(-1))
57 extern const char SmDebugMagic
[];
59 typedef struct sm_debug SM_DEBUG_T
;
62 const char *sm_magic
; /* points to SmDebugMagic */
65 ** debug_level is the activation level of this debug
66 ** object. Level 0 means no debug activity.
67 ** It is initialized to SM_DEBUG_UNKNOWN, which indicates
68 ** that the true value is unknown. If debug_level ==
69 ** SM_DEBUG_UNKNOWN, then the access functions will look up
70 ** its true value in the internal table of debug settings.
73 SM_ATOMIC_UINT_T debug_level
;
76 ** debug_name is the name used to reference this SM_DEBUG
77 ** structure via the sendmail -d option.
83 ** debug_desc is a literal character string of the form
84 ** "@(#)$Debug: <name> - <short description> $"
90 ** We keep a linked list of initialized SM_DEBUG structures
91 ** so that when sm_debug_addsetting is called, we can reset
92 ** them all back to the uninitialized state.
95 SM_DEBUG_T
*debug_next
;
98 # ifndef SM_DEBUG_CHECK
99 # define SM_DEBUG_CHECK 1
100 # endif /* ! SM_DEBUG_CHECK */
104 ** This macro is cleverly designed so that if the debug object is below
105 ** the specified level, then the only overhead is a single comparison
106 ** (except for the first time this macro is invoked).
109 # define sm_debug_active(debug, level) \
110 ((debug)->debug_level >= (level) && \
111 ((debug)->debug_level != SM_DEBUG_UNKNOWN || \
112 sm_debug_loadactive(debug, level)))
114 # define sm_debug_level(debug) \
115 ((debug)->debug_level == SM_DEBUG_UNKNOWN \
116 ? sm_debug_loadlevel(debug) : (debug)->debug_level)
118 # define sm_debug_unknown(debug) ((debug)->debug_level == SM_DEBUG_UNKNOWN)
119 # else /* SM_DEBUG_CHECK */
120 # define sm_debug_active(debug, level) 0
121 # define sm_debug_level(debug) 0
122 # define sm_debug_unknown(debug) 0
123 # endif /* SM_DEBUG_CHECK */
126 sm_debug_loadactive
__P((
131 sm_debug_loadlevel
__P((
134 # define SM_DEBUG_INITIALIZER(name, desc) { \
141 #endif /* ! SM_DEBUG_H */