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 (c) 1997-1999 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_ERRLOG_H
28 #define	_ERRLOG_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  *  errlog -- error logging facility for application programs
36  *
37  */
38 
39 extern void errlog(const int, const char *, ...);
40 extern void seterrline(const int, const char *, const char *, const char *);
41 extern void seterrseverity(const int);
42 extern void openerrlog(const char *, const int, const int);
43 extern void closeerrlog(void);
44 
45 /*
46  * The first (non-short) int of errlog really describes a packed
47  * form of three extensible enumerations, similar to:
48  * typedef struct severity {
49  *	int	descriptor:  8;	OTHER=0, INPUT or PROGRAM.
50  *	int     attributes:  8;	NONE=0, INDENTED, OUTDENTED, etc.
51  *	int	severity:   16;	FATAL (_ERROR)=-1, (RECOVERABLE_) ERROR=0
52  *				WARNING, TRACING, VERBOSE (_TRACING), etc.
53  * } severity_t;
54  */
55 
56 #define	FATAL	0x00FF
57 #define	ERROR	0
58 
59 #define	WARNING 1
60 #define	STATUS  2
61 #define	TRACING	3
62 #define	VERBOSE	4
63 
64 #define	INPUT	(1 << 8)
65 #define	PROGRAM	(2 << 8)
66 #define	OTHER	0
67 
68 /* Reserved for implementor. */
69 #define	INDENTED (1 << 16)
70 #define	OUTDENTED (2 << 16)
71 #define	BEGIN	(OTHER | TRACING | INDENTED)
72 #define	END	(OTHER | TRACING | OUTDENTED)
73 
74 #ifndef assert
75 /* EXPERIMENTAL assert replacement, deliberately not source-compatable */
76 #define	assert(cond, string) \
77 	if (!(cond)) { \
78 		seterrline(__LINE__, __FILE__, NULL, NULL); \
79 		errlog(FATAL|PROGRAM, string);	\
80 	}
81 #else
82 #error "assert.h and errlog.h both define assert: choose only one"
83 #endif	/* assert */
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif	/* _ERRLOG_H */
90