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.Dd August 5, 2002 27823f68a2SMike Barcroft.Dt FMTMSG 3 28823f68a2SMike Barcroft.Os 29823f68a2SMike Barcroft.Sh NAME 30823f68a2SMike Barcroft.Nm fmtmsg 31823f68a2SMike Barcroft.Nd display a detailed diagnostic message 32823f68a2SMike Barcroft.Sh LIBRARY 33823f68a2SMike Barcroft.Lb libc 34823f68a2SMike Barcroft.Sh SYNOPSIS 35823f68a2SMike Barcroft.In fmtmsg.h 36823f68a2SMike Barcroft.Ft int 37304d1f73SRuslan Ermilov.Fo fmtmsg 38304d1f73SRuslan Ermilov.Fa "long classification" "const char *label" "int severity" 39304d1f73SRuslan Ermilov.Fa "const char *text" "const char *action" "const char *tag" 40304d1f73SRuslan Ermilov.Fc 41823f68a2SMike Barcroft.Sh DESCRIPTION 42823f68a2SMike BarcroftThe 43823f68a2SMike Barcroft.Fn fmtmsg 44823f68a2SMike Barcroftfunction displays a detailed diagnostic message, based on 45304d1f73SRuslan Ermilovthe supplied arguments, to 46ae828962SRuslan Ermilov.Dv stderr 47823f68a2SMike Barcroftand/or the system console. 48823f68a2SMike Barcroft.Pp 49823f68a2SMike BarcroftThe 50823f68a2SMike Barcroft.Fa classification 51823f68a2SMike Barcroftargument is the bitwise inclusive 52823f68a2SMike Barcroft.Tn OR 53823f68a2SMike Barcroftof zero or one of the manifest constants from 54823f68a2SMike Barcrofteach of the classification groups below. 55823f68a2SMike BarcroftThe Output classification group is an exception since both 56823f68a2SMike Barcroft.Dv MM_PRINT 57823f68a2SMike Barcroftand 58823f68a2SMike Barcroft.Dv MM_CONSOLE 59823f68a2SMike Barcroftmay be specified. 60304d1f73SRuslan Ermilov.Bl -tag -width indent 61304d1f73SRuslan Ermilov.It Output 62304d1f73SRuslan Ermilov.Bl -tag -width ".Dv MM_CONSOLE" 63823f68a2SMike Barcroft.It Dv MM_PRINT 64823f68a2SMike BarcroftOutput should take place on 65ae828962SRuslan Ermilov.Dv stderr . 66823f68a2SMike Barcroft.It Dv MM_CONSOLE 67823f68a2SMike BarcroftOutput should take place on the system console. 68823f68a2SMike Barcroft.El 69304d1f73SRuslan Ermilov.It "Source of Condition (Major)" 70304d1f73SRuslan Ermilov.Bl -tag -width ".Dv 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 78304d1f73SRuslan Ermilov.It "Source of Condition (Minor)" 79304d1f73SRuslan Ermilov.Bl -tag -width ".Dv MM_CONSOLE" 80823f68a2SMike Barcroft.It Dv MM_APPL 81823f68a2SMike BarcroftThe condition was detected at the application level. 82823f68a2SMike Barcroft.It Dv MM_UTIL 83823f68a2SMike BarcroftThe condition was detected at the utility level. 84823f68a2SMike Barcroft.It Dv MM_OPSYS 85823f68a2SMike BarcroftThe condition was detected at the operating system level. 86823f68a2SMike Barcroft.El 87304d1f73SRuslan Ermilov.It Status 88304d1f73SRuslan Ermilov.Bl -tag -width ".Dv MM_CONSOLE" 89823f68a2SMike Barcroft.It Dv MM_RECOVER 90823f68a2SMike BarcroftThe application can recover from the condition. 91823f68a2SMike Barcroft.It Dv MM_NRECOV 92823f68a2SMike BarcroftThe application is unable to recover from the condition. 93823f68a2SMike Barcroft.El 94304d1f73SRuslan Ermilov.El 95823f68a2SMike Barcroft.Pp 96823f68a2SMike BarcroftAlternatively, the 97823f68a2SMike Barcroft.Dv MM_NULLMC 98823f68a2SMike Barcroftmanifest constant may be used to specify no classification. 99823f68a2SMike Barcroft.Pp 100823f68a2SMike BarcroftThe 101823f68a2SMike Barcroft.Fa label 102823f68a2SMike Barcroftargument indicates the source of the message. 1032b239dd1SJens SchweikhardtIt is made up of two fields separated by a colon 104304d1f73SRuslan Ermilov.Pq Ql \&: . 105823f68a2SMike BarcroftThe first field can be up to 10 bytes, 106823f68a2SMike Barcroftand the second field can be up to 14 bytes. 107823f68a2SMike BarcroftThe 108823f68a2SMike Barcroft.Dv MM_NULLLBL 109823f68a2SMike Barcroftmanifest constant may be used to specify no label. 110823f68a2SMike Barcroft.Pp 111823f68a2SMike BarcroftThe 112823f68a2SMike Barcroft.Fa severity 113823f68a2SMike Barcroftargument identifies the importance of the condition. 114823f68a2SMike BarcroftOne of the following manifest constants should be used for this argument. 115304d1f73SRuslan Ermilov.Bl -tag -offset indent -width ".Dv MM_WARNING" 116823f68a2SMike Barcroft.It Dv MM_HALT 117823f68a2SMike BarcroftThe application has confronted a serious fault and is halting. 118823f68a2SMike Barcroft.It Dv MM_ERROR 119823f68a2SMike BarcroftThe application has detected a fault. 120823f68a2SMike Barcroft.It Dv MM_WARNING 121823f68a2SMike BarcroftThe application has detected an unusual condition, 122823f68a2SMike Barcroftthat could be indicative of a problem. 123823f68a2SMike Barcroft.It Dv MM_INFO 124823f68a2SMike BarcroftThe application is providing information about a non-error condition. 125823f68a2SMike Barcroft.It Dv MM_NOSEV 126823f68a2SMike BarcroftNo severity level supplied. 127823f68a2SMike Barcroft.El 128823f68a2SMike Barcroft.Pp 129823f68a2SMike BarcroftThe 130823f68a2SMike Barcroft.Fa text 131823f68a2SMike Barcroftargument details the error condition that caused the message. 132823f68a2SMike BarcroftThere is no limit on the size of this character string. 133823f68a2SMike BarcroftThe 134823f68a2SMike Barcroft.Dv MM_NULLTXT 135823f68a2SMike Barcroftmanifest constant may be used to specify no text. 136823f68a2SMike Barcroft.Pp 137823f68a2SMike BarcroftThe 138823f68a2SMike Barcroft.Fa action 139823f68a2SMike Barcroftargument details how the error-recovery process should begin. 140823f68a2SMike BarcroftUpon output, 141823f68a2SMike Barcroft.Fn fmtmsg 142823f68a2SMike Barcroftwill prefix 143304d1f73SRuslan Ermilov.Qq Li "TO FIX:" 144304d1f73SRuslan Ermilovto the beginning of the 145823f68a2SMike Barcroft.Fa action 146823f68a2SMike Barcroftargument. 147823f68a2SMike BarcroftThe 148823f68a2SMike Barcroft.Dv MM_NULLACT 149823f68a2SMike Barcroftmanifest constant may be used to specify no action. 150823f68a2SMike Barcroft.Pp 151823f68a2SMike BarcroftThe 152823f68a2SMike Barcroft.Fa tag 153823f68a2SMike Barcroftargument should reference online documentation for the message. 154823f68a2SMike BarcroftThis usually includes the 155823f68a2SMike Barcroft.Fa label 156823f68a2SMike Barcroftand a unique identifying number. 157823f68a2SMike BarcroftAn example tag is 158304d1f73SRuslan Ermilov.Qq Li BSD:ls:168 . 159823f68a2SMike BarcroftThe 160823f68a2SMike Barcroft.Dv MM_NULLTAG 161823f68a2SMike Barcroftmanifest constant may be used to specify no tag. 162823f68a2SMike Barcroft.Sh RETURN VALUES 163823f68a2SMike BarcroftThe 164823f68a2SMike Barcroft.Fn fmtmsg 165823f68a2SMike Barcroftfunction returns 166823f68a2SMike Barcroft.Dv MM_OK 167823f68a2SMike Barcroftupon success, 168823f68a2SMike Barcroft.Dv MM_NOMSG 169823f68a2SMike Barcroftto indicate output to 170ae828962SRuslan Ermilov.Dv stderr 171823f68a2SMike Barcroftfailed, 172823f68a2SMike Barcroft.Dv MM_NOCON 173823f68a2SMike Barcroftto indicate output to the system console failed, or 174823f68a2SMike Barcroft.Dv MM_NOTOK 175823f68a2SMike Barcroftto indicate output to 176ae828962SRuslan Ermilov.Dv stderr 177823f68a2SMike Barcroftand the system console failed. 178823f68a2SMike Barcroft.Sh ENVIRONMENT 179823f68a2SMike BarcroftThe 180304d1f73SRuslan Ermilov.Ev MSGVERB 181304d1f73SRuslan Ermilov(message verbosity) 182823f68a2SMike Barcroftenvironment variable specifies which arguments to 183823f68a2SMike Barcroft.Fn fmtmsg 1842b239dd1SJens Schweikhardtwill be output to 185ae828962SRuslan Ermilov.Dv stderr , 186823f68a2SMike Barcroftand in which order. 187304d1f73SRuslan Ermilov.Ev MSGVERB 188823f68a2SMike Barcroftshould be a colon 189304d1f73SRuslan Ermilov.Pq Ql \&: 1902b239dd1SJens Schweikhardtseparated list of identifiers. 191304d1f73SRuslan ErmilovValid identifiers include: 192304d1f73SRuslan Ermilov.Li label , severity , text , action , 193304d1f73SRuslan Ermilovand 194304d1f73SRuslan Ermilov.Li tag . 1952b239dd1SJens SchweikhardtIf invalid identifiers are specified or incorrectly separated, 196823f68a2SMike Barcroftthe default message verbosity and ordering will be used. 197823f68a2SMike BarcroftThe default ordering is equivalent to a 198304d1f73SRuslan Ermilov.Ev MSGVERB 199823f68a2SMike Barcroftwith a value of 200304d1f73SRuslan Ermilov.Qq Li label:severity:text:action:tag . 201823f68a2SMike Barcroft.Sh EXAMPLES 202823f68a2SMike BarcroftThe code: 203823f68a2SMike Barcroft.Bd -literal -offset indent 204823f68a2SMike Barcroftfmtmsg(MM_UTIL | MM_PRINT, "BSD:ls", MM_ERROR, 205823f68a2SMike Barcroft "illegal option -- z", "refer to manual", "BSD:ls:001"); 206823f68a2SMike Barcroft.Ed 207823f68a2SMike Barcroft.Pp 208823f68a2SMike Barcroftwill output: 209823f68a2SMike Barcroft.Bd -literal -offset indent 210823f68a2SMike BarcroftBSD:ls: ERROR: illegal option -- z 211823f68a2SMike BarcroftTO FIX: refer to manual BSD:ls:001 212823f68a2SMike Barcroft.Ed 213823f68a2SMike Barcroft.Pp 214823f68a2SMike Barcroftto 215ae828962SRuslan Ermilov.Dv stderr . 216823f68a2SMike Barcroft.Pp 217823f68a2SMike BarcroftThe same code, with 218304d1f73SRuslan Ermilov.Ev MSGVERB 219823f68a2SMike Barcroftset to 220304d1f73SRuslan Ermilov.Qq Li "text:severity:action:tag" , 221823f68a2SMike Barcroftproduces: 222823f68a2SMike Barcroft.Bd -literal -offset indent 223823f68a2SMike Barcroftillegal option -- z: ERROR 224823f68a2SMike BarcroftTO FIX: refer to manual BSD:ls:001 225823f68a2SMike Barcroft.Ed 226823f68a2SMike Barcroft.Sh SEE ALSO 227823f68a2SMike Barcroft.Xr err 3 , 228823f68a2SMike Barcroft.Xr exit 3 , 229823f68a2SMike Barcroft.Xr strerror 3 230823f68a2SMike Barcroft.Sh STANDARDS 231823f68a2SMike BarcroftThe 232823f68a2SMike Barcroft.Fn fmtmsg 233823f68a2SMike Barcroftfunction conforms to 234823f68a2SMike Barcroft.St -p1003.1-2001 . 235823f68a2SMike Barcroft.Sh HISTORY 236823f68a2SMike BarcroftThe 237823f68a2SMike Barcroft.Fn fmtmsg 238823f68a2SMike Barcroftfunction first appeared in 239823f68a2SMike Barcroft.Fx 5.0 . 240823f68a2SMike Barcroft.Sh BUGS 241823f68a2SMike BarcroftSpecifying 242823f68a2SMike Barcroft.Dv MM_NULLMC 243823f68a2SMike Barcroftfor the 244823f68a2SMike Barcroft.Fa classification 245823f68a2SMike Barcroftargument makes little sense, since without an output specified, 246823f68a2SMike Barcroft.Fn fmtmsg 247823f68a2SMike Barcroftis unable to do anything useful. 248823f68a2SMike Barcroft.Pp 249823f68a2SMike BarcroftIn order for 250823f68a2SMike Barcroft.Fn fmtmsg 251823f68a2SMike Barcroftto output to the system console, the effective 252823f68a2SMike Barcroftuser must have appropriate permission to write to 253823f68a2SMike Barcroft.Pa /dev/console . 254823f68a2SMike BarcroftThis means that on most systems 255823f68a2SMike Barcroft.Fn fmtmsg 256823f68a2SMike Barcroftwill return 257823f68a2SMike Barcroft.Dv MM_NOCON 258823f68a2SMike Barcroftunless the effective user is root. 259