Display a message in the specified format on standard error, the console, or both.
Standard C Library (libc.a)
#include <fmtmsg.h> int fmtmsg (long Classification, const char *Label, int Severity, cont char *Text; cont char *Action, cont char *Tag)
The fmtmsg subroutine can be used to display messages in a specified format instead of the traditional printf subroutine interface.
Base on a message's classification component, the fmtmsg subroutine either writes a formatted message to standard error, the console, or both.
A formatted message consists of up to five parameters. The Classification parameter is not part of a message displayed to the user, but defines the source of the message and directs the display of the formatted message.
|Classification|| Contains identifiers from the following groups of major classifications and subclassifications. Any one identifier from a subclass may be used in combination with a single identifier from a different subclass. Two or more identifiers from the same subclass should not be used together, with the exception of identifiers from the display subclass. (Both display subclass identifiers may be used so that messages can be displayed to both standard error and system console).
|Label||Identifies the source to the message. The format is two fields separated by a colon. The first field is up to 10 bytes, the second field is up to 14 bytes.|
|Text||Describes the error condition that produced the message. The character string is not limited to a specific size. If the character string is null then a message will be issued stating that no text has been provided.|
|Action||Describes the first step to be taken in the error-recovery process. The fmtmsg subroutine precedes the action string with the prefix: TO FIX: . The Action string is not limited to a specific size.|
|Tag||An identifier which references online documentation for the message. Suggested usage is that tag includes the Label and a unique identifying number. A sample tag is UX:cat:146.|
The MSGVERB (message verbosity) environment variable controls the behavior of the fmtmsg subroutine.
MSGVERB tells the fmtmsg subroutine which message components it is to select when writing messages to standard error. The value of MSGVERB is a colon-separated list of optional keywords. MSGVERB can be set as follows:
MSGVERB=[keyword[:keyword[:...]]] export MSGVERB
Valid keywords are: Label, Severity, Text, Action, and Tag. If MSGVERB contains a keyword for a component and the component's value is not the component's null value, fmtmsg subroutine includes that component in the message when writing the message to standard error. If MSGVERB does not include a keyword for a message component, that component is not included in the display of the message. The keywords may appear in any order. If MSGVERB is not defined, if its value is the null string, if its value is not of the correct format, of if it contains keywords other than the valid ones listed previously, the fmtmsg subroutine selects all components.
MSGVERB affects only which components are selected for display to standard error. All message components are included in console messages.
One or more message components may be systematically omitted from messages generated by an application by using the null value of the parameter for that component. The table below indicates the null values and identifiers for fmtmsg subroutine parameters.
Another means of systematically omitting a component is by omitting the component keywords when defining the MSGVERB environment variable.
The exit codes for the fmtmsg subroutine are the following:
|MM_OK||The function succeeded.|
|MM_NOTOK||The function failed completely.|
|MM_MOMSG||The function was unable to generate a message on standard error.|
|MM_NOCON||The function was unable to generate a console message.|
fmtmsg(MM_PRINT, "UX:cat", MM_ERROR, "illegal option", "refer tp cat in user's reference manual", "UX:cat:001")produces a complete message in the specified message format:
UX:cat ERROR: illegal option TO FIX: refer to cat in user's reference manual UX:cat:001
MSGVERB=severity:text:actionand the Example 1 is used, the fmtmsg subroutine produces:
ERROR: illegal option TO FIX: refer to cat in user's reference manual UX:cat:001
This subroutine is part of Base Operating System (BOS) Runtime.
The printf routine.