Sync usage with man page.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / global / cleanup_strerror.c
blobb1fb6b4e723e0aaf176682b26f9d2f4659d37487
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* cleanup_strerror 3
6 /* SUMMARY
7 /* cleanup status code to string
8 /* SYNOPSIS
9 /* #include <cleanup_user.h>
11 /* typedef struct {
12 /* .in +4
13 /* const unsigned status; /* cleanup status */
14 /* const int smtp; /* RFC 821 */
15 /* const char *dsn; /* RFC 3463 */
16 /* const char *text; /* free text */
17 /* .in -4
18 /* } CLEANUP_STAT_DETAIL;
20 /* const char *cleanup_strerror(code)
21 /* int code;
23 /* const CLEANUP_STAT_DETAIL *cleanup_stat_detail(code)
24 /* int code;
25 /* DESCRIPTION
26 /* cleanup_strerror() maps a status code returned by the \fIcleanup\fR
27 /* service to printable string.
28 /* The result is for read purposes only.
30 /* cleanup_stat_detail() returns a pointer to structure with
31 /* assorted information.
32 /* DIAGNOSTICS:
33 /* Panic: unknown status.
34 /* LICENSE
35 /* .ad
36 /* .fi
37 /* The Secure Mailer license must be distributed with this software.
38 /* AUTHOR(S)
39 /* Wietse Venema
40 /* IBM T.J. Watson Research
41 /* P.O. Box 704
42 /* Yorktown Heights, NY 10598, USA
43 /*--*/
45 /* System library. */
47 #include <sys_defs.h>
49 /* Utility library. */
51 #include <vstring.h>
52 #include <msg.h>
54 /* Global library. */
56 #include <cleanup_user.h>
59 * Mapping from status code to printable string. One message may suffer from
60 * multiple errors, to it is important to list the most severe errors first,
61 * because cleanup_strerror() can report only one error.
63 static const CLEANUP_STAT_DETAIL cleanup_stat_map[] = {
64 CLEANUP_STAT_DEFER, 451, "4.7.1", "service unavailable",
65 CLEANUP_STAT_PROXY, 451, "4.3.0", "queue file write error",
66 CLEANUP_STAT_BAD, 451, "4.3.0", "internal protocol error",
67 CLEANUP_STAT_RCPT, 550, "5.1.0", "no recipients specified",
68 CLEANUP_STAT_HOPS, 554, "5.4.0", "too many hops",
69 CLEANUP_STAT_SIZE, 552, "5.3.4", "message file too big",
70 CLEANUP_STAT_CONT, 550, "5.7.1", "message content rejected",
71 CLEANUP_STAT_WRITE, 451, "4.3.0", "queue file write error",
74 static CLEANUP_STAT_DETAIL cleanup_stat_success = {
75 CLEANUP_STAT_OK, 250, "2.0.0", "Success",
78 /* cleanup_strerror - map status code to printable string */
80 const char *cleanup_strerror(unsigned status)
82 unsigned i;
84 if (status == CLEANUP_STAT_OK)
85 return ("Success");
87 for (i = 0; i < sizeof(cleanup_stat_map) / sizeof(cleanup_stat_map[0]); i++)
88 if (cleanup_stat_map[i].status & status)
89 return (cleanup_stat_map[i].text);
91 msg_panic("cleanup_strerror: unknown status %u", status);
94 /* cleanup_stat_detail - map status code to table entry with assorted data */
96 const CLEANUP_STAT_DETAIL *cleanup_stat_detail(unsigned status)
98 unsigned i;
100 if (status == CLEANUP_STAT_OK)
101 return (&cleanup_stat_success);
103 for (i = 0; i < sizeof(cleanup_stat_map) / sizeof(cleanup_stat_map[0]); i++)
104 if (cleanup_stat_map[i].status & status)
105 return (cleanup_stat_map + i);
107 msg_panic("cleanup_stat_detail: unknown status %u", status);