xref: /titanic_44/usr/src/lib/libast/sparcv9/include/ast/ast.h (revision a38ddfee9c8c6b6c5a2947ff52fd2338362a4444)
1 
2 /* : : generated by proto : : */
3 /***********************************************************************
4 *                                                                      *
5 *               This software is part of the ast package               *
6 *           Copyright (c) 1985-2007 AT&T Knowledge Ventures            *
7 *                      and is licensed under the                       *
8 *                  Common Public License, Version 1.0                  *
9 *                      by AT&T Knowledge Ventures                      *
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 ***********************************************************************/
24 
25 /*
26  * Advanced Software Technology Library
27  * AT&T Research
28  *
29  * std + posix + ast
30  */
31 
32 #ifndef _AST_H
33 #if !defined(__PROTO__)
34 #include <prototyped.h>
35 #endif
36 #if !defined(__LINKAGE__)
37 #define __LINKAGE__		/* 2004-08-11 transition */
38 #endif
39 
40 #define _AST_H
41 
42 #include <ast_version.h>
43 
44 #ifndef _AST_STD_H
45 #include <ast_std.h>
46 #endif
47 
48 #ifndef _SFIO_H
49 #include <sfio.h>
50 #endif
51 
52 #ifndef	ast
53 #define ast		_ast_info
54 #endif
55 
56 #ifndef PATH_MAX
57 #define PATH_MAX	1024
58 #endif
59 
60 /*
61  * workaround botched headers that assume <stdio.h>
62  */
63 
64 #ifndef FILE
65 #ifndef _SFIO_H
66 struct _sfio_s;
67 #endif
68 #define FILE		struct _sfio_s
69 #ifndef	__FILE_typedef
70 #define __FILE_typedef	1
71 #endif
72 #ifndef _FILEDEFED
73 #define _FILEDEFED	1
74 #endif
75 #endif
76 
77 /*
78  * exit() support -- this matches shell exit codes
79  */
80 
81 #define EXIT_BITS	8			/* # exit status bits	*/
82 
83 #define EXIT_USAGE	2			/* usage exit code	*/
84 #define EXIT_QUIT	((1<<(EXIT_BITS))-1)	/* parent should quit	*/
85 #define EXIT_NOTFOUND	((1<<(EXIT_BITS-1))-1)	/* command not found	*/
86 #define EXIT_NOEXEC	((1<<(EXIT_BITS-1))-2)	/* other exec error	*/
87 
88 #define EXIT_CODE(x)	((x)&((1<<EXIT_BITS)-1))
89 #define EXIT_CORE(x)	(EXIT_CODE(x)|(1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))
90 #define EXIT_TERM(x)	(EXIT_CODE(x)|(1<<EXIT_BITS))
91 
92 /*
93  * NOTE: for compatibility the following work for EXIT_BITS={7,8}
94  */
95 
96 #define EXIT_STATUS(x)	(((x)&((1<<(EXIT_BITS-2))-1))?(x):EXIT_CODE((x)>>EXIT_BITS))
97 
98 #define EXITED_CORE(x)	(((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))==((1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))||((x)&((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))==((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))
99 #define EXITED_TERM(x)	((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))
100 
101 /*
102  * astconflist() flags
103  */
104 
105 #define ASTCONF_parse		0x0001
106 #define ASTCONF_write		0x0002
107 #define ASTCONF_read		0x0004
108 #define ASTCONF_lower		0x0008
109 #define ASTCONF_base		0x0010
110 #define ASTCONF_defined		0x0020
111 #define ASTCONF_quote		0x0040
112 #define ASTCONF_table		0x0080
113 #define ASTCONF_matchcall	0x0100
114 #define ASTCONF_matchname	0x0200
115 #define ASTCONF_matchstandard	0x0400
116 #define ASTCONF_error		0x0800
117 #define ASTCONF_system		0x1000
118 #define ASTCONF_AST		0x2000
119 
120 /*
121  * pathcanon() flags
122  */
123 
124 #define PATH_PHYSICAL	01
125 #define PATH_DOTDOT	02
126 #define PATH_EXISTS	04
127 #define PATH_VERIFIED(n) (((n)&01777)<<5)
128 
129 /*
130  * pathaccess() flags
131  */
132 
133 #define PATH_READ	004
134 #define PATH_WRITE	002
135 #define PATH_EXECUTE	001
136 #define	PATH_REGULAR	010
137 #define PATH_ABSOLUTE	020
138 
139 /*
140  * touch() flags
141  */
142 
143 #define PATH_TOUCH_CREATE	01
144 #define PATH_TOUCH_VERBATIM	02
145 
146 /*
147  * pathcheck() info
148  */
149 
150 typedef struct
151 {
152 	unsigned long	date;
153 	char*		feature;
154 	char*		host;
155 	char*		user;
156 } Pathcheck_t;
157 
158 /*
159  * strgrpmatch() flags
160  */
161 
162 #define STR_MAXIMAL	01		/* maximal match		*/
163 #define STR_LEFT	02		/* implicit left anchor		*/
164 #define STR_RIGHT	04		/* implicit right anchor	*/
165 #define STR_ICASE	010		/* ignore case			*/
166 #define STR_GROUP	020		/* (|&) inside [@|&](...) only	*/
167 
168 /*
169  * fmtquote() flags
170  */
171 
172 #define FMT_ALWAYS	0x01		/* always quote			*/
173 #define FMT_ESCAPED	0x02		/* already escaped		*/
174 #define FMT_SHELL	0x04		/* escape $ ` too		*/
175 #define FMT_WIDE	0x08		/* don't escape 8 bit chars	*/
176 #define FMT_PARAM	0x10		/* disable FMT_SHELL ${$( quote	*/
177 
178 /*
179  * multibyte macros
180  */
181 
182 #define mbmax()		(ast.mb_cur_max)
183 #define mberr()		(ast.tmp_int<0)
184 
185 #define mbcoll()	(ast.mb_xfrm!=0)
186 #define mbwide()	(mbmax()>1)
187 
188 #define mbchar(p)	(mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p++,ast.tmp_int)):(*(unsigned char*)(p++)))
189 #define mbinit()	(mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0)
190 #define mbsize(p)	(mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1))
191 #define mbconv(s,w)	(ast.mb_conv?(*ast.mb_conv)(s,w):((*(s)=(w)),1))
192 #define mbwidth(w)	(ast.mb_width&&((ast.tmp_int=(*ast.mb_width)(w))>=0||(w)>UCHAR_MAX)?ast.tmp_int:1)
193 #define mbxfrm(t,f,n)	(mbcoll()?(*ast.mb_xfrm)((char*)(t),(char*)(f),n):0)
194 
195 /*
196  * common macros
197  */
198 
199 #define elementsof(x)	(sizeof(x)/sizeof(x[0]))
200 #define integralof(x)	(((char*)(x))-((char*)0))
201 #define newof(p,t,n,x)	((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
202 #define oldof(p,t,n,x)	((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)malloc(sizeof(t)*(n)+(x)))
203 #define pointerof(x)	((__V_*)((char*)0+(x)))
204 #define roundof(x,y)	(((x)+(y)-1)&~((y)-1))
205 #define ssizeof(x)	((int)sizeof(x))
206 
207 #define streq(a,b)	(*(a)==*(b)&&!strcmp(a,b))
208 #define strneq(a,b,n)	(*(a)==*(b)&&!strncmp(a,b,n))
209 #define strsignal(s)	fmtsignal(s)
210 
211 #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
212 #define NiL		0
213 #define NoP(x)		(void)(x)
214 #else
215 #define NiL		((char*)0)
216 #define NoP(x)		(&x,1)
217 #endif
218 
219 #if !defined(NoF)
220 #if defined(__STDC__) || defined(__STDPP__)
221 #define NoF(x)		void _DATA_ ## x () {}
222 #else
223 #define NoF(x)		void _DATA_/**/x () {}
224 #endif
225 #if !defined(_DATA_)
226 #define _DATA_
227 #endif
228 #endif
229 
230 #if !defined(NoN)
231 #if defined(__STDC__) || defined(__STDPP__)
232 #define NoN(x)		void _STUB_ ## x () {}
233 #else
234 #define NoN(x)		void _STUB_/**/x () {}
235 #endif
236 #if !defined(_STUB_)
237 #define _STUB_
238 #endif
239 #endif
240 
241 #define NOT_USED(x)	NoP(x)
242 
243 typedef int (*Error_f) __PROTO__((__V_*, __V_*, int, ...));
244 
245 typedef int (*Ast_confdisc_f) __PROTO__((const char*, const char*, const char*));
246 typedef int (*Strcmp_context_f) __PROTO__((const char*, const char*, __V_*));
247 typedef int (*Strcmp_f) __PROTO__((const char*, const char*));
248 
249 #if _BLD_ast && defined(__EXPORT__)
250 #undef __MANGLE__
251 #define __MANGLE__ __LINKAGE__		__EXPORT__
252 #endif
253 
254 extern __MANGLE__ char*		astgetconf __PROTO__((const char*, const char*, const char*, int, Error_f));
255 extern __MANGLE__ char*		astconf __PROTO__((const char*, const char*, const char*));
256 extern __MANGLE__ Ast_confdisc_f	astconfdisc __PROTO__((Ast_confdisc_f));
257 extern __MANGLE__ void		astconflist __PROTO__((Sfio_t*, const char*, int, const char*));
258 extern __MANGLE__ off_t		astcopy __PROTO__((int, int, off_t));
259 extern __MANGLE__ int		astlicense __PROTO__((char*, int, char*, char*, int, int, int));
260 extern __MANGLE__ int		astquery __PROTO__((int, const char*, ...));
261 extern __MANGLE__ void		astwinsize __PROTO__((int, int*, int*));
262 
263 extern __MANGLE__ ssize_t		base64encode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
264 extern __MANGLE__ ssize_t		base64decode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
265 extern __MANGLE__ int		chresc __PROTO__((const char*, char**));
266 extern __MANGLE__ int		chrtoi __PROTO__((const char*));
267 extern __MANGLE__ int		eaccess __PROTO__((const char*, int));
268 extern __MANGLE__ char*		fmtbase __PROTO__((long, int, int));
269 extern __MANGLE__ char*		fmtbasell __PROTO__((intmax_t, int, int));
270 #define fmtbase(a,b,c)	fmtbasell((intmax_t)(a),b,c) /* until 2003-09-01 */
271 extern __MANGLE__ char*		fmtbuf __PROTO__((size_t));
272 extern __MANGLE__ char*		fmtclock __PROTO__((Sfulong_t));
273 extern __MANGLE__ char*		fmtelapsed __PROTO__((unsigned long, int));
274 extern __MANGLE__ char*		fmterror __PROTO__((int));
275 extern __MANGLE__ char*		fmtesc __PROTO__((const char*));
276 extern __MANGLE__ char*		fmtesq __PROTO__((const char*, const char*));
277 extern __MANGLE__ char*		fmtident __PROTO__((const char*));
278 extern __MANGLE__ char*		fmtip4 __PROTO__((uint32_t, int));
279 extern __MANGLE__ char*		fmtfmt __PROTO__((const char*));
280 extern __MANGLE__ char*		fmtgid __PROTO__((int));
281 extern __MANGLE__ char*		fmtmatch __PROTO__((const char*));
282 extern __MANGLE__ char*		fmtmode __PROTO__((int, int));
283 extern __MANGLE__ char*		fmtnesq __PROTO__((const char*, const char*, size_t));
284 extern __MANGLE__ char*		fmtnum __PROTO__((unsigned long, int));
285 extern __MANGLE__ char*		fmtperm __PROTO__((int));
286 extern __MANGLE__ char*		fmtquote __PROTO__((const char*, const char*, const char*, size_t, int));
287 extern __MANGLE__ char*		fmtre __PROTO__((const char*));
288 extern __MANGLE__ char*		fmtscale __PROTO__((Sfulong_t, int));
289 extern __MANGLE__ char*		fmtsignal __PROTO__((int));
290 extern __MANGLE__ char*		fmttime __PROTO__((const char*, time_t));
291 extern __MANGLE__ char*		fmtuid __PROTO__((int));
292 extern __MANGLE__ char*		fmtversion __PROTO__((unsigned long));
293 extern __MANGLE__ __V_*		memdup __PROTO__((const __V_*, size_t));
294 extern __MANGLE__ void		memfatal __PROTO__((void));
295 extern __MANGLE__ unsigned int	memhash __PROTO__((const __V_*, int));
296 extern __MANGLE__ unsigned long	memsum __PROTO__((const __V_*, int, unsigned long));
297 extern __MANGLE__ char*		pathaccess __PROTO__((char*, const char*, const char*, const char*, int));
298 extern __MANGLE__ char*		pathbin __PROTO__((void));
299 extern __MANGLE__ char*		pathcanon __PROTO__((char*, int));
300 extern __MANGLE__ char*		pathcat __PROTO__((char*, const char*, int, const char*, const char*));
301 extern __MANGLE__ int		pathcd __PROTO__((const char*, const char*));
302 extern __MANGLE__ int		pathcheck __PROTO__((const char*, const char*, Pathcheck_t*));
303 extern __MANGLE__ int		pathexists __PROTO__((char*, int));
304 extern __MANGLE__ char*		pathfind __PROTO__((const char*, const char*, const char*, char*, size_t));
305 extern __MANGLE__ int		pathgetlink __PROTO__((const char*, char*, int));
306 extern __MANGLE__ int		pathinclude __PROTO__((const char*));
307 extern __MANGLE__ char*		pathkey __PROTO__((char*, char*, const char*, const char*, const char*));
308 extern __MANGLE__ size_t		pathnative __PROTO__((const char*, char*, size_t));
309 extern __MANGLE__ char*		pathpath __PROTO__((char*, const char*, const char*, int));
310 extern __MANGLE__ size_t		pathposix __PROTO__((const char*, char*, size_t));
311 extern __MANGLE__ char*		pathprobe __PROTO__((char*, char*, const char*, const char*, const char*, int));
312 extern __MANGLE__ char*		pathrepl __PROTO__((char*, const char*, const char*));
313 extern __MANGLE__ int		pathsetlink __PROTO__((const char*, const char*));
314 extern __MANGLE__ char*		pathshell __PROTO__((void));
315 extern __MANGLE__ char*		pathtemp __PROTO__((char*, size_t, const char*, const char*, int*));
316 extern __MANGLE__ char*		pathtmp __PROTO__((char*, const char*, const char*, int*));
317 extern __MANGLE__ char*		setenviron __PROTO__((const char*));
318 extern __MANGLE__ int		stracmp __PROTO__((const char*, const char*));
319 extern __MANGLE__ char*		strcopy __PROTO__((char*, const char*));
320 extern __MANGLE__ unsigned long	strelapsed __PROTO__((const char*, char**, int));
321 extern __MANGLE__ int		stresc __PROTO__((char*));
322 extern __MANGLE__ long		streval __PROTO__((const char*, char**, long(*)(const char*, char**)));
323 extern __MANGLE__ long		strexpr __PROTO__((const char*, char**, long(*)(const char*, char**, __V_*), __V_*));
324 extern __MANGLE__ int		strgid __PROTO__((const char*));
325 extern __MANGLE__ int		strgrpmatch __PROTO__((const char*, const char*, int*, int, int));
326 extern __MANGLE__ unsigned int	strhash __PROTO__((const char*));
327 extern __MANGLE__ __V_*		strlook __PROTO__((const __V_*, size_t, const char*));
328 extern __MANGLE__ int		strmatch __PROTO__((const char*, const char*));
329 extern __MANGLE__ int		strmode __PROTO__((const char*));
330 extern __MANGLE__ int		strnacmp __PROTO__((const char*, const char*, size_t));
331 extern __MANGLE__ char*		strncopy __PROTO__((char*, const char*, size_t));
332 extern __MANGLE__ double		strntod __PROTO__((const char*, size_t, char**));
333 extern __MANGLE__ _ast_fltmax_t	strntold __PROTO__((const char*, size_t, char**));
334 extern __MANGLE__ long		strntol __PROTO__((const char*, size_t, char**, int));
335 extern __MANGLE__ intmax_t		strntoll __PROTO__((const char*, size_t, char**, int));
336 extern __MANGLE__ unsigned long	strntoul __PROTO__((const char*, size_t, char**, int));
337 extern __MANGLE__ uintmax_t	strntoull __PROTO__((const char*, size_t, char**, int));
338 extern __MANGLE__ int		stropt __PROTO__((const char*, const __V_*, int, int(*)(__V_*, const __V_*, int, const char*), __V_*));
339 extern __MANGLE__ int		strperm __PROTO__((const char*, char**, int));
340 extern __MANGLE__ __V_*		strpsearch __PROTO__((const __V_*, size_t, size_t, const char*, char**));
341 extern __MANGLE__ __V_*		strsearch __PROTO__((const __V_*, size_t, size_t, Strcmp_f, const char*, __V_*));
342 extern __MANGLE__ void		strsort __PROTO__((char**, int, int(*)(const char*, const char*)));
343 extern __MANGLE__ char*		strsubmatch __PROTO__((const char*, const char*, int));
344 extern __MANGLE__ unsigned long	strsum __PROTO__((const char*, unsigned long));
345 extern __MANGLE__ char*		strtape __PROTO__((const char*, char**));
346 extern __MANGLE__ int		strtoip4 __PROTO__((const char*, char**, uint32_t*, unsigned char*));
347 extern __MANGLE__ long		strton __PROTO__((const char*, char**, char*, int));
348 extern __MANGLE__ intmax_t		strtonll __PROTO__((const char*, char**, char*, int));
349 extern __MANGLE__ int		struid __PROTO__((const char*));
350 extern __MANGLE__ int		struniq __PROTO__((char**, int));
351 
352 #undef __MANGLE__
353 #define __MANGLE__ __LINKAGE__
354 
355 /*
356  * C library global data symbols not prototyped by <unistd.h>
357  */
358 
359 #if !defined(environ) && defined(__DYNAMIC__)
360 #define	environ		__DYNAMIC__(environ)
361 #else
362 extern __MANGLE__ char**		environ;
363 #endif
364 
365 /*
366  * really handy malloc()/free() (__FILE__,__LINE__,__FUNCTION__) tracing
367  * make with VMDEBUG==1 or debug=1 or CCFLAGS=$(CC.DEBUG)
368  * VMDEBUG==0 disables
369  * at runtime export VMDEBUG or VMTRACE per vmalloc.3
370  * to list originating call locations
371  */
372 
373 #if !_std_malloc && !defined(VMFL) && !defined(_VMHDR_H) && \
374 	(!defined(VMDEBUG) || VMDEBUG) && (VMDEBUG || _BLD_DEBUG)
375 
376 #define VMFL	1
377 #include <vmalloc.h>
378 
379 #endif
380 
381 #endif
382