4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * pfmt_print() - format and print
43 #include "pfmt_data.h"
45 /* Catalogue for local messages */
46 #define fmt_cat "uxlibc"
47 #define def_colon ": "
50 /* Table of default severities */
51 static const char *sev_list
[] = {
61 __pfmt_print(FILE *stream
, long flag
, const char *format
,
62 const char **text_ptr
, const char **sev_ptr
, va_list args
)
65 char catbuf
[DB_NAME_LEN
];
69 int dofmt
= (flag
& (long)MM_NOSTD
) == 0;
70 long doact
= (flag
& (long)MM_ACTION
);
72 if (format
&& !(flag
& (long)MM_NOGET
)) {
75 for (i
= 0; i
< DB_NAME_LEN
- 1 && (c
= *ptr
++) && c
!= ':';
78 /* Extract the message number */
79 if (i
!= DB_NAME_LEN
- 1 && c
) {
81 while (isdigit(c
= *ptr
++)) {
90 format
= __gtxt(catbuf
, txtmsgnum
, ptr
);
98 int severity
, sev
, d_sev
;
99 const char *psev
= NULL
, *colon
;
101 lrw_rdlock(&_rw_pfmt_label
);
102 (void) strlcpy(label
, __pfmt_label
, MAXLABEL
);
103 lrw_unlock(&_rw_pfmt_label
);
105 colon
= __gtxt(fmt_cat
, def_colonid
, def_colon
);
107 if (label
[0] != '\0' && stream
) {
108 if ((status
= fputs(label
, stream
)) < 0)
111 if ((status
= fputs(colon
, stream
)) < 0)
116 severity
= (int)(flag
& 0xff);
120 } else if (severity
<= MM_INFO
) {
122 d_sev
= severity
+ 2;
125 lrw_rdlock(&_rw_pfmt_sev_tab
);
126 for (i
= 0; i
< __pfmt_nsev
; i
++) {
127 if (__pfmt_sev_tab
[i
].severity
== severity
) {
128 psev
= __pfmt_sev_tab
[i
].string
;
133 lrw_unlock(&_rw_pfmt_sev_tab
);
134 if (i
== __pfmt_nsev
)
139 psev
= __gtxt(fmt_cat
, sev
, sev_list
[d_sev
]);
146 if ((status
= fprintf(stream
, psev
, severity
)) < 0)
149 if ((status
= fputs(colon
, stream
)) < 0)
158 if ((status
= vfprintf(stream
, format
, args
)) < 0)