2002-08-05 06:49:58 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
|
|
|
.Dd August 5, 2002
|
|
|
|
.Dt FMTMSG 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm fmtmsg
|
|
|
|
.Nd display a detailed diagnostic message
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In fmtmsg.h
|
|
|
|
.Ft int
|
2002-12-04 15:47:41 +00:00
|
|
|
.Fo fmtmsg
|
|
|
|
.Fa "long classification" "const char *label" "int severity"
|
|
|
|
.Fa "const char *text" "const char *action" "const char *tag"
|
|
|
|
.Fc
|
2002-08-05 06:49:58 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn fmtmsg
|
|
|
|
function displays a detailed diagnostic message, based on
|
2002-12-04 15:47:41 +00:00
|
|
|
the supplied arguments, to
|
2002-08-05 06:49:58 +00:00
|
|
|
.Em stderr
|
|
|
|
and/or the system console.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa classification
|
|
|
|
argument is the bitwise inclusive
|
|
|
|
.Tn OR
|
|
|
|
of zero or one of the manifest constants from
|
|
|
|
each of the classification groups below.
|
|
|
|
The Output classification group is an exception since both
|
|
|
|
.Dv MM_PRINT
|
|
|
|
and
|
|
|
|
.Dv MM_CONSOLE
|
|
|
|
may be specified.
|
2002-12-04 15:47:41 +00:00
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Output
|
|
|
|
.Bl -tag -width ".Dv MM_CONSOLE"
|
2002-08-05 06:49:58 +00:00
|
|
|
.It Dv MM_PRINT
|
|
|
|
Output should take place on
|
|
|
|
.Em stderr .
|
|
|
|
.It Dv MM_CONSOLE
|
|
|
|
Output should take place on the system console.
|
|
|
|
.El
|
2002-12-04 15:47:41 +00:00
|
|
|
.It "Source of Condition (Major)"
|
|
|
|
.Bl -tag -width ".Dv MM_CONSOLE"
|
2002-08-05 06:49:58 +00:00
|
|
|
.It Dv MM_HARD
|
|
|
|
The source of the condition is hardware related.
|
|
|
|
.It Dv MM_SOFT
|
|
|
|
The source of the condition is software related.
|
|
|
|
.It Dv MM_FIRM
|
|
|
|
The source of the condition is firmware related.
|
|
|
|
.El
|
2002-12-04 15:47:41 +00:00
|
|
|
.It "Source of Condition (Minor)"
|
|
|
|
.Bl -tag -width ".Dv MM_CONSOLE"
|
2002-08-05 06:49:58 +00:00
|
|
|
.It Dv MM_APPL
|
|
|
|
The condition was detected at the application level.
|
|
|
|
.It Dv MM_UTIL
|
|
|
|
The condition was detected at the utility level.
|
|
|
|
.It Dv MM_OPSYS
|
|
|
|
The condition was detected at the operating system level.
|
|
|
|
.El
|
2002-12-04 15:47:41 +00:00
|
|
|
.It Status
|
|
|
|
.Bl -tag -width ".Dv MM_CONSOLE"
|
2002-08-05 06:49:58 +00:00
|
|
|
.It Dv MM_RECOVER
|
|
|
|
The application can recover from the condition.
|
|
|
|
.It Dv MM_NRECOV
|
|
|
|
The application is unable to recover from the condition.
|
|
|
|
.El
|
2002-12-04 15:47:41 +00:00
|
|
|
.El
|
2002-08-05 06:49:58 +00:00
|
|
|
.Pp
|
|
|
|
Alternatively, the
|
|
|
|
.Dv MM_NULLMC
|
|
|
|
manifest constant may be used to specify no classification.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa label
|
|
|
|
argument indicates the source of the message.
|
2002-08-11 13:05:30 +00:00
|
|
|
It is made up of two fields separated by a colon
|
2002-12-04 15:47:41 +00:00
|
|
|
.Pq Ql \&: .
|
2002-08-05 06:49:58 +00:00
|
|
|
The first field can be up to 10 bytes,
|
|
|
|
and the second field can be up to 14 bytes.
|
|
|
|
The
|
|
|
|
.Dv MM_NULLLBL
|
|
|
|
manifest constant may be used to specify no label.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa severity
|
|
|
|
argument identifies the importance of the condition.
|
|
|
|
One of the following manifest constants should be used for this argument.
|
2002-12-04 15:47:41 +00:00
|
|
|
.Bl -tag -offset indent -width ".Dv MM_WARNING"
|
2002-08-05 06:49:58 +00:00
|
|
|
.It Dv MM_HALT
|
|
|
|
The application has confronted a serious fault and is halting.
|
|
|
|
.It Dv MM_ERROR
|
|
|
|
The application has detected a fault.
|
|
|
|
.It Dv MM_WARNING
|
|
|
|
The application has detected an unusual condition,
|
|
|
|
that could be indicative of a problem.
|
|
|
|
.It Dv MM_INFO
|
|
|
|
The application is providing information about a non-error condition.
|
|
|
|
.It Dv MM_NOSEV
|
|
|
|
No severity level supplied.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa text
|
|
|
|
argument details the error condition that caused the message.
|
|
|
|
There is no limit on the size of this character string.
|
|
|
|
The
|
|
|
|
.Dv MM_NULLTXT
|
|
|
|
manifest constant may be used to specify no text.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa action
|
|
|
|
argument details how the error-recovery process should begin.
|
|
|
|
Upon output,
|
|
|
|
.Fn fmtmsg
|
|
|
|
will prefix
|
2002-12-04 15:47:41 +00:00
|
|
|
.Qq Li "TO FIX:"
|
|
|
|
to the beginning of the
|
2002-08-05 06:49:58 +00:00
|
|
|
.Fa action
|
|
|
|
argument.
|
|
|
|
The
|
|
|
|
.Dv MM_NULLACT
|
|
|
|
manifest constant may be used to specify no action.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa tag
|
|
|
|
argument should reference online documentation for the message.
|
|
|
|
This usually includes the
|
|
|
|
.Fa label
|
|
|
|
and a unique identifying number.
|
|
|
|
An example tag is
|
2002-12-04 15:47:41 +00:00
|
|
|
.Qq Li BSD:ls:168 .
|
2002-08-05 06:49:58 +00:00
|
|
|
The
|
|
|
|
.Dv MM_NULLTAG
|
|
|
|
manifest constant may be used to specify no tag.
|
|
|
|
.Sh RETURN VALUES
|
|
|
|
The
|
|
|
|
.Fn fmtmsg
|
|
|
|
function returns
|
|
|
|
.Dv MM_OK
|
|
|
|
upon success,
|
|
|
|
.Dv MM_NOMSG
|
|
|
|
to indicate output to
|
|
|
|
.Em stderr
|
|
|
|
failed,
|
|
|
|
.Dv MM_NOCON
|
|
|
|
to indicate output to the system console failed, or
|
|
|
|
.Dv MM_NOTOK
|
|
|
|
to indicate output to
|
|
|
|
.Em stderr
|
|
|
|
and the system console failed.
|
|
|
|
.Sh ENVIRONMENT
|
|
|
|
The
|
2002-12-04 15:47:41 +00:00
|
|
|
.Ev MSGVERB
|
|
|
|
(message verbosity)
|
2002-08-05 06:49:58 +00:00
|
|
|
environment variable specifies which arguments to
|
|
|
|
.Fn fmtmsg
|
2002-08-11 13:05:30 +00:00
|
|
|
will be output to
|
2002-08-05 06:49:58 +00:00
|
|
|
.Em stderr ,
|
|
|
|
and in which order.
|
2002-12-04 15:47:41 +00:00
|
|
|
.Ev MSGVERB
|
2002-08-05 06:49:58 +00:00
|
|
|
should be a colon
|
2002-12-04 15:47:41 +00:00
|
|
|
.Pq Ql \&:
|
2002-08-11 13:05:30 +00:00
|
|
|
separated list of identifiers.
|
2002-12-04 15:47:41 +00:00
|
|
|
Valid identifiers include:
|
|
|
|
.Li label , severity , text , action ,
|
|
|
|
and
|
|
|
|
.Li tag .
|
2002-08-11 13:05:30 +00:00
|
|
|
If invalid identifiers are specified or incorrectly separated,
|
2002-08-05 06:49:58 +00:00
|
|
|
the default message verbosity and ordering will be used.
|
|
|
|
The default ordering is equivalent to a
|
2002-12-04 15:47:41 +00:00
|
|
|
.Ev MSGVERB
|
2002-08-05 06:49:58 +00:00
|
|
|
with a value of
|
2002-12-04 15:47:41 +00:00
|
|
|
.Qq Li label:severity:text:action:tag .
|
2002-08-05 06:49:58 +00:00
|
|
|
.Sh EXAMPLES
|
|
|
|
The code:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
fmtmsg(MM_UTIL | MM_PRINT, "BSD:ls", MM_ERROR,
|
|
|
|
"illegal option -- z", "refer to manual", "BSD:ls:001");
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
will output:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
BSD:ls: ERROR: illegal option -- z
|
|
|
|
TO FIX: refer to manual BSD:ls:001
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
to
|
|
|
|
.Em stderr .
|
|
|
|
.Pp
|
|
|
|
The same code, with
|
2002-12-04 15:47:41 +00:00
|
|
|
.Ev MSGVERB
|
2002-08-05 06:49:58 +00:00
|
|
|
set to
|
2002-12-04 15:47:41 +00:00
|
|
|
.Qq Li "text:severity:action:tag" ,
|
2002-08-05 06:49:58 +00:00
|
|
|
produces:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
illegal option -- z: ERROR
|
|
|
|
TO FIX: refer to manual BSD:ls:001
|
|
|
|
.Ed
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr err 3 ,
|
|
|
|
.Xr exit 3 ,
|
|
|
|
.Xr strerror 3
|
|
|
|
.Sh STANDARDS
|
|
|
|
The
|
|
|
|
.Fn fmtmsg
|
|
|
|
function conforms to
|
|
|
|
.St -p1003.1-2001 .
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Fn fmtmsg
|
|
|
|
function first appeared in
|
|
|
|
.Fx 5.0 .
|
|
|
|
.Sh BUGS
|
|
|
|
Specifying
|
|
|
|
.Dv MM_NULLMC
|
|
|
|
for the
|
|
|
|
.Fa classification
|
|
|
|
argument makes little sense, since without an output specified,
|
|
|
|
.Fn fmtmsg
|
|
|
|
is unable to do anything useful.
|
|
|
|
.Pp
|
|
|
|
In order for
|
|
|
|
.Fn fmtmsg
|
|
|
|
to output to the system console, the effective
|
|
|
|
user must have appropriate permission to write to
|
|
|
|
.Pa /dev/console .
|
|
|
|
This means that on most systems
|
|
|
|
.Fn fmtmsg
|
|
|
|
will return
|
|
|
|
.Dv MM_NOCON
|
|
|
|
unless the effective user is root.
|