Pristine Ack-5.5
[Ack-5.5.git] / util / led / error.c
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5 #ifndef lint
6 static char rcsid[] = "$Id: error.c,v 3.6 1994/06/24 10:34:38 ceriel Exp $";
7 #endif
8
9 #include <stdio.h>
10 #include <out.h>
11 #include "const.h"
12
13 static short    nerrors = 0;
14 static          diag();
15
16 stop()
17 {
18         extern char     *outputname;
19         extern int      exitstatus;
20
21         if (nerrors) {
22                 unlink(outputname);
23                 exit(nerrors);
24         }
25
26         exit(exitstatus);
27 }
28
29 /* VARARGS1 */
30 fatal(format, a1, a2, a3, a4)
31         char    *format;
32 {
33         nerrors++;
34         diag("fatal", format, a1, a2, a3, a4);
35         stop();
36 }
37
38 /* VARARGS1 */
39 warning(format, a1, a2, a3, a4)
40         char    *format;
41 {
42         diag("warning", format, a1, a2, a3, a4);
43 }
44
45 /* VARARGS1 */
46 error(format, a1, a2, a3, a4)
47         char    *format;
48 {
49         nerrors++;
50         diag("error", format, a1, a2, a3, a4);
51 }
52
53 /* VARARGS1 */
54 do_verbose(format, a1, a2, a3, a4)
55         char    *format;
56 {
57         diag((char *) 0, format, a1, a2, a3, a4);
58 }
59
60 static
61 diag(tail, format, a1, a2, a3, a4)
62         char    *tail;
63         char    *format;
64 {
65         extern char     *progname, *archname, *modulname; 
66
67         fprintf(stderr, "%s: ", progname);
68         if (archname && modulname)
69                 fprintf(stderr, "%s(%.14s): ", archname, modulname);
70         else if (archname)
71                 fprintf(stderr, "%s: ", archname);
72         else if (modulname)
73                 fprintf(stderr, "%s: ", modulname);
74         fprintf(stderr, format, a1, a2, a3, a4);
75         if (tail) fprintf(stderr, " (%s)\n", tail);
76         else putc('\n', stderr);
77 }