xref: /onnv-gate/usr/src/lib/libast/sparc/include/ast/error.h (revision 12068:08a39a083754)
14887Schin 
24887Schin /* : : generated by proto : : */
34887Schin /***********************************************************************
44887Schin *                                                                      *
54887Schin *               This software is part of the ast package               *
6*12068SRoger.Faulkner@Oracle.COM *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
74887Schin *                      and is licensed under the                       *
84887Schin *                  Common Public License, Version 1.0                  *
98462SApril.Chin@Sun.COM *                    by AT&T Intellectual Property                     *
104887Schin *                                                                      *
114887Schin *                A copy of the License is available at                 *
124887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
134887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
144887Schin *                                                                      *
154887Schin *              Information and Software Systems Research               *
164887Schin *                            AT&T Research                             *
174887Schin *                           Florham Park NJ                            *
184887Schin *                                                                      *
194887Schin *                 Glenn Fowler <gsf@research.att.com>                  *
204887Schin *                  David Korn <dgk@research.att.com>                   *
214887Schin *                   Phong Vo <kpv@research.att.com>                    *
224887Schin *                                                                      *
234887Schin ***********************************************************************/
244887Schin 
254887Schin /*
264887Schin  * Glenn Fowler
274887Schin  * AT&T Research
284887Schin  *
294887Schin  * option, error and message formatter external definitions
304887Schin  */
314887Schin 
324887Schin #ifndef _ERROR_H
334887Schin #if !defined(__PROTO__)
344887Schin #include <prototyped.h>
354887Schin #endif
364887Schin #if !defined(__LINKAGE__)
374887Schin #define __LINKAGE__		/* 2004-08-11 transition */
384887Schin #endif
394887Schin 
404887Schin #define _ERROR_H
414887Schin 
424887Schin #include <ast.h>
434887Schin #include <option.h>
444887Schin #include <errno.h>
454887Schin 
464887Schin #define ERROR_VERSION	20070319L
474887Schin 
484887Schin #if !defined(errno) && defined(__DYNAMIC__)
494887Schin #define errno		__DYNAMIC__(errno)
504887Schin #endif
514887Schin 
524887Schin #define ERROR_debug(n)	(-(n))
534887Schin #define ERROR_exit(n)	((n)+ERROR_ERROR)
544887Schin #define ERROR_system(n)	(((n)+ERROR_ERROR)|ERROR_SYSTEM)
554887Schin #define ERROR_usage(n)	((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE)
564887Schin #define ERROR_warn(n)	(ERROR_WARNING)
574887Schin 
584887Schin #ifndef ERROR_catalog
594887Schin #define ERROR_catalog(t)		t
604887Schin #endif
614887Schin #ifndef ERROR_dictionary
624887Schin #define ERROR_dictionary(t)		t
634887Schin #endif
644887Schin 
654887Schin #ifndef ERROR_translate
664887Schin #define ERROR_translating()		(error_info.translate&&(ast.locale.set&(1<<AST_LC_MESSAGES)))
67*12068SRoger.Faulkner@Oracle.COM #define ERROR_translate(l,i,d,m)	(ERROR_translating()?errorx((const char*)(l),(const char*)(i),(const char*)(d),(const char*)(m)):(char*)(m))
684887Schin #endif
694887Schin 
704887Schin #define ERROR_INFO	0		/* info message -- no err_id	*/
714887Schin #define ERROR_WARNING	1		/* warning message		*/
724887Schin #define ERROR_ERROR	2		/* error message -- no err_exit	*/
734887Schin #define ERROR_FATAL	3		/* error message with err_exit	*/
744887Schin #define ERROR_NOEXEC	EXIT_NOEXEC	/* shell convention		*/
754887Schin #define ERROR_NOENT	EXIT_NOTFOUND	/* shell convention		*/
764887Schin #define ERROR_PANIC	ERROR_LEVEL	/* panic message with err_exit	*/
774887Schin 
784887Schin #define ERROR_LEVEL	0x00ff		/* level portion of status	*/
794887Schin #define ERROR_SYSTEM	0x0100		/* report system errno message	*/
804887Schin #define ERROR_OUTPUT	0x0200		/* next arg is error fd		*/
814887Schin #define ERROR_SOURCE	0x0400		/* next 2 args are FILE,LINE	*/
824887Schin #define ERROR_USAGE	0x0800		/* usage message		*/
834887Schin #define ERROR_PROMPT	0x1000		/* omit trailing newline	*/
844887Schin #define ERROR_NOID	0x2000		/* omit err_id			*/
854887Schin #define ERROR_LIBRARY	0x4000		/* library routine error	*/
864887Schin 
874887Schin #define ERROR_INTERACTIVE	0x0001	/* context is interactive	*/
884887Schin #define ERROR_SILENT		0x0002	/* context is silent		*/
894887Schin #define ERROR_NOTIFY		0x0004	/* main(-sig,0,ctx) on signal	*/
904887Schin 
914887Schin #define ERROR_FREE		0x0010	/* free context on pop		*/
924887Schin #define ERROR_POP		0x0020	/* pop context			*/
934887Schin #define ERROR_PUSH		0x0040	/* push context			*/
944887Schin #define ERROR_SET		0x0080	/* set context			*/
954887Schin 
964887Schin /*
974887Schin  * errorpush()/errorpop() are obsolete -- use errorctx() instead
984887Schin  */
994887Schin 
1004887Schin #ifndef ERROR_CONTEXT_T
1014887Schin #define ERROR_CONTEXT_T		Error_info_t
1024887Schin #endif
1034887Schin 
1044887Schin #define ERROR_CONTEXT_BASE	((Error_context_t*)&error_info.context)
1054887Schin 
1064887Schin #define errorpush(p,f)	(*(p)= *ERROR_CONTEXT_BASE,*ERROR_CONTEXT_BASE=error_info.empty,error_info.context=(Error_context_t*)(p),error_info.flags=(f))
1074887Schin #define errorpop(p)	(*ERROR_CONTEXT_BASE= *(p))
1084887Schin 
1094887Schin typedef struct Error_info_s Error_info_t;
1104887Schin typedef struct Error_context_s Error_context_t;
1114887Schin 
1124887Schin #define ERROR_CONTEXT \
1134887Schin 	ERROR_CONTEXT_T* context;	/* prev context stack element	*/ \
1144887Schin 	int	errors;			/* >= ERROR_ERROR count		*/ \
1154887Schin 	int	flags;			/* context flags		*/ \
1164887Schin 	int	line;			/* input|output line number	*/ \
1174887Schin 	int	warnings;		/* ERROR_WARNING count		*/ \
1184887Schin 	char*	file;			/* input|output file name	*/ \
1194887Schin 	char*	id;			/* command id			*/
1204887Schin 
1214887Schin struct Error_context_s			/* context stack element	*/
1224887Schin {
1234887Schin 	ERROR_CONTEXT
1244887Schin };
1254887Schin 
1264887Schin struct Error_info_s			/* error state			*/
1274887Schin {
1284887Schin 	int	fd;			/* write(2) fd			*/
1294887Schin 
1304887Schin 	void	(*exit) __PROTO__((int));		/* error exit			*/
1314887Schin 	ssize_t	(*write) __PROTO__((int, const __V_*, size_t)); /* error output	*/
1324887Schin 
1334887Schin 	/* the rest are implicitly initialized				*/
1344887Schin 
1354887Schin 	int	clear;			/* default clear ERROR_* flags	*/
1364887Schin 	int	core;			/* level>=core -> core dump	*/
1374887Schin 	int	indent;			/* debug trace indent level	*/
1384887Schin 	int	init;			/* initialized			*/
1394887Schin 	int	last_errno;		/* last reported errno		*/
1404887Schin 	int	mask;			/* multi level debug trace mask	*/
1414887Schin 	int	set;			/* default set ERROR_* flags	*/
1424887Schin 	int	trace;			/* debug trace level		*/
1434887Schin 
1444887Schin 	char*	version;		/* ERROR_SOURCE command version	*/
1454887Schin 
1464887Schin 	int	(*auxilliary) __PROTO__((Sfio_t*, int, int)); /* aux info to append	*/
1474887Schin 
1484887Schin 	ERROR_CONTEXT			/* top of context stack		*/
1494887Schin 
1504887Schin 	Error_context_t	empty;		/* empty context stack element	*/
1514887Schin 
1524887Schin 	unsigned long	time;		/* debug time trace		*/
1534887Schin 
1544887Schin 	char*	(*translate) __PROTO__((const char*, const char*, const char*, const char*));	/* format translator */
1554887Schin 
1564887Schin 	const char*	catalog;	/* message catalog		*/
1574887Schin };
1584887Schin 
1594887Schin #ifndef errno
1604887Schin extern __MANGLE__ int	errno;			/* system call error status	*/
1614887Schin #endif
1624887Schin 
1634887Schin #if _BLD_ast && defined(__EXPORT__)
1644887Schin #undef __MANGLE__
1654887Schin #define __MANGLE__ __LINKAGE__ __EXPORT__
1664887Schin #endif
1674887Schin #if !_BLD_ast && defined(__IMPORT__)
1684887Schin #undef __MANGLE__
1694887Schin #define __MANGLE__ __LINKAGE__ __IMPORT__
1704887Schin #endif
1714887Schin 
1724887Schin extern __MANGLE__ Error_info_t*	_error_infop_;
1734887Schin 
1744887Schin #define error_info	(*_error_infop_)
1754887Schin 
1764887Schin #undef __MANGLE__
1774887Schin #define __MANGLE__ __LINKAGE__
1784887Schin 
1794887Schin #if _BLD_ast && defined(__EXPORT__)
1804887Schin #undef __MANGLE__
1814887Schin #define __MANGLE__ __LINKAGE__		__EXPORT__
1824887Schin #endif
1834887Schin 
1844887Schin extern __MANGLE__ void		error __PROTO__((int, ...));
1854887Schin extern __MANGLE__ int		errormsg __PROTO__((const char*, int, ...));
1864887Schin extern __MANGLE__ int		errorf __PROTO__((__V_*, __V_*, int, ...));
1874887Schin extern __MANGLE__ void		errorv __PROTO__((const char*, int, va_list));
1884887Schin #ifndef errorx
1894887Schin extern __MANGLE__ char*		errorx __PROTO__((const char*, const char*, const char*, const char*));
1904887Schin #endif
1914887Schin extern __MANGLE__ Error_info_t*	errorctx __PROTO__((Error_info_t*, int, int));
1924887Schin 
1934887Schin #undef __MANGLE__
1944887Schin #define __MANGLE__ __LINKAGE__
1954887Schin 
1964887Schin #endif
197