xref: /dflybsd-src/lib/libc/gen/fmtmsg.3 (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino.\"
2*86d7f5d3SJohn Marino.\" Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
3*86d7f5d3SJohn Marino.\" All rights reserved.
4*86d7f5d3SJohn Marino.\"
5*86d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without
6*86d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions
7*86d7f5d3SJohn Marino.\" are met:
8*86d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright
9*86d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer.
10*86d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright
11*86d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer in the
12*86d7f5d3SJohn Marino.\"    documentation and/or other materials provided with the distribution.
13*86d7f5d3SJohn Marino.\"
14*86d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*86d7f5d3SJohn Marino.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*86d7f5d3SJohn Marino.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*86d7f5d3SJohn Marino.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*86d7f5d3SJohn Marino.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*86d7f5d3SJohn Marino.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*86d7f5d3SJohn Marino.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*86d7f5d3SJohn Marino.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*86d7f5d3SJohn Marino.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*86d7f5d3SJohn Marino.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*86d7f5d3SJohn Marino.\" SUCH DAMAGE.
25*86d7f5d3SJohn Marino.\"
26*86d7f5d3SJohn Marino.\" $FreeBSD: src/lib/libc/gen/fmtmsg.3,v 1.4 2002/12/04 18:57:44 ru Exp $
27*86d7f5d3SJohn Marino.\" $DragonFly: src/lib/libc/gen/fmtmsg.3,v 1.1 2008/10/06 21:01:37 swildner Exp $
28*86d7f5d3SJohn Marino.\"
29*86d7f5d3SJohn Marino.Dd October 6, 2008
30*86d7f5d3SJohn Marino.Dt FMTMSG 3
31*86d7f5d3SJohn Marino.Os
32*86d7f5d3SJohn Marino.Sh NAME
33*86d7f5d3SJohn Marino.Nm fmtmsg
34*86d7f5d3SJohn Marino.Nd display a detailed diagnostic message
35*86d7f5d3SJohn Marino.Sh LIBRARY
36*86d7f5d3SJohn Marino.Lb libc
37*86d7f5d3SJohn Marino.Sh SYNOPSIS
38*86d7f5d3SJohn Marino.In fmtmsg.h
39*86d7f5d3SJohn Marino.Ft int
40*86d7f5d3SJohn Marino.Fo fmtmsg
41*86d7f5d3SJohn Marino.Fa "long classification" "const char *label" "int severity"
42*86d7f5d3SJohn Marino.Fa "const char *text" "const char *action" "const char *tag"
43*86d7f5d3SJohn Marino.Fc
44*86d7f5d3SJohn Marino.Sh DESCRIPTION
45*86d7f5d3SJohn MarinoThe
46*86d7f5d3SJohn Marino.Fn fmtmsg
47*86d7f5d3SJohn Marinofunction displays a detailed diagnostic message, based on
48*86d7f5d3SJohn Marinothe supplied arguments, to
49*86d7f5d3SJohn Marino.Dv stderr
50*86d7f5d3SJohn Marinoand/or the system console.
51*86d7f5d3SJohn Marino.Pp
52*86d7f5d3SJohn MarinoThe
53*86d7f5d3SJohn Marino.Fa classification
54*86d7f5d3SJohn Marinoargument is the bitwise inclusive
55*86d7f5d3SJohn Marino.Tn OR
56*86d7f5d3SJohn Marinoof zero or one of the manifest constants from
57*86d7f5d3SJohn Marinoeach of the classification groups below.
58*86d7f5d3SJohn MarinoThe Output classification group is an exception since both
59*86d7f5d3SJohn Marino.Dv MM_PRINT
60*86d7f5d3SJohn Marinoand
61*86d7f5d3SJohn Marino.Dv MM_CONSOLE
62*86d7f5d3SJohn Marinomay be specified.
63*86d7f5d3SJohn Marino.Bl -tag -width indent
64*86d7f5d3SJohn Marino.It Output
65*86d7f5d3SJohn Marino.Bl -tag -width ".Dv MM_CONSOLE"
66*86d7f5d3SJohn Marino.It Dv MM_PRINT
67*86d7f5d3SJohn MarinoOutput should take place on
68*86d7f5d3SJohn Marino.Dv stderr .
69*86d7f5d3SJohn Marino.It Dv MM_CONSOLE
70*86d7f5d3SJohn MarinoOutput should take place on the system console.
71*86d7f5d3SJohn Marino.El
72*86d7f5d3SJohn Marino.It "Source of Condition (Major)"
73*86d7f5d3SJohn Marino.Bl -tag -width ".Dv MM_CONSOLE"
74*86d7f5d3SJohn Marino.It Dv MM_HARD
75*86d7f5d3SJohn MarinoThe source of the condition is hardware related.
76*86d7f5d3SJohn Marino.It Dv MM_SOFT
77*86d7f5d3SJohn MarinoThe source of the condition is software related.
78*86d7f5d3SJohn Marino.It Dv MM_FIRM
79*86d7f5d3SJohn MarinoThe source of the condition is firmware related.
80*86d7f5d3SJohn Marino.El
81*86d7f5d3SJohn Marino.It "Source of Condition (Minor)"
82*86d7f5d3SJohn Marino.Bl -tag -width ".Dv MM_CONSOLE"
83*86d7f5d3SJohn Marino.It Dv MM_APPL
84*86d7f5d3SJohn MarinoThe condition was detected at the application level.
85*86d7f5d3SJohn Marino.It Dv MM_UTIL
86*86d7f5d3SJohn MarinoThe condition was detected at the utility level.
87*86d7f5d3SJohn Marino.It Dv MM_OPSYS
88*86d7f5d3SJohn MarinoThe condition was detected at the operating system level.
89*86d7f5d3SJohn Marino.El
90*86d7f5d3SJohn Marino.It Status
91*86d7f5d3SJohn Marino.Bl -tag -width ".Dv MM_CONSOLE"
92*86d7f5d3SJohn Marino.It Dv MM_RECOVER
93*86d7f5d3SJohn MarinoThe application can recover from the condition.
94*86d7f5d3SJohn Marino.It Dv MM_NRECOV
95*86d7f5d3SJohn MarinoThe application is unable to recover from the condition.
96*86d7f5d3SJohn Marino.El
97*86d7f5d3SJohn Marino.El
98*86d7f5d3SJohn Marino.Pp
99*86d7f5d3SJohn MarinoAlternatively, the
100*86d7f5d3SJohn Marino.Dv MM_NULLMC
101*86d7f5d3SJohn Marinomanifest constant may be used to specify no classification.
102*86d7f5d3SJohn Marino.Pp
103*86d7f5d3SJohn MarinoThe
104*86d7f5d3SJohn Marino.Fa label
105*86d7f5d3SJohn Marinoargument indicates the source of the message.
106*86d7f5d3SJohn MarinoIt is made up of two fields separated by a colon
107*86d7f5d3SJohn Marino.Pq Ql \&: .
108*86d7f5d3SJohn MarinoThe first field can be up to 10 bytes,
109*86d7f5d3SJohn Marinoand the second field can be up to 14 bytes.
110*86d7f5d3SJohn MarinoThe
111*86d7f5d3SJohn Marino.Dv MM_NULLLBL
112*86d7f5d3SJohn Marinomanifest constant may be used to specify no label.
113*86d7f5d3SJohn Marino.Pp
114*86d7f5d3SJohn MarinoThe
115*86d7f5d3SJohn Marino.Fa severity
116*86d7f5d3SJohn Marinoargument identifies the importance of the condition.
117*86d7f5d3SJohn MarinoOne of the following manifest constants should be used for this argument.
118*86d7f5d3SJohn Marino.Bl -tag -offset indent -width ".Dv MM_WARNING"
119*86d7f5d3SJohn Marino.It Dv MM_HALT
120*86d7f5d3SJohn MarinoThe application has confronted a serious fault and is halting.
121*86d7f5d3SJohn Marino.It Dv MM_ERROR
122*86d7f5d3SJohn MarinoThe application has detected a fault.
123*86d7f5d3SJohn Marino.It Dv MM_WARNING
124*86d7f5d3SJohn MarinoThe application has detected an unusual condition,
125*86d7f5d3SJohn Marinothat could be indicative of a problem.
126*86d7f5d3SJohn Marino.It Dv MM_INFO
127*86d7f5d3SJohn MarinoThe application is providing information about a non-error condition.
128*86d7f5d3SJohn Marino.It Dv MM_NOSEV
129*86d7f5d3SJohn MarinoNo severity level supplied.
130*86d7f5d3SJohn Marino.El
131*86d7f5d3SJohn Marino.Pp
132*86d7f5d3SJohn MarinoThe
133*86d7f5d3SJohn Marino.Fa text
134*86d7f5d3SJohn Marinoargument details the error condition that caused the message.
135*86d7f5d3SJohn MarinoThere is no limit on the size of this character string.
136*86d7f5d3SJohn MarinoThe
137*86d7f5d3SJohn Marino.Dv MM_NULLTXT
138*86d7f5d3SJohn Marinomanifest constant may be used to specify no text.
139*86d7f5d3SJohn Marino.Pp
140*86d7f5d3SJohn MarinoThe
141*86d7f5d3SJohn Marino.Fa action
142*86d7f5d3SJohn Marinoargument details how the error-recovery process should begin.
143*86d7f5d3SJohn MarinoUpon output,
144*86d7f5d3SJohn Marino.Fn fmtmsg
145*86d7f5d3SJohn Marinowill prefix
146*86d7f5d3SJohn Marino.Qq Li "TO FIX:"
147*86d7f5d3SJohn Marinoto the beginning of the
148*86d7f5d3SJohn Marino.Fa action
149*86d7f5d3SJohn Marinoargument.
150*86d7f5d3SJohn MarinoThe
151*86d7f5d3SJohn Marino.Dv MM_NULLACT
152*86d7f5d3SJohn Marinomanifest constant may be used to specify no action.
153*86d7f5d3SJohn Marino.Pp
154*86d7f5d3SJohn MarinoThe
155*86d7f5d3SJohn Marino.Fa tag
156*86d7f5d3SJohn Marinoargument should reference online documentation for the message.
157*86d7f5d3SJohn MarinoThis usually includes the
158*86d7f5d3SJohn Marino.Fa label
159*86d7f5d3SJohn Marinoand a unique identifying number.
160*86d7f5d3SJohn MarinoAn example tag is
161*86d7f5d3SJohn Marino.Qq Li BSD:ls:168 .
162*86d7f5d3SJohn MarinoThe
163*86d7f5d3SJohn Marino.Dv MM_NULLTAG
164*86d7f5d3SJohn Marinomanifest constant may be used to specify no tag.
165*86d7f5d3SJohn Marino.Sh RETURN VALUES
166*86d7f5d3SJohn MarinoThe
167*86d7f5d3SJohn Marino.Fn fmtmsg
168*86d7f5d3SJohn Marinofunction returns
169*86d7f5d3SJohn Marino.Dv MM_OK
170*86d7f5d3SJohn Marinoupon success,
171*86d7f5d3SJohn Marino.Dv MM_NOMSG
172*86d7f5d3SJohn Marinoto indicate output to
173*86d7f5d3SJohn Marino.Dv stderr
174*86d7f5d3SJohn Marinofailed,
175*86d7f5d3SJohn Marino.Dv MM_NOCON
176*86d7f5d3SJohn Marinoto indicate output to the system console failed, or
177*86d7f5d3SJohn Marino.Dv MM_NOTOK
178*86d7f5d3SJohn Marinoto indicate output to
179*86d7f5d3SJohn Marino.Dv stderr
180*86d7f5d3SJohn Marinoand the system console failed.
181*86d7f5d3SJohn Marino.Sh ENVIRONMENT
182*86d7f5d3SJohn MarinoThe
183*86d7f5d3SJohn Marino.Ev MSGVERB
184*86d7f5d3SJohn Marino(message verbosity)
185*86d7f5d3SJohn Marinoenvironment variable specifies which arguments to
186*86d7f5d3SJohn Marino.Fn fmtmsg
187*86d7f5d3SJohn Marinowill be output to
188*86d7f5d3SJohn Marino.Dv stderr ,
189*86d7f5d3SJohn Marinoand in which order.
190*86d7f5d3SJohn Marino.Ev MSGVERB
191*86d7f5d3SJohn Marinoshould be a colon
192*86d7f5d3SJohn Marino.Pq Ql \&:
193*86d7f5d3SJohn Marinoseparated list of identifiers.
194*86d7f5d3SJohn MarinoValid identifiers include:
195*86d7f5d3SJohn Marino.Li label , severity , text , action ,
196*86d7f5d3SJohn Marinoand
197*86d7f5d3SJohn Marino.Li tag .
198*86d7f5d3SJohn MarinoIf invalid identifiers are specified or incorrectly separated,
199*86d7f5d3SJohn Marinothe default message verbosity and ordering will be used.
200*86d7f5d3SJohn MarinoThe default ordering is equivalent to a
201*86d7f5d3SJohn Marino.Ev MSGVERB
202*86d7f5d3SJohn Marinowith a value of
203*86d7f5d3SJohn Marino.Qq Li label:severity:text:action:tag .
204*86d7f5d3SJohn Marino.Sh EXAMPLES
205*86d7f5d3SJohn MarinoThe code:
206*86d7f5d3SJohn Marino.Bd -literal -offset indent
207*86d7f5d3SJohn Marinofmtmsg(MM_UTIL | MM_PRINT, "BSD:ls", MM_ERROR,
208*86d7f5d3SJohn Marino    "illegal option -- z", "refer to manual", "BSD:ls:001");
209*86d7f5d3SJohn Marino.Ed
210*86d7f5d3SJohn Marino.Pp
211*86d7f5d3SJohn Marinowill output:
212*86d7f5d3SJohn Marino.Bd -literal -offset indent
213*86d7f5d3SJohn MarinoBSD:ls: ERROR: illegal option -- z
214*86d7f5d3SJohn MarinoTO FIX: refer to manual BSD:ls:001
215*86d7f5d3SJohn Marino.Ed
216*86d7f5d3SJohn Marino.Pp
217*86d7f5d3SJohn Marinoto
218*86d7f5d3SJohn Marino.Dv stderr .
219*86d7f5d3SJohn Marino.Pp
220*86d7f5d3SJohn MarinoThe same code, with
221*86d7f5d3SJohn Marino.Ev MSGVERB
222*86d7f5d3SJohn Marinoset to
223*86d7f5d3SJohn Marino.Qq Li "text:severity:action:tag" ,
224*86d7f5d3SJohn Marinoproduces:
225*86d7f5d3SJohn Marino.Bd -literal -offset indent
226*86d7f5d3SJohn Marinoillegal option -- z: ERROR
227*86d7f5d3SJohn MarinoTO FIX: refer to manual BSD:ls:001
228*86d7f5d3SJohn Marino.Ed
229*86d7f5d3SJohn Marino.Sh SEE ALSO
230*86d7f5d3SJohn Marino.Xr err 3 ,
231*86d7f5d3SJohn Marino.Xr exit 3 ,
232*86d7f5d3SJohn Marino.Xr strerror 3
233*86d7f5d3SJohn Marino.Sh STANDARDS
234*86d7f5d3SJohn MarinoThe
235*86d7f5d3SJohn Marino.Fn fmtmsg
236*86d7f5d3SJohn Marinofunction conforms to
237*86d7f5d3SJohn Marino.St -p1003.1-2001 .
238*86d7f5d3SJohn Marino.Sh HISTORY
239*86d7f5d3SJohn MarinoThe
240*86d7f5d3SJohn Marino.Fn fmtmsg
241*86d7f5d3SJohn Marinofunction first appeared in
242*86d7f5d3SJohn Marino.Fx 5.0 .
243*86d7f5d3SJohn MarinoIt was imported into
244*86d7f5d3SJohn Marino.Dx 2.1 .
245*86d7f5d3SJohn Marino.Sh BUGS
246*86d7f5d3SJohn MarinoSpecifying
247*86d7f5d3SJohn Marino.Dv MM_NULLMC
248*86d7f5d3SJohn Marinofor the
249*86d7f5d3SJohn Marino.Fa classification
250*86d7f5d3SJohn Marinoargument makes little sense, since without an output specified,
251*86d7f5d3SJohn Marino.Fn fmtmsg
252*86d7f5d3SJohn Marinois unable to do anything useful.
253*86d7f5d3SJohn Marino.Pp
254*86d7f5d3SJohn MarinoIn order for
255*86d7f5d3SJohn Marino.Fn fmtmsg
256*86d7f5d3SJohn Marinoto output to the system console, the effective
257*86d7f5d3SJohn Marinouser must have appropriate permission to write to
258*86d7f5d3SJohn Marino.Pa /dev/console .
259*86d7f5d3SJohn MarinoThis means that on most systems
260*86d7f5d3SJohn Marino.Fn fmtmsg
261*86d7f5d3SJohn Marinowill return
262*86d7f5d3SJohn Marino.Dv MM_NOCON
263*86d7f5d3SJohn Marinounless the effective user is root.
264