1295Seric # include <stdio.h> 2295Seric # include "dlvrmail.h" 3295Seric # ifdef LOG 4295Seric # include <log.h> 5295Seric # endif LOG 6295Seric 7*406Seric static char SccsId[] = "@(#)err.c 1.2 07/25/80"; 8*406Seric 9295Seric /* 10295Seric ** ERR -- 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: 23295Seric ** Sets Error. 24295Seric ** Sets ExitStat. 25295Seric ** 26295Seric ** Requires: 27295Seric ** sprintf (sys) 28295Seric ** printf (sys) 29295Seric ** logmsg 30295Seric ** 31295Seric ** History: 32295Seric ** 12/29/79 -- written. 33295Seric */ 34295Seric 35295Seric /*VARARGS1*/ 36295Seric syserr(fmt, a, b, c, d, e) 37295Seric char *fmt; 38295Seric { 39295Seric extern int errno; 40295Seric static char errbuf[MAXLINE+1]; 41295Seric register char *p; 42295Seric extern char *sys_errlist[]; 43295Seric extern int sys_nerr; 44295Seric 45295Seric sprintf(errbuf, fmt, a, b, c, d, e); 46295Seric if (errno != 0) 47295Seric { 48295Seric p = &errbuf[strlen(errbuf)]; 49295Seric if (errno < sys_nerr && errno > 0) 50295Seric sprintf(p, ": %s", sys_errlist[errno]); 51295Seric else 52295Seric sprintf(p, ": error %d", errno); 53295Seric } 54295Seric printf("delivermail: %s\n", errbuf); 55295Seric Error++; 56295Seric 57295Seric /* determine exit status if not already set */ 58295Seric if (ExitStat == EX_OK) 59295Seric { 60295Seric if (errno == 0) 61295Seric ExitStat = EX_SOFTWARE; 62295Seric else 63295Seric ExitStat = EX_UNAVAIL; 64295Seric } 65295Seric 66295Seric # ifdef LOG 67295Seric logmsg(LOG_ERR, "%s->%s: %s", From.q_paddr, To, errbuf); 68295Seric # endif LOG 69295Seric errno = 0; 70295Seric return (-1); 71295Seric } 72295Seric /* 73295Seric ** USRERR -- Signal user error. 74295Seric ** 75295Seric ** This is much like syserr except it is for user errors. 76295Seric ** 77295Seric ** Parameters: 78295Seric ** fmt, a, b, c, d -- printf strings 79295Seric ** 80295Seric ** Returns: 81295Seric ** -1 82295Seric ** 83295Seric ** Side Effects: 84295Seric ** sets Error. 85295Seric ** 86295Seric ** Requires: 87295Seric ** printf (sys) 88295Seric ** 89295Seric ** History: 90295Seric ** 1/1/80 -- written. 91295Seric */ 92295Seric 93295Seric /*VARARGS1*/ 94295Seric usrerr(fmt, a, b, c, d, e) 95295Seric char *fmt; 96295Seric { 97295Seric extern char SuprErrs; 98295Seric 99295Seric if (SuprErrs) 100295Seric return; 101295Seric 102295Seric Error++; 103295Seric if (To != NULL) 104295Seric printf("%s... ", To); 105295Seric printf(fmt, a, b, c, d, e); 106295Seric printf("\n"); 107295Seric return (-1); 108295Seric } 109