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