xref: /illumos-gate/usr/src/head/fmtmsg.h (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved	*/
24 
25 
26 /*
27  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28  * Copyright 2014-2015 PALO, Richard.
29  *
30  * Copyright 1996-2003 Sun Microsystems, Inc.  All rights reserved.
31  * Use is subject to license terms.
32  */
33 
34 #ifndef	_FMTMSG_H
35 #define	_FMTMSG_H
36 
37 #include <sys/feature_tests.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * fmtmsg.h
45  *
46  *	The <fmtmsg.h> header file contains the definitions needed
47  *	to use the fmtmsg() function.  This function writes messages
48  *	in a standard format to the standard error stream (stderr)
49  *	and to the system console.
50  */
51 
52 /*
53  * Constraint definitions:
54  *	MM_MXLABELLN	Maximum size of a "label" in a message
55  *	MM_MXTAGLN	Maximum size of a "tag" in a message
56  *	MM_MXTXTLN	Maximum size of a text string
57  *	MM_MXACTLN	Maximum size of an action string
58  */
59 
60 #define	MM_MXLABELLN	25
61 #define	MM_MXTAGLN	32
62 #define	MM_MXTXTLN	512
63 #define	MM_MXACTLN	512
64 
65 /*
66  * Environment variable names used by fmtmsg():
67  *	MSGVERB		Tells fmtmsg() which components it is to write
68  *			to the standard error stream
69  */
70 
71 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
72 #define	MSGVERB		"MSGVERB"
73 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
74 
75 /*
76  * Classification information
77  *	- Definition of classifications
78  *	- Definition of recoverability
79  *	- Definition of source classifications
80  */
81 
82 /*
83  * Definition of the "null" classification
84  *	MM_NULL		Indicates that the classification has been omitted
85  */
86 
87 #define	MM_NULL		0L
88 
89 /*
90  * Definitions of type classifications:
91  *	MM_HARD		Hardware
92  *	MM_SOFT		Software
93  *	MM_FIRM		Firmware
94  */
95 
96 #define	MM_HARD		0x00000001L
97 #define	MM_SOFT		0x00000002L
98 #define	MM_FIRM		0x00000004L
99 
100 /*
101  * Definitions of recoverability subclassification
102  *	MM_RECOVER	Recoverable
103  *	MM_NRECOV	Non-recoverable
104  */
105 
106 #define	MM_RECOVER	0x00000100L
107 #define	MM_NRECOV	0x00000200L
108 
109 /*
110  * Definitions of source subclassification
111  *	MM_APPL		Application
112  *	MM_UTIL		Utility
113  *	MM_OPSYS	Kernel
114  */
115 
116 #define	MM_APPL		0x00000008L
117 #define	MM_UTIL		0x00000010L
118 #define	MM_OPSYS	0x00000020L
119 
120 /*
121  * Definitions for the action to take with the message:
122  *	MM_PRINT	Write to the standard error stream
123  *	MM_CONSOLE	Treat the message as a console message
124  */
125 
126 #define	MM_PRINT	0x00000040L
127 #define	MM_CONSOLE	0x00000080L
128 
129 /*
130  * Constants for severity values
131  *
132  *	SEV_LEVEL	Names the env variable that defines severities
133  *
134  *	MM_NOSEV	Message has no severity
135  *	MM_HALT		Message describes a severe error condition
136  *	MM_ERROR	Message describes an error condition
137  *	MM_WARNING	Message tells of probable error condition
138  *	MM_INFO		Message informs, not in error
139  */
140 
141 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
142 #define	SEV_LEVEL	"SEV_LEVEL"
143 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
144 
145 #define	MM_NOSEV	0
146 #define	MM_HALT		1
147 #define	MM_ERROR	2
148 #define	MM_WARNING	3
149 #define	MM_INFO		4
150 
151 /*
152  * Null values for message components
153  *	MM_NULLLBL		Null value for the label-component
154  *	MM_NULLSEV		Null value for the severity-component
155  *	MM_NULLMC		Null value for the classification-component
156  *	MM_NULLTXT		Null value for the text-component
157  *	MM_NULLACT		Null value for the action-component
158  *	MM_NULLTAG		Null value for the tag-component
159  */
160 
161 #define	MM_NULLLBL	((char *)0)
162 #define	MM_NULLSEV	MM_NOSEV
163 #define	MM_NULLMC	MM_NULL
164 #define	MM_NULLTXT	((char *)0)
165 #define	MM_NULLACT	((char *)0)
166 #define	MM_NULLTAG	((char *)0)
167 
168 /*
169  * Values returned by fmtmsg()
170  *
171  *	MM_NOTOK	None of the requested messages were generated
172  *	MM_NOMSG	No message was written to stderr
173  *	MM_NOCON	No console message was generated
174  */
175 
176 #define	MM_NOTOK	-1
177 #define	MM_OK		0x00
178 #define	MM_NOMSG	0x01
179 #define	MM_NOCON	0x04
180 
181 /* Function definition */
182 
183 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
184 int	addseverity(int, const char *);
185 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
186 
187 int	fmtmsg(long, const char *, int, const char *, const char *,
188 	    const char *);
189 
190 #ifdef	__cplusplus
191 }
192 #endif
193 
194 #endif	/* _FMTMSG_H */
195