1 1.3 riastrad /* $NetBSD: printf.c,v 1.3 2020/03/03 06:44:38 riastradh Exp $ */ 2 1.1 haad 3 1.1 haad /* 4 1.1 haad * CDDL HEADER START 5 1.1 haad * 6 1.1 haad * The contents of this file are subject to the terms of the 7 1.1 haad * Common Development and Distribution License (the "License"). 8 1.1 haad * You may not use this file except in compliance with the License. 9 1.1 haad * 10 1.1 haad * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 1.1 haad * or http://www.opensolaris.org/os/licensing. 12 1.1 haad * See the License for the specific language governing permissions 13 1.1 haad * and limitations under the License. 14 1.1 haad * 15 1.1 haad * When distributing Covered Code, include this CDDL HEADER in each 16 1.1 haad * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 1.1 haad * If applicable, add the following below this CDDL HEADER, with the 18 1.1 haad * fields enclosed by brackets "[]" replaced with your own identifying 19 1.1 haad * information: Portions Copyright [yyyy] [name of copyright owner] 20 1.1 haad * 21 1.1 haad * CDDL HEADER END 22 1.1 haad */ 23 1.1 haad /* 24 1.1 haad * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25 1.1 haad * Use is subject to license terms. 26 1.1 haad */ 27 1.1 haad 28 1.1 haad #pragma ident "%Z%%M% %I% %E% SMI" 29 1.1 haad 30 1.1 haad #include <sys/param.h> 31 1.1 haad #include <sys/types.h> 32 1.1 haad #include <sys/systm.h> 33 1.1 haad #include <sys/cmn_err.h> 34 1.1 haad 35 1.1 haad static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" }; 36 1.1 haad static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" }; 37 1.1 haad 38 1.1 haad void 39 1.1 haad vcmn_err(int ce, const char *fmt, va_list adx) 40 1.1 haad { 41 1.1 haad char buf[256]; 42 1.2 chs size_t len; 43 1.1 haad 44 1.3 riastrad if (ce == CE_PANIC) 45 1.3 riastrad vpanic(fmt, adx); 46 1.1 haad 47 1.1 haad if ((uint_t)ce < CE_IGNORE) { 48 1.1 haad strcpy(buf, ce_prefix[ce]); 49 1.2 chs len = strlen(buf); 50 1.2 chs vsnprintf(buf + len, sizeof(buf) - len, 51 1.1 haad fmt, adx); 52 1.1 haad strlcat(buf, ce_suffix[ce], sizeof(buf)); 53 1.1 haad printf("%s", buf); 54 1.1 haad } 55 1.1 haad } 56 1.1 haad 57 1.1 haad void 58 1.1 haad cmn_err(int ce, const char *fmt, ...) 59 1.1 haad { 60 1.1 haad va_list adx; 61 1.1 haad 62 1.1 haad va_start(adx, fmt); 63 1.1 haad vcmn_err(ce, fmt, adx); 64 1.1 haad va_end(adx); 65 1.1 haad } 66