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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 23 * 24 * logadm/err.h -- public definitions for error module 25 */ 26 27#ifndef _LOGADM_ERR_H 28#define _LOGADM_ERR_H 29 30#include <setjmp.h> 31 32#ifdef __cplusplus 33extern "C" { 34#endif 35 36/* basic error handling routines */ 37void err_init(const char *myname); 38void err_fileline(const char *file, int line); 39void err(int flags, const char *fmt, ...); 40void out(const char *fmt, ...); 41void err_fromfd(int fd); 42void err_done(int exitcode); 43void err_exitcode(int exitcode); 44void err_mailto(const char *recipient); 45 46/* flags for err() */ 47#define EF_WARN 0x01 /* print warning and return */ 48#define EF_FILE 0x02 /* prepend file:line from last err_fileline() call */ 49#define EF_SYS 0x04 /* append errno text to message */ 50#define EF_JMP 0x08 /* longjmp through Error_env after printing error */ 51#define EF_RAW 0x10 /* don't prepend/append anything to message */ 52 53jmp_buf Err_env; 54extern jmp_buf *Err_env_ptr; 55 56#define SETJMP setjmp(*(Err_env_ptr = &Err_env)) 57#define LOCAL_ERR_BEGIN { jmp_buf Err_env, *Save_err_env_ptr = Err_env_ptr; { 58#define LOCAL_ERR_END } Err_env_break: Err_env_ptr = Save_err_env_ptr; } 59#define LOCAL_ERR_BREAK goto Err_env_break 60 61#define MALLOC(nbytes) err_malloc(nbytes, __FILE__, __LINE__) 62void *err_malloc(int nbytes, const char *fname, int line); 63 64#define REALLOC(ptr, nbytes) err_realloc(ptr, nbytes, __FILE__, __LINE__) 65void *err_realloc(void *ptr, int nbytes, const char *fname, int line); 66 67#define FREE(ptr) err_free(ptr, __FILE__, __LINE__) 68void err_free(void *ptr, const char *fname, int line); 69 70#define STRDUP(ptr) err_strdup(ptr, __FILE__, __LINE__) 71char *err_strdup(const char *ptr, const char *fname, int line); 72 73int Debug; /* replace with #define to zero to compile out Debug code */ 74 75#ifdef __cplusplus 76} 77#endif 78 79#endif /* _LOGADM_ERR_H */ 80