1295Seric # include <stdio.h> 2295Seric # include "dlvrmail.h" 3295Seric # ifdef LOG 4295Seric # include <log.h> 5295Seric # endif LOG 6295Seric 7*1514Seric static char SccsId[] = "@(#)err.c 1.4 10/18/80"; 8406Seric 9295Seric /* 10*1514Seric ** 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: 23*1514Seric ** increments Errors. 24*1514Seric ** 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*1514Seric Errors++; 48295Seric 49295Seric /* determine exit status if not already set */ 50295Seric if (ExitStat == EX_OK) 51295Seric { 52295Seric if (errno == 0) 53295Seric ExitStat = EX_SOFTWARE; 54295Seric else 55295Seric ExitStat = EX_UNAVAIL; 56295Seric } 57295Seric 58295Seric # ifdef LOG 59295Seric logmsg(LOG_ERR, "%s->%s: %s", From.q_paddr, To, errbuf); 60295Seric # endif LOG 61295Seric errno = 0; 62295Seric return (-1); 63295Seric } 64295Seric /* 65295Seric ** USRERR -- Signal user error. 66295Seric ** 67295Seric ** This is much like syserr except it is for user errors. 68295Seric ** 69295Seric ** Parameters: 70295Seric ** fmt, a, b, c, d -- printf strings 71295Seric ** 72295Seric ** Returns: 73295Seric ** -1 74295Seric ** 75295Seric ** Side Effects: 76*1514Seric ** increments Errors. 77295Seric */ 78295Seric 79295Seric /*VARARGS1*/ 80295Seric usrerr(fmt, a, b, c, d, e) 81295Seric char *fmt; 82295Seric { 83295Seric extern char SuprErrs; 84295Seric 85295Seric if (SuprErrs) 86295Seric return; 87295Seric 88*1514Seric Errors++; 89295Seric if (To != NULL) 90295Seric printf("%s... ", To); 91295Seric printf(fmt, a, b, c, d, e); 92295Seric printf("\n"); 93295Seric return (-1); 94295Seric } 95