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
50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
70Sstevel@tonic-gate * with the License.
80Sstevel@tonic-gate *
90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate * See the License for the specific language governing permissions
120Sstevel@tonic-gate * and limitations under the License.
130Sstevel@tonic-gate *
140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate *
200Sstevel@tonic-gate * CDDL HEADER END
210Sstevel@tonic-gate */
220Sstevel@tonic-gate /*
23*1137Sarutz * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
280Sstevel@tonic-gate
290Sstevel@tonic-gate
300Sstevel@tonic-gate #include <stdio.h>
310Sstevel@tonic-gate #include <stdlib.h>
320Sstevel@tonic-gate #include <stdarg.h>
330Sstevel@tonic-gate #include <unistd.h>
340Sstevel@tonic-gate #include <time.h>
350Sstevel@tonic-gate #include <syslog.h>
360Sstevel@tonic-gate #include <errno.h>
370Sstevel@tonic-gate #include <string.h>
380Sstevel@tonic-gate #include <sys/types.h>
390Sstevel@tonic-gate #include <sys/stat.h>
400Sstevel@tonic-gate #include <sys/smedia.h>
410Sstevel@tonic-gate #include "smserver.h"
420Sstevel@tonic-gate
430Sstevel@tonic-gate #define DEBUGMSG "Level[%d]: %s"
440Sstevel@tonic-gate
450Sstevel@tonic-gate void
fatal(const char * fmt,...)460Sstevel@tonic-gate fatal(const char *fmt, ...)
470Sstevel@tonic-gate {
480Sstevel@tonic-gate va_list ap;
490Sstevel@tonic-gate
500Sstevel@tonic-gate va_start(ap, fmt);
510Sstevel@tonic-gate (void) vsyslog(LOG_DAEMON|LOG_CRIT, fmt, ap);
520Sstevel@tonic-gate va_end(ap);
530Sstevel@tonic-gate
540Sstevel@tonic-gate exit(-1);
550Sstevel@tonic-gate }
560Sstevel@tonic-gate
570Sstevel@tonic-gate void
quit(const char * fmt,...)580Sstevel@tonic-gate quit(const char *fmt, ...)
590Sstevel@tonic-gate {
600Sstevel@tonic-gate va_list ap;
610Sstevel@tonic-gate
620Sstevel@tonic-gate va_start(ap, fmt);
630Sstevel@tonic-gate (void) vsyslog(LOG_DAEMON|LOG_ERR, fmt, ap);
640Sstevel@tonic-gate va_end(ap);
650Sstevel@tonic-gate
660Sstevel@tonic-gate exit(0);
670Sstevel@tonic-gate }
680Sstevel@tonic-gate
690Sstevel@tonic-gate
700Sstevel@tonic-gate void
noise(const char * fmt,...)710Sstevel@tonic-gate noise(const char *fmt, ...)
720Sstevel@tonic-gate {
730Sstevel@tonic-gate va_list ap;
740Sstevel@tonic-gate
750Sstevel@tonic-gate va_start(ap, fmt);
760Sstevel@tonic-gate (void) vsyslog(LOG_DAEMON|LOG_WARNING, fmt, ap);
770Sstevel@tonic-gate va_end(ap);
780Sstevel@tonic-gate }
790Sstevel@tonic-gate
800Sstevel@tonic-gate void
warning(const char * fmt,...)810Sstevel@tonic-gate warning(const char *fmt, ...)
820Sstevel@tonic-gate {
830Sstevel@tonic-gate va_list ap;
840Sstevel@tonic-gate
850Sstevel@tonic-gate va_start(ap, fmt);
860Sstevel@tonic-gate (void) vsyslog(LOG_DAEMON|LOG_WARNING, fmt, ap);
870Sstevel@tonic-gate va_end(ap);
880Sstevel@tonic-gate }
890Sstevel@tonic-gate
900Sstevel@tonic-gate
910Sstevel@tonic-gate void
info(const char * fmt,...)920Sstevel@tonic-gate info(const char *fmt, ...)
930Sstevel@tonic-gate {
940Sstevel@tonic-gate extern int verbose;
950Sstevel@tonic-gate va_list ap;
960Sstevel@tonic-gate
970Sstevel@tonic-gate if (verbose == 0) {
980Sstevel@tonic-gate return;
990Sstevel@tonic-gate }
1000Sstevel@tonic-gate
1010Sstevel@tonic-gate va_start(ap, fmt);
1020Sstevel@tonic-gate (void) vsyslog(LOG_DAEMON|LOG_INFO, fmt, ap);
1030Sstevel@tonic-gate va_end(ap);
1040Sstevel@tonic-gate }
1050Sstevel@tonic-gate
1060Sstevel@tonic-gate /*PRINTFLIKE2*/
1070Sstevel@tonic-gate void
debug(uint_t level,const char * fmt,...)1080Sstevel@tonic-gate debug(uint_t level, const char *fmt, ...)
1090Sstevel@tonic-gate {
1100Sstevel@tonic-gate extern int debug_level;
1110Sstevel@tonic-gate va_list ap;
1120Sstevel@tonic-gate char dbgmsg[BUFSIZ];
1130Sstevel@tonic-gate
1140Sstevel@tonic-gate if (level > debug_level) {
1150Sstevel@tonic-gate return;
1160Sstevel@tonic-gate }
1170Sstevel@tonic-gate
1180Sstevel@tonic-gate (void) snprintf(dbgmsg, sizeof (dbgmsg), DEBUGMSG, level, fmt);
1190Sstevel@tonic-gate va_start(ap, fmt);
1200Sstevel@tonic-gate (void) vsyslog(LOG_DAEMON|LOG_DEBUG, dbgmsg, ap);
1210Sstevel@tonic-gate va_end(ap);
1220Sstevel@tonic-gate }
123