10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
53247Sgjelinek * Common Development and Distribution License (the "License").
63247Sgjelinek * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
21*13093SRoger.Faulkner@Oracle.COM
220Sstevel@tonic-gate /*
23*13093SRoger.Faulkner@Oracle.COM * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #ifndef _UTILS_H
270Sstevel@tonic-gate #define _UTILS_H
280Sstevel@tonic-gate
290Sstevel@tonic-gate #include <assert.h>
300Sstevel@tonic-gate #include <libintl.h>
310Sstevel@tonic-gate #include <stdarg.h>
320Sstevel@tonic-gate #include <time.h>
333247Sgjelinek #include <libzonecfg.h>
340Sstevel@tonic-gate
350Sstevel@tonic-gate #ifdef __cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate
390Sstevel@tonic-gate #define E_SUCCESS 0 /* Exit status for success */
400Sstevel@tonic-gate #define E_ERROR 1 /* Exit status for error */
410Sstevel@tonic-gate #define E_USAGE 2 /* Exit status for usage error */
420Sstevel@tonic-gate
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate * Message filter levels by priority
450Sstevel@tonic-gate */
460Sstevel@tonic-gate typedef enum rcm_level {
470Sstevel@tonic-gate RCM_NONE = 0, /* No messages */
480Sstevel@tonic-gate RCM_ERR, /* Errors only */
490Sstevel@tonic-gate RCM_WARN, /* Warnings */
500Sstevel@tonic-gate RCM_INFO, /* Information */
510Sstevel@tonic-gate RCM_DEBUG, /* Everything */
520Sstevel@tonic-gate RCM_DEBUG_HIGH /* Fire hose */
530Sstevel@tonic-gate } rcm_level_t;
540Sstevel@tonic-gate
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate * Message destinations
570Sstevel@tonic-gate */
580Sstevel@tonic-gate typedef enum rcm_dst {
590Sstevel@tonic-gate RCD_STD = 1, /* Standard output/error, depending */
600Sstevel@tonic-gate /* on level */
610Sstevel@tonic-gate RCD_SYSLOG /* syslog() daemon facility */
620Sstevel@tonic-gate } rcm_dst_t;
630Sstevel@tonic-gate
643247Sgjelinek typedef struct zone_entry {
653247Sgjelinek zoneid_t zid;
663247Sgjelinek char zname[ZONENAME_MAX];
673247Sgjelinek } zone_entry_t;
683247Sgjelinek
690Sstevel@tonic-gate #define LINELEN 256 /* max. message length */
700Sstevel@tonic-gate
710Sstevel@tonic-gate #ifdef DEBUG
720Sstevel@tonic-gate #undef ASSERT
730Sstevel@tonic-gate #define ASSERT(x) (assert(x))
740Sstevel@tonic-gate #else /* !DEBUG */
750Sstevel@tonic-gate #undef ASSERT
760Sstevel@tonic-gate #define ASSERT(x) ((void)0)
770Sstevel@tonic-gate #endif /* DEBUG */
780Sstevel@tonic-gate
790Sstevel@tonic-gate #ifdef DEBUG_MSG
800Sstevel@tonic-gate extern void debug(char *, ...);
810Sstevel@tonic-gate extern void debug_high(char *, ...);
820Sstevel@tonic-gate #else /* !DEBUG_MSG */
830Sstevel@tonic-gate /*LINTED: static unused*/
debug(char * format,...)840Sstevel@tonic-gate static void debug(char *format, ...) /*ARGSUSED*/ {}
850Sstevel@tonic-gate /*LINTED: static unused*/
debug_high(char * format,...)860Sstevel@tonic-gate static void debug_high(char *format, ...) /*ARGSUSED*/ {}
870Sstevel@tonic-gate #endif /* DEBUG_MSG */
880Sstevel@tonic-gate
890Sstevel@tonic-gate extern void die(char *, ...);
900Sstevel@tonic-gate extern void info(char *, ...);
910Sstevel@tonic-gate extern rcm_level_t get_message_priority(void);
920Sstevel@tonic-gate extern rcm_level_t set_message_priority(rcm_level_t);
930Sstevel@tonic-gate extern rcm_dst_t set_message_destination(rcm_dst_t);
94*13093SRoger.Faulkner@Oracle.COM extern char *setpname(char *);
954891Svk199839 extern void warn(const char *, ...);
960Sstevel@tonic-gate extern int valid_abspath(char *);
974891Svk199839 extern void vdprintfe(int, const char *, va_list);
980Sstevel@tonic-gate extern void dprintfe(int, char *, ...);
990Sstevel@tonic-gate extern void hrt2ts(hrtime_t, timestruc_t *);
1000Sstevel@tonic-gate extern int xatoi(char *);
1013247Sgjelinek extern int get_running_zones(uint_t *, zone_entry_t **);
1020Sstevel@tonic-gate
1030Sstevel@tonic-gate #ifdef __cplusplus
1040Sstevel@tonic-gate }
1050Sstevel@tonic-gate #endif
1060Sstevel@tonic-gate
1070Sstevel@tonic-gate #endif /* _UTILS_H */
108