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