xref: /illumos-gate/usr/src/cmd/tic/tic_error.c (revision 2a8bcb4e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1988 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 /*
32  * University Copyright- Copyright (c) 1982, 1986, 1988
33  * The Regents of the University of California
34  * All Rights Reserved
35  *
36  * University Acknowledgment- Portions of this document are derived from
37  * software developed by the University of California, Berkeley, and its
38  * contributors.
39  */
40 
41 /*
42  *			COPYRIGHT NOTICE
43  *
44  *	This software is copyright(C) 1982 by Pavel Curtis
45  *
46  *	Permission is granted to reproduce and distribute
47  *	this file by any means so long as no fee is charged
48  *	above a nominal handling fee and so long as this
49  *	notice is always included in the copies.
50  *
51  *	Other rights are reserved except as explicitly granted
52  *	by written permission of the author.
53  *		Pavel Curtis
54  *		Computer Science Dept.
55  *		405 Upson Hall
56  *		Cornell University
57  *		Ithaca, NY 14853
58  *
59  *		Ph- (607) 256-4934
60  *
61  *		Pavel.Cornell@Udel-Relay(ARPAnet)
62  *		decvax!cornell!pavel(UUCPnet)
63  */
64 
65 /*
66  *	tic_error.c -- Error message routines
67  *
68  *  $Log:	RCS/tic_error.v $
69  * Revision 2.1  82/10/25  14:45:31  pavel
70  * Added Copyright Notice
71  *
72  * Revision 2.0  82/10/24  15:16:32  pavel
73  * Beta-one Test Release
74  *
75  * Revision 1.3  82/08/23  22:29:31  pavel
76  * The REAL Alpha-one Release Version
77  *
78  * Revision 1.2  82/08/19  19:09:44  pavel
79  * Alpha Test Release One
80  *
81  * Revision 1.1  82/08/12  18:36:02  pavel
82  * Initial revision
83  *
84  *
85  */
86 
87 #include <unistd.h>
88 #include <stdarg.h>
89 #include <stdlib.h>
90 
91 #include "compiler.h"
92 
93 extern char *string_table;
94 extern short term_names;
95 extern char *progname;
96 
97 /* VARARGS1 */
98 void
warning(char * fmt,...)99 warning(char *fmt, ...)
100 {
101 	va_list args;
102 
103 	va_start(args, fmt);
104 	fprintf(stderr, "%s: Warning: near line %d: ", progname, curr_line);
105 	if (string_table != NULL) {
106 		fprintf(stderr, "terminal '%s', ", string_table+term_names);
107 	}
108 	vfprintf(stderr, fmt, args);
109 	fprintf(stderr, "\n");
110 	va_end(args);
111 }
112 
113 
114 /* VARARGS1 */
115 void
err_abort(char * fmt,...)116 err_abort(char *fmt, ...)
117 {
118 	va_list args;
119 
120 	va_start(args, fmt);
121 	fprintf(stderr, "%s: Line %d: ", progname, curr_line);
122 	if (string_table != NULL) {
123 		fprintf(stderr, "terminal '%s', ", string_table+term_names);
124 	}
125 	vfprintf(stderr, fmt, args);
126 	fprintf(stderr, "\n");
127 	va_end(args);
128 	exit(1);
129 }
130 
131 
132 /* VARARGS1 */
133 void
syserr_abort(char * fmt,...)134 syserr_abort(char *fmt, ...)
135 {
136 	va_list args;
137 
138 	va_start(args, fmt);
139 	fprintf(stderr, "PROGRAM ERROR: Line %d: ", curr_line);
140 	if (string_table != NULL) {
141 		fprintf(stderr, "terminal '%s', ", string_table+term_names);
142 	}
143 	vfprintf(stderr, fmt, args);
144 	fprintf(stderr, "\n");
145 	fprintf(stderr, "*** Possibly corrupted terminfo file ***\n");
146 	va_end(args);
147 	exit(1);
148 }
149