dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / mdb / common / kmdb / kctl / kctl_err.c
blobbeab90ac09969c767a4761f27f2fc462054c8107
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
30 #include <sys/cmn_err.h>
31 #include <sys/varargs.h>
32 #include <sys/bootconf.h>
33 #include <sys/sysmacros.h>
34 #include <sys/kmdb.h>
37 * The boot printing interfaces don't expose anything that'll allow us
38 * to print multiple arguments at once. That is, they expose printf-like
39 * interfaces, but these interfaces only support one format specifier per
40 * invocation. The routines in this file allow the rest of the driver
41 * to pretend that this limitation doesn't exist.
44 #include <kmdb/kctl/kctl.h>
46 static void
47 kctl_vprintf(int code, const char *format, va_list ap)
49 if (kctl.kctl_boot_ops == NULL) {
50 vcmn_err(code, format, ap);
52 } else {
53 char buf[128];
55 if (code == CE_WARN)
56 BOP_PUTSARG(kctl.kctl_boot_ops, "WARNING: ", NULL);
57 else if (code == CE_NOTE)
58 BOP_PUTSARG(kctl.kctl_boot_ops, "NOTE: ", NULL);
60 (void) vsnprintf(buf, sizeof (buf), format, ap);
61 BOP_PUTSARG(kctl.kctl_boot_ops, "%s\n", buf);
65 void
66 kctl_warn(const char *format, ...)
68 va_list ap;
70 va_start(ap, format);
71 kctl_vprintf(CE_WARN, format, ap);
72 va_end(ap);
75 void
76 kctl_dprintf(const char *format, ...)
78 va_list ap;
80 if (!(kctl.kctl_flags & KMDB_F_DRV_DEBUG))
81 return;
83 va_start(ap, format);
84 kctl_vprintf(CE_NOTE, format, ap);
85 va_end(ap);