xref: /titanic_50/usr/src/lib/libast/common/include/ast_std.h (revision 888e055994b8b0dc77b98c53dd97026237caec5d)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2009 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  * Advanced Software Technology Library
25  * AT&T Research
26  *
27  * a union of standard headers that works
28  * with local extensions enabled
29  * and local omission compensation
30  */
31 
32 #ifndef _AST_STD_H
33 #define _AST_STD_H		1
34 #define _AST_STD_I		1
35 
36 #include <ast_common.h>
37 
38 #if _BLD_ast
39 #define _BLD_cdt	1
40 #define _BLD_sfio	1
41 #if !_UWIN
42 #define _BLD_vmalloc	1
43 #endif
44 #endif
45 
46 #ifdef	_SFSTDIO_H
47 #define _SKIP_SFSTDIO_H
48 #else
49 #define _SFSTDIO_H
50 #ifndef FILE
51 #ifndef _SFIO_H
52 struct _sfio_s;
53 #endif
54 #define FILE		struct _sfio_s
55 #ifndef	__FILE_typedef
56 #define __FILE_typedef	1
57 #endif
58 #ifndef _FILEDEFED
59 #define _FILEDEFED	1
60 #endif
61 #endif
62 #endif
63 
64 #include <ast_lib.h>
65 #include <ast_sys.h>
66 #include <ast_getopt.h>	/* <stdlib.h> does this */
67 #include <ast_fcntl.h>
68 #include <ast_limits.h>
69 #include <ast_botch.h>
70 
71 #ifdef	_SKIP_SFSTDIO_H
72 #undef	_SKIP_SFSTDIO_H
73 #else
74 #undef	_SFSTDIO_H
75 #undef	FILE
76 #endif
77 
78 /* locale stuff */
79 
80 #if !_hdr_locale
81 
82 struct lconv
83 {
84 	char*	decimal_point;
85 	char*	thousands_sep;
86 	char*	grouping;
87 	char*	int_curr_symbol;
88 	char*	currency_symbol;
89 	char*	mon_decimal_point;
90 	char*	mon_thousands_sep;
91 	char*	mon_grouping;
92 	char*	positive_sign;
93 	char*	negative_sign;
94 	char	int_frac_digits;
95 	char	frac_digits;
96 	char	p_cs_precedes;
97 	char	p_sep_by_space;
98 	char	n_cs_precedes;
99 	char	n_sep_by_space;
100 	char	p_sign_posn;
101 	char	n_sign_posn;
102 };
103 
104 #endif
105 
106 #if _BLD_ast && defined(__EXPORT__)
107 #define extern		__EXPORT__
108 #endif
109 
110 #if !_UWIN /* for ast54 compatibility */
111 
112 #undef	getenv
113 #define getenv		_ast_getenv
114 
115 #undef	setenviron
116 #define setenviron	_ast_setenviron
117 
118 extern char*		getenv(const char*);
119 
120 #endif
121 
122 #undef	localeconv
123 #define localeconv	_ast_localeconv
124 
125 #undef	setlocale
126 #define setlocale	_ast_setlocale
127 
128 #undef	strerror
129 #define strerror	_ast_strerror
130 
131 extern struct lconv*	localeconv(void);
132 extern char*		setenviron(const char*);
133 extern char*		setlocale(int, const char*);
134 extern char*		strerror(int);
135 
136 #define AST_MESSAGE_SET		3	/* see <mc.h> mcindex()		*/
137 
138 /*
139  * maintain this order when adding categories
140  */
141 
142 #define AST_LC_ALL		0
143 #define AST_LC_COLLATE		1
144 #define AST_LC_CTYPE		2
145 #define AST_LC_MESSAGES		3
146 #define AST_LC_MONETARY		4
147 #define AST_LC_NUMERIC		5
148 #define AST_LC_TIME		6
149 #define AST_LC_IDENTIFICATION	7
150 #define AST_LC_ADDRESS		8
151 #define AST_LC_NAME		9
152 #define AST_LC_TELEPHONE	10
153 #define AST_LC_XLITERATE	11
154 #define AST_LC_MEASUREMENT	12
155 #define AST_LC_PAPER		13
156 #define AST_LC_COUNT		14
157 #define AST_LC_LANG		255
158 
159 #define AST_LC_find		(1L<<28)
160 #define AST_LC_debug		(1L<<29)
161 #define AST_LC_setlocale	(1L<<30)
162 #define AST_LC_translate	(1L<<31)
163 
164 #ifndef LC_ALL
165 #define LC_ALL			(-AST_LC_ALL)
166 #endif
167 #ifndef LC_COLLATE
168 #define LC_COLLATE		(-AST_LC_COLLATE)
169 #endif
170 #ifndef LC_CTYPE
171 #define LC_CTYPE		(-AST_LC_CTYPE)
172 #endif
173 #ifndef LC_MESSAGES
174 #define LC_MESSAGES		(-AST_LC_MESSAGES)
175 #endif
176 #ifndef LC_MONETARY
177 #define LC_MONETARY		(-AST_LC_MONETARY)
178 #endif
179 #ifndef LC_NUMERIC
180 #define LC_NUMERIC		(-AST_LC_NUMERIC)
181 #endif
182 #ifndef LC_TIME
183 #define LC_TIME			(-AST_LC_TIME)
184 #endif
185 #ifndef LC_ADDRESS
186 #define LC_ADDRESS		(-AST_LC_ADDRESS)
187 #endif
188 #ifndef LC_IDENTIFICATION
189 #define LC_IDENTIFICATION	(-AST_LC_IDENTIFICATION)
190 #endif
191 #ifndef LC_NAME
192 #define LC_NAME			(-AST_LC_NAME)
193 #endif
194 #ifndef LC_TELEPHONE
195 #define LC_TELEPHONE		(-AST_LC_TELEPHONE)
196 #endif
197 #ifndef LC_XLITERATE
198 #define LC_XLITERATE		(-AST_LC_XLITERATE)
199 #endif
200 #ifndef LC_MEASUREMENT
201 #define LC_MEASUREMENT		(-AST_LC_MEASUREMENT)
202 #endif
203 #ifndef LC_PAPER
204 #define LC_PAPER		(-AST_LC_PAPER)
205 #endif
206 #ifndef LC_LANG
207 #define LC_LANG			(-AST_LC_LANG)
208 #endif
209 
210 #undef	extern
211 
212 #undef	strcoll
213 #if _std_strcoll
214 #define strcoll		_ast_info.collate
215 #else
216 #define strcoll		strcmp
217 #endif
218 
219 typedef struct
220 {
221 
222 	char*		id;
223 
224 	struct
225 	{
226 	uint32_t	serial;
227 	uint32_t	set;
228 	}		locale;
229 
230 	long		tmp_long;
231 	size_t		tmp_size;
232 	short		tmp_short;
233 	char		tmp_char;
234 	wchar_t		tmp_wchar;
235 
236 	int		(*collate)(const char*, const char*);
237 
238 	int		tmp_int;
239 	void*		tmp_pointer;
240 
241 	int		mb_cur_max;
242 	int		(*mb_len)(const char*, size_t);
243 	int		(*mb_towc)(wchar_t*, const char*, size_t);
244 	size_t		(*mb_xfrm)(char*, const char*, size_t);
245 	int		(*mb_width)(wchar_t);
246 	int		(*mb_conv)(char*, wchar_t);
247 
248 	uint32_t	env_serial;
249 	uint32_t	mb_sync;
250 
251 	char		pad[940];
252 
253 } _Ast_info_t;
254 
255 #if _BLD_ast && defined(__EXPORT__)
256 #define extern		extern __EXPORT__
257 #endif
258 #if !_BLD_ast && defined(__IMPORT__)
259 #define extern		extern __IMPORT__
260 #endif
261 
262 extern _Ast_info_t	_ast_info;
263 
264 #undef	extern
265 
266 /* largefile hackery -- ast uses the large versions by default */
267 
268 #if _typ_off64_t
269 #undef	off_t
270 #define off_t		off64_t
271 #endif
272 #if !defined(ftruncate) && _lib_ftruncate64
273 #define ftruncate	ftruncate64
274 extern int		ftruncate64(int, off64_t);
275 #endif
276 #if !defined(lseek) && _lib_lseek64
277 #define lseek		lseek64
278 extern off64_t		lseek64(int, off64_t, int);
279 #endif
280 #if !defined(truncate) && _lib_truncate64
281 #define truncate	truncate64
282 extern int		truncate64(const char*, off64_t);
283 #endif
284 
285 /* direct macro access for bsd crossover */
286 
287 #if !defined(__cplusplus)
288 
289 #if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
290 #define memcpy(t,f,n)	(bcopy(f,t,n),(t))
291 #endif
292 
293 #if !defined(memzero) && !defined(_lib_memzero)
294 #if defined(_lib_memset) || !defined(_lib_bzero)
295 #define memzero(b,n)	memset(b,0,n)
296 #else
297 #define memzero(b,n)	(bzero(b,n),(b))
298 #endif
299 #endif
300 
301 #endif
302 
303 #if !defined(remove)
304 extern int		remove(const char*);
305 #endif
306 
307 #if !defined(rename)
308 extern int		rename(const char*, const char*);
309 #endif
310 
311 #if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index)
312 #define strchr(s,c)	index(s,c)
313 #endif
314 
315 #if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex)
316 #define strrchr(s,c)	rindex(s,c)
317 #endif
318 
319 /* and now introducing prototypes botched by the standard(s) */
320 
321 #if _BLD_ast && defined(__EXPORT__)
322 #define extern		__EXPORT__
323 #endif
324 
325 #undef	getpgrp
326 #define	getpgrp()	_ast_getpgrp()
327 extern int		_ast_getpgrp(void);
328 
329 #undef	extern
330 
331 /*
332  * and finally, standard interfaces hijacked by ast
333  * _ATS_STD_I delays headers that require <ast_map.h>
334  */
335 
336 #include <ast_map.h>
337 
338 #undef	_AST_STD_I
339 
340 #if _AST_GETOPT_H < 0
341 #undef	_AST_GETOPT_H
342 #include <ast_getopt.h>
343 #endif
344 
345 #if _GETOPT_H < 0
346 #undef	_GETOPT_H
347 #include <getopt.h>
348 #endif
349 
350 #if _REGEX_H < 0
351 #undef	_REGEX_H
352 #include <regex.h>
353 #endif
354 
355 #endif
356