xref: /csrg-svn/usr.sbin/sendmail/src/err.c (revision 2097)
1295Seric # include <stdio.h>
2295Seric # include "dlvrmail.h"
3295Seric # ifdef LOG
4295Seric # include <log.h>
5295Seric # endif LOG
6295Seric 
7*2097Seric static char	SccsId[] = "@(#)err.c	2.2	01/10/81";
8406Seric 
9295Seric /*
101514Seric **  SYSERR -- Print error message.
11295Seric **
12295Seric **	Prints an error message via printf to the diagnostic
13295Seric **	output.  If LOG is defined, it logs it also.
14295Seric **
15295Seric **	Parameters:
16295Seric **		f -- the format string
17295Seric **		a, b, c, d, e -- parameters
18295Seric **
19295Seric **	Returns:
20295Seric **		-1 always
21295Seric **
22295Seric **	Side Effects:
231514Seric **		increments Errors.
241514Seric **		sets ExitStat.
25295Seric */
26295Seric 
27295Seric /*VARARGS1*/
28295Seric syserr(fmt, a, b, c, d, e)
29295Seric 	char *fmt;
30295Seric {
31295Seric 	extern int errno;
32295Seric 	static char errbuf[MAXLINE+1];
33295Seric 	register char *p;
34295Seric 	extern char *sys_errlist[];
35295Seric 	extern int sys_nerr;
36295Seric 
37295Seric 	sprintf(errbuf, fmt, a, b, c, d, e);
38295Seric 	if (errno != 0)
39295Seric 	{
40295Seric 		p = &errbuf[strlen(errbuf)];
41295Seric 		if (errno < sys_nerr && errno > 0)
42295Seric 			sprintf(p, ": %s", sys_errlist[errno]);
43295Seric 		else
44295Seric 			sprintf(p, ": error %d", errno);
45295Seric 	}
46295Seric 	printf("delivermail: %s\n", errbuf);
47*2097Seric 	fflush(stdout);
481514Seric 	Errors++;
49295Seric 
50295Seric 	/* determine exit status if not already set */
51295Seric 	if (ExitStat == EX_OK)
52295Seric 	{
53295Seric 		if (errno == 0)
54295Seric 			ExitStat = EX_SOFTWARE;
55295Seric 		else
561598Seric 			ExitStat = EX_OSERR;
57295Seric 	}
58295Seric 
59295Seric # ifdef LOG
60295Seric 	logmsg(LOG_ERR, "%s->%s: %s", From.q_paddr, To, errbuf);
61295Seric # endif LOG
62295Seric 	errno = 0;
63295Seric 	return (-1);
64295Seric }
65295Seric /*
66295Seric **  USRERR -- Signal user error.
67295Seric **
68295Seric **	This is much like syserr except it is for user errors.
69295Seric **
70295Seric **	Parameters:
71295Seric **		fmt, a, b, c, d -- printf strings
72295Seric **
73295Seric **	Returns:
74295Seric **		-1
75295Seric **
76295Seric **	Side Effects:
771514Seric **		increments Errors.
78295Seric */
79295Seric 
80295Seric /*VARARGS1*/
81295Seric usrerr(fmt, a, b, c, d, e)
82295Seric 	char *fmt;
83295Seric {
84295Seric 	extern char SuprErrs;
85295Seric 
86295Seric 	if (SuprErrs)
87295Seric 		return;
88295Seric 
891514Seric 	Errors++;
90295Seric 	if (To != NULL)
91295Seric 		printf("%s... ", To);
92295Seric 	printf(fmt, a, b, c, d, e);
93295Seric 	printf("\n");
94*2097Seric 	fflush(stdout);
95295Seric 	return (-1);
96295Seric }
97