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
11

NAME

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

SYNOPSIS

17       #include <fmtmsg.h>
18
19       int fmtmsg(long classification, const char *label, int severity,
20           const char *text, const char *action, const char *tag);
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
36                   constants defined below. Any one identifier from a subclass
37                   may be used in combination with a single identifier from  a
38                   different  subclass.  Two or more identifiers from the same
39                   subclass should not be used together, with the exception of
40                   identifiers  from  the display subclass. (Both display sub‐
41                   class identifiers may be used so that messages can be  dis‐
42                   played to both standard error and the system console.)
43
44                   Major Classifications
45                         Identifies  the  source of the condition. Identifiers
46                         are:  MM_HARD  (hardware),  MM_SOFT  (software),  and
47                         MM_FIRM (firmware).
48
49                   Message Source Subclassifications
50                         Identifies  the type of software in which the problem
51                         is detected.  Identifiers are: MM_APPL (application),
52                         MM_UTIL (utility), and MM_OPSYS (operating system).
53
54                   Display Subclassifications
55                         Indicates where the message is to be displayed. Iden‐
56                         tifiers are: MM_PRINT to display the message  on  the
57                         standard error stream, MM_CONSOLE to display the mes‐
58                         sage on the system console. One or  both  identifiers
59                         may be used.
60
61                   Status Subclassifications
62                         Indicates  whether  the  application can recover from
63                         the condition.  Identifiers are: MM_RECOVER (recover‐
64                         able) and MM_NRECOV (non-recoverable).
65
66                   An  additional  identifier,  MM_NULLMC,  indicates  that no
67                   classification component is supplied for the message.
68
69       label       Identifies the source of the message.  The  format  is  two
70                   fields separated by a <colon>.  The first field is up to 10
71                   bytes, the second is up to 14 bytes.
72
73       severity    Indicates the seriousness of the condition. Identifiers for
74                   the levels of severity are:
75
76                   MM_HALT     Indicates  that the application has encountered
77                               a severe fault and  is  halting.  Produces  the
78                               string "HALT".
79
80                   MM_ERROR    Indicates  that  the application has detected a
81                               fault. Produces the string "ERROR".
82
83                   MM_WARNING  Indicates a condition that is out of the  ordi‐
84                               nary,  that  might  be a problem, and should be
85                               watched. Produces the string "WARNING".
86
87                   MM_INFO     Provides information about a condition that  is
88                               not in error. Produces the string "INFO".
89
90                   MM_NOSEV    Indicates  that  no  severity level is supplied
91                               for the message.
92
93       text        Describes the error condition that  produced  the  message.
94                   The  character string is not limited to a specific size. If
95                   the character string is empty, then the  text  produced  is
96                   unspecified.
97
98       action      Describes  the first step to be taken in the error-recovery
99                   process.  The fmtmsg() function precedes the action  string
100                   with  the  prefix: "TOFIX:".  The action string is not lim‐
101                   ited to a specific size.
102
103       tag         An identifier that references on-line documentation for the
104                   message.   Suggested  usage  is that tag includes the label
105                   and  a  unique  identifying  number.  A   sample   tag   is
106                   "XSI:cat:146".
107
108       The  MSGVERB  environment variable (for message verbosity) shall deter‐
109       mine for fmtmsg() which message components it is to select when writing
110       messages   to   standard  error.  The  value  of  MSGVERB  shall  be  a
111       <colon>-separated list of optional keywords. Valid keywords are: label,
112       severity,  text,  action,  and tag. If MSGVERB contains a keyword for a
113       component and the component's value is not the component's null  value,
114       fmtmsg()  shall  include that component in the message when writing the
115       message to standard error. If MSGVERB does not include a keyword for  a
116       message  component, that component shall not be included in the display
117       of the message. The keywords may appear in any order. If MSGVERB is not
118       defined,  if  its  value is the null string, if its value is not of the
119       correct format, or if it contains keywords other than  the  valid  ones
120       listed above, fmtmsg() shall select all components.
121
122       MSGVERB  shall  determine  which components are selected for display to
123       standard error. All message components shall  be  included  in  console
124       messages.
125

RETURN VALUE

127       The fmtmsg() function shall return one of the following values:
128
129       MM_OK       The function succeeded.
130
131       MM_NOTOK    The function failed completely.
132
133       MM_NOMSG    The  function  was unable to generate a message on standard
134                   error, but otherwise succeeded.
135
136       MM_NOCON    The function was unable to generate a console message,  but
137                   otherwise succeeded.
138

ERRORS

140       None.
141
142       The following sections are informative.
143

EXAMPLES

145        1. The following example of fmtmsg():
146
147               fmtmsg(MM_PRINT, "XSI:cat", MM_ERROR, "illegal option",
148               "refer to cat in user's reference manual", "XSI:cat:001")
149
150           produces a complete message in the specified message format:
151
152               XSI:cat: ERROR: illegal option
153               TO FIX: refer to cat in user's reference manual XSI:cat:001
154
155        2. When the environment variable MSGVERB is set as follows:
156
157               MSGVERB=severity:text:action
158
159           and Example 1 is used, fmtmsg() produces:
160
161               ERROR: illegal option
162               TO FIX: refer to cat in user's reference manual
163

APPLICATION USAGE

165       One  or more message components may be systematically omitted from mes‐
166       sages generated by an application by using the null value of the  argu‐
167       ment for that component.
168

RATIONALE

170       None.
171

FUTURE DIRECTIONS

173       None.
174

SEE ALSO

176       fprintf()
177
178       The Base Definitions volume of POSIX.1‐2008, <fmtmsg.h>
179
181       Portions  of  this text are reprinted and reproduced in electronic form
182       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
183       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
184       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
185       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
186       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
187       event of any discrepancy between this version and the original IEEE and
188       The Open Group Standard, the original IEEE and The Open Group  Standard
189       is  the  referee document. The original Standard can be obtained online
190       at http://www.unix.org/online.html .
191
192       Any typographical or formatting errors that appear  in  this  page  are
193       most likely to have been introduced during the conversion of the source
194       files to man page format. To report such errors,  see  https://www.ker
195       nel.org/doc/man-pages/reporting_bugs.html .
196
197
198
199IEEE/The Open Group                  2013                           FMTMSG(3P)
Impressum