1*b30d1939SAndy Fiddaman /***********************************************************************
2*b30d1939SAndy Fiddaman *                                                                      *
3*b30d1939SAndy Fiddaman *               This software is part of the ast package               *
4*b30d1939SAndy Fiddaman *          Copyright (c) 1985-2011 AT&T Intellectual Property          *
5*b30d1939SAndy Fiddaman *                      and is licensed under the                       *
6*b30d1939SAndy Fiddaman *                 Eclipse Public License, Version 1.0                  *
7*b30d1939SAndy Fiddaman *                    by AT&T Intellectual Property                     *
8*b30d1939SAndy Fiddaman *                                                                      *
9*b30d1939SAndy Fiddaman *                A copy of the License is available at                 *
10*b30d1939SAndy Fiddaman *          http://www.eclipse.org/org/documents/epl-v10.html           *
11*b30d1939SAndy Fiddaman *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12*b30d1939SAndy Fiddaman *                                                                      *
13*b30d1939SAndy Fiddaman *              Information and Software Systems Research               *
14*b30d1939SAndy Fiddaman *                            AT&T Research                             *
15*b30d1939SAndy Fiddaman *                           Florham Park NJ                            *
16*b30d1939SAndy Fiddaman *                                                                      *
17*b30d1939SAndy Fiddaman *                 Glenn Fowler <gsf@research.att.com>                  *
18*b30d1939SAndy Fiddaman *                  David Korn <dgk@research.att.com>                   *
19*b30d1939SAndy Fiddaman *                   Phong Vo <kpv@research.att.com>                    *
20*b30d1939SAndy Fiddaman *                                                                      *
21*b30d1939SAndy Fiddaman ***********************************************************************/
22*b30d1939SAndy Fiddaman #pragma prototyped
23*b30d1939SAndy Fiddaman /*
24*b30d1939SAndy Fiddaman  * fmtmsg interface definitions
25*b30d1939SAndy Fiddaman  */
26*b30d1939SAndy Fiddaman 
27*b30d1939SAndy Fiddaman #ifndef _FMTMSG_H
28*b30d1939SAndy Fiddaman #define _FMTMSG_H
29*b30d1939SAndy Fiddaman 
30*b30d1939SAndy Fiddaman #define	MM_VERB_ENV	"MSGVERB"	/* keyword filter env var	*/
31*b30d1939SAndy Fiddaman #define	MM_SEVERITY_ENV	"SEV_LEVEL"	/* alternate severity env var	*/
32*b30d1939SAndy Fiddaman 
33*b30d1939SAndy Fiddaman /* max component length */
34*b30d1939SAndy Fiddaman 
35*b30d1939SAndy Fiddaman #define MM_LABEL_1_MAX	10		/* label field 1 length		*/
36*b30d1939SAndy Fiddaman #define MM_LABEL_2_MAX	14		/* label field 2 length		*/
37*b30d1939SAndy Fiddaman 
38*b30d1939SAndy Fiddaman /* classification type */
39*b30d1939SAndy Fiddaman 
40*b30d1939SAndy Fiddaman #define	MM_HARD		0x00000001L	/* hardware			*/
41*b30d1939SAndy Fiddaman #define	MM_SOFT		0x00000002L	/* software			*/
42*b30d1939SAndy Fiddaman #define	MM_FIRM		0x00000004L	/* firmware			*/
43*b30d1939SAndy Fiddaman 
44*b30d1939SAndy Fiddaman /* classification source */
45*b30d1939SAndy Fiddaman 
46*b30d1939SAndy Fiddaman #define	MM_APPL		0x00000010L	/* application			*/
47*b30d1939SAndy Fiddaman #define MM_UTIL		0x00000020L	/* utility			*/
48*b30d1939SAndy Fiddaman #define	MM_OPSYS	0x00000040L	/* kernel			*/
49*b30d1939SAndy Fiddaman 
50*b30d1939SAndy Fiddaman /* classification display */
51*b30d1939SAndy Fiddaman 
52*b30d1939SAndy Fiddaman #define	MM_PRINT	0x00000100L	/* stderr			*/
53*b30d1939SAndy Fiddaman #define	MM_CONSOLE	0x00000200L	/* console			*/
54*b30d1939SAndy Fiddaman 
55*b30d1939SAndy Fiddaman /* classification status */
56*b30d1939SAndy Fiddaman 
57*b30d1939SAndy Fiddaman #define	MM_RECOVER	0x00001000L	/* recoverable			*/
58*b30d1939SAndy Fiddaman #define	MM_NRECOV	0x00002000L	/* non-recoverable		*/
59*b30d1939SAndy Fiddaman 
60*b30d1939SAndy Fiddaman /* severity */
61*b30d1939SAndy Fiddaman 
62*b30d1939SAndy Fiddaman #define MM_NOSEV	0x0		/* no severity			*/
63*b30d1939SAndy Fiddaman #define	MM_HALT		0x1		/* severe fault			*/
64*b30d1939SAndy Fiddaman #define	MM_ERROR	0x2		/* fault			*/
65*b30d1939SAndy Fiddaman #define	MM_WARNING	0x4		/* could be a problem		*/
66*b30d1939SAndy Fiddaman #define	MM_INFO		0x8		/* not an error (noise?)	*/
67*b30d1939SAndy Fiddaman 
68*b30d1939SAndy Fiddaman /* fmtmsg return value */
69*b30d1939SAndy Fiddaman 
70*b30d1939SAndy Fiddaman #define	MM_OK		0		/* succeeded			*/
71*b30d1939SAndy Fiddaman #define	MM_NOTOK	3		/* failed completely		*/
72*b30d1939SAndy Fiddaman #define	MM_NOMSG	1		/* stderr message failed	*/
73*b30d1939SAndy Fiddaman #define MM_NOCON	2		/* console message failed	*/
74*b30d1939SAndy Fiddaman 
75*b30d1939SAndy Fiddaman /* null argument values -- 0 just doesn't get any respect */
76*b30d1939SAndy Fiddaman 
77*b30d1939SAndy Fiddaman #define MM_NULLLBL	(char*)0	/* label			*/
78*b30d1939SAndy Fiddaman #define MM_NULLSEV	0		/* severity			*/
79*b30d1939SAndy Fiddaman #define	MM_NULLMC	0L		/* class			*/
80*b30d1939SAndy Fiddaman #define MM_NULLTXT	(char*)0	/* text				*/
81*b30d1939SAndy Fiddaman #define MM_NULLACT	(char*)0	/* action			*/
82*b30d1939SAndy Fiddaman #define MM_NULLTAG	(char*)0	/* tag				*/
83*b30d1939SAndy Fiddaman 
84*b30d1939SAndy Fiddaman #ifdef MM_TABLES
85*b30d1939SAndy Fiddaman 
86*b30d1939SAndy Fiddaman /* encoding support */
87*b30d1939SAndy Fiddaman 
88*b30d1939SAndy Fiddaman typedef struct
89*b30d1939SAndy Fiddaman {
90*b30d1939SAndy Fiddaman 	const char*	name;
91*b30d1939SAndy Fiddaman 	const char*	display;
92*b30d1939SAndy Fiddaman 	unsigned int	value;
93*b30d1939SAndy Fiddaman } MM_table_t;
94*b30d1939SAndy Fiddaman 
95*b30d1939SAndy Fiddaman #define mm_class	_mm_class
96*b30d1939SAndy Fiddaman #define mm_severity	_mm_severity()
97*b30d1939SAndy Fiddaman #define mm_verb		_mm_verb
98*b30d1939SAndy Fiddaman 
99*b30d1939SAndy Fiddaman #define MM_all		0xff
100*b30d1939SAndy Fiddaman #define MM_action	0x01
101*b30d1939SAndy Fiddaman #define MM_class	0x02
102*b30d1939SAndy Fiddaman #define MM_label	0x04
103*b30d1939SAndy Fiddaman #define MM_severity	0x08
104*b30d1939SAndy Fiddaman #define MM_source	0x10
105*b30d1939SAndy Fiddaman #define MM_status	0x20
106*b30d1939SAndy Fiddaman #define MM_tag		0x40
107*b30d1939SAndy Fiddaman #define MM_text		0x80
108*b30d1939SAndy Fiddaman 
109*b30d1939SAndy Fiddaman #define MM_default	(MM_action|MM_label|MM_severity|MM_tag|MM_text)
110*b30d1939SAndy Fiddaman 
111*b30d1939SAndy Fiddaman #if _BLD_ast && defined(__EXPORT__)
112*b30d1939SAndy Fiddaman #define extern		__EXPORT__
113*b30d1939SAndy Fiddaman #endif
114*b30d1939SAndy Fiddaman #if !_BLD_ast && defined(__IMPORT__)
115*b30d1939SAndy Fiddaman #define extern		extern __IMPORT__
116*b30d1939SAndy Fiddaman #endif
117*b30d1939SAndy Fiddaman 
118*b30d1939SAndy Fiddaman extern const MM_table_t		mm_class[];
119*b30d1939SAndy Fiddaman extern const MM_table_t		mm_verb[];
120*b30d1939SAndy Fiddaman 
121*b30d1939SAndy Fiddaman #undef	extern
122*b30d1939SAndy Fiddaman 
123*b30d1939SAndy Fiddaman #if _BLD_ast && defined(__EXPORT__)
124*b30d1939SAndy Fiddaman #define extern		__EXPORT__
125*b30d1939SAndy Fiddaman #endif
126*b30d1939SAndy Fiddaman 
127*b30d1939SAndy Fiddaman extern const MM_table_t*	mm_severity;
128*b30d1939SAndy Fiddaman 
129*b30d1939SAndy Fiddaman #undef	extern
130*b30d1939SAndy Fiddaman 
131*b30d1939SAndy Fiddaman #endif
132*b30d1939SAndy Fiddaman 
133*b30d1939SAndy Fiddaman #if _BLD_ast && defined(__EXPORT__)
134*b30d1939SAndy Fiddaman #define extern		__EXPORT__
135*b30d1939SAndy Fiddaman #endif
136*b30d1939SAndy Fiddaman 
137*b30d1939SAndy Fiddaman extern int	fmtmsg(long, const char*, int, const char*, const char*, const char*);
138*b30d1939SAndy Fiddaman 
139*b30d1939SAndy Fiddaman #undef	extern
140*b30d1939SAndy Fiddaman 
141*b30d1939SAndy Fiddaman #endif