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