xref: /titanic_44/usr/src/cmd/logadm/err.h (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
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) 2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  *
26  * logadm/err.h -- public definitions for error module
27  */
28 
29 #ifndef	_LOGADM_ERR_H
30 #define	_LOGADM_ERR_H
31 
32 #pragma ident	"%Z%%M%	%I%	%E% SMI"
33 
34 #include <setjmp.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /* basic error handling routines */
41 void err_init(const char *myname);
42 void err_fileline(const char *file, int line);
43 void err(int flags, const char *fmt, ...);
44 void out(const char *fmt, ...);
45 void err_fromfd(int fd);
46 void err_done(int exitcode);
47 void err_exitcode(int exitcode);
48 void err_mailto(const char *recipient);
49 
50 /* flags for err() */
51 #define	EF_WARN	0x01	/* print warning and return */
52 #define	EF_FILE	0x02	/* prepend file:line from last err_fileline() call */
53 #define	EF_SYS	0x04	/* append errno text to message */
54 #define	EF_JMP	0x08	/* longjmp through Error_env after printing error */
55 #define	EF_RAW	0x10	/* don't prepend/append anything to message */
56 
57 jmp_buf Err_env;
58 
59 #define	SETJMP	setjmp(Err_env)
60 
61 #define	MALLOC(nbytes) err_malloc(nbytes, __FILE__, __LINE__)
62 void *err_malloc(int nbytes, const char *fname, int line);
63 
64 #define	REALLOC(ptr, nbytes) err_realloc(ptr, nbytes, __FILE__, __LINE__)
65 void *err_realloc(void *ptr, int nbytes, const char *fname, int line);
66 
67 #define	FREE(ptr) err_free(ptr, __FILE__, __LINE__)
68 void err_free(void *ptr, const char *fname, int line);
69 
70 #define	STRDUP(ptr) err_strdup(ptr, __FILE__, __LINE__)
71 char *err_strdup(const char *ptr, const char *fname, int line);
72 
73 int 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