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 */ 210Sstevel@tonic-gate /* 22*4891Svk199839 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _UTILS_H 270Sstevel@tonic-gate #define _UTILS_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <assert.h> 320Sstevel@tonic-gate #include <libintl.h> 330Sstevel@tonic-gate #include <stdarg.h> 340Sstevel@tonic-gate #include <time.h> 353247Sgjelinek #include <libzonecfg.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef __cplusplus 380Sstevel@tonic-gate extern "C" { 390Sstevel@tonic-gate #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate #define E_SUCCESS 0 /* Exit status for success */ 420Sstevel@tonic-gate #define E_ERROR 1 /* Exit status for error */ 430Sstevel@tonic-gate #define E_USAGE 2 /* Exit status for usage error */ 440Sstevel@tonic-gate 450Sstevel@tonic-gate /* 460Sstevel@tonic-gate * Message filter levels by priority 470Sstevel@tonic-gate */ 480Sstevel@tonic-gate typedef enum rcm_level { 490Sstevel@tonic-gate RCM_NONE = 0, /* No messages */ 500Sstevel@tonic-gate RCM_ERR, /* Errors only */ 510Sstevel@tonic-gate RCM_WARN, /* Warnings */ 520Sstevel@tonic-gate RCM_INFO, /* Information */ 530Sstevel@tonic-gate RCM_DEBUG, /* Everything */ 540Sstevel@tonic-gate RCM_DEBUG_HIGH /* Fire hose */ 550Sstevel@tonic-gate } rcm_level_t; 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* 580Sstevel@tonic-gate * Message destinations 590Sstevel@tonic-gate */ 600Sstevel@tonic-gate typedef enum rcm_dst { 610Sstevel@tonic-gate RCD_STD = 1, /* Standard output/error, depending */ 620Sstevel@tonic-gate /* on level */ 630Sstevel@tonic-gate RCD_SYSLOG /* syslog() daemon facility */ 640Sstevel@tonic-gate } rcm_dst_t; 650Sstevel@tonic-gate 663247Sgjelinek typedef struct zone_entry { 673247Sgjelinek zoneid_t zid; 683247Sgjelinek char zname[ZONENAME_MAX]; 693247Sgjelinek } zone_entry_t; 703247Sgjelinek 710Sstevel@tonic-gate #define LINELEN 256 /* max. message length */ 720Sstevel@tonic-gate 730Sstevel@tonic-gate #ifdef DEBUG 740Sstevel@tonic-gate #undef ASSERT 750Sstevel@tonic-gate #define ASSERT(x) (assert(x)) 760Sstevel@tonic-gate #else /* !DEBUG */ 770Sstevel@tonic-gate #undef ASSERT 780Sstevel@tonic-gate #define ASSERT(x) ((void)0) 790Sstevel@tonic-gate #endif /* DEBUG */ 800Sstevel@tonic-gate 810Sstevel@tonic-gate #ifdef DEBUG_MSG 820Sstevel@tonic-gate extern void debug(char *, ...); 830Sstevel@tonic-gate extern void debug_high(char *, ...); 840Sstevel@tonic-gate #else /* !DEBUG_MSG */ 850Sstevel@tonic-gate /*LINTED: static unused*/ 860Sstevel@tonic-gate static void debug(char *format, ...) /*ARGSUSED*/ {} 870Sstevel@tonic-gate /*LINTED: static unused*/ 880Sstevel@tonic-gate static void debug_high(char *format, ...) /*ARGSUSED*/ {} 890Sstevel@tonic-gate #endif /* DEBUG_MSG */ 900Sstevel@tonic-gate 910Sstevel@tonic-gate extern void die(char *, ...); 920Sstevel@tonic-gate extern void info(char *, ...); 930Sstevel@tonic-gate extern rcm_level_t get_message_priority(void); 940Sstevel@tonic-gate extern rcm_level_t set_message_priority(rcm_level_t); 950Sstevel@tonic-gate extern rcm_dst_t set_message_destination(rcm_dst_t); 960Sstevel@tonic-gate extern char *setprogname(char *); 97*4891Svk199839 extern void warn(const char *, ...); 980Sstevel@tonic-gate extern int valid_abspath(char *); 99*4891Svk199839 extern void vdprintfe(int, const char *, va_list); 1000Sstevel@tonic-gate extern void dprintfe(int, char *, ...); 1010Sstevel@tonic-gate extern void hrt2ts(hrtime_t, timestruc_t *); 1020Sstevel@tonic-gate extern int xatoi(char *); 1033247Sgjelinek extern int get_running_zones(uint_t *, zone_entry_t **); 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate #ifdef __cplusplus 1060Sstevel@tonic-gate } 1070Sstevel@tonic-gate #endif 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate #endif /* _UTILS_H */ 110