fmtmsg(3) Library Functions Manual fmtmsg(3) fmtmsg - LIBRARY Standard C library (libc, -lc) #include int fmtmsg(long classification, const char *label, int severity, const char *text, const char *action, const char *tag); , , (), classification. , stderr, MSGVERB. label . , ; 10 , -- 14. text . action . , <>. tag -, . label . . (classification) MM_NULLMC (0L) , . (severity) NO_SEV (0) , . MM_NULLLBL, MM_NULLTXT, MM_NULLACT, MM_NULLTAG ((char *) 0) -- , MM_NULLSEV -- NO_SEV. classification -- , 4 . . MM_PRINT stderr. MM_CONSOLE . MM_PRINT | MM_CONSOLE . . MM_HARD . MM_FIRM . MM_SOFT . . MM_APPL . MM_UTIL . MM_OPSYS . : MM_RECOVER . MM_NRECOV . severity : MM_NOSEV . MM_HALT . MM_ERROR . MM_WARNING . MM_INFO . 0 4. addseverity(3) SEV_LEVEL . 4 : MM_OK . MM_NOTOK . MM_NOMSG stderr. MM_NOCON . The environment variable MSGVERB ("message verbosity") can be used to suppress parts of the output to stderr. (It does not influence output to the console.) When this variable is defined, is non-NULL, and is a colon-separated list of valid keywords, then only the parts of the message corresponding to these keywords is printed. Valid keywords are "label", "severity", "text", "action", and "tag". SEV_LEVEL . , , . fmtmsg() . SEV_LEVEL SEV_LEVEL=[[:[:...]]] fmtmsg() --,,- then fmtmsg() will also accept the indicated values for the level (in addition to the standard levels 0-4), and use the indicated printstring when such a level occurs. <<-->> fmtmsg(), . <<>> -- , . 4. fmtmsg() . . <<->> -- , , fmtmsg(). attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |fmtmsg() | | glibc >= 2.16: MT-Safe; | | | | glibc < 2.16: MT-Unsafe | +----------------------------+----------------------------------------------------------+--------------------------+ glibc 2.16 fmtmsg() , . glibc 2.16 fmtmsg() , . fmtmsg() MSGVERB POSIX.1-2008. fmtmsg() System V. POSIX.1-2001 and POSIX.1-2008. glibc 2.1. MSGVERB System V. POSIX.1-2001 and POSIX.1-2008. SEV_LEVEL System V. System V UnixWare , < addsev()>> < vlfmt()>>, . #include #include #include int main(void) { long class = MM_PRINT | MM_SOFT | MM_OPSYS | MM_RECOVER; int err; err = fmtmsg(class, "util-linux:mount", MM_ERROR, "unknown mount option", "See mount(8).", "util-linux:mount:017"); switch (err) { case MM_OK: break; case MM_NOTOK: printf("Nothing printed\n"); break; case MM_NOMSG: printf("Nothing printed to stderr\n"); break; case MM_NOCON: printf("No console output\n"); break; default: printf("Unknown error from fmtmsg()\n"); } exit(EXIT_SUCCESS); } : util-linux:mount: ERROR: unknown mount option TO FIX: mount(8). util-linux:mount:017 MSGVERB=text:action; export MSGVERB : mount TO FIX: mount(8). . addseverity(3), perror(3) Azamat Hackimov , Dmitry Bolkhovskikh , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . fmtmsg(3)