* Copyright (c) 1983 Eric P. Allman
* Copyright (c) 1988 Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)err.c 5.11 (Berkeley) 3/2/91";
** SYSERR -- Print error message.
** Prints an error message via printf to the diagnostic
** output. If LOG is defined, it logs it also.
** f -- the format string
** a, b, c, d, e -- parameters
** Through TopFrame if QuickAbort is set.
char MsgBuf
[BUFSIZ
*2]; /* text of most recent message */
syserr(fmt
, a
, b
, c
, d
, e
)
extern char Arpa_PSyserr
[];
extern char Arpa_TSyserr
[];
/* format and output the error message */
fmtmsg(MsgBuf
, (char *) NULL
, p
, olderrno
, fmt
, a
, b
, c
, d
, e
);
/* determine exit status if not already set */
syslog(LOG_CRIT
, "%s: SYSERR: %s",
CurEnv
->e_id
== NULL
? "NOQUEUE" : CurEnv
->e_id
,
** USRERR -- Signal user error.
** This is much like syserr except it is for user errors.
** fmt, a, b, c, d -- printf strings
** Through TopFrame if QuickAbort is set.
usrerr(fmt
, a
, b
, c
, d
, e
)
extern char Arpa_Usrerr
[];
fmtmsg(MsgBuf
, CurEnv
->e_to
, Arpa_Usrerr
, errno
, fmt
, a
, b
, c
, d
, e
);
** MESSAGE -- print message (not necessarily an error)
** num -- the default ARPANET error number (in ascii)
** msg -- the message (printf fmt) -- if it begins
** with a digit, this number overrides num.
** a, b, c, d, e -- printf arguments
message(num
, msg
, a
, b
, c
, d
, e
)
fmtmsg(MsgBuf
, CurEnv
->e_to
, num
, 0, msg
, a
, b
, c
, d
, e
);
** NMESSAGE -- print message (not necessarily an error)
** Just like "message" except it never puts the to... tag on.
** num -- the default ARPANET error number (in ascii)
** msg -- the message (printf fmt) -- if it begins
** with three digits, this number overrides num.
** a, b, c, d, e -- printf arguments
nmessage(num
, msg
, a
, b
, c
, d
, e
)
fmtmsg(MsgBuf
, (char *) NULL
, num
, 0, msg
, a
, b
, c
, d
, e
);
** PUTMSG -- output error message to transcript and channel
** msg -- message to output (in SMTP format).
** holdmsg -- if TRUE, don't output a copy of the message to
** Outputs msg to the transcript.
** If appropriate, outputs it to the channel.
** Deletes SMTP reply code number as appropriate.
/* output to transcript if serious */
if (CurEnv
->e_xfp
!= NULL
&& (msg
[0] == '4' || msg
[0] == '5'))
fprintf(CurEnv
->e_xfp
, "%s\n", msg
);
/* output to channel if appropriate */
if (!holdmsg
&& (Verbose
|| msg
[0] != '0'))
if (OpMode
== MD_SMTP
|| OpMode
== MD_ARPAFTP
)
fprintf(OutChannel
, "%s\r\n", msg
);
fprintf(OutChannel
, "%s\n", &msg
[4]);
(void) fflush(OutChannel
);
** PUTERRMSG -- like putmsg, but does special processing for error messages
** msg -- the message to output.
** Sets the fatal error bit in the envelope as appropriate.
/* output the message as usual */
CurEnv
->e_flags
|= EF_FATALERRS
;
** FMTMSG -- format a message into buffer.
** eb -- error buffer to get result.
** to -- the recipient tag for this message.
** num -- arpanet error number.
** en -- the error number to display.
** fmt -- format of string.
** a, b, c, d, e -- arguments.
fmtmsg(eb
, to
, num
, eno
, fmt
, a
, b
, c
, d
, e
)
/* output the reply code */
if (isdigit(fmt
[0]) && isdigit(fmt
[1]) && isdigit(fmt
[2]))
(void) sprintf(eb
, "%3.3s%c", num
, del
);
/* output the file name and line number */
(void) sprintf(eb
, "%s: line %d: ", FileName
, LineNumber
);
/* output the "to" person */
if (to
!= NULL
&& to
[0] != '\0')
(void) sprintf(eb
, "%s... ", to
);
(void) sprintf(eb
, fmt
, a
, b
, c
, d
, e
);
/* output the error code, if any */
extern char *errstring();
(void) sprintf(eb
, ": %s", errstring(eno
));
** ERRSTRING -- return string description of error code
** errno -- the error number to translate
** A string description of errno.
extern char *sys_errlist
[];
** Handle special network error codes.
** These are 4.2/4.3bsd specific; they should be in daemon.c.
(void) strcpy(buf
, sys_errlist
[errno
]);
(void) strcat(buf
, " during ");
(void) strcat(buf
, SmtpPhase
);
(void) strcat(buf
, " with ");
(void) strcat(buf
, CurHostName
);
(void) sprintf(buf
, "Host %s is down", CurHostName
);
(void) sprintf(buf
, "Connection refused by %s", CurHostName
);
case (TRY_AGAIN
+MAX_ERRNO
):
(void) sprintf(buf
, "Host Name Lookup Failure");
if (errno
> 0 && errno
< sys_nerr
)
return (sys_errlist
[errno
]);
(void) sprintf(buf
, "Error %d", errno
);