xref: /titanic_51/usr/src/head/fmtmsg.h (revision 4870e0a7381ec2ec57437062574e6ddc3dd48d7f)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
237c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28*4870e0a7SRichard PALO  * Copyright 2014-2015 PALO, Richard.
29ba3594baSGarrett D'Amore  *
307c478bd9Sstevel@tonic-gate  * Copyright 1996-2003 Sun Microsystems, Inc.  All rights reserved.
317c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifndef	_FMTMSG_H
357c478bd9Sstevel@tonic-gate #define	_FMTMSG_H
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
407c478bd9Sstevel@tonic-gate extern "C" {
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate  * fmtmsg.h
457c478bd9Sstevel@tonic-gate  *
467c478bd9Sstevel@tonic-gate  *	The <fmtmsg.h> header file contains the definitions needed
477c478bd9Sstevel@tonic-gate  *	to use the fmtmsg() function.  This function writes messages
487c478bd9Sstevel@tonic-gate  *	in a standard format to the standard error stream (stderr)
497c478bd9Sstevel@tonic-gate  *	and to the system console.
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * Constraint definitions:
547c478bd9Sstevel@tonic-gate  *	MM_MXLABELLN	Maximum size of a "label" in a message
557c478bd9Sstevel@tonic-gate  *	MM_MXTAGLN	Maximum size of a "tag" in a message
567c478bd9Sstevel@tonic-gate  *	MM_MXTXTLN	Maximum size of a text string
577c478bd9Sstevel@tonic-gate  *	MM_MXACTLN	Maximum size of an action string
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #define	MM_MXLABELLN	25
617c478bd9Sstevel@tonic-gate #define	MM_MXTAGLN	32
627c478bd9Sstevel@tonic-gate #define	MM_MXTXTLN	512
637c478bd9Sstevel@tonic-gate #define	MM_MXACTLN	512
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate /*
667c478bd9Sstevel@tonic-gate  * Environment variable names used by fmtmsg():
677c478bd9Sstevel@tonic-gate  *	MSGVERB		Tells fmtmsg() which components it is to write
687c478bd9Sstevel@tonic-gate  *			to the standard error stream
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
727c478bd9Sstevel@tonic-gate #define	MSGVERB		"MSGVERB"
737c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate /*
767c478bd9Sstevel@tonic-gate  * Classification information
777c478bd9Sstevel@tonic-gate  *	- Definition of classifications
787c478bd9Sstevel@tonic-gate  *	- Definition of recoverability
797c478bd9Sstevel@tonic-gate  *	- Definition of source classifications
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * Definition of the "null" classification
847c478bd9Sstevel@tonic-gate  *	MM_NULL		Indicates that the classification has been omitted
857c478bd9Sstevel@tonic-gate  */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #define	MM_NULL		0L
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate /*
907c478bd9Sstevel@tonic-gate  * Definitions of type classifications:
917c478bd9Sstevel@tonic-gate  *	MM_HARD		Hardware
927c478bd9Sstevel@tonic-gate  *	MM_SOFT		Software
937c478bd9Sstevel@tonic-gate  *	MM_FIRM		Firmware
947c478bd9Sstevel@tonic-gate  */
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate #define	MM_HARD		0x00000001L
977c478bd9Sstevel@tonic-gate #define	MM_SOFT		0x00000002L
987c478bd9Sstevel@tonic-gate #define	MM_FIRM		0x00000004L
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * Definitions of recoverability subclassification
1027c478bd9Sstevel@tonic-gate  *	MM_RECOVER	Recoverable
1037c478bd9Sstevel@tonic-gate  *	MM_NRECOV	Non-recoverable
1047c478bd9Sstevel@tonic-gate  */
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate #define	MM_RECOVER	0x00000100L
1077c478bd9Sstevel@tonic-gate #define	MM_NRECOV	0x00000200L
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate /*
1107c478bd9Sstevel@tonic-gate  * Definitions of source subclassification
1117c478bd9Sstevel@tonic-gate  *	MM_APPL		Application
1127c478bd9Sstevel@tonic-gate  *	MM_UTIL		Utility
1137c478bd9Sstevel@tonic-gate  *	MM_OPSYS	Kernel
1147c478bd9Sstevel@tonic-gate  */
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #define	MM_APPL		0x00000008L
1177c478bd9Sstevel@tonic-gate #define	MM_UTIL		0x00000010L
1187c478bd9Sstevel@tonic-gate #define	MM_OPSYS	0x00000020L
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate /*
1217c478bd9Sstevel@tonic-gate  * Definitions for the action to take with the message:
1227c478bd9Sstevel@tonic-gate  *	MM_PRINT	Write to the standard error stream
1237c478bd9Sstevel@tonic-gate  *	MM_CONSOLE	Treat the message as a console message
1247c478bd9Sstevel@tonic-gate  */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #define	MM_PRINT	0x00000040L
1277c478bd9Sstevel@tonic-gate #define	MM_CONSOLE	0x00000080L
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * Constants for severity values
1317c478bd9Sstevel@tonic-gate  *
1327c478bd9Sstevel@tonic-gate  *	SEV_LEVEL	Names the env variable that defines severities
1337c478bd9Sstevel@tonic-gate  *
1347c478bd9Sstevel@tonic-gate  *	MM_NOSEV	Message has no severity
1357c478bd9Sstevel@tonic-gate  *	MM_HALT		Message describes a severe error condition
1367c478bd9Sstevel@tonic-gate  *	MM_ERROR	Message describes an error condition
1377c478bd9Sstevel@tonic-gate  *	MM_WARNING	Message tells of probable error condition
1387c478bd9Sstevel@tonic-gate  *	MM_INFO		Message informs, not in error
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
1427c478bd9Sstevel@tonic-gate #define	SEV_LEVEL	"SEV_LEVEL"
1437c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate #define	MM_NOSEV	0
1467c478bd9Sstevel@tonic-gate #define	MM_HALT		1
1477c478bd9Sstevel@tonic-gate #define	MM_ERROR	2
1487c478bd9Sstevel@tonic-gate #define	MM_WARNING	3
1497c478bd9Sstevel@tonic-gate #define	MM_INFO		4
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * Null values for message components
1537c478bd9Sstevel@tonic-gate  *	MM_NULLLBL		Null value for the label-component
1547c478bd9Sstevel@tonic-gate  *	MM_NULLSEV		Null value for the severity-component
1557c478bd9Sstevel@tonic-gate  *	MM_NULLMC		Null value for the classification-component
1567c478bd9Sstevel@tonic-gate  *	MM_NULLTXT		Null value for the text-component
1577c478bd9Sstevel@tonic-gate  *	MM_NULLACT		Null value for the action-component
1587c478bd9Sstevel@tonic-gate  *	MM_NULLTAG		Null value for the tag-component
1597c478bd9Sstevel@tonic-gate  */
1607c478bd9Sstevel@tonic-gate 
161*4870e0a7SRichard PALO #define	MM_NULLLBL	((char *)0)
1627c478bd9Sstevel@tonic-gate #define	MM_NULLSEV	MM_NOSEV
1637c478bd9Sstevel@tonic-gate #define	MM_NULLMC	MM_NULL
164*4870e0a7SRichard PALO #define	MM_NULLTXT	((char *)0)
165*4870e0a7SRichard PALO #define	MM_NULLACT	((char *)0)
166*4870e0a7SRichard PALO #define	MM_NULLTAG	((char *)0)
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate /*
1697c478bd9Sstevel@tonic-gate  * Values returned by fmtmsg()
1707c478bd9Sstevel@tonic-gate  *
1717c478bd9Sstevel@tonic-gate  *	MM_NOTOK	None of the requested messages were generated
1727c478bd9Sstevel@tonic-gate  *	MM_NOMSG	No message was written to stderr
1737c478bd9Sstevel@tonic-gate  *	MM_NOCON	No console message was generated
1747c478bd9Sstevel@tonic-gate  */
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate #define	MM_NOTOK	-1
1777c478bd9Sstevel@tonic-gate #define	MM_OK		0x00
1787c478bd9Sstevel@tonic-gate #define	MM_NOMSG	0x01
1797c478bd9Sstevel@tonic-gate #define	MM_NOCON	0x04
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate /* Function definition */
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
1847c478bd9Sstevel@tonic-gate int	addseverity(int, const char *);
1857c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate int	fmtmsg(long, const char *, int, const char *, const char *,
1887c478bd9Sstevel@tonic-gate 	    const char *);
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate #endif
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate #endif	/* _FMTMSG_H */
195