Commit | Line | Data |
---|---|---|
b3cbe40f EA |
1 | # include <stdio.h> |
2 | # include "dlvrmail.h" | |
3 | # ifdef LOG | |
4 | # include <log.h> | |
5 | # endif LOG | |
6 | ||
916b3375 EA |
7 | static char SccsId[] = "@(#)err.c 1.2 %G%"; |
8 | ||
b3cbe40f EA |
9 | /* |
10 | ** ERR -- Print error message. | |
11 | ** | |
12 | ** Prints an error message via printf to the diagnostic | |
13 | ** output. If LOG is defined, it logs it also. | |
14 | ** | |
15 | ** Parameters: | |
16 | ** f -- the format string | |
17 | ** a, b, c, d, e -- parameters | |
18 | ** | |
19 | ** Returns: | |
20 | ** -1 always | |
21 | ** | |
22 | ** Side Effects: | |
23 | ** Sets Error. | |
24 | ** Sets ExitStat. | |
25 | ** | |
26 | ** Requires: | |
27 | ** sprintf (sys) | |
28 | ** printf (sys) | |
29 | ** logmsg | |
30 | ** | |
31 | ** History: | |
32 | ** 12/29/79 -- written. | |
33 | */ | |
34 | ||
35 | /*VARARGS1*/ | |
36 | syserr(fmt, a, b, c, d, e) | |
37 | char *fmt; | |
38 | { | |
39 | extern int errno; | |
40 | static char errbuf[MAXLINE+1]; | |
41 | register char *p; | |
42 | extern char *sys_errlist[]; | |
43 | extern int sys_nerr; | |
44 | ||
45 | sprintf(errbuf, fmt, a, b, c, d, e); | |
46 | if (errno != 0) | |
47 | { | |
48 | p = &errbuf[strlen(errbuf)]; | |
49 | if (errno < sys_nerr && errno > 0) | |
50 | sprintf(p, ": %s", sys_errlist[errno]); | |
51 | else | |
52 | sprintf(p, ": error %d", errno); | |
53 | } | |
54 | printf("delivermail: %s\n", errbuf); | |
55 | Error++; | |
56 | ||
57 | /* determine exit status if not already set */ | |
58 | if (ExitStat == EX_OK) | |
59 | { | |
60 | if (errno == 0) | |
61 | ExitStat = EX_SOFTWARE; | |
62 | else | |
63 | ExitStat = EX_UNAVAIL; | |
64 | } | |
65 | ||
66 | # ifdef LOG | |
67 | logmsg(LOG_ERR, "%s->%s: %s", From.q_paddr, To, errbuf); | |
68 | # endif LOG | |
69 | errno = 0; | |
70 | return (-1); | |
71 | } | |
72 | \f/* | |
73 | ** USRERR -- Signal user error. | |
74 | ** | |
75 | ** This is much like syserr except it is for user errors. | |
76 | ** | |
77 | ** Parameters: | |
78 | ** fmt, a, b, c, d -- printf strings | |
79 | ** | |
80 | ** Returns: | |
81 | ** -1 | |
82 | ** | |
83 | ** Side Effects: | |
84 | ** sets Error. | |
85 | ** | |
86 | ** Requires: | |
87 | ** printf (sys) | |
88 | ** | |
89 | ** History: | |
90 | ** 1/1/80 -- written. | |
91 | */ | |
92 | ||
93 | /*VARARGS1*/ | |
94 | usrerr(fmt, a, b, c, d, e) | |
95 | char *fmt; | |
96 | { | |
97 | extern char SuprErrs; | |
98 | ||
99 | if (SuprErrs) | |
100 | return; | |
101 | ||
102 | Error++; | |
103 | if (To != NULL) | |
104 | printf("%s... ", To); | |
105 | printf(fmt, a, b, c, d, e); | |
106 | printf("\n"); | |
107 | return (-1); | |
108 | } |