* Copyright (c) 1983 Eric P. Allman
* Copyright (c) 1988 Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)err.c 5.17 (Berkeley) %G%";
** 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 VA_ARG_FORMAL
)
extern char Arpa_PSyserr
[];
extern char Arpa_TSyserr
[];
/* format and output the error message */
fmtmsg(MsgBuf
, (char *) NULL
, p
, olderrno
, fmt
, ap
);
/* 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 VA_ARG_FORMAL
)
extern char Arpa_Usrerr
[];
fmtmsg(MsgBuf
, CurEnv
->e_to
, Arpa_Usrerr
, errno
, fmt
, ap
);
if (LogLevel
> 1 && LogUsrErrs
)
syslog(LOG_NOTICE
, "%s: %s",
CurEnv
->e_id
== NULL
? "NOQUEUE" : CurEnv
->e_id
,
** 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 VA_ARG_FORMAL
)
fmtmsg(MsgBuf
, CurEnv
->e_to
, num
, 0, msg
, ap
);
** 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 VA_ARG_FORMAL
)
fmtmsg(MsgBuf
, (char *) NULL
, num
, 0, msg
, ap
);
** 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'))
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
, ap
)
/* 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) vsprintf(eb
, fmt
, ap
);
/* 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
[];
static char buf
[MAXLINE
];
** 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
);