xref: /titanic_50/usr/src/cmd/abi/spectrans/parser/errlog.h (revision 753d2d2e8e7fd0c9bcf736d9bf2f2faf4d6234cc)
1*753d2d2eSraf /*
2*753d2d2eSraf  * CDDL HEADER START
3*753d2d2eSraf  *
4*753d2d2eSraf  * The contents of this file are subject to the terms of the
5*753d2d2eSraf  * Common Development and Distribution License, Version 1.0 only
6*753d2d2eSraf  * (the "License").  You may not use this file except in compliance
7*753d2d2eSraf  * with the License.
8*753d2d2eSraf  *
9*753d2d2eSraf  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*753d2d2eSraf  * or http://www.opensolaris.org/os/licensing.
11*753d2d2eSraf  * See the License for the specific language governing permissions
12*753d2d2eSraf  * and limitations under the License.
13*753d2d2eSraf  *
14*753d2d2eSraf  * When distributing Covered Code, include this CDDL HEADER in each
15*753d2d2eSraf  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*753d2d2eSraf  * If applicable, add the following below this CDDL HEADER, with the
17*753d2d2eSraf  * fields enclosed by brackets "[]" replaced with your own identifying
18*753d2d2eSraf  * information: Portions Copyright [yyyy] [name of copyright owner]
19*753d2d2eSraf  *
20*753d2d2eSraf  * CDDL HEADER END
21*753d2d2eSraf  */
22*753d2d2eSraf /*
23*753d2d2eSraf  * Copyright (c) 1997-1999 by Sun Microsystems, Inc.
24*753d2d2eSraf  * All rights reserved.
25*753d2d2eSraf  */
26*753d2d2eSraf 
27*753d2d2eSraf #ifndef	_ERRLOG_H
28*753d2d2eSraf #define	_ERRLOG_H
29*753d2d2eSraf 
30*753d2d2eSraf #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*753d2d2eSraf 
32*753d2d2eSraf #ifdef	__cplusplus
33*753d2d2eSraf extern "C" {
34*753d2d2eSraf #endif
35*753d2d2eSraf 
36*753d2d2eSraf /*
37*753d2d2eSraf  *  errlog -- error logging facility for application programs
38*753d2d2eSraf  *
39*753d2d2eSraf  */
40*753d2d2eSraf 
41*753d2d2eSraf extern void errlog(const int, const char *, ...);
42*753d2d2eSraf extern void seterrline(const int, const char *, const char *, const char *);
43*753d2d2eSraf extern void seterrseverity(const int);
44*753d2d2eSraf extern void openerrlog(const char *, const int, const int);
45*753d2d2eSraf extern void closeerrlog(void);
46*753d2d2eSraf 
47*753d2d2eSraf /*
48*753d2d2eSraf  * The first (non-short) int of errlog really describes a packed
49*753d2d2eSraf  * form of three extensible enumerations, similar to:
50*753d2d2eSraf  * typedef struct severity {
51*753d2d2eSraf  *	int	descriptor:  8;	OTHER=0, INPUT or PROGRAM.
52*753d2d2eSraf  *	int     attributes:  8;	NONE=0, INDENTED, OUTDENTED, etc.
53*753d2d2eSraf  *	int	severity:   16;	FATAL (_ERROR)=-1, (RECOVERABLE_) ERROR=0
54*753d2d2eSraf  *				WARNING, TRACING, VERBOSE (_TRACING), etc.
55*753d2d2eSraf  * } severity_t;
56*753d2d2eSraf  */
57*753d2d2eSraf 
58*753d2d2eSraf #define	FATAL	0x00FF
59*753d2d2eSraf #define	ERROR	0
60*753d2d2eSraf 
61*753d2d2eSraf #define	WARNING 1
62*753d2d2eSraf #define	STATUS  2
63*753d2d2eSraf #define	TRACING	3
64*753d2d2eSraf #define	VERBOSE	4
65*753d2d2eSraf 
66*753d2d2eSraf #define	INPUT	(1 << 8)
67*753d2d2eSraf #define	PROGRAM	(2 << 8)
68*753d2d2eSraf #define	OTHER	0
69*753d2d2eSraf 
70*753d2d2eSraf /* Reserved for implementor. */
71*753d2d2eSraf #define	INDENTED (1 << 16)
72*753d2d2eSraf #define	OUTDENTED (2 << 16)
73*753d2d2eSraf #define	BEGIN	(OTHER | TRACING | INDENTED)
74*753d2d2eSraf #define	END	(OTHER | TRACING | OUTDENTED)
75*753d2d2eSraf 
76*753d2d2eSraf #ifndef assert
77*753d2d2eSraf /* EXPERIMENTAL assert replacement, deliberately not source-compatable */
78*753d2d2eSraf #define	assert(cond, string) \
79*753d2d2eSraf 	if (!(cond)) { \
80*753d2d2eSraf 		seterrline(__LINE__, __FILE__, NULL, NULL); \
81*753d2d2eSraf 		errlog(FATAL|PROGRAM, string);	\
82*753d2d2eSraf 	}
83*753d2d2eSraf #else
84*753d2d2eSraf #error "assert.h and errlog.h both define assert: choose only one"
85*753d2d2eSraf #endif	/* assert */
86*753d2d2eSraf 
87*753d2d2eSraf #ifdef	__cplusplus
88*753d2d2eSraf }
89*753d2d2eSraf #endif
90*753d2d2eSraf 
91*753d2d2eSraf #endif	/* _ERRLOG_H */
92