FMTMSG(3P)
π FMTMSG(3P) β the POSIX Programmer's Manual, but make it cute π
okay bestie, welcome to the glow-up of FMTMSG(3P), straight outta the POSIX Programmer's Manual. π
β¨ PROLOG β¨
so like, real talk before we get into it: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β so if you're on Linux, go consult the corresponding Linux manual page for the deets on Linux behavior, mmkay? Or, plot twist, the interface might not even be implemented on Linux at all. π
πΈ NAME πΈ
fmtmsg β display a message in the specified format on standard error and/or a system console
π¦ SYNOPSIS π¦
#include <fmtmsg.h>
int fmtmsg(long classification, const char *label, int severity,
const char *text, const char *action, const char *tag);
π DESCRIPTION π
So the fmtmsg() function shall display messages in a specified format instead of using the traditional printf() function. She's not like other girls, okay? She has a format. β¨
Based on a message's classification component, fmtmsg() shall write a formatted message either to standard error, to the console, or to both. Choose your fighter (or both, we love an overachiever).
A formatted message consists of up to five components, defined below. The component classification is not part of a message displayed to the user, but it defines the source of the message and directs the display of the formatted message. It's giving backstage crew β you don't see her, but the whole show runs on her energy. π
classificationβ Contains the sum of identifying values constructed from the constants defined below. 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 the system console.) Slay responsibly.
Major Classifications
Identifies the source of the condition. Identifiers are:
MM_HARDβ hardwareMM_SOFTβ softwareMM_FIRMβ firmware
Message Source Subclassifications
Identifies the type of software in which the problem is detected. Identifiers are:
MM_APPLβ applicationMM_UTILβ utilityMM_OPSYSβ operating system
Display Subclassifications
Indicates where the message is to be displayed. Identifiers are:
MM_PRINTβ to display the message on the standard error streamMM_CONSOLEβ to display the message on the system console
One or both identifiers may be used. Pick one, pick both, live your truth. π«Ά
Status Subclassifications
Indicates whether the application can recover from the condition. Identifiers are:
MM_RECOVERβ recoverableMM_NRECOVβ non-recoverable
An additional identifier, MM_NULLMC, indicates that no classification component is supplied for the message. (Basically the "no thoughts, head empty" option. π)
labelβ Identifies the source of the message. The format is two fields separated by a<colon>. The first field is up to 10 bytes, the second is up to 14 bytes. Tiny but mighty, fr fr.severityβ Indicates the seriousness of the condition. Identifiers for the levels of severity are:MM_HALTβ Indicates that the application has encountered a severe fault and is halting. Produces the string"HALT".MM_ERRORβ Indicates that the application has detected a fault. Produces the string"ERROR".MM_WARNINGβ Indicates a condition that is out of the ordinary, that might be a problem, and should be watched. Produces the string"WARNING".MM_INFOβ Provides information about a condition that is not in error. Produces the string"INFO".MM_NOSEVβ Indicates that no severity level is supplied for the message.
textβ Describes the error condition that produced the message. The character string is not limited to a specific size. If the character string is empty, then the text produced is unspecified. (iykyk β don't test it, bestie. π)actionβ Describes the first step to be taken in the error-recovery process. Thefmtmsg()function precedes the action string with the prefix:"TOFIX:". The action string is not limited to a specific size. She's long-winded and we respect it. πtagβ An identifier that references on-line documentation for the message. Suggested usage is thattagincludes thelabeland a unique identifying number. A sample tag is"XSI:cat:146".
The MSGVERB environment variable (for message verbosity) shall determine for fmtmsg() which message components it is to select when writing messages to standard error. The value of MSGVERB shall be a <colon>-separated list of optional keywords. 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() shall include 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 shall not be 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, or if it contains keywords other than the valid ones listed above, fmtmsg() shall select all components. She's generous like that.
MSGVERB shall determine which components are selected for display to standard error. All message components shall be included in console messages. No cherry-picking for the console, bestie. π
π RETURN VALUE π
The fmtmsg() function shall return one of the following values:
MM_OKβ The function succeeded. π iconic.MM_NOTOKβ The function failed completely. πMM_NOMSGβ The function was unable to generate a message on standard error, but otherwise succeeded.MM_NOCONβ The function was unable to generate a console message, but otherwise succeeded.
π ERRORS π
None.
The following sections are informative.
β EXAMPLES β
- The following example of
fmtmsg():
fmtmsg(MM_PRINT, "XSI:cat", MM_ERROR, "illegal option",
"refer to cat in user's reference manual", "XSI:cat:001")
produces a complete message in the specified message format:
XSI:cat: ERROR: illegal option
TO FIX: refer to cat in user's reference manual XSI:cat:001
- When the environment variable
MSGVERBis set as follows:
MSGVERB=severity:text:action
and Example 1 is used, fmtmsg() produces:
ERROR: illegal option
TO FIX: refer to cat in user's reference manual
π§ APPLICATION USAGE π§
One or more message components may be systematically omitted from messages generated by an application by using the null value of the argument for that component. Ghost them (the components, not your friends). π»
π RATIONALE π
None.
π FUTURE DIRECTIONS π
None.
πΈ SEE ALSO πΈ
fprintf()- The Base Definitions volume of POSIX.1β2017,
<fmtmsg.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay that's the whole thing bestie, no notes, she ate and left no crumbs π β¨ β this was IEEE/The Open Group, 2017, signing off π«Άπ
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms