[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

fmtmsg Subroutine

Purpose

Display a message in the specified format on standard error, the console, or both.

Library

Standard C Library (libc.a)

Syntax

#include <fmtmsg.h>

int fmtmsg (long Classification,
const char *Label,
int Severity,
cont char *Text;
cont char *Action,
cont char *Tag)

Description

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.

Parameters

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).
major classifications
Identifies the source of the condition. Identifiers are: MM_HARD (hardware), MM_SOFT (software), and MM_FIRM (firmware).
message source subclassifications
Identifies the type of software in which the problem is detected. Identifiers are: MM_APPL (application), MM_UTIL (utility), and MM_OPSYS (operating system).
display subclassification
Indicates where the message is to be displayed. Identifiers are: MM_PRINT to display the message on the standard error stream, MM_CONSOLE to display the message on the system console. One or both identifiers may be used.
status subclassifications
Indicates whether the application will recover from the condition. Identifiers are:MM_RECOVER (recoverable) and MM_RECOV (non-recoverable).

An additional identifier, MM_NULLMC, identifies that no classification component is supplied for the message.

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.
Severity  
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.

Environment Variables

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.

Application Usage

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.

Return Values

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.

Examples

  1. The following example of the fmtmsg subroutine:

    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
  2. When the environment variable MSGVERB is set as follows:

    MSGVERB=severity:text:action

    and 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

Related Information

The printf (printf, fprintf, sprintf, snprintf, wsprintf, vprintf, vfprintf, vsprintf, or vwsprintf Subroutine) subroutine.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]