Commit | Line | Data |
---|---|---|
b2a81223 | 1 | /* |
792e6158 | 2 | * Copyright (c) 1983, 1995 Eric P. Allman |
24634489 KB |
3 | * Copyright (c) 1988, 1993 |
4 | * The Regents of the University of California. All rights reserved. | |
bee79b64 | 5 | * |
417f7a11 | 6 | * %sccs.include.redist.c% |
bee79b64 | 7 | */ |
b2a81223 DF |
8 | |
9 | #ifndef lint | |
5c5d2382 | 10 | static char sccsid[] = "@(#)sysexits.c 8.3 (Berkeley) %G%"; |
bee79b64 | 11 | #endif /* not lint */ |
b2a81223 | 12 | |
f56c6cd5 | 13 | #include <sysexits.h> |
b3cbe40f | 14 | |
f895a45d | 15 | /* |
e9e433bc EA |
16 | ** SYSEXITS.C -- error messages corresponding to sysexits.h |
17 | ** | |
18 | ** If the first character of the string is a colon, interpolate | |
19 | ** the current errno after the rest of the string. | |
20 | */ | |
21 | ||
22 | char *SysExMsg[] = | |
23 | { | |
24 | /* 64 USAGE */ " 500 Bad usage", | |
25 | /* 65 DATAERR */ " 501 Data format error", | |
26 | /* 66 NOINPUT */ ":550 Cannot open input", | |
27 | /* 67 NOUSER */ " 550 User unknown", | |
28 | /* 68 NOHOST */ " 550 Host unknown", | |
29 | /* 69 UNAVAILABLE */ " 554 Service unavailable", | |
30 | /* 70 SOFTWARE */ ":554 Internal error", | |
31 | /* 71 OSERR */ ":451 Operating system error", | |
32 | /* 72 OSFILE */ ":554 System file missing", | |
33 | /* 73 CANTCREAT */ ":550 Can't create output", | |
34 | /* 74 IOERR */ ":451 I/O error", | |
35 | /* 75 TEMPFAIL */ " 250 Deferred", | |
36 | /* 76 PROTOCOL */ " 554 Remote protocol error", | |
37 | /* 77 NOPERM */ ":550 Insufficient permission", | |
38 | /* 78 CONFIG */ " 554 Local configuration error", | |
b3cbe40f EA |
39 | }; |
40 | ||
f56c6cd5 | 41 | int N_SysEx = sizeof(SysExMsg) / sizeof(SysExMsg[0]); |
5c5d2382 EA |
42 | \f/* |
43 | ** DSNTOEXITSTAT -- convert DSN-style error code to EX_ style. | |
44 | ** | |
45 | ** Parameters: | |
46 | ** dsncode -- the text of the DSN-style code. | |
47 | ** | |
48 | ** Returns: | |
49 | ** The corresponding exit status. | |
50 | */ | |
51 | ||
52 | int | |
53 | dsntoexitstat(dsncode) | |
54 | char *dsncode; | |
55 | { | |
56 | int code2, code3; | |
57 | ||
58 | /* first the easy cases.... */ | |
59 | if (*dsncode == '2') | |
60 | return EX_OK; | |
61 | if (*dsncode == '4') | |
62 | return EX_TEMPFAIL; | |
63 | ||
64 | /* now decode the other two field parts */ | |
65 | if (*++dsncode == '.') | |
66 | dsncode++; | |
67 | code2 = atoi(dsncode); | |
68 | while (*dsncode != '\0' && *dsncode != '.') | |
69 | dsncode++; | |
70 | if (*dsncode != '\0') | |
71 | dsncode++; | |
72 | code3 = atoi(dsncode); | |
73 | ||
74 | /* and do a nested switch to work them out */ | |
75 | switch (code2) | |
76 | { | |
77 | case 0: /* Other or Undefined status */ | |
78 | return EX_UNAVAILABLE; | |
79 | ||
80 | case 1: /* Address Status */ | |
81 | switch (code3) | |
82 | { | |
83 | case 0: /* Other Address Status */ | |
84 | return EX_DATAERR; | |
85 | ||
86 | case 1: /* Bad mailbox address */ | |
87 | case 6: /* Mailbox has moved, No forwarding address */ | |
88 | return EX_NOUSER; | |
89 | ||
90 | case 2: /* Bad system address */ | |
91 | return EX_NOHOST; | |
92 | ||
93 | case 3: /* Bad mailbox address syntax */ | |
94 | return EX_USAGE; | |
95 | ||
96 | case 4: /* Mailbox address ambiguous */ | |
97 | return EX_UNAVAILABLE; | |
98 | ||
99 | case 5: /* Address valid */ | |
100 | return EX_OK; | |
101 | } | |
102 | break; | |
103 | ||
104 | case 2: /* Mailbox Status */ | |
105 | switch (code3) | |
106 | { | |
107 | case 0: /* Other or Undefined mailbox status */ | |
108 | case 1: /* Mailbox disabled, not acccepting messages */ | |
109 | case 2: /* Mailbox full */ | |
110 | case 4: /* Mailing list expansion problem */ | |
111 | return EX_UNAVAILABLE; | |
112 | ||
113 | case 3: /* Message length exceeds administrative lim */ | |
114 | return EX_DATAERR; | |
115 | } | |
116 | break; | |
117 | ||
118 | case 3: /* System Status */ | |
119 | return EX_OSERR; | |
120 | ||
121 | case 4: /* Network and Routing Status */ | |
122 | switch (code3) | |
123 | { | |
124 | case 0: /* Other or undefined network or routing stat */ | |
125 | return EX_IOERR; | |
126 | ||
127 | case 1: /* No answer from host */ | |
128 | case 3: /* Routing server failure */ | |
129 | case 5: /* Network congestion */ | |
130 | return EX_TEMPFAIL; | |
131 | ||
132 | case 2: /* Bad connection */ | |
133 | return EX_IOERR; | |
134 | ||
135 | case 4: /* Unable to route */ | |
136 | return EX_PROTOCOL; | |
137 | ||
138 | case 6: /* Routing loop detected */ | |
139 | return EX_CONFIG; | |
140 | ||
141 | case 7: /* Delivery time expired */ | |
142 | return EX_UNAVAILABLE; | |
143 | } | |
144 | break; | |
145 | ||
146 | case 5: /* Protocol Status */ | |
147 | return EX_PROTOCOL; | |
148 | ||
149 | case 6: /* Message Content or Media Status */ | |
150 | return EX_UNAVAILABLE; | |
151 | ||
152 | case 7: /* Security Status */ | |
153 | return EX_DATAERR; | |
154 | } | |
155 | return EX_CONFIG; | |
156 | } |