17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
50209230bSgjelinek * Common Development and Distribution License (the "License").
60209230bSgjelinek * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
21*23a1cceaSRoger A. Faulkner
227c478bd9Sstevel@tonic-gate /*
23*23a1cceaSRoger A. Faulkner * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #ifndef _UTILS_H
277c478bd9Sstevel@tonic-gate #define _UTILS_H
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate #include <assert.h>
307c478bd9Sstevel@tonic-gate #include <libintl.h>
317c478bd9Sstevel@tonic-gate #include <stdarg.h>
327c478bd9Sstevel@tonic-gate #include <time.h>
330209230bSgjelinek #include <libzonecfg.h>
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate #ifdef __cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate #define E_SUCCESS 0 /* Exit status for success */
407c478bd9Sstevel@tonic-gate #define E_ERROR 1 /* Exit status for error */
417c478bd9Sstevel@tonic-gate #define E_USAGE 2 /* Exit status for usage error */
427c478bd9Sstevel@tonic-gate
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate * Message filter levels by priority
457c478bd9Sstevel@tonic-gate */
467c478bd9Sstevel@tonic-gate typedef enum rcm_level {
477c478bd9Sstevel@tonic-gate RCM_NONE = 0, /* No messages */
487c478bd9Sstevel@tonic-gate RCM_ERR, /* Errors only */
497c478bd9Sstevel@tonic-gate RCM_WARN, /* Warnings */
507c478bd9Sstevel@tonic-gate RCM_INFO, /* Information */
517c478bd9Sstevel@tonic-gate RCM_DEBUG, /* Everything */
527c478bd9Sstevel@tonic-gate RCM_DEBUG_HIGH /* Fire hose */
537c478bd9Sstevel@tonic-gate } rcm_level_t;
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate * Message destinations
577c478bd9Sstevel@tonic-gate */
587c478bd9Sstevel@tonic-gate typedef enum rcm_dst {
597c478bd9Sstevel@tonic-gate RCD_STD = 1, /* Standard output/error, depending */
607c478bd9Sstevel@tonic-gate /* on level */
617c478bd9Sstevel@tonic-gate RCD_SYSLOG /* syslog() daemon facility */
627c478bd9Sstevel@tonic-gate } rcm_dst_t;
637c478bd9Sstevel@tonic-gate
640209230bSgjelinek typedef struct zone_entry {
650209230bSgjelinek zoneid_t zid;
660209230bSgjelinek char zname[ZONENAME_MAX];
670209230bSgjelinek } zone_entry_t;
680209230bSgjelinek
697c478bd9Sstevel@tonic-gate #define LINELEN 256 /* max. message length */
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gate #ifdef DEBUG
727c478bd9Sstevel@tonic-gate #undef ASSERT
737c478bd9Sstevel@tonic-gate #define ASSERT(x) (assert(x))
747c478bd9Sstevel@tonic-gate #else /* !DEBUG */
757c478bd9Sstevel@tonic-gate #undef ASSERT
767c478bd9Sstevel@tonic-gate #define ASSERT(x) ((void)0)
777c478bd9Sstevel@tonic-gate #endif /* DEBUG */
787c478bd9Sstevel@tonic-gate
797c478bd9Sstevel@tonic-gate #ifdef DEBUG_MSG
807c478bd9Sstevel@tonic-gate extern void debug(char *, ...);
817c478bd9Sstevel@tonic-gate extern void debug_high(char *, ...);
827c478bd9Sstevel@tonic-gate #else /* !DEBUG_MSG */
837c478bd9Sstevel@tonic-gate /*LINTED: static unused*/
debug(char * format,...)847c478bd9Sstevel@tonic-gate static void debug(char *format, ...) /*ARGSUSED*/ {}
857c478bd9Sstevel@tonic-gate /*LINTED: static unused*/
debug_high(char * format,...)867c478bd9Sstevel@tonic-gate static void debug_high(char *format, ...) /*ARGSUSED*/ {}
877c478bd9Sstevel@tonic-gate #endif /* DEBUG_MSG */
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate extern void die(char *, ...);
907c478bd9Sstevel@tonic-gate extern void info(char *, ...);
917c478bd9Sstevel@tonic-gate extern rcm_level_t get_message_priority(void);
927c478bd9Sstevel@tonic-gate extern rcm_level_t set_message_priority(rcm_level_t);
937c478bd9Sstevel@tonic-gate extern rcm_dst_t set_message_destination(rcm_dst_t);
94*23a1cceaSRoger A. Faulkner extern char *setpname(char *);
95d362b749Svk199839 extern void warn(const char *, ...);
967c478bd9Sstevel@tonic-gate extern int valid_abspath(char *);
97d362b749Svk199839 extern void vdprintfe(int, const char *, va_list);
987c478bd9Sstevel@tonic-gate extern void dprintfe(int, char *, ...);
997c478bd9Sstevel@tonic-gate extern void hrt2ts(hrtime_t, timestruc_t *);
1007c478bd9Sstevel@tonic-gate extern int xatoi(char *);
1010209230bSgjelinek extern int get_running_zones(uint_t *, zone_entry_t **);
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1047c478bd9Sstevel@tonic-gate }
1057c478bd9Sstevel@tonic-gate #endif
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate #endif /* _UTILS_H */
108