13311Seric # include "sendmail.h" 2295Seric # ifdef LOG 32775Seric # include <syslog.h> 4295Seric # endif LOG 5295Seric 6*4577Seric static char SccsId[] = "@(#)err.c 3.12 10/22/81"; 7406Seric 84162Seric extern bool HasXscrpt; 94162Seric 10295Seric /* 111514Seric ** SYSERR -- Print error message. 12295Seric ** 13295Seric ** Prints an error message via printf to the diagnostic 14295Seric ** output. If LOG is defined, it logs it also. 15295Seric ** 16295Seric ** Parameters: 17295Seric ** f -- the format string 18295Seric ** a, b, c, d, e -- parameters 19295Seric ** 20295Seric ** Returns: 214084Seric ** none 22295Seric ** 23295Seric ** Side Effects: 241514Seric ** increments Errors. 251514Seric ** sets ExitStat. 26295Seric */ 27295Seric 284084Seric # ifdef lint 294084Seric int sys_nerr; 304084Seric char *sys_errlist[]; 314084Seric # endif lint 324084Seric 33295Seric /*VARARGS1*/ 34295Seric syserr(fmt, a, b, c, d, e) 35295Seric char *fmt; 36295Seric { 37295Seric static char errbuf[MAXLINE+1]; 38295Seric extern char *sys_errlist[]; 39295Seric extern int sys_nerr; 404063Seric register char *eb = errbuf; 414167Seric extern char Arpa_Syserr[]; 42295Seric 434063Seric /* add arpanet error number if not present */ 444063Seric if (!isdigit(*fmt)) 454063Seric { 464167Seric (void) strcpy(eb, Arpa_Syserr); 474167Seric eb[3] = ' '; 484063Seric eb += 4; 494063Seric } 504063Seric 514063Seric /* put error message into buffer */ 524084Seric (void) sprintf(eb, fmt, a, b, c, d, e); 53295Seric if (errno != 0) 54295Seric { 554063Seric eb += strlen(eb); 56295Seric if (errno < sys_nerr && errno > 0) 574084Seric (void) sprintf(eb, ": %s", sys_errlist[errno]); 58295Seric else 594084Seric (void) sprintf(eb, ": error %d", errno); 60295Seric } 614063Seric 624162Seric if (ArpaMode != ARPA_NONE && !HasXscrpt) 634552Seric fprintf(OutChannel, "%s\r\n", errbuf); 644063Seric else 654552Seric fprintf(OutChannel, "sendmail: %s\n", &errbuf[4]); 664552Seric (void) fflush(OutChannel); 671514Seric Errors++; 68295Seric 69295Seric /* determine exit status if not already set */ 70295Seric if (ExitStat == EX_OK) 71295Seric { 72295Seric if (errno == 0) 73295Seric ExitStat = EX_SOFTWARE; 74295Seric else 751598Seric ExitStat = EX_OSERR; 76295Seric } 77295Seric 78295Seric # ifdef LOG 794316Seric syslog(LOG_ERR, "%s->%s: %s", From.q_paddr, To, &errbuf[4]); 80295Seric # endif LOG 81295Seric errno = 0; 82295Seric } 83295Seric /* 84295Seric ** USRERR -- Signal user error. 85295Seric ** 86295Seric ** This is much like syserr except it is for user errors. 87295Seric ** 88295Seric ** Parameters: 89295Seric ** fmt, a, b, c, d -- printf strings 90295Seric ** 91295Seric ** Returns: 924084Seric ** none 93295Seric ** 94295Seric ** Side Effects: 951514Seric ** increments Errors. 96295Seric */ 97295Seric 98295Seric /*VARARGS1*/ 99295Seric usrerr(fmt, a, b, c, d, e) 100295Seric char *fmt; 101295Seric { 102295Seric extern char SuprErrs; 1034167Seric extern char Arpa_Usrerr[]; 104295Seric 105295Seric if (SuprErrs) 1064084Seric return; 1074063Seric Errors++; 108295Seric 1094167Seric message(Arpa_Usrerr, fmt, a, b, c, d, e); 1104063Seric } 1114063Seric /* 1124063Seric ** MESSAGE -- print message (not necessarily an error) 1134063Seric ** 1144063Seric ** Parameters: 1154063Seric ** num -- the default ARPANET error number (in ascii) 1164063Seric ** msg -- the message (printf fmt) -- if it begins 1174063Seric ** with a digit, this number overrides num. 1184063Seric ** a, b, c, d, e -- printf arguments 1194063Seric ** 1204063Seric ** Returns: 1214063Seric ** none 1224063Seric ** 1234063Seric ** Side Effects: 1244063Seric ** none. 1254063Seric */ 1264063Seric 1274084Seric /*VARARGS2*/ 1284063Seric message(num, msg, a, b, c, d, e) 1294063Seric register char *num; 1304063Seric register char *msg; 1314063Seric { 1324063Seric /* compute error number */ 1334063Seric if (isdigit(*msg)) 1344063Seric { 1354063Seric num = msg; 1364063Seric msg += 4; 1374063Seric } 1384063Seric 1394063Seric /* print arpa format header if needed */ 1404162Seric if (ArpaMode != ARPA_NONE && !HasXscrpt) 141*4577Seric { 142*4577Seric register char del; 1434063Seric 144*4577Seric if (num[3] == '-') 145*4577Seric del = '-'; 146*4577Seric else 147*4577Seric del = ' '; 148*4577Seric fprintf(OutChannel, "%3.3s%c", num, del); 149*4577Seric } 150*4577Seric 1514063Seric if (To != NULL && To[0] != '\0') 1524552Seric fprintf(OutChannel, "%s... ", To); 1534552Seric fprintf(OutChannel, msg, a, b, c, d, e); 1544162Seric if (ArpaMode != ARPA_NONE && !HasXscrpt) 1554552Seric fprintf(OutChannel, "\r"); 1564552Seric fprintf(OutChannel, "\n"); 1574552Seric (void) fflush(OutChannel); 158295Seric } 159