7 /* sendmail-compatible exit status handling
9 /* #include <sys_exits.h>
13 /* int status; /* exit status */
14 /* const char *dsn; /* RFC 3463 */
15 /* const char *text; /* free text */
17 /* } SYS_EXITS_DETAIL;
19 /* int SYS_EXITS_CODE(code)
22 /* const char *sys_exits_strerror(code)
25 /* const SYS_EXITS_DETAIL *sys_exits_detail(code)
28 /* int sys_exits_softerror(code)
31 /* This module interprets sendmail-compatible process exit status
34 /* SYS_EXITS_CODE() returns non-zero when the specified code
35 /* is a sendmail-compatible process exit status code.
37 /* sys_exits_strerror() returns a descriptive text for the
38 /* specified sendmail-compatible status code, or a generic
39 /* text for an unknown status code.
41 /* sys_exits_detail() returns a table entry with assorted
42 /* information about the specified sendmail-compatible status
43 /* code, or a generic entry for an unknown status code.
45 /* sys_exits_softerror() returns non-zero when the specified
46 /* sendmail-compatible status code corresponds to a recoverable error.
47 /* An unknown status code is always unrecoverable.
49 /* Fatal: out of memory.
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. */
72 #include <sys_exits.h>
74 /* Application-specific. */
76 static const SYS_EXITS_DETAIL sys_exits_table
[] = {
77 EX_USAGE
, "5.3.0", "command line usage error",
78 EX_DATAERR
, "5.6.0", "data format error",
79 EX_NOINPUT
, "5.3.0", "cannot open input",
80 EX_NOUSER
, "5.1.1", "user unknown",
81 EX_NOHOST
, "5.1.2", "host name unknown",
82 EX_UNAVAILABLE
, "5.3.0", "service unavailable",
83 EX_SOFTWARE
, "5.3.0", "internal software error",
84 EX_OSERR
, "4.3.0", "system resource problem",
85 EX_OSFILE
, "5.3.0", "critical OS file missing",
86 EX_CANTCREAT
, "5.2.0", "can't create user output file",
87 EX_IOERR
, "5.3.0", "input/output error",
88 EX_TEMPFAIL
, "4.3.0", "temporary failure",
89 EX_PROTOCOL
, "5.5.0", "remote error in protocol",
90 EX_NOPERM
, "5.7.0", "permission denied",
91 EX_CONFIG
, "5.3.5", "local configuration error",
94 static VSTRING
*sys_exits_def_text
= 0;
96 static SYS_EXITS_DETAIL sys_exits_default
[] = {
100 /* sys_exits_fake - fake an entry for an unknown code */
102 static SYS_EXITS_DETAIL
*sys_exits_fake(int code
)
104 if (sys_exits_def_text
== 0)
105 sys_exits_def_text
= vstring_alloc(30);
107 vstring_sprintf(sys_exits_def_text
, "unknown mail system error %d", code
);
108 sys_exits_default
->text
= vstring_str(sys_exits_def_text
);
109 return(sys_exits_default
);
112 /* sys_exits_strerror - map exit status to error string */
114 const char *sys_exits_strerror(int code
)
116 if (!SYS_EXITS_CODE(code
)) {
117 return (sys_exits_fake(code
)->text
);
119 return (sys_exits_table
[code
- EX__BASE
].text
);
123 /* sys_exits_detail - map exit status info table entry */
125 const SYS_EXITS_DETAIL
*sys_exits_detail(int code
)
127 if (!SYS_EXITS_CODE(code
)) {
128 return (sys_exits_fake(code
));
130 return (sys_exits_table
+ code
- EX__BASE
);
134 /* sys_exits_softerror - determine if error is transient */
136 int sys_exits_softerror(int code
)
138 if (!SYS_EXITS_CODE(code
)) {
139 return (sys_exits_default
->dsn
[0] == '4');
141 return (sys_exits_table
[code
- EX__BASE
].dsn
[0] == '4');