int fmtmsg(long classification, const char *label, int severity, const char *text, const char *action, const char *tag);
You can use fmtmsg( ) instead of the traditional printf(S) interface to display messages.
A formatted message has up to five standard components as defined below. The component classification is not part of the standard message displayed to the user. Instead, it defines the source of the message and directs the display of the formatted message.
An additional identifier, MM_NULLMC, indicates that the message has no classification component.
SCO:program2could indicate SCO Open Systems Software and application program2.
You can add other severity levels by using the addseverity(S) routine.
TO FIX:. The action string is not limited to a specific size.
which message components to select when writing messages
The value of MSGVERB is a colon-separated list of optional keywords.
MSGVERB can be set as follows:
MSGVERB=[keyword[:keyword[:. . .]]]
The 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( ) includes that component in the message when writing the message to stderr.
If MSGVERB does not include a keyword for a message component, that component is not included in the display of the message. The keywords can appear in any order.
fmtmsg( ) selects all components if MSGVERB is not defined, if its value is the null string, if its value is not of the correct format, or if it contains keywords other than the valid ones listed above.
The first time fmtmsg( ) is called, it examines the MSGVERB environment variable to see which message components to select when generating a message to write to the standard error stream, stderr. The values accepted on the initial call are saved for future calls.
MSGVERB affects only which components are selected for display to the standard error stream. All message components are included in console messages.
SEV_LEVEL defines severity levels and associates print strings with them for use by fmtmsg( ). The standard severity levels shown below cannot be modified. Additional severity levels can also be defined, redefined, and removed using addseverity( ). If both SEV_LEVEL and addseverity( ) define the same severity level, addseverity( ) rules. The levels are:
description is a comma-separated list
containing three fields:
severity_keyword is a character string that is used as the keyword on the -s severity option to fmtmsg( ). (This field is not used by fmtmsg( ).)
level is a character string that evaluates to a positive integer (other than 0, 1, 2, 3, or 4, which are reserved for the standard severity levels). If the keyword severity_keyword is used, level is the severity value passed on to fmtmsg( ).
printstring is the character string used by fmtmsg( ) in the standard message format whenever the severity value level is used.
If a description in the colon list is not a three-field comma list, or, if the second field of a comma list does not evaluate to a positive integer, that description in the colon list is ignored.
The first time fmtmsg( ) is called, it looks for the SEV_LEVEL environment variable. If SEV_LEVEL is defined, fmtmsg( ) examines it to see whether the environment expands the levels of severity beyond the five standard levels and those defined using addseverity( ). The values accepted on the initial call are saved for future calls.
The table below indicates the null values and identifiers for fmtmsg( ) arguments.
fmtmsg(MM_PRINT, "SCO:program2", MM_ERROR, "invalid syntax", "refer to manual", "SCO:program2:001")produces a complete message in the standard message format:
SCO:program2: ERROR: invalid syntax TO FIX: refer to manual SCO:program2:001
MSGVERB=severity:text:actionand the Example 1 is used, fmtmsg( ) produces:
ERROR: invalid syntax TO FIX: refer to manual
SEV_LEVEL=note,5,NOTEthe following call to fmtmsg( ):
fmtmsg(MM_UTIL|MM_PRINT, "SCO:program2", 5, "invalid syntax", "refer to manual", "SCO:program2:001")produces:
SCO:program2: NOTE: invalid syntax TO FIX: refer to manual SCO:program2:001
X/Open CAE Specification, System Interfaces and Headers, Issue 4, Version 2.