SCCSID(@
(#)err.c 3.40 1/5/83);
** 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
, fmt
, a
, b
, c
, d
, e
);
/* determine exit status if not already set */
/* insure that we have a queue id for logging */
(void) queuename(CurEnv
, '\0');
syslog(LOG_ERR
, "%s: SYSERR: %s", CurEnv
->e_id
, &MsgBuf
[4]);
** 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
, 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
, 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 a digit, this number overrides num.
** a, b, c, d, e -- printf arguments
nmessage(num
, msg
, a
, b
, c
, d
, e
)
fmtmsg(MsgBuf
, (char *) NULL
, num
, 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 (CurEnv
->e_xfp
!= NULL
)
fprintf(CurEnv
->e_xfp
, "%s\n", OpMode
== MD_SMTP
? msg
: &msg
[4]);
/* 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.
** fmt -- format of string.
** a, b, c, d, e -- arguments.
fmtmsg(eb
, to
, num
, fmt
, a
, b
, c
, d
, e
)
/* output the reply code */
(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 *sys_errlist
[];
if (errno
< sys_nerr
&& errno
> 0)
(void) sprintf(eb
, ": %s", sys_errlist
[errno
]);
(void) sprintf(eb
, ": error %d", errno
);