xref: /titanic_44/usr/src/cmd/rcap/common/utils.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_UTILS_H
28 #define	_UTILS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <assert.h>
33 #include <libintl.h>
34 #include <stdarg.h>
35 #include <time.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #define	E_SUCCESS	0		/* Exit status for success */
42 #define	E_ERROR		1		/* Exit status for error */
43 #define	E_USAGE		2		/* Exit status for usage error */
44 
45 /*
46  * Message filter levels by priority
47  */
48 typedef enum rcm_level {
49 	RCM_NONE = 0,			/* No messages */
50 	RCM_ERR,			/* Errors only */
51 	RCM_WARN,			/* Warnings */
52 	RCM_INFO,			/* Information */
53 	RCM_DEBUG,			/* Everything */
54 	RCM_DEBUG_HIGH			/* Fire hose */
55 } rcm_level_t;
56 
57 /*
58  * Message destinations
59  */
60 typedef enum rcm_dst {
61 	RCD_STD = 1,			/* Standard output/error, depending */
62 					/* on level */
63 	RCD_SYSLOG			/* syslog() daemon facility */
64 } rcm_dst_t;
65 
66 #define	LINELEN		256		/* max. message length */
67 
68 #ifdef DEBUG
69 #undef ASSERT
70 #define	ASSERT(x)	(assert(x))
71 #else /* !DEBUG */
72 #undef ASSERT
73 #define	ASSERT(x)	((void)0)
74 #endif /* DEBUG */
75 
76 #ifdef DEBUG_MSG
77 extern void debug(char *, ...);
78 extern void debug_high(char *, ...);
79 #else /* !DEBUG_MSG */
80 /*LINTED: static unused*/
81 static void debug(char *format, ...) /*ARGSUSED*/ {}
82 /*LINTED: static unused*/
83 static void debug_high(char *format, ...) /*ARGSUSED*/ {}
84 #endif /* DEBUG_MSG */
85 
86 extern void die(char *, ...);
87 extern void info(char *, ...);
88 extern rcm_level_t get_message_priority(void);
89 extern rcm_level_t set_message_priority(rcm_level_t);
90 extern rcm_dst_t set_message_destination(rcm_dst_t);
91 extern char *setprogname(char *);
92 extern void warn(char *, ...);
93 extern int valid_abspath(char *);
94 extern void vdprintfe(int, char *, va_list);
95 extern void dprintfe(int, char *, ...);
96 extern void hrt2ts(hrtime_t, timestruc_t *);
97 extern int xatoi(char *);
98 
99 #ifdef	__cplusplus
100 }
101 #endif
102 
103 #endif	/* _UTILS_H */
104