2 .\" Copyright 1989 AT&T Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH PFMT 3C "Dec 29, 1996"
8 pfmt \- display error message in standard format
14 \fBint\fR \fBpfmt\fR(\fBFILE *\fR\fIstream\fR, \fBlong\fR \fIflags\fR, \fBchar *\fR\fIformat\fR, \fB\&... /*\fR \fIarg */\fR);
20 The \fBpfmt()\fR retrieves a format string from a locale-specific message
21 database (unless \fBMM_NOGET\fR is specified) and uses it for \fBprintf\fR(3C)
22 style formatting of \fIargs\fR. The output is displayed on \fIstream\fR.
25 The \fBpfmt()\fR function encapsulates the output in the standard error message
26 format (unless \fBMM_NOSTD\fR is specified, in which case the output is similar
30 If the \fBprintf()\fR format string is to be retrieved from a message database,
31 the \fBformat\fR argument must have the following structure:
34 \fI<catalog>\fR\fB:\fR\fI<msgnum>\fR\fB:\fR\fI<defmsg>\fR\&.
37 If \fBMM_NOGET\fR is specified, only the \fIdefmsg\fR field must be specified.
40 The \fIcatalog\fR field is used to indicate the message database that contains
41 the localized version of the format string. This field must be limited to 14
42 characters selected from the set of all characters values, excluding \fB\e0\fR
43 (null) and the ASCII codes for \fB/\fR (slash) and \fB:\fR (colon).
46 The \fImsgnum\fR field is a positive number that indicates the index of the
47 string into the message database.
50 If the catalog does not exist in the locale (specified by the last call to
51 \fBsetlocale\fR(3C) using the \fBLC_ALL\fR or \fBLC_MESSAGES\fR categories), or
52 if the message number is out of bound, \fBpfmt()\fR will attempt to retrieve
53 the message from the C locale. If this second retrieval fails, \fBpfmt()\fR
54 uses the \fIdefmsg\fR field of the \fBformat\fR argument.
57 If \fIcatalog\fR is omitted, \fBpfmt()\fR will attempt to retrieve the string
58 from the default catalog specified by the last call to \fBsetcat\fR(3C). In
59 this case, the \fBformat\fR argument has the following structure:
62 \fB:\fR\fI<msgnum>\fR\fB:\fR\fI<defmsg>\fR\&.
65 The \fBpfmt()\fR will output \fBMessage not found!!\en\fR as format string if
66 \fIcatalog\fR is not a valid catalog name, if no catalog is specified (either
67 explicitely or with \fBsetcat()\fR), if \fImsgnum\fR is not a valid number, or
68 if no message could be retrieved from the message databases and \fIdefmsg\fR
72 The \fIflags\fR argument determine the type of output (such as whether the
73 \fBformat\fR should be interpreted as is or encapsulated in the standard
74 message format), and the access to message catalogs to retrieve a localized
75 version of \fBformat\fR.
78 The \fIflags\fR argument is composed of several groups, and can take the
79 following values (one from each group):
82 \fIOutput format control\fR
89 Do not use the standard message format, interpret \fBformat\fR as
90 \fBprintf()\fR \fBformat\fR. Only \fIcatalog access control flags\fR should be
91 specified if \fBMM_NOSTD\fR is used; all other flags will be ignored.
100 Output using the standard message format (default value 0).
105 \fICatalog access control\fR
112 Do not retrieve a localized version of \fBformat\fR. In this case, only the
113 \fIdefmsg\fR field of the \fBformat\fR is specified.
122 Retrieve a localized version of \fBformat\fR from the \fIcatalog\fR, using
123 \fImsgid\fR as the index and \fIdefmsg\fR as the default message (default value
129 \fISeverity (standard message format only)\fR
136 Generate a localized version of \fBHALT,\fR but do not halt the machine.
145 Generate a localized version of \fBERROR\fR (default value 0).
151 \fB\fBMM_WARNING\fR\fR
154 Generate a localized version of \fBWARNING.\fR
163 Generate a localized version of \fBINFO.\fR
168 Additional severities can be defined. Add-on severities can be defined with
169 number-string pairs with numeric values from the range [5-255], using
170 \fBaddsev\fR(3C). The specified severity will be generated from the bitwise
171 \fBOR\fR operation of the numeric value and other \fIflags\fR If the severity
172 is not defined, \fBpfmt()\fR uses the string \fBSEV=\fR\fIN\fR, where \fIN\fR
173 is replaced by the integer severity value passed in \fIflags\fR.
176 Multiple severities passed in \fIflags\fR will not be detected as an error. Any
177 combination of severities will be summed and the numeric value will cause the
178 display of either a severity string (if defined) or the string
179 \fBSEV=\fR\fIN\fR (if undefined).
186 \fB\fBMM_ACTION\fR\fR
189 Specify an action message. Any severity value is superseded and replaced by a
190 localized version of \fBTO FIX\fR.
193 .SH STANDARD ERROR MESSAGE FORMAT
196 The \fBpfmt()\fR function displays error messages in the following format:
200 \fIlabel\fR: \fIseverity\fR: \fItext\fR
206 If no \fIlabel\fR was defined by a call to \fBsetlabel\fR(3C), the message is
207 displayed in the format:
211 \fIseverity\fR: \fItext\fR
217 If \fBpfmt()\fR is called twice to display an error message and a helpful
218 \fIaction\fR or recovery message, the output can look like:
222 \fIlabel\fR: \fIseverity\fR: \fItext\fR\fIlabel\fR: TO FIX: \fItext\fR
237 Upon success, \fBpfmt()\fR returns the number of bytes transmitted. Upon
238 failure, it returns a negative value:
245 Write error to \fIstream\fR.
250 \fBExample 1 \fRExample of \fBpfmt()\fR function.
259 pfmt(stderr, MM_ERROR, "test:2:Cannot open file: %s\en",
262 displays the message:
264 UX:test: ERROR: Cannot open file: No such file or directory
277 pfmt(stderr, MM_ERROR, ":10:Syntax error\en");
278 pfmt(stderr, MM_ACTION, "55:Usage ...\en");
289 UX:test: ERROR: Syntax error
290 UX:test: TO FIX: Usage ...
297 Since it uses \fBgettxt\fR(3C), \fBpfmt()\fR should not be used.
301 See \fBattributes\fR(5) for descriptions of the following attributes:
309 ATTRIBUTE TYPE ATTRIBUTE VALUE
317 \fBaddsev\fR(3C), \fBgettxt\fR(3C), \fBlfmt\fR(3C), \fBprintf\fR(3C),
318 \fBsetcat\fR(3C), \fBsetlabel\fR(3C), \fBsetlocale\fR(3C), \fBattributes\fR(5),