Import sendmail 8.13.4 into a new contrib directory as the first step
[dragonfly.git] / contrib / sendmail-8.13.4 / include / sm / debug.h
blobe3142b2fa4234b9494a7791e7dd2413dfaebea54
1 /*
2 * Copyright (c) 2000, 2001, 2003 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
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 $
13 ** libsm debugging and tracing
14 ** See libsm/debug.html for documentation.
17 #ifndef SM_DEBUG_H
18 # define SM_DEBUG_H
20 # include <sm/gen.h>
21 # include <sm/io.h>
24 ** abstractions for printing trace messages
27 extern SM_FILE_T *
28 sm_debug_file __P((void));
30 extern void
31 sm_debug_setfile __P(( SM_FILE_T *));
33 extern void PRINTFLIKE(1, 2)
34 sm_dprintf __P((char *_fmt, ...));
36 extern void
37 sm_dflush __P((void));
39 extern void
40 sm_debug_close __P((void));
43 ** abstractions for setting and testing debug activation levels
46 extern void
47 sm_debug_addsettings_x __P((const char *));
49 extern void
50 sm_debug_addsetting_x __P((const char *, int));
52 # define SM_DEBUG_UNKNOWN ((SM_ATOMIC_UINT_T)(-1))
54 extern const char SmDebugMagic[];
56 typedef struct sm_debug SM_DEBUG_T;
57 struct sm_debug
59 const char *sm_magic; /* points to SmDebugMagic */
62 ** debug_level is the activation level of this debug
63 ** object. Level 0 means no debug activity.
64 ** It is initialized to SM_DEBUG_UNKNOWN, which indicates
65 ** that the true value is unknown. If debug_level ==
66 ** SM_DEBUG_UNKNOWN, then the access functions will look up
67 ** its true value in the internal table of debug settings.
70 SM_ATOMIC_UINT_T debug_level;
73 ** debug_name is the name used to reference this SM_DEBUG
74 ** structure via the sendmail -d option.
77 char *debug_name;
80 ** debug_desc is a literal character string of the form
81 ** "@(#)$Debug: <name> - <short description> $"
84 char *debug_desc;
87 ** We keep a linked list of initialized SM_DEBUG structures
88 ** so that when sm_debug_addsetting is called, we can reset
89 ** them all back to the uninitialized state.
92 SM_DEBUG_T *debug_next;
95 # ifndef SM_DEBUG_CHECK
96 # define SM_DEBUG_CHECK 1
97 # endif /* ! SM_DEBUG_CHECK */
99 # if SM_DEBUG_CHECK
101 ** This macro is cleverly designed so that if the debug object is below
102 ** the specified level, then the only overhead is a single comparison
103 ** (except for the first time this macro is invoked).
106 # define sm_debug_active(debug, level) \
107 ((debug)->debug_level >= (level) && \
108 ((debug)->debug_level != SM_DEBUG_UNKNOWN || \
109 sm_debug_loadactive(debug, level)))
111 # define sm_debug_level(debug) \
112 ((debug)->debug_level == SM_DEBUG_UNKNOWN \
113 ? sm_debug_loadlevel(debug) : (debug)->debug_level)
115 # define sm_debug_unknown(debug) ((debug)->debug_level == SM_DEBUG_UNKNOWN)
116 # else /* SM_DEBUG_CHECK */
117 # define sm_debug_active(debug, level) 0
118 # define sm_debug_level(debug) 0
119 # define sm_debug_unknown(debug) 0
120 # endif /* SM_DEBUG_CHECK */
122 extern bool
123 sm_debug_loadactive __P((SM_DEBUG_T *, int));
125 extern int
126 sm_debug_loadlevel __P((SM_DEBUG_T *));
128 # define SM_DEBUG_INITIALIZER(name, desc) { \
129 SmDebugMagic, \
130 SM_DEBUG_UNKNOWN, \
131 name, \
132 desc, \
133 NULL}
135 #endif /* ! SM_DEBUG_H */