xref: /freebsd/lib/libc/gen/fmtmsg.3 (revision 823f68a28a501b4c919e2dd0327af1fd3503d3da)
1823f68a2SMike Barcroft.\"
2823f68a2SMike Barcroft.\" Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
3823f68a2SMike Barcroft.\" All rights reserved.
4823f68a2SMike Barcroft.\"
5823f68a2SMike Barcroft.\" Redistribution and use in source and binary forms, with or without
6823f68a2SMike Barcroft.\" modification, are permitted provided that the following conditions
7823f68a2SMike Barcroft.\" are met:
8823f68a2SMike Barcroft.\" 1. Redistributions of source code must retain the above copyright
9823f68a2SMike Barcroft.\"    notice, this list of conditions and the following disclaimer.
10823f68a2SMike Barcroft.\" 2. Redistributions in binary form must reproduce the above copyright
11823f68a2SMike Barcroft.\"    notice, this list of conditions and the following disclaimer in the
12823f68a2SMike Barcroft.\"    documentation and/or other materials provided with the distribution.
13823f68a2SMike Barcroft.\"
14823f68a2SMike Barcroft.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15823f68a2SMike Barcroft.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16823f68a2SMike Barcroft.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17823f68a2SMike Barcroft.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18823f68a2SMike Barcroft.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19823f68a2SMike Barcroft.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20823f68a2SMike Barcroft.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21823f68a2SMike Barcroft.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22823f68a2SMike Barcroft.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23823f68a2SMike Barcroft.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24823f68a2SMike Barcroft.\" SUCH DAMAGE.
25823f68a2SMike Barcroft.\"
26823f68a2SMike Barcroft.\" $FreeBSD$
27823f68a2SMike Barcroft.\"
28823f68a2SMike Barcroft.Dd August 5, 2002
29823f68a2SMike Barcroft.Dt FMTMSG 3
30823f68a2SMike Barcroft.Os
31823f68a2SMike Barcroft.Sh NAME
32823f68a2SMike Barcroft.Nm fmtmsg
33823f68a2SMike Barcroft.Nd display a detailed diagnostic message
34823f68a2SMike Barcroft.Sh LIBRARY
35823f68a2SMike Barcroft.Lb libc
36823f68a2SMike Barcroft.Sh SYNOPSIS
37823f68a2SMike Barcroft.In fmtmsg.h
38823f68a2SMike Barcroft.Ft int
39823f68a2SMike Barcroft.Fn fmtmsg "long classification" "const char *label" "int severity" "const char *text" "const char *action" "const char *tag"
40823f68a2SMike Barcroft.Sh DESCRIPTION
41823f68a2SMike BarcroftThe
42823f68a2SMike Barcroft.Fn fmtmsg
43823f68a2SMike Barcroftfunction displays a detailed diagnostic message, based on
44823f68a2SMike Barcroftthe supplied augments, to
45823f68a2SMike Barcroft.Em stderr
46823f68a2SMike Barcroftand/or the system console.
47823f68a2SMike Barcroft.Pp
48823f68a2SMike BarcroftThe
49823f68a2SMike Barcroft.Fa classification
50823f68a2SMike Barcroftargument is the bitwise inclusive
51823f68a2SMike Barcroft.Tn OR
52823f68a2SMike Barcroftof zero or one of the manifest constants from
53823f68a2SMike Barcrofteach of the classification groups below.
54823f68a2SMike BarcroftThe Output classification group is an exception since both
55823f68a2SMike Barcroft.Dv MM_PRINT
56823f68a2SMike Barcroftand
57823f68a2SMike Barcroft.Dv MM_CONSOLE
58823f68a2SMike Barcroftmay be specified.
59823f68a2SMike Barcroft.Pp
60823f68a2SMike BarcroftOutput
61823f68a2SMike Barcroft.Bl -tag -offset indent -width MM_CONSOLE
62823f68a2SMike Barcroft.It Dv MM_PRINT
63823f68a2SMike BarcroftOutput should take place on
64823f68a2SMike Barcroft.Em stderr .
65823f68a2SMike Barcroft.It Dv MM_CONSOLE
66823f68a2SMike BarcroftOutput should take place on the system console.
67823f68a2SMike Barcroft.El
68823f68a2SMike Barcroft.Pp
69823f68a2SMike BarcroftSource of Condition (Major)
70823f68a2SMike Barcroft.Bl -tag -offset indent -width MM_CONSOLE
71823f68a2SMike Barcroft.It Dv MM_HARD
72823f68a2SMike BarcroftThe source of the condition is hardware related.
73823f68a2SMike Barcroft.It Dv MM_SOFT
74823f68a2SMike BarcroftThe source of the condition is software related.
75823f68a2SMike Barcroft.It Dv MM_FIRM
76823f68a2SMike BarcroftThe source of the condition is firmware related.
77823f68a2SMike Barcroft.El
78823f68a2SMike Barcroft.Pp
79823f68a2SMike BarcroftSource of Condition (Minor)
80823f68a2SMike Barcroft.Bl -tag -offset indent -width MM_CONSOLE
81823f68a2SMike Barcroft.It Dv MM_APPL
82823f68a2SMike BarcroftThe condition was detected at the application level.
83823f68a2SMike Barcroft.It Dv MM_UTIL
84823f68a2SMike BarcroftThe condition was detected at the utility level.
85823f68a2SMike Barcroft.It Dv MM_OPSYS
86823f68a2SMike BarcroftThe condition was detected at the operating system level.
87823f68a2SMike Barcroft.El
88823f68a2SMike Barcroft.Pp
89823f68a2SMike BarcroftStatus
90823f68a2SMike Barcroft.Bl -tag -offset indent -width MM_CONSOLE
91823f68a2SMike Barcroft.It Dv MM_RECOVER
92823f68a2SMike BarcroftThe application can recover from the condition.
93823f68a2SMike Barcroft.It Dv MM_NRECOV
94823f68a2SMike BarcroftThe application is unable to recover from the condition.
95823f68a2SMike Barcroft.El
96823f68a2SMike Barcroft.Pp
97823f68a2SMike BarcroftAlternatively, the
98823f68a2SMike Barcroft.Dv MM_NULLMC
99823f68a2SMike Barcroftmanifest constant may be used to specify no classification.
100823f68a2SMike Barcroft.Pp
101823f68a2SMike BarcroftThe
102823f68a2SMike Barcroft.Fa label
103823f68a2SMike Barcroftargument indicates the source of the message.
104823f68a2SMike BarcroftIt is made up of two fields seperated by a colon
105823f68a2SMike Barcroft.Pq \&: .
106823f68a2SMike BarcroftThe first field can be up to 10 bytes,
107823f68a2SMike Barcroftand the second field can be up to 14 bytes.
108823f68a2SMike BarcroftThe
109823f68a2SMike Barcroft.Dv MM_NULLLBL
110823f68a2SMike Barcroftmanifest constant may be used to specify no label.
111823f68a2SMike Barcroft.Pp
112823f68a2SMike BarcroftThe
113823f68a2SMike Barcroft.Fa severity
114823f68a2SMike Barcroftargument identifies the importance of the condition.
115823f68a2SMike BarcroftOne of the following manifest constants should be used for this argument.
116823f68a2SMike Barcroft.Bl -tag -offset indent -width MM_WARNING
117823f68a2SMike Barcroft.It Dv MM_HALT
118823f68a2SMike BarcroftThe application has confronted a serious fault and is halting.
119823f68a2SMike Barcroft.It Dv MM_ERROR
120823f68a2SMike BarcroftThe application has detected a fault.
121823f68a2SMike Barcroft.It Dv MM_WARNING
122823f68a2SMike BarcroftThe application has detected an unusual condition,
123823f68a2SMike Barcroftthat could be indicative of a problem.
124823f68a2SMike Barcroft.It Dv MM_INFO
125823f68a2SMike BarcroftThe application is providing information about a non-error condition.
126823f68a2SMike Barcroft.It Dv MM_NOSEV
127823f68a2SMike BarcroftNo severity level supplied.
128823f68a2SMike Barcroft.El
129823f68a2SMike Barcroft.Pp
130823f68a2SMike BarcroftThe
131823f68a2SMike Barcroft.Fa text
132823f68a2SMike Barcroftargument details the error condition that caused the message.
133823f68a2SMike BarcroftThere is no limit on the size of this character string.
134823f68a2SMike BarcroftThe
135823f68a2SMike Barcroft.Dv MM_NULLTXT
136823f68a2SMike Barcroftmanifest constant may be used to specify no text.
137823f68a2SMike Barcroft.Pp
138823f68a2SMike BarcroftThe
139823f68a2SMike Barcroft.Fa action
140823f68a2SMike Barcroftargument details how the error-recovery process should begin.
141823f68a2SMike BarcroftUpon output,
142823f68a2SMike Barcroft.Fn fmtmsg
143823f68a2SMike Barcroftwill prefix
144823f68a2SMike Barcroft.Qq TO FIX:
145823f68a2SMike Barcroftto the begin of the
146823f68a2SMike Barcroft.Fa action
147823f68a2SMike Barcroftargument.
148823f68a2SMike BarcroftThe
149823f68a2SMike Barcroft.Dv MM_NULLACT
150823f68a2SMike Barcroftmanifest constant may be used to specify no action.
151823f68a2SMike Barcroft.Pp
152823f68a2SMike BarcroftThe
153823f68a2SMike Barcroft.Fa tag
154823f68a2SMike Barcroftargument should reference online documentation for the message.
155823f68a2SMike BarcroftThis usually includes the
156823f68a2SMike Barcroft.Fa label
157823f68a2SMike Barcroftand a unique identifying number.
158823f68a2SMike BarcroftAn example tag is
159823f68a2SMike Barcroft.Qq BSD:ls:168 .
160823f68a2SMike BarcroftThe
161823f68a2SMike Barcroft.Dv MM_NULLTAG
162823f68a2SMike Barcroftmanifest constant may be used to specify no tag.
163823f68a2SMike Barcroft.Sh RETURN VALUES
164823f68a2SMike BarcroftThe
165823f68a2SMike Barcroft.Fn fmtmsg
166823f68a2SMike Barcroftfunction returns
167823f68a2SMike Barcroft.Dv MM_OK
168823f68a2SMike Barcroftupon success,
169823f68a2SMike Barcroft.Dv MM_NOMSG
170823f68a2SMike Barcroftto indicate output to
171823f68a2SMike Barcroft.Em stderr
172823f68a2SMike Barcroftfailed,
173823f68a2SMike Barcroft.Dv MM_NOCON
174823f68a2SMike Barcroftto indicate output to the system console failed, or
175823f68a2SMike Barcroft.Dv MM_NOTOK
176823f68a2SMike Barcroftto indicate output to
177823f68a2SMike Barcroft.Em stderr
178823f68a2SMike Barcroftand the system console failed.
179823f68a2SMike Barcroft.Sh ENVIRONMENT
180823f68a2SMike BarcroftThe
181823f68a2SMike Barcroft.Va MSGVERB
182823f68a2SMike Barcroft.Pq message verbosity
183823f68a2SMike Barcroftenvironment variable specifies which arguments to
184823f68a2SMike Barcroft.Fn fmtmsg
185823f68a2SMike Barcroftwill be outputted to
186823f68a2SMike Barcroft.Em stderr ,
187823f68a2SMike Barcroftand in which order.
188823f68a2SMike Barcroft.Va MSGVERB
189823f68a2SMike Barcroftshould be a colon
190823f68a2SMike Barcroft.Pq \&:
191823f68a2SMike Barcroftseperated list of identifiers.
192823f68a2SMike BarcroftValid identifiers include: label, severity, text, action, and tag.
193823f68a2SMike BarcroftIf invalid identifiers are specified or incorrectly seperated,
194823f68a2SMike Barcroftthe default message verbosity and ordering will be used.
195823f68a2SMike BarcroftThe default ordering is equivalent to a
196823f68a2SMike Barcroft.Va MSGVERB
197823f68a2SMike Barcroftwith a value of
198823f68a2SMike Barcroft.Qq label:severity:text:action:tag .
199823f68a2SMike Barcroft.Sh EXAMPLES
200823f68a2SMike BarcroftThe code:
201823f68a2SMike Barcroft.Bd -literal -offset indent
202823f68a2SMike Barcroftfmtmsg(MM_UTIL | MM_PRINT, "BSD:ls", MM_ERROR,
203823f68a2SMike Barcroft    "illegal option -- z", "refer to manual", "BSD:ls:001");
204823f68a2SMike Barcroft.Ed
205823f68a2SMike Barcroft.Pp
206823f68a2SMike Barcroftwill output:
207823f68a2SMike Barcroft.Bd -literal -offset indent
208823f68a2SMike BarcroftBSD:ls: ERROR: illegal option -- z
209823f68a2SMike BarcroftTO FIX: refer to manual BSD:ls:001
210823f68a2SMike Barcroft.Ed
211823f68a2SMike Barcroft.Pp
212823f68a2SMike Barcroftto
213823f68a2SMike Barcroft.Em stderr .
214823f68a2SMike Barcroft.Pp
215823f68a2SMike BarcroftThe same code, with
216823f68a2SMike Barcroft.Va MSGVERB
217823f68a2SMike Barcroftset to
218823f68a2SMike Barcroft.Qq "text:severity:action:tag" ,
219823f68a2SMike Barcroftproduces:
220823f68a2SMike Barcroft.Bd -literal -offset indent
221823f68a2SMike Barcroftillegal option -- z: ERROR
222823f68a2SMike BarcroftTO FIX: refer to manual BSD:ls:001
223823f68a2SMike Barcroft.Ed
224823f68a2SMike Barcroft.Sh SEE ALSO
225823f68a2SMike Barcroft.Xr err 3 ,
226823f68a2SMike Barcroft.Xr exit 3 ,
227823f68a2SMike Barcroft.Xr strerror 3
228823f68a2SMike Barcroft.Sh STANDARDS
229823f68a2SMike BarcroftThe
230823f68a2SMike Barcroft.Fn fmtmsg
231823f68a2SMike Barcroftfunction conforms to
232823f68a2SMike Barcroft.St -p1003.1-2001 .
233823f68a2SMike Barcroft.Sh HISTORY
234823f68a2SMike BarcroftThe
235823f68a2SMike Barcroft.Fn fmtmsg
236823f68a2SMike Barcroftfunction first appeared in
237823f68a2SMike Barcroft.Fx 5.0 .
238823f68a2SMike Barcroft.Sh BUGS
239823f68a2SMike BarcroftSpecifying
240823f68a2SMike Barcroft.Dv MM_NULLMC
241823f68a2SMike Barcroftfor the
242823f68a2SMike Barcroft.Fa classification
243823f68a2SMike Barcroftargument makes little sense, since without an output specified,
244823f68a2SMike Barcroft.Fn fmtmsg
245823f68a2SMike Barcroftis unable to do anything useful.
246823f68a2SMike Barcroft.Pp
247823f68a2SMike BarcroftIn order for
248823f68a2SMike Barcroft.Fn fmtmsg
249823f68a2SMike Barcroftto output to the system console, the effective
250823f68a2SMike Barcroftuser must have appropriate permission to write to
251823f68a2SMike Barcroft.Pa /dev/console .
252823f68a2SMike BarcroftThis means that on most systems
253823f68a2SMike Barcroft.Fn fmtmsg
254823f68a2SMike Barcroftwill return
255823f68a2SMike Barcroft.Dv MM_NOCON
256823f68a2SMike Barcroftunless the effective user is root.
257