7 /* cleanup status code to string
9 /* #include <cleanup_user.h>
13 /* const unsigned status; /* cleanup status */
14 /* const int smtp; /* RFC 821 */
15 /* const char *dsn; /* RFC 3463 */
16 /* const char *text; /* free text */
18 /* } CLEANUP_STAT_DETAIL;
20 /* const char *cleanup_strerror(code)
23 /* const CLEANUP_STAT_DETAIL *cleanup_stat_detail(code)
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.
33 /* Panic: unknown status.
37 /* The Secure Mailer license must be distributed with this software.
40 /* IBM T.J. Watson Research
42 /* Yorktown Heights, NY 10598, USA
49 /* Utility 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
)
84 if (status
== CLEANUP_STAT_OK
)
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
)
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
);