7 /* increase verbose logging for specific peers
9 /* #include <debug_peer.h>
11 /* void debug_peer_init(void)
13 /* int peer_debug_check(peer_name, peer_addr)
14 /* const char *peer_name;
15 /* const char *peer_addr;
17 /* void debug_peer_restore()
19 /* This module implements increased verbose logging for specific
22 /* The \fIdebug_peer_list\fR configuration parameter
23 /* specifies what peers receive this special treatment; see
24 /* namadr_list(3) for a description of the matching process.
26 /* The \fIdebug_peer_level\fR configuration parameter specifies
27 /* by what amount the verbose logging level should increase when
28 /* a peer is listed in \fIdebug_peer_list\fR.
30 /* debug_peer_init() performs initializations that must be
31 /* performed once at the start of the program.
33 /* debug_peer_check() increases the verbose logging level when the
34 /* client name or address matches the debug_peer_list pattern.
35 /* The result is non-zero when the noise leven was increased.
37 /* debug_peer_restore() restores the verbose logging level.
38 /* This routine has no effect when debug_peer_check() had no
39 /* effect; this routine can safely be called multiple times.
41 /* Panic: interface violations.
42 /* Fatal errors: unable to access a peer_list file; invalid
43 /* peer_list pattern; invalid verbosity level increment.
45 /* msg(3) the msg_verbose variable
46 /* namadr_list(3) match host by name or by address
48 /* debug_peer_list, patterns as described in namadr_list(3)
49 /* debug_peer_level, verbose logging level
53 /* The Secure Mailer license must be distributed with this software.
56 /* IBM T.J. Watson Research
58 /* Yorktown Heights, NY 10598, USA
65 /* Utility library. */
71 #include <mail_params.h>
72 #include <namadr_list.h>
73 #include <debug_peer.h>
74 #include <match_parent_style.h>
76 /* Application-specific. */
78 #define UNUSED_SAVED_LEVEL (-1)
80 static NAMADR_LIST
*debug_peer_list
;
81 static int saved_level
= UNUSED_SAVED_LEVEL
;
83 /* debug_peer_init - initialize */
85 void debug_peer_init(void)
87 const char *myname
= "debug_peer_init";
93 msg_panic("%s: repeated call", myname
);
94 if (var_debug_peer_list
== 0)
95 msg_panic("%s: uninitialized %s", myname
, VAR_DEBUG_PEER_LIST
);
96 if (var_debug_peer_level
<= 0)
97 msg_fatal("%s: %s <= 0", myname
, VAR_DEBUG_PEER_LEVEL
);
102 if (*var_debug_peer_list
)
104 namadr_list_init(match_parent_style(VAR_DEBUG_PEER_LIST
),
105 var_debug_peer_list
);
108 /* debug_peer_check - see if this peer needs verbose logging */
110 int debug_peer_check(const char *name
, const char *addr
)
114 * Crank up the noise when this peer is listed.
116 if (debug_peer_list
!= 0
117 && saved_level
== UNUSED_SAVED_LEVEL
118 && namadr_list_match(debug_peer_list
, name
, addr
) != 0) {
119 saved_level
= msg_verbose
;
120 msg_verbose
+= var_debug_peer_level
;
126 /* debug_peer_restore - restore logging level */
128 void debug_peer_restore(void)
130 if (saved_level
!= UNUSED_SAVED_LEVEL
) {
131 msg_verbose
= saved_level
;
132 saved_level
= UNUSED_SAVED_LEVEL
;