1FMTMSG(3P)                 POSIX Programmer's Manual                FMTMSG(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       fmtmsg - display a message in the specified format  on  standard  error
13       and/or a system console
14

SYNOPSIS

16       #include <fmtmsg.h>
17
18       int fmtmsg(long classification, const char *label, int severity,
19              const char *text, const char *action, const char *tag);
20
21

DESCRIPTION

23       The  fmtmsg()  function  shall  display  messages in a specified format
24       instead of the traditional printf() function.
25
26       Based on a message's classification component, fmtmsg() shall  write  a
27       formatted message either to standard error, to the console, or to both.
28
29       A formatted message consists of up to five components as defined below.
30       The component classification is not part of a message displayed to  the
31       user,  but defines the source of the message and directs the display of
32       the formatted message.
33
34       classification
35              Contains the sum of identifying values constructed from the con‐
36              stants  defined below. Any one identifier from a subclass may be
37              used in combination with a single identifier  from  a  different
38              subclass.  Two or more identifiers from the same subclass should
39              not be used together, with the exception of identifiers from the
40              display subclass. (Both display subclass identifiers may be used
41              so that messages can be displayed to both standard error and the
42              system console.)
43
44       Major Classifications
45
46              Identifies the source of the condition. Identifiers are: MM_HARD
47              (hardware), MM_SOFT (software), and MM_FIRM (firmware).
48
49       Message Source Subclassifications
50
51              Identifies  the  type  of  software  in  which  the  problem  is
52              detected.    Identifiers  are:  MM_APPL  (application),  MM_UTIL
53              (utility), and MM_OPSYS (operating system).
54
55       Display Subclassifications
56
57              Indicates where the message is to be displayed. Identifiers are:
58              MM_PRINT  to  display  the message on the standard error stream,
59              MM_CONSOLE to display the message on the system console. One  or
60              both identifiers may be used.
61
62       Status Subclassifications
63
64              Indicates  whether  the  application can recover from the condi‐
65              tion.  Identifiers are: MM_RECOVER (recoverable)  and  MM_NRECOV
66              (non-recoverable).
67
68
69       An  additional  identifier, MM_NULLMC, indicates that no classification
70       component is supplied for the message.
71
72       label  Identifies the source of the message. The format is  two  fields
73              separated  by  a  colon.  The first field is up to 10 bytes, the
74              second is up to 14 bytes.
75
76       severity
77              Indicates the seriousness of the condition. Identifiers for  the
78              levels of severity are:
79
80       MM_HALT
81              Indicates  that  the  application has encountered a severe fault
82              and is halting. Produces the string "HALT" .
83
84       MM_ERROR
85              Indicates that the application has detected  a  fault.  Produces
86              the string "ERROR" .
87
88       MM_WARNING
89              Indicates a condition that is out of the ordinary, that might be
90              a problem, and should be watched. Produces the string  "WARNING"
91              .
92
93       MM_INFO
94              Provides  information  about  a  condition that is not in error.
95              Produces the string "INFO" .
96
97       MM_NOSEV
98              Indicates that no severity level is supplied for the message.
99
100
101       text   Describes the error condition that  produced  the  message.  The
102              character string is not limited to a specific size. If the char‐
103              acter string is empty, then the text produced is unspecified.
104
105       action Describes the first step  to  be  taken  in  the  error-recovery
106              process.   The fmtmsg() function precedes the action string with
107              the prefix: "TO FIX:" . The action string is not  limited  to  a
108              specific size.
109
110       tag    An identifier that references on-line documentation for the mes‐
111              sage.  Suggested usage is that tag  includes  the  label  and  a
112              unique identifying number. A sample tag is "XSI:cat:146" .
113
114
115       The  MSGVERB  environment variable (for message verbosity) shall deter‐
116       mine for fmtmsg() which message components it is to select when writing
117       messages to standard error. The value of MSGVERB shall be a colon-sepa‐
118       rated list of optional keywords. Valid keywords are:  label,  severity,
119       text,  action,  and  tag. If MSGVERB contains a keyword for a component
120       and the component's value is not the component's null  value,  fmtmsg()
121       shall include that component in the message when writing the message to
122       standard error. If MSGVERB does not include a  keyword  for  a  message
123       component,  that  component shall not be included in the display of the
124       message.  The keywords may appear in  any  order.  If  MSGVERB  is  not
125       defined,  if  its  value is the null string, if its value is not of the
126       correct format, or if it contains keywords other than  the  valid  ones
127       listed above, fmtmsg() shall select all components.
128
129       MSGVERB  shall  determine  which components are selected for display to
130       standard error. All message components shall  be  included  in  console
131       messages.
132

RETURN VALUE

134       The fmtmsg() function shall return one of the following values:
135
136       MM_OK  The function succeeded.
137
138       MM_NOTOK
139              The function failed completely.
140
141       MM_NOMSG
142              The function was unable to generate a message on standard error,
143              but otherwise succeeded.
144
145       MM_NOCON
146              The function was unable to generate a console message, but  oth‐
147              erwise succeeded.
148
149

ERRORS

151       None.
152
153       The following sections are informative.
154

EXAMPLES

156        1. The following example of fmtmsg():
157
158
159           fmtmsg(MM_PRINT, "XSI:cat", MM_ERROR, "illegal option",
160           "refer to cat in user's reference manual", "XSI:cat:001")
161
162       produces a complete message in the specified message format:
163
164
165              XSI:cat: ERROR: illegal option
166              TO FIX: refer to cat in user's reference manual XSI:cat:001
167
168        2. When the environment variable MSGVERB is set as follows:
169
170
171           MSGVERB=severity:text:action
172
173       and Example 1 is used, fmtmsg() produces:
174
175
176              ERROR: illegal option
177              TO FIX: refer to cat in user's reference manual
178

APPLICATION USAGE

180       One  or more message components may be systematically omitted from mes‐
181       sages generated by an application by using the null value of the  argu‐
182       ment for that component.
183

RATIONALE

185       None.
186

FUTURE DIRECTIONS

188       None.
189

SEE ALSO

191       printf(),   the   Base   Definitions  volume  of  IEEE Std 1003.1-2001,
192       <fmtmsg.h>
193
195       Portions of this text are reprinted and reproduced in  electronic  form
196       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
197       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
198       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
199       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
200       event of any discrepancy between this version and the original IEEE and
201       The Open Group Standard, the original IEEE and The Open Group  Standard
202       is  the  referee document. The original Standard can be obtained online
203       at http://www.opengroup.org/unix/online.html .
204
205
206
207IEEE/The Open Group                  2003                           FMTMSG(3P)
Impressum