Display a message in the specified format on standard error, the console, or both.
#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.
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.
Parameter | Type | Null-Value | Identifier |
label | char* | (char*)0 | MM_NULLLBL |
severity | int | 0 | MM_NULLSEV |
class | long | 0L | MM_NULLMC |
text | char* | (char*)0 | MM_NULLTXT |
action | char* | (char*)0 | MM_NULLACT |
tag | char* | (char*)0 | MM_NULLTAG |
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:
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.