xref: /csrg-svn/usr.bin/uucp/assert.c (revision 13636)
1*13636Ssam #ifndef lint
2*13636Ssam static char sccsid[] = "@(#)assert.c	5.1 (Berkeley) 07/02/83";
3*13636Ssam #endif
4*13636Ssam 
5*13636Ssam #include "uucp.h"
6*13636Ssam #include <time.h>
7*13636Ssam #include <sys/types.h>
8*13636Ssam #include <errno.h>
9*13636Ssam 
10*13636Ssam /*******
11*13636Ssam  *	assert - print out assetion error
12*13636Ssam  *
13*13636Ssam  *	return code - none
14*13636Ssam  */
15*13636Ssam 
16*13636Ssam assert(s1, s2, i1)
17*13636Ssam char *s1, *s2;
18*13636Ssam {
19*13636Ssam 	register FILE *errlog;
20*13636Ssam 	register struct tm *tp;
21*13636Ssam 	extern struct tm *localtime();
22*13636Ssam 	extern time_t time();
23*13636Ssam 	time_t clock;
24*13636Ssam 	int pid;
25*13636Ssam 
26*13636Ssam 	if (Debug)
27*13636Ssam 		errlog = stderr;
28*13636Ssam 	else {
29*13636Ssam 		int savemask;
30*13636Ssam 		savemask = umask(LOGMASK);
31*13636Ssam 		errlog = fopen(ERRLOG, "a");
32*13636Ssam 		umask(savemask);
33*13636Ssam 	}
34*13636Ssam 	if (errlog == NULL)
35*13636Ssam 		return;
36*13636Ssam 
37*13636Ssam 	pid = getpid();
38*13636Ssam 	fprintf(errlog, "ASSERT ERROR (%.9s)  ", Progname);
39*13636Ssam 	fprintf(errlog, "pid: %d  ", pid);
40*13636Ssam 	time(&clock);
41*13636Ssam 	tp = localtime(&clock);
42*13636Ssam 	fprintf(errlog, "(%d/%d-%d:%02d) ", tp->tm_mon + 1,
43*13636Ssam 		tp->tm_mday, tp->tm_hour, tp->tm_min);
44*13636Ssam 	fprintf(errlog, "%s %s (%d)\n", s1, s2, i1);
45*13636Ssam 	fclose(errlog);
46*13636Ssam 	return;
47*13636Ssam }
48