15c51f124SMoriah Waterland /*
25c51f124SMoriah Waterland * CDDL HEADER START
35c51f124SMoriah Waterland *
45c51f124SMoriah Waterland * The contents of this file are subject to the terms of the
55c51f124SMoriah Waterland * Common Development and Distribution License (the "License").
65c51f124SMoriah Waterland * You may not use this file except in compliance with the License.
75c51f124SMoriah Waterland *
85c51f124SMoriah Waterland * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95c51f124SMoriah Waterland * or http://www.opensolaris.org/os/licensing.
105c51f124SMoriah Waterland * See the License for the specific language governing permissions
115c51f124SMoriah Waterland * and limitations under the License.
125c51f124SMoriah Waterland *
135c51f124SMoriah Waterland * When distributing Covered Code, include this CDDL HEADER in each
145c51f124SMoriah Waterland * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155c51f124SMoriah Waterland * If applicable, add the following below this CDDL HEADER, with the
165c51f124SMoriah Waterland * fields enclosed by brackets "[]" replaced with your own identifying
175c51f124SMoriah Waterland * information: Portions Copyright [yyyy] [name of copyright owner]
185c51f124SMoriah Waterland *
195c51f124SMoriah Waterland * CDDL HEADER END
205c51f124SMoriah Waterland */
215c51f124SMoriah Waterland
225c51f124SMoriah Waterland /*
235c51f124SMoriah Waterland * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
245c51f124SMoriah Waterland * Use is subject to license terms.
255c51f124SMoriah Waterland */
265c51f124SMoriah Waterland
275c51f124SMoriah Waterland /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
285c51f124SMoriah Waterland /* All Rights Reserved */
295c51f124SMoriah Waterland
305c51f124SMoriah Waterland
315c51f124SMoriah Waterland
325c51f124SMoriah Waterland #include <stdio.h>
335c51f124SMoriah Waterland #include <string.h>
345c51f124SMoriah Waterland #include <stdarg.h>
355c51f124SMoriah Waterland #include "pkglocale.h"
365c51f124SMoriah Waterland
37*4656d474SGarrett D'Amore /*PRINTFLIKE1*/
385c51f124SMoriah Waterland void
logerr(char * fmt,...)395c51f124SMoriah Waterland logerr(char *fmt, ...)
405c51f124SMoriah Waterland {
415c51f124SMoriah Waterland va_list ap;
425c51f124SMoriah Waterland char *pt, buffer[2048];
435c51f124SMoriah Waterland int flag;
445c51f124SMoriah Waterland char *estr = pkg_gt("ERROR:");
455c51f124SMoriah Waterland char *wstr = pkg_gt("WARNING:");
465c51f124SMoriah Waterland char *nstr = pkg_gt("NOTE:");
475c51f124SMoriah Waterland
485c51f124SMoriah Waterland va_start(ap, fmt);
495c51f124SMoriah Waterland flag = 0;
505c51f124SMoriah Waterland /* This may have to use the i18n strcmp() routines. */
515c51f124SMoriah Waterland if (strncmp(fmt, estr, strlen(estr)) &&
525c51f124SMoriah Waterland strncmp(fmt, wstr, strlen(wstr)) &&
535c51f124SMoriah Waterland strncmp(fmt, nstr, strlen(nstr))) {
545c51f124SMoriah Waterland flag++;
555c51f124SMoriah Waterland (void) fprintf(stderr, " ");
565c51f124SMoriah Waterland }
575c51f124SMoriah Waterland /*
585c51f124SMoriah Waterland * NOTE: internationalization in next line REQUIRES that caller of
595c51f124SMoriah Waterland * this routine be in the same internationalization domain
605c51f124SMoriah Waterland * as this library.
615c51f124SMoriah Waterland */
62*4656d474SGarrett D'Amore (void) vsnprintf(buffer, sizeof (buffer), fmt, ap);
635c51f124SMoriah Waterland
645c51f124SMoriah Waterland va_end(ap);
655c51f124SMoriah Waterland
665c51f124SMoriah Waterland for (pt = buffer; *pt; pt++) {
675c51f124SMoriah Waterland (void) putc(*pt, stderr);
685c51f124SMoriah Waterland if (flag && (*pt == '\n') && pt[1])
695c51f124SMoriah Waterland (void) fprintf(stderr, " ");
705c51f124SMoriah Waterland }
715c51f124SMoriah Waterland (void) putc('\n', stderr);
725c51f124SMoriah Waterland }
73