1 # include <stdio.h> 2 # include "sendmail.h" 3 # ifdef LOG 4 # include <syslog.h> 5 # endif LOG 6 7 static char SccsId[] = "@(#)err.c 3.3 03/20/81"; 8 9 /* 10 ** SYSERR -- 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 ** increments Errors. 24 ** sets ExitStat. 25 */ 26 27 /*VARARGS1*/ 28 syserr(fmt, a, b, c, d, e) 29 char *fmt; 30 { 31 extern int errno; 32 static char errbuf[MAXLINE+1]; 33 register char *p; 34 extern char *sys_errlist[]; 35 extern int sys_nerr; 36 extern char *sprintf(); 37 38 sprintf(errbuf, fmt, a, b, c, d, e); 39 if (errno != 0) 40 { 41 p = &errbuf[strlen(errbuf)]; 42 if (errno < sys_nerr && errno > 0) 43 sprintf(p, ": %s", sys_errlist[errno]); 44 else 45 sprintf(p, ": error %d", errno); 46 } 47 printf("sendmail: %s\n", errbuf); 48 fflush(stdout); 49 Errors++; 50 51 /* determine exit status if not already set */ 52 if (ExitStat == EX_OK) 53 { 54 if (errno == 0) 55 ExitStat = EX_SOFTWARE; 56 else 57 ExitStat = EX_OSERR; 58 } 59 60 # ifdef LOG 61 syslog(LOG_ERR, "%s->%s: %s", From.q_paddr, To, errbuf); 62 # endif LOG 63 errno = 0; 64 return (-1); 65 } 66 /* 67 ** USRERR -- Signal user error. 68 ** 69 ** This is much like syserr except it is for user errors. 70 ** 71 ** Parameters: 72 ** fmt, a, b, c, d -- printf strings 73 ** 74 ** Returns: 75 ** -1 76 ** 77 ** Side Effects: 78 ** increments Errors. 79 */ 80 81 /*VARARGS1*/ 82 usrerr(fmt, a, b, c, d, e) 83 char *fmt; 84 { 85 extern char SuprErrs; 86 87 if (SuprErrs) 88 return (0); 89 90 Errors++; 91 if (To != NULL) 92 printf("%s... ", To); 93 printf(fmt, a, b, c, d, e); 94 printf("\n"); 95 fflush(stdout); 96 return (-1); 97 } 98