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