186d7f5d3SJohn Marino.\" 286d7f5d3SJohn Marino.\" Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> 386d7f5d3SJohn Marino.\" All rights reserved. 486d7f5d3SJohn Marino.\" 586d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without 686d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions 786d7f5d3SJohn Marino.\" are met: 886d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 986d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer. 1086d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 1186d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 1286d7f5d3SJohn Marino.\" documentation and/or other materials provided with the distribution. 1386d7f5d3SJohn Marino.\" 1486d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1586d7f5d3SJohn Marino.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1686d7f5d3SJohn Marino.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1786d7f5d3SJohn Marino.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1886d7f5d3SJohn Marino.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1986d7f5d3SJohn Marino.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2086d7f5d3SJohn Marino.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2186d7f5d3SJohn Marino.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2286d7f5d3SJohn Marino.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2386d7f5d3SJohn Marino.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2486d7f5d3SJohn Marino.\" SUCH DAMAGE. 2586d7f5d3SJohn Marino.\" 2686d7f5d3SJohn Marino.\" $FreeBSD: src/lib/libc/gen/fmtmsg.3,v 1.4 2002/12/04 18:57:44 ru Exp $ 2786d7f5d3SJohn Marino.\" $DragonFly: src/lib/libc/gen/fmtmsg.3,v 1.1 2008/10/06 21:01:37 swildner Exp $ 2886d7f5d3SJohn Marino.\" 2986d7f5d3SJohn Marino.Dd October 6, 2008 3086d7f5d3SJohn Marino.Dt FMTMSG 3 3186d7f5d3SJohn Marino.Os 3286d7f5d3SJohn Marino.Sh NAME 3386d7f5d3SJohn Marino.Nm fmtmsg 3486d7f5d3SJohn Marino.Nd display a detailed diagnostic message 3586d7f5d3SJohn Marino.Sh LIBRARY 3686d7f5d3SJohn Marino.Lb libc 3786d7f5d3SJohn Marino.Sh SYNOPSIS 3886d7f5d3SJohn Marino.In fmtmsg.h 3986d7f5d3SJohn Marino.Ft int 4086d7f5d3SJohn Marino.Fo fmtmsg 4186d7f5d3SJohn Marino.Fa "long classification" "const char *label" "int severity" 4286d7f5d3SJohn Marino.Fa "const char *text" "const char *action" "const char *tag" 4386d7f5d3SJohn Marino.Fc 4486d7f5d3SJohn Marino.Sh DESCRIPTION 4586d7f5d3SJohn MarinoThe 4686d7f5d3SJohn Marino.Fn fmtmsg 4786d7f5d3SJohn Marinofunction displays a detailed diagnostic message, based on 4886d7f5d3SJohn Marinothe supplied arguments, to 4986d7f5d3SJohn Marino.Dv stderr 5086d7f5d3SJohn Marinoand/or the system console. 5186d7f5d3SJohn Marino.Pp 5286d7f5d3SJohn MarinoThe 5386d7f5d3SJohn Marino.Fa classification 5486d7f5d3SJohn Marinoargument is the bitwise inclusive 5586d7f5d3SJohn Marino.Tn OR 5686d7f5d3SJohn Marinoof zero or one of the manifest constants from 5786d7f5d3SJohn Marinoeach of the classification groups below. 5886d7f5d3SJohn MarinoThe Output classification group is an exception since both 5986d7f5d3SJohn Marino.Dv MM_PRINT 6086d7f5d3SJohn Marinoand 6186d7f5d3SJohn Marino.Dv MM_CONSOLE 6286d7f5d3SJohn Marinomay be specified. 6386d7f5d3SJohn Marino.Bl -tag -width indent 6486d7f5d3SJohn Marino.It Output 6586d7f5d3SJohn Marino.Bl -tag -width ".Dv MM_CONSOLE" 6686d7f5d3SJohn Marino.It Dv MM_PRINT 6786d7f5d3SJohn MarinoOutput should take place on 6886d7f5d3SJohn Marino.Dv stderr . 6986d7f5d3SJohn Marino.It Dv MM_CONSOLE 7086d7f5d3SJohn MarinoOutput should take place on the system console. 7186d7f5d3SJohn Marino.El 7286d7f5d3SJohn Marino.It "Source of Condition (Major)" 7386d7f5d3SJohn Marino.Bl -tag -width ".Dv MM_CONSOLE" 7486d7f5d3SJohn Marino.It Dv MM_HARD 7586d7f5d3SJohn MarinoThe source of the condition is hardware related. 7686d7f5d3SJohn Marino.It Dv MM_SOFT 7786d7f5d3SJohn MarinoThe source of the condition is software related. 7886d7f5d3SJohn Marino.It Dv MM_FIRM 7986d7f5d3SJohn MarinoThe source of the condition is firmware related. 8086d7f5d3SJohn Marino.El 8186d7f5d3SJohn Marino.It "Source of Condition (Minor)" 8286d7f5d3SJohn Marino.Bl -tag -width ".Dv MM_CONSOLE" 8386d7f5d3SJohn Marino.It Dv MM_APPL 8486d7f5d3SJohn MarinoThe condition was detected at the application level. 8586d7f5d3SJohn Marino.It Dv MM_UTIL 8686d7f5d3SJohn MarinoThe condition was detected at the utility level. 8786d7f5d3SJohn Marino.It Dv MM_OPSYS 8886d7f5d3SJohn MarinoThe condition was detected at the operating system level. 8986d7f5d3SJohn Marino.El 9086d7f5d3SJohn Marino.It Status 9186d7f5d3SJohn Marino.Bl -tag -width ".Dv MM_CONSOLE" 9286d7f5d3SJohn Marino.It Dv MM_RECOVER 9386d7f5d3SJohn MarinoThe application can recover from the condition. 9486d7f5d3SJohn Marino.It Dv MM_NRECOV 9586d7f5d3SJohn MarinoThe application is unable to recover from the condition. 9686d7f5d3SJohn Marino.El 9786d7f5d3SJohn Marino.El 9886d7f5d3SJohn Marino.Pp 9986d7f5d3SJohn MarinoAlternatively, the 10086d7f5d3SJohn Marino.Dv MM_NULLMC 10186d7f5d3SJohn Marinomanifest constant may be used to specify no classification. 10286d7f5d3SJohn Marino.Pp 10386d7f5d3SJohn MarinoThe 10486d7f5d3SJohn Marino.Fa label 10586d7f5d3SJohn Marinoargument indicates the source of the message. 10686d7f5d3SJohn MarinoIt is made up of two fields separated by a colon 10786d7f5d3SJohn Marino.Pq Ql \&: . 10886d7f5d3SJohn MarinoThe first field can be up to 10 bytes, 10986d7f5d3SJohn Marinoand the second field can be up to 14 bytes. 11086d7f5d3SJohn MarinoThe 11186d7f5d3SJohn Marino.Dv MM_NULLLBL 11286d7f5d3SJohn Marinomanifest constant may be used to specify no label. 11386d7f5d3SJohn Marino.Pp 11486d7f5d3SJohn MarinoThe 11586d7f5d3SJohn Marino.Fa severity 11686d7f5d3SJohn Marinoargument identifies the importance of the condition. 11786d7f5d3SJohn MarinoOne of the following manifest constants should be used for this argument. 11886d7f5d3SJohn Marino.Bl -tag -offset indent -width ".Dv MM_WARNING" 11986d7f5d3SJohn Marino.It Dv MM_HALT 12086d7f5d3SJohn MarinoThe application has confronted a serious fault and is halting. 12186d7f5d3SJohn Marino.It Dv MM_ERROR 12286d7f5d3SJohn MarinoThe application has detected a fault. 12386d7f5d3SJohn Marino.It Dv MM_WARNING 12486d7f5d3SJohn MarinoThe application has detected an unusual condition, 12586d7f5d3SJohn Marinothat could be indicative of a problem. 12686d7f5d3SJohn Marino.It Dv MM_INFO 12786d7f5d3SJohn MarinoThe application is providing information about a non-error condition. 12886d7f5d3SJohn Marino.It Dv MM_NOSEV 12986d7f5d3SJohn MarinoNo severity level supplied. 13086d7f5d3SJohn Marino.El 13186d7f5d3SJohn Marino.Pp 13286d7f5d3SJohn MarinoThe 13386d7f5d3SJohn Marino.Fa text 13486d7f5d3SJohn Marinoargument details the error condition that caused the message. 13586d7f5d3SJohn MarinoThere is no limit on the size of this character string. 13686d7f5d3SJohn MarinoThe 13786d7f5d3SJohn Marino.Dv MM_NULLTXT 13886d7f5d3SJohn Marinomanifest constant may be used to specify no text. 13986d7f5d3SJohn Marino.Pp 14086d7f5d3SJohn MarinoThe 14186d7f5d3SJohn Marino.Fa action 14286d7f5d3SJohn Marinoargument details how the error-recovery process should begin. 14386d7f5d3SJohn MarinoUpon output, 14486d7f5d3SJohn Marino.Fn fmtmsg 14586d7f5d3SJohn Marinowill prefix 14686d7f5d3SJohn Marino.Qq Li "TO FIX:" 14786d7f5d3SJohn Marinoto the beginning of the 14886d7f5d3SJohn Marino.Fa action 14986d7f5d3SJohn Marinoargument. 15086d7f5d3SJohn MarinoThe 15186d7f5d3SJohn Marino.Dv MM_NULLACT 15286d7f5d3SJohn Marinomanifest constant may be used to specify no action. 15386d7f5d3SJohn Marino.Pp 15486d7f5d3SJohn MarinoThe 15586d7f5d3SJohn Marino.Fa tag 15686d7f5d3SJohn Marinoargument should reference online documentation for the message. 15786d7f5d3SJohn MarinoThis usually includes the 15886d7f5d3SJohn Marino.Fa label 15986d7f5d3SJohn Marinoand a unique identifying number. 16086d7f5d3SJohn MarinoAn example tag is 16186d7f5d3SJohn Marino.Qq Li BSD:ls:168 . 16286d7f5d3SJohn MarinoThe 16386d7f5d3SJohn Marino.Dv MM_NULLTAG 16486d7f5d3SJohn Marinomanifest constant may be used to specify no tag. 16586d7f5d3SJohn Marino.Sh RETURN VALUES 16686d7f5d3SJohn MarinoThe 16786d7f5d3SJohn Marino.Fn fmtmsg 16886d7f5d3SJohn Marinofunction returns 16986d7f5d3SJohn Marino.Dv MM_OK 17086d7f5d3SJohn Marinoupon success, 17186d7f5d3SJohn Marino.Dv MM_NOMSG 17286d7f5d3SJohn Marinoto indicate output to 17386d7f5d3SJohn Marino.Dv stderr 17486d7f5d3SJohn Marinofailed, 17586d7f5d3SJohn Marino.Dv MM_NOCON 17686d7f5d3SJohn Marinoto indicate output to the system console failed, or 17786d7f5d3SJohn Marino.Dv MM_NOTOK 17886d7f5d3SJohn Marinoto indicate output to 17986d7f5d3SJohn Marino.Dv stderr 18086d7f5d3SJohn Marinoand the system console failed. 18186d7f5d3SJohn Marino.Sh ENVIRONMENT 18286d7f5d3SJohn MarinoThe 18386d7f5d3SJohn Marino.Ev MSGVERB 18486d7f5d3SJohn Marino(message verbosity) 18586d7f5d3SJohn Marinoenvironment variable specifies which arguments to 18686d7f5d3SJohn Marino.Fn fmtmsg 18786d7f5d3SJohn Marinowill be output to 18886d7f5d3SJohn Marino.Dv stderr , 18986d7f5d3SJohn Marinoand in which order. 19086d7f5d3SJohn Marino.Ev MSGVERB 19186d7f5d3SJohn Marinoshould be a colon 19286d7f5d3SJohn Marino.Pq Ql \&: 19386d7f5d3SJohn Marinoseparated list of identifiers. 19486d7f5d3SJohn MarinoValid identifiers include: 19586d7f5d3SJohn Marino.Li label , severity , text , action , 19686d7f5d3SJohn Marinoand 19786d7f5d3SJohn Marino.Li tag . 19886d7f5d3SJohn MarinoIf invalid identifiers are specified or incorrectly separated, 19986d7f5d3SJohn Marinothe default message verbosity and ordering will be used. 20086d7f5d3SJohn MarinoThe default ordering is equivalent to a 20186d7f5d3SJohn Marino.Ev MSGVERB 20286d7f5d3SJohn Marinowith a value of 20386d7f5d3SJohn Marino.Qq Li label:severity:text:action:tag . 20486d7f5d3SJohn Marino.Sh EXAMPLES 20586d7f5d3SJohn MarinoThe code: 20686d7f5d3SJohn Marino.Bd -literal -offset indent 20786d7f5d3SJohn Marinofmtmsg(MM_UTIL | MM_PRINT, "BSD:ls", MM_ERROR, 20886d7f5d3SJohn Marino "illegal option -- z", "refer to manual", "BSD:ls:001"); 20986d7f5d3SJohn Marino.Ed 21086d7f5d3SJohn Marino.Pp 21186d7f5d3SJohn Marinowill output: 21286d7f5d3SJohn Marino.Bd -literal -offset indent 21386d7f5d3SJohn MarinoBSD:ls: ERROR: illegal option -- z 21486d7f5d3SJohn MarinoTO FIX: refer to manual BSD:ls:001 21586d7f5d3SJohn Marino.Ed 21686d7f5d3SJohn Marino.Pp 21786d7f5d3SJohn Marinoto 21886d7f5d3SJohn Marino.Dv stderr . 21986d7f5d3SJohn Marino.Pp 22086d7f5d3SJohn MarinoThe same code, with 22186d7f5d3SJohn Marino.Ev MSGVERB 22286d7f5d3SJohn Marinoset to 22386d7f5d3SJohn Marino.Qq Li "text:severity:action:tag" , 22486d7f5d3SJohn Marinoproduces: 22586d7f5d3SJohn Marino.Bd -literal -offset indent 22686d7f5d3SJohn Marinoillegal option -- z: ERROR 22786d7f5d3SJohn MarinoTO FIX: refer to manual BSD:ls:001 22886d7f5d3SJohn Marino.Ed 22986d7f5d3SJohn Marino.Sh SEE ALSO 23086d7f5d3SJohn Marino.Xr err 3 , 23186d7f5d3SJohn Marino.Xr exit 3 , 23286d7f5d3SJohn Marino.Xr strerror 3 23386d7f5d3SJohn Marino.Sh STANDARDS 23486d7f5d3SJohn MarinoThe 23586d7f5d3SJohn Marino.Fn fmtmsg 23686d7f5d3SJohn Marinofunction conforms to 23786d7f5d3SJohn Marino.St -p1003.1-2001 . 23886d7f5d3SJohn Marino.Sh HISTORY 23986d7f5d3SJohn MarinoThe 24086d7f5d3SJohn Marino.Fn fmtmsg 24186d7f5d3SJohn Marinofunction first appeared in 24286d7f5d3SJohn Marino.Fx 5.0 . 24386d7f5d3SJohn MarinoIt was imported into 24486d7f5d3SJohn Marino.Dx 2.1 . 24586d7f5d3SJohn Marino.Sh BUGS 24686d7f5d3SJohn MarinoSpecifying 24786d7f5d3SJohn Marino.Dv MM_NULLMC 24886d7f5d3SJohn Marinofor the 24986d7f5d3SJohn Marino.Fa classification 25086d7f5d3SJohn Marinoargument makes little sense, since without an output specified, 25186d7f5d3SJohn Marino.Fn fmtmsg 25286d7f5d3SJohn Marinois unable to do anything useful. 25386d7f5d3SJohn Marino.Pp 25486d7f5d3SJohn MarinoIn order for 25586d7f5d3SJohn Marino.Fn fmtmsg 25686d7f5d3SJohn Marinoto output to the system console, the effective 25786d7f5d3SJohn Marinouser must have appropriate permission to write to 25886d7f5d3SJohn Marino.Pa /dev/console . 25986d7f5d3SJohn MarinoThis means that on most systems 26086d7f5d3SJohn Marino.Fn fmtmsg 26186d7f5d3SJohn Marinowill return 26286d7f5d3SJohn Marino.Dv MM_NOCON 26386d7f5d3SJohn Marinounless the effective user is root. 264