1FMTMSG(P) POSIX Programmer's Manual FMTMSG(P)
2
3
4
6 fmtmsg - display a message in the specified format on standard error
7 and/or a system console
8
10 #include <fmtmsg.h>
11
12 int fmtmsg(long classification, const char *label, int severity,
13 const char *text, const char *action, const char *tag);
14
15
17 The fmtmsg() function shall display messages in a specified format
18 instead of the traditional printf() function.
19
20 Based on a message's classification component, fmtmsg() shall write a
21 formatted message either to standard error, to the console, or to both.
22
23 A formatted message consists of up to five components as defined below.
24 The component classification is not part of a message displayed to the
25 user, but defines the source of the message and directs the display of
26 the formatted message.
27
28 classification
29 Contains the sum of identifying values constructed from the con‐
30 stants defined below. Any one identifier from a subclass may be
31 used in combination with a single identifier from a different
32 subclass. Two or more identifiers from the same subclass should
33 not be used together, with the exception of identifiers from the
34 display subclass. (Both display subclass identifiers may be used
35 so that messages can be displayed to both standard error and the
36 system console.)
37
38 Major Classifications
39
40 Identifies the source of the condition. Identifiers are: MM_HARD
41 (hardware), MM_SOFT (software), and MM_FIRM (firmware).
42
43 Message Source Subclassifications
44
45 Identifies the type of software in which the problem is
46 detected. Identifiers are: MM_APPL (application), MM_UTIL
47 (utility), and MM_OPSYS (operating system).
48
49 Display Subclassifications
50
51 Indicates where the message is to be displayed. Identifiers are:
52 MM_PRINT to display the message on the standard error stream,
53 MM_CONSOLE to display the message on the system console. One or
54 both identifiers may be used.
55
56 Status Subclassifications
57
58 Indicates whether the application can recover from the condi‐
59 tion. Identifiers are: MM_RECOVER (recoverable) and MM_NRECOV
60 (non-recoverable).
61
62
63 An additional identifier, MM_NULLMC, indicates that no classification
64 component is supplied for the message.
65
66 label Identifies the source of the message. The format is two fields
67 separated by a colon. The first field is up to 10 bytes, the
68 second is up to 14 bytes.
69
70 severity
71 Indicates the seriousness of the condition. Identifiers for the
72 levels of severity are:
73
74 MM_HALT
75 Indicates that the application has encountered a severe fault
76 and is halting. Produces the string "HALT" .
77
78 MM_ERROR
79 Indicates that the application has detected a fault. Produces
80 the string "ERROR" .
81
82 MM_WARNING
83 Indicates a condition that is out of the ordinary, that might be
84 a problem, and should be watched. Produces the string "WARNING"
85 .
86
87 MM_INFO
88 Provides information about a condition that is not in error.
89 Produces the string "INFO" .
90
91 MM_NOSEV
92 Indicates that no severity level is supplied for the message.
93
94
95 text Describes the error condition that produced the message. The
96 character string is not limited to a specific size. If the char‐
97 acter string is empty, then the text produced is unspecified.
98
99 action Describes the first step to be taken in the error-recovery
100 process. The fmtmsg() function precedes the action string with
101 the prefix: "TO FIX:" . The action string is not limited to a
102 specific size.
103
104 tag An identifier that references on-line documentation for the mes‐
105 sage. Suggested usage is that tag includes the label and a
106 unique identifying number. A sample tag is "XSI:cat:146" .
107
108
109 The MSGVERB environment variable (for message verbosity) shall deter‐
110 mine for fmtmsg() which message components it is to select when writing
111 messages to standard error. The value of MSGVERB shall be a colon-sepa‐
112 rated list of optional keywords. Valid keywords are: label, severity,
113 text, action, and tag. If MSGVERB contains a keyword for a component
114 and the component's value is not the component's null value, fmtmsg()
115 shall include that component in the message when writing the message to
116 standard error. If MSGVERB does not include a keyword for a message
117 component, that component shall not be included in the display of the
118 message. The keywords may appear in any order. If MSGVERB is not
119 defined, if its value is the null string, if its value is not of the
120 correct format, or if it contains keywords other than the valid ones
121 listed above, fmtmsg() shall select all components.
122
123 MSGVERB shall determine which components are selected for display to
124 standard error. All message components shall be included in console
125 messages.
126
128 The fmtmsg() function shall return one of the following values:
129
130 MM_OK The function succeeded.
131
132 MM_NOTOK
133 The function failed completely.
134
135 MM_NOMSG
136 The function was unable to generate a message on standard error,
137 but otherwise succeeded.
138
139 MM_NOCON
140 The function was unable to generate a console message, but oth‐
141 erwise succeeded.
142
143
145 None.
146
147 The following sections are informative.
148
150 1. The following example of fmtmsg():
151
152
153 fmtmsg(MM_PRINT, "XSI:cat", MM_ERROR, "illegal option",
154 "refer to cat in user's reference manual", "XSI:cat:001")
155
156 produces a complete message in the specified message format:
157
158
159 XSI:cat: ERROR: illegal option
160 TO FIX: refer to cat in user's reference manual XSI:cat:001
161
162 2. When the environment variable MSGVERB is set as follows:
163
164
165 MSGVERB=severity:text:action
166
167 and Example 1 is used, fmtmsg() produces:
168
169
170 ERROR: illegal option
171 TO FIX: refer to cat in user's reference manual
172
174 One or more message components may be systematically omitted from mes‐
175 sages generated by an application by using the null value of the argu‐
176 ment for that component.
177
179 None.
180
182 None.
183
185 printf() , the Base Definitions volume of IEEE Std 1003.1-2001,
186 <fmtmsg.h>
187
189 Portions of this text are reprinted and reproduced in electronic form
190 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
191 -- Portable Operating System Interface (POSIX), The Open Group Base
192 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
193 Electrical and Electronics Engineers, Inc and The Open Group. In the
194 event of any discrepancy between this version and the original IEEE and
195 The Open Group Standard, the original IEEE and The Open Group Standard
196 is the referee document. The original Standard can be obtained online
197 at http://www.opengroup.org/unix/online.html .
198
199
200
201IEEE/The Open Group 2003 FMTMSG(P)