|
|
1.1 root 1: /*
2: * Mach Operating System
3: * Copyright (c) 1991,1990 Carnegie Mellon University
4: * All Rights Reserved.
5: *
6: * Permission to use, copy, modify and distribute this software and its
7: * documentation is hereby granted, provided that both the copyright
8: * notice and this permission notice appear in all copies of the
9: * software, derivative works or modified versions, and any portions
10: * thereof, and that both notices appear in supporting documentation.
11: *
12: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15: *
16: * Carnegie Mellon requests users of this software to return to
17: *
18: * Software Distribution Coordinator or [email protected]
19: * School of Computer Science
20: * Carnegie Mellon University
21: * Pittsburgh PA 15213-3890
22: *
23: * any improvements or extensions that they make and grant Carnegie the
24: * rights to redistribute these changes.
25: */
26:
27: #include <stdio.h>
28: #include <stdarg.h>
29:
30: #include "global.h"
31: #include "error.h"
32: #include "lexxer.h"
33:
34: static const char *program;
35: int errors = 0;
36:
37: void
38: fatal(const char *format, ...)
39: {
40: va_list pvar;
41: va_start(pvar, format);
42: fprintf(stderr, "%s: fatal: ", program);
43: (void) vfprintf(stderr, format, pvar);
44: fprintf(stderr, "\n");
45: va_end(pvar);
46: exit(1);
47: }
48:
49: void
50: warn(const char *format, ...)
51: {
52: va_list pvar;
53: va_start(pvar, format);
54: if (!BeQuiet && (errors == 0))
55: {
56: fprintf(stderr, "\"%s\", line %d: warning: ", inname, lineno-1);
57: (void) vfprintf(stderr, format, pvar);
58: fprintf(stderr, "\n");
59: }
60: va_end(pvar);
61: }
62:
63: void
64: error(const char *format, ...)
65: {
66: va_list pvar;
67: va_start(pvar, format);
68: fprintf(stderr, "\"%s\", line %d: ", inname, lineno-1);
69: (void) vfprintf(stderr, format, pvar);
70: fprintf(stderr, "\n");
71: va_end(pvar);
72: errors++;
73: }
74:
75: const char *
76: unix_error_string(int error_num)
77: {
78: static char buffer[256];
79: const char *error_mess;
80:
81: error_mess = strerror (error_num);
82:
83: sprintf(buffer, "%s (%d)", error_mess, error_num);
84: return buffer;
85: }
86:
87: void
88: set_program_name(const char *name)
89: {
90: program = name;
91: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.