#ifndef lint
static char *sccsid = "@(#)error.c	1.1 (Steve Hill) 3/9/90";
#endif

/* ERROR.C
 *
 * Error handling routines.
 */

#include <stdio.h>

#include "basetype.h"
#include "error.h"

/* FatalError
 *
 * General purpose error routine.  The first three arguments should
 * be the file, line and format strings.  File is the file in which a
 * module resides (use the preprocessor symbol __FILE__).  Similarly
 * the line number may be generated with __LINE__.  The format string
 * is passed to fprintf, so should obey the conventions of that function.
 * The remaining parameters a-j provide a crude form of varargs (ie.
 * functions with variable numbers of parameters).  Just supply the
 * arguments that satisfy the format string.  This seems to be about
 * the only way that one can achieve variable numbers of arguments in
 * a machine independent way.  Note you may have to shout at your
 * compiler to get it to compile!
 */

/*VARARGS3*/
extern void
FatalError(file, line, format, a, b, c, d, e, f, g, h, i, j)
char	*file, *format;
int	line;
char	*a, *b, *c, *d, *e, *f, *g, *h, *i, *j;
{
	(void) fprintf(stderr, "PANIC: Error in file %s at line %d\n", file, line);
	(void) fprintf(stderr, format, a, b, c, d, e, f, g, h, i, j);
	(void) fputc('\n', stderr);
	(void) exit(1);
}

extern void
Error(format, a, b, c, d, e, f, g, h, i, j)
char	*format;
char	*a, *b, *c, *d, *e, *f, *g, *h, *i, *j;
{
	(void) fprintf(stderr, format, a, b, c, d, e, f, g, h, i, j);
	(void) fputc('\n', stderr);
	(void) exit(1);
}
