8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / logadm / err.h
blobde2abd930062fa9071d24f00a8fc4f44363100b0
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
24 * logadm/err.h -- public definitions for error module
27 #ifndef _LOGADM_ERR_H
28 #define _LOGADM_ERR_H
30 #include <setjmp.h>
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 /* basic error handling routines */
37 void err_init(const char *myname);
38 void err_fileline(const char *file, int line);
39 void err(int flags, const char *fmt, ...);
40 void out(const char *fmt, ...);
41 void err_fromfd(int fd);
42 void err_done(int exitcode);
43 void err_exitcode(int exitcode);
44 void err_mailto(const char *recipient);
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 */
53 jmp_buf Err_env;
54 extern jmp_buf *Err_env_ptr;
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
61 #define MALLOC(nbytes) err_malloc(nbytes, __FILE__, __LINE__)
62 void *err_malloc(int nbytes, const char *fname, int line);
64 #define REALLOC(ptr, nbytes) err_realloc(ptr, nbytes, __FILE__, __LINE__)
65 void *err_realloc(void *ptr, int nbytes, const char *fname, int line);
67 #define FREE(ptr) err_free(ptr, __FILE__, __LINE__)
68 void err_free(void *ptr, const char *fname, int line);
70 #define STRDUP(ptr) err_strdup(ptr, __FILE__, __LINE__)
71 char *err_strdup(const char *ptr, const char *fname, int line);
73 int Debug; /* replace with #define to zero to compile out Debug code */
75 #ifdef __cplusplus
77 #endif
79 #endif /* _LOGADM_ERR_H */