dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libast / i386 / include / ast / error.h
blobc0e21dadd7cdfcabc1ef35730caa9c02b2969fab
2 /* : : generated by proto : : */
3 /***********************************************************************
4 * *
5 * This software is part of the ast package *
6 * Copyright (c) 1985-2010 AT&T Intellectual Property *
7 * and is licensed under the *
8 * Common Public License, Version 1.0 *
9 * by AT&T Intellectual Property *
10 * *
11 * A copy of the License is available at *
12 * http://www.opensource.org/licenses/cpl1.0.txt *
13 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
14 * *
15 * Information and Software Systems Research *
16 * AT&T Research *
17 * Florham Park NJ *
18 * *
19 * Glenn Fowler <gsf@research.att.com> *
20 * David Korn <dgk@research.att.com> *
21 * Phong Vo <kpv@research.att.com> *
22 * *
23 ***********************************************************************/
26 * Glenn Fowler
27 * AT&T Research
29 * option, error and message formatter external definitions
32 #ifndef _ERROR_H
33 #if !defined(__PROTO__)
34 #include <prototyped.h>
35 #endif
36 #if !defined(__LINKAGE__)
37 #define __LINKAGE__ /* 2004-08-11 transition */
38 #endif
40 #define _ERROR_H
42 #include <ast.h>
43 #include <option.h>
44 #include <errno.h>
46 #define ERROR_VERSION 20070319L
48 #if !defined(errno) && defined(__DYNAMIC__)
49 #define errno __DYNAMIC__(errno)
50 #endif
52 #define ERROR_debug(n) (-(n))
53 #define ERROR_exit(n) ((n)+ERROR_ERROR)
54 #define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM)
55 #define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE)
56 #define ERROR_warn(n) (ERROR_WARNING)
58 #ifndef ERROR_catalog
59 #define ERROR_catalog(t) t
60 #endif
61 #ifndef ERROR_dictionary
62 #define ERROR_dictionary(t) t
63 #endif
65 #ifndef ERROR_translate
66 #define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<<AST_LC_MESSAGES)))
67 #define ERROR_translate(l,i,d,m) (ERROR_translating()?errorx((const char*)(l),(const char*)(i),(const char*)(d),(const char*)(m)):(char*)(m))
68 #endif
70 #define ERROR_INFO 0 /* info message -- no err_id */
71 #define ERROR_WARNING 1 /* warning message */
72 #define ERROR_ERROR 2 /* error message -- no err_exit */
73 #define ERROR_FATAL 3 /* error message with err_exit */
74 #define ERROR_NOEXEC EXIT_NOEXEC /* shell convention */
75 #define ERROR_NOENT EXIT_NOTFOUND /* shell convention */
76 #define ERROR_PANIC ERROR_LEVEL /* panic message with err_exit */
78 #define ERROR_LEVEL 0x00ff /* level portion of status */
79 #define ERROR_SYSTEM 0x0100 /* report system errno message */
80 #define ERROR_OUTPUT 0x0200 /* next arg is error fd */
81 #define ERROR_SOURCE 0x0400 /* next 2 args are FILE,LINE */
82 #define ERROR_USAGE 0x0800 /* usage message */
83 #define ERROR_PROMPT 0x1000 /* omit trailing newline */
84 #define ERROR_NOID 0x2000 /* omit err_id */
85 #define ERROR_LIBRARY 0x4000 /* library routine error */
87 #define ERROR_INTERACTIVE 0x0001 /* context is interactive */
88 #define ERROR_SILENT 0x0002 /* context is silent */
89 #define ERROR_NOTIFY 0x0004 /* main(-sig,0,ctx) on signal */
91 #define ERROR_FREE 0x0010 /* free context on pop */
92 #define ERROR_POP 0x0020 /* pop context */
93 #define ERROR_PUSH 0x0040 /* push context */
94 #define ERROR_SET 0x0080 /* set context */
97 * errorpush()/errorpop() are obsolete -- use errorctx() instead
100 #ifndef ERROR_CONTEXT_T
101 #define ERROR_CONTEXT_T Error_info_t
102 #endif
104 #define ERROR_CONTEXT_BASE ((Error_context_t*)&error_info.context)
106 #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))
107 #define errorpop(p) (*ERROR_CONTEXT_BASE= *(p))
109 typedef struct Error_info_s Error_info_t;
110 typedef struct Error_context_s Error_context_t;
112 #define ERROR_CONTEXT \
113 ERROR_CONTEXT_T* context; /* prev context stack element */ \
114 int errors; /* >= ERROR_ERROR count */ \
115 int flags; /* context flags */ \
116 int line; /* input|output line number */ \
117 int warnings; /* ERROR_WARNING count */ \
118 char* file; /* input|output file name */ \
119 char* id; /* command id */
121 struct Error_context_s /* context stack element */
123 ERROR_CONTEXT
126 struct Error_info_s /* error state */
128 int fd; /* write(2) fd */
130 void (*exit) __PROTO__((int)); /* error exit */
131 ssize_t (*write) __PROTO__((int, const __V_*, size_t)); /* error output */
133 /* the rest are implicitly initialized */
135 int clear; /* default clear ERROR_* flags */
136 int core; /* level>=core -> core dump */
137 int indent; /* debug trace indent level */
138 int init; /* initialized */
139 int last_errno; /* last reported errno */
140 int mask; /* multi level debug trace mask */
141 int set; /* default set ERROR_* flags */
142 int trace; /* debug trace level */
144 char* version; /* ERROR_SOURCE command version */
146 int (*auxilliary) __PROTO__((Sfio_t*, int, int)); /* aux info to append */
148 ERROR_CONTEXT /* top of context stack */
150 Error_context_t empty; /* empty context stack element */
152 unsigned long time; /* debug time trace */
154 char* (*translate) __PROTO__((const char*, const char*, const char*, const char*)); /* format translator */
156 const char* catalog; /* message catalog */
159 #ifndef errno
160 extern __MANGLE__ int errno; /* system call error status */
161 #endif
163 #if _BLD_ast && defined(__EXPORT__)
164 #undef __MANGLE__
165 #define __MANGLE__ __LINKAGE__ __EXPORT__
166 #endif
167 #if !_BLD_ast && defined(__IMPORT__)
168 #undef __MANGLE__
169 #define __MANGLE__ __LINKAGE__ __IMPORT__
170 #endif
172 extern __MANGLE__ Error_info_t* _error_infop_;
174 #define error_info (*_error_infop_)
176 #undef __MANGLE__
177 #define __MANGLE__ __LINKAGE__
179 #if _BLD_ast && defined(__EXPORT__)
180 #undef __MANGLE__
181 #define __MANGLE__ __LINKAGE__ __EXPORT__
182 #endif
184 extern __MANGLE__ void error __PROTO__((int, ...));
185 extern __MANGLE__ int errormsg __PROTO__((const char*, int, ...));
186 extern __MANGLE__ int errorf __PROTO__((__V_*, __V_*, int, ...));
187 extern __MANGLE__ void errorv __PROTO__((const char*, int, va_list));
188 #ifndef errorx
189 extern __MANGLE__ char* errorx __PROTO__((const char*, const char*, const char*, const char*));
190 #endif
191 extern __MANGLE__ Error_info_t* errorctx __PROTO__((Error_info_t*, int, int));
193 #undef __MANGLE__
194 #define __MANGLE__ __LINKAGE__
196 #endif