1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*++
/* NAME
/* sys_exits 3
/* SUMMARY
/* sendmail-compatible exit status handling
/* SYNOPSIS
/* #include <sys_exits.h>
/*
/* int SYS_EXITS_CODE(code)
/* int code;
/*
/* const char *sys_exits_strerror(code)
/* int code;
/*
/* int sys_exits_softerror(code)
/* int code;
/* DESCRIPTION
/* This module interprets sendmail-compatible process exit status
/* codes. A default result is returned for other exit codes.
/*
/* SYS_EXITS_CODE() returns non-zero when the specified code
/* is a sendmail-compatible process exit status code.
/*
/* sys_exits_strerror() returns a descriptive text for the
/* specified sendmail-compatible status code.
/*
/* sys_exits_softerror() returns non-zero when the specified
/* sendmail-compatible status code corresponds to a recoverable error.
/* DIAGNOSTICS
/* Panic: invalid status code. Fatal error: out of memory.
/* LICENSE
/* .ad
/* .fi
/* The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/* Wietse Venema
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
/*--*/
/* System library. */
#include <sys_defs.h>
/* Utility library. */
#include <msg.h>
/* Global library. */
#include <sys_exits.h>
/* Application-specific. */
typedef struct {
int flags; /* non-zero if recoverable */
int code; /* exit status code */
const char *text; /* descriptive text */
} SYS_EXITS_TABLE;
static SYS_EXITS_TABLE sys_exits_table[] = {
0, EX_USAGE, "command line usage error",
0, EX_DATAERR, "data format error",
0, EX_NOINPUT, "cannot open input",
0, EX_NOUSER, "user unknown",
0, EX_NOHOST, "host name unknown",
0, EX_UNAVAILABLE, "service unavailable",
0, EX_SOFTWARE, "internal software error",
1, EX_OSERR, "system resource problem",
0, EX_OSFILE, "critical OS file missing",
0, EX_CANTCREAT, "can't create user output file",
0, EX_IOERR, "input/output error",
1, EX_TEMPFAIL, "temporary failure",
0, EX_PROTOCOL, "remote error in protocol",
0, EX_NOPERM, "permission denied",
0, EX_CONFIG, "local configuration error",
};
/* sys_exits_strerror - map exit status to error string */
const char *sys_exits_strerror(int code)
{
char *myname = "sys_exits_strerror";
if (!SYS_EXITS_CODE(code))
msg_panic("%s: bad code: %d", myname, code);
return (sys_exits_table[code - EX__BASE].text);
}
/* sys_exits_softerror - determine if error is transient */
int sys_exits_softerror(int code)
{
char *myname = "sys_exits_softerror";
if (!SYS_EXITS_CODE(code))
msg_panic("%s: bad code: %d", myname, code);
return (sys_exits_table[code - EX__BASE].flags);
}
|