source: trunk/third/sendmail/src/sysexits.c @ 12554

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