Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / xsasl / xsasl_cyrus_log.c
blobaad2116ae1c19de5f75c5445ced9310e7fa06492
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* xsasl_cyrus_log 3
6 /* SUMMARY
7 /* Cyrus SASL logging call-back routine
8 /* SYNOPSIS
9 /* #include <xsasl_cyrus_common.h>
11 /* int xsasl_cyrus_log(context, priority, text)
12 /* void *context;
13 /* int priority;
14 /* const char *text;
15 /* DESCRIPTION
16 /* xsasl_cyrus_log() logs a Cyrus message.
17 /* DIAGNOSTICS:
18 /* Fatal: out of memory.
19 /* LICENSE
20 /* .ad
21 /* .fi
22 /* The Secure Mailer license must be distributed with this software.
23 /* AUTHOR(S)
24 /* Wietse Venema
25 /* IBM T.J. Watson Research
26 /* P.O. Box 704
27 /* Yorktown Heights, NY 10598, USA
28 /*--*/
30 /* System library. */
32 #include <sys_defs.h>
34 /* Utility library. */
36 #include <msg.h>
38 /* Application-specific */
40 #include <xsasl_cyrus_common.h>
42 #if defined(USE_SASL_AUTH) && defined(USE_CYRUS_SASL)
44 #include <sasl.h>
45 #include <saslutil.h>
47 /* xsasl_cyrus_log - logging callback */
49 int xsasl_cyrus_log(void *unused_context, int priority,
50 const char *message)
52 switch (priority) {
53 case SASL_LOG_ERR: /* unusual errors */
54 #ifdef SASL_LOG_WARN /* non-fatal warnings (Cyrus-SASL v2) */
55 case SASL_LOG_WARN:
56 #endif
57 #ifdef SASL_LOG_WARNING /* non-fatal warnings (Cyrus-SASL v1) */
58 case SASL_LOG_WARNING:
59 #endif
60 msg_warn("SASL authentication problem: %s", message);
61 break;
62 #ifdef SASL_LOG_INFO
63 case SASL_LOG_INFO: /* other info (Cyrus-SASL v1) */
64 if (msg_verbose)
65 msg_info("SASL authentication info: %s", message);
66 break;
67 #endif
68 #ifdef SASL_LOG_NOTE
69 case SASL_LOG_NOTE: /* other info (Cyrus-SASL v2) */
70 if (msg_verbose)
71 msg_info("SASL authentication info: %s", message);
72 break;
73 #endif
74 #ifdef SASL_LOG_FAIL
75 case SASL_LOG_FAIL: /* authentication failures
76 * (Cyrus-SASL v2) */
77 msg_warn("SASL authentication failure: %s", message);
78 break;
79 #endif
80 #ifdef SASL_LOG_DEBUG
81 case SASL_LOG_DEBUG: /* more verbose than LOG_NOTE
82 * (Cyrus-SASL v2) */
83 if (msg_verbose > 1)
84 msg_info("SASL authentication debug: %s", message);
85 break;
86 #endif
87 #ifdef SASL_LOG_TRACE
88 case SASL_LOG_TRACE: /* traces of internal
89 * protocols (Cyrus-SASL v2) */
90 if (msg_verbose > 1)
91 msg_info("SASL authentication trace: %s", message);
92 break;
93 #endif
94 #ifdef SASL_LOG_PASS
95 case SASL_LOG_PASS: /* traces of internal
96 * protocols, including
97 * passwords (Cyrus-SASL v2) */
98 if (msg_verbose > 1)
99 msg_info("SASL authentication pass: %s", message);
100 break;
101 #endif
103 return (SASL_OK);
106 #endif