1987-03-09 19:15:41 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1985-01-10 13:17:22 +00:00
|
|
|
#ifndef lint
|
1994-06-24 11:31:16 +00:00
|
|
|
static char rcsid[] = "$Id$";
|
1985-01-10 13:17:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2017-01-18 18:55:56 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdarg.h>
|
2019-03-22 19:15:40 +00:00
|
|
|
#include <unistd.h>
|
1986-10-20 10:17:57 +00:00
|
|
|
#include <out.h>
|
1985-01-10 13:17:22 +00:00
|
|
|
#include "const.h"
|
|
|
|
|
|
|
|
static short nerrors = 0;
|
2012-10-24 17:44:50 +00:00
|
|
|
static void diag(char *, char *, va_list);
|
1985-01-10 13:17:22 +00:00
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
extern char *outputname;
|
1986-10-20 10:17:57 +00:00
|
|
|
extern int exitstatus;
|
1985-01-10 13:17:22 +00:00
|
|
|
|
1986-10-20 10:17:57 +00:00
|
|
|
if (nerrors) {
|
1985-01-10 13:17:22 +00:00
|
|
|
unlink(outputname);
|
1986-10-20 10:17:57 +00:00
|
|
|
exit(nerrors);
|
|
|
|
}
|
1985-01-10 13:17:22 +00:00
|
|
|
|
1986-10-20 10:17:57 +00:00
|
|
|
exit(exitstatus);
|
1985-01-10 13:17:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* VARARGS1 */
|
2012-10-24 17:44:50 +00:00
|
|
|
void
|
|
|
|
fatal(char *format, ...)
|
1985-01-10 13:17:22 +00:00
|
|
|
{
|
2012-10-24 17:44:50 +00:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
1985-01-10 13:17:22 +00:00
|
|
|
nerrors++;
|
2012-10-24 17:44:50 +00:00
|
|
|
diag("fatal", format, ap);
|
1985-01-10 13:17:22 +00:00
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* VARARGS1 */
|
2012-10-24 17:44:50 +00:00
|
|
|
void
|
|
|
|
warning(char *format, ...)
|
1985-01-10 13:17:22 +00:00
|
|
|
{
|
2012-10-24 17:44:50 +00:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
|
|
|
diag("warning", format, ap);
|
|
|
|
va_end(ap);
|
1985-01-10 13:17:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* VARARGS1 */
|
2012-10-24 17:44:50 +00:00
|
|
|
void
|
|
|
|
error(char *format, ...)
|
1985-01-10 13:17:22 +00:00
|
|
|
{
|
2012-10-24 17:44:50 +00:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
1985-01-10 13:17:22 +00:00
|
|
|
nerrors++;
|
2012-10-24 17:44:50 +00:00
|
|
|
diag("error", format, ap);
|
|
|
|
va_end(ap);
|
1985-01-10 13:17:22 +00:00
|
|
|
}
|
|
|
|
|
1990-03-15 10:44:14 +00:00
|
|
|
/* VARARGS1 */
|
2012-10-24 17:44:50 +00:00
|
|
|
void
|
|
|
|
do_verbose(char *format, ...)
|
1990-03-15 10:44:14 +00:00
|
|
|
{
|
2012-10-24 17:44:50 +00:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
|
|
|
diag((char *) 0, format, ap);
|
|
|
|
va_end(ap);
|
1990-03-15 10:44:14 +00:00
|
|
|
}
|
|
|
|
|
2012-10-24 17:44:50 +00:00
|
|
|
static void
|
|
|
|
diag(char *tail, char *format, va_list ap)
|
1985-01-10 13:17:22 +00:00
|
|
|
{
|
2017-01-18 18:55:56 +00:00
|
|
|
extern char *progname, *archname, *modulname;
|
1985-01-10 13:17:22 +00:00
|
|
|
|
|
|
|
fprintf(stderr, "%s: ", progname);
|
1990-03-15 10:44:14 +00:00
|
|
|
if (archname && modulname)
|
1990-07-30 11:56:28 +00:00
|
|
|
fprintf(stderr, "%s(%.14s): ", archname, modulname);
|
1990-03-15 10:44:14 +00:00
|
|
|
else if (archname)
|
1985-01-10 13:17:22 +00:00
|
|
|
fprintf(stderr, "%s: ", archname);
|
1990-03-15 10:44:14 +00:00
|
|
|
else if (modulname)
|
1990-11-27 09:39:52 +00:00
|
|
|
fprintf(stderr, "%s: ", modulname);
|
2012-10-24 17:44:50 +00:00
|
|
|
vfprintf(stderr, format, ap);
|
1990-03-15 10:44:14 +00:00
|
|
|
if (tail) fprintf(stderr, " (%s)\n", tail);
|
|
|
|
else putc('\n', stderr);
|
1985-01-10 13:17:22 +00:00
|
|
|
}
|