2 * Copyright (c) 2000, 2001, 2003 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.16 2003/01/10 00:26:06 ca Exp $
12 #pragma ident "%Z%%M% %I% %E% SMI"
15 ** libsm debugging and tracing
16 ** See libsm/debug.html for documentation.
26 ** abstractions for printing trace messages
30 sm_debug_file
__P((void));
33 sm_debug_setfile
__P(( SM_FILE_T
*));
35 extern void PRINTFLIKE(1, 2)
36 sm_dprintf
__P((char *_fmt
, ...));
39 sm_dflush
__P((void));
42 sm_debug_close
__P((void));
45 ** abstractions for setting and testing debug activation levels
49 sm_debug_addsettings_x
__P((const char *));
52 sm_debug_addsetting_x
__P((const char *, int));
54 # define SM_DEBUG_UNKNOWN ((SM_ATOMIC_UINT_T)(-1))
56 extern const char SmDebugMagic
[];
58 typedef struct sm_debug SM_DEBUG_T
;
61 const char *sm_magic
; /* points to SmDebugMagic */
64 ** debug_level is the activation level of this debug
65 ** object. Level 0 means no debug activity.
66 ** It is initialized to SM_DEBUG_UNKNOWN, which indicates
67 ** that the true value is unknown. If debug_level ==
68 ** SM_DEBUG_UNKNOWN, then the access functions will look up
69 ** its true value in the internal table of debug settings.
72 SM_ATOMIC_UINT_T debug_level
;
75 ** debug_name is the name used to reference this SM_DEBUG
76 ** structure via the sendmail -d option.
82 ** debug_desc is a literal character string of the form
83 ** "@(#)$Debug: <name> - <short description> $"
89 ** We keep a linked list of initialized SM_DEBUG structures
90 ** so that when sm_debug_addsetting is called, we can reset
91 ** them all back to the uninitialized state.
94 SM_DEBUG_T
*debug_next
;
97 # ifndef SM_DEBUG_CHECK
98 # define SM_DEBUG_CHECK 1
99 # endif /* ! SM_DEBUG_CHECK */
103 ** This macro is cleverly designed so that if the debug object is below
104 ** the specified level, then the only overhead is a single comparison
105 ** (except for the first time this macro is invoked).
108 # define sm_debug_active(debug, level) \
109 ((debug)->debug_level >= (level) && \
110 ((debug)->debug_level != SM_DEBUG_UNKNOWN || \
111 sm_debug_loadactive(debug, level)))
113 # define sm_debug_level(debug) \
114 ((debug)->debug_level == SM_DEBUG_UNKNOWN \
115 ? sm_debug_loadlevel(debug) : (debug)->debug_level)
117 # define sm_debug_unknown(debug) ((debug)->debug_level == SM_DEBUG_UNKNOWN)
118 # else /* SM_DEBUG_CHECK */
119 # define sm_debug_active(debug, level) 0
120 # define sm_debug_level(debug) 0
121 # define sm_debug_unknown(debug) 0
122 # endif /* SM_DEBUG_CHECK */
125 sm_debug_loadactive
__P((SM_DEBUG_T
*, int));
128 sm_debug_loadlevel
__P((SM_DEBUG_T
*));
130 # define SM_DEBUG_INITIALIZER(name, desc) { \
137 #endif /* ! SM_DEBUG_H */