xref: /titanic_51/usr/src/lib/libast/common/include/ast_std.h (revision 0cd13cbfb4270b840b4bd22ec5f673b2b6a2c02b)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *           Copyright (c) 1985-2007 AT&T Knowledge Ventures            *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                      by AT&T Knowledge Ventures                      *
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 #undef	localeconv
111 #define localeconv	_ast_localeconv
112 
113 #undef	setlocale
114 #define setlocale	_ast_setlocale
115 
116 #undef	strerror
117 #define strerror	_ast_strerror
118 
119 extern struct lconv*	localeconv(void);
120 extern char*		setlocale(int, const char*);
121 extern char*		strerror(int);
122 
123 #define AST_MESSAGE_SET		3	/* see <mc.h> mcindex()		*/
124 
125 /*
126  * maintain this order when adding categories
127  */
128 
129 #define AST_LC_ALL		0
130 #define AST_LC_COLLATE		1
131 #define AST_LC_CTYPE		2
132 #define AST_LC_MESSAGES		3
133 #define AST_LC_MONETARY		4
134 #define AST_LC_NUMERIC		5
135 #define AST_LC_TIME		6
136 #define AST_LC_IDENTIFICATION	7
137 #define AST_LC_ADDRESS		8
138 #define AST_LC_NAME		9
139 #define AST_LC_TELEPHONE	10
140 #define AST_LC_XLITERATE	11
141 #define AST_LC_MEASUREMENT	12
142 #define AST_LC_PAPER		13
143 #define AST_LC_COUNT		14
144 
145 #define AST_LC_find		(1L<<28)
146 #define AST_LC_debug		(1L<<29)
147 #define AST_LC_setlocale	(1L<<30)
148 #define AST_LC_translate	(1L<<31)
149 
150 #ifndef LC_ALL
151 #define LC_ALL			(-AST_LC_ALL)
152 #endif
153 #ifndef LC_COLLATE
154 #define LC_COLLATE		(-AST_LC_COLLATE)
155 #endif
156 #ifndef LC_CTYPE
157 #define LC_CTYPE		(-AST_LC_CTYPE)
158 #endif
159 #ifndef LC_MESSAGES
160 #define LC_MESSAGES		(-AST_LC_MESSAGES)
161 #endif
162 #ifndef LC_MONETARY
163 #define LC_MONETARY		(-AST_LC_MONETARY)
164 #endif
165 #ifndef LC_NUMERIC
166 #define LC_NUMERIC		(-AST_LC_NUMERIC)
167 #endif
168 #ifndef LC_TIME
169 #define LC_TIME			(-AST_LC_TIME)
170 #endif
171 #ifndef LC_ADDRESS
172 #define LC_ADDRESS		(-AST_LC_ADDRESS)
173 #endif
174 #ifndef LC_IDENTIFICATION
175 #define LC_IDENTIFICATION	(-AST_LC_IDENTIFICATION)
176 #endif
177 #ifndef LC_NAME
178 #define LC_NAME			(-AST_LC_NAME)
179 #endif
180 #ifndef LC_TELEPHONE
181 #define LC_TELEPHONE		(-AST_LC_TELEPHONE)
182 #endif
183 #ifndef LC_XLITERATE
184 #define LC_XLITERATE		(-AST_LC_XLITERATE)
185 #endif
186 #ifndef LC_MEASUREMENT
187 #define LC_MEASUREMENT		(-AST_LC_MEASUREMENT)
188 #endif
189 #ifndef LC_PAPER
190 #define LC_PAPER		(-AST_LC_PAPER)
191 #endif
192 
193 #undef	extern
194 
195 #undef	strcoll
196 #if _std_strcoll
197 #define strcoll		_ast_info.collate
198 #else
199 #define strcoll		strcmp
200 #endif
201 
202 typedef struct
203 {
204 
205 	char*		id;
206 
207 	struct
208 	{
209 	uint32_t	serial;
210 	uint32_t	set;
211 	}		locale;
212 
213 	long		tmp_long;
214 	size_t		tmp_size;
215 	short		tmp_short;
216 	char		tmp_char;
217 	wchar_t		tmp_wchar;
218 
219 	int		(*collate)(const char*, const char*);
220 
221 	int		tmp_int;
222 	void*		tmp_pointer;
223 
224 	int		mb_cur_max;
225 	int		(*mb_len)(const char*, size_t);
226 	int		(*mb_towc)(wchar_t*, const char*, size_t);
227 	size_t		(*mb_xfrm)(char*, const char*, size_t);
228 	int		(*mb_width)(wchar_t);
229 	int		(*mb_conv)(char*, wchar_t);
230 
231 	uint32_t	env_serial;
232 
233 	char		pad[944];
234 
235 } _Ast_info_t;
236 
237 #if _BLD_ast && defined(__EXPORT__)
238 #define extern		extern __EXPORT__
239 #endif
240 #if !_BLD_ast && defined(__IMPORT__)
241 #define extern		extern __IMPORT__
242 #endif
243 
244 extern _Ast_info_t	_ast_info;
245 
246 #undef	extern
247 
248 /* largefile hackery -- ast uses the large versions by default */
249 
250 #if _typ_off64_t
251 #undef	off_t
252 #define off_t		off64_t
253 #endif
254 #if !defined(ftruncate) && _lib_ftruncate64
255 #define ftruncate	ftruncate64
256 extern int		ftruncate64(int, off64_t);
257 #endif
258 #if !defined(lseek) && _lib_lseek64
259 #define lseek		lseek64
260 extern off64_t		lseek64(int, off64_t, int);
261 #endif
262 #if !defined(truncate) && _lib_truncate64
263 #define truncate	truncate64
264 extern int		truncate64(const char*, off64_t);
265 #endif
266 
267 /* direct macro access for bsd crossover */
268 
269 #if !defined(__cplusplus)
270 
271 #if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
272 #define memcpy(t,f,n)	(bcopy(f,t,n),(t))
273 #endif
274 
275 #if !defined(memzero) && !defined(_lib_memzero)
276 #if defined(_lib_memset) || !defined(_lib_bzero)
277 #define memzero(b,n)	memset(b,0,n)
278 #else
279 #define memzero(b,n)	(bzero(b,n),(b))
280 #endif
281 #endif
282 
283 #endif
284 
285 #if !defined(remove)
286 extern int		remove(const char*);
287 #endif
288 
289 #if !defined(rename)
290 extern int		rename(const char*, const char*);
291 #endif
292 
293 #if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index)
294 #define strchr(s,c)	index(s,c)
295 #endif
296 
297 #if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex)
298 #define strrchr(s,c)	rindex(s,c)
299 #endif
300 
301 /* and now introducing prototypes botched by the standard(s) */
302 
303 #if _BLD_ast && defined(__EXPORT__)
304 #define extern		__EXPORT__
305 #endif
306 
307 #undef	getpgrp
308 #define	getpgrp()	_ast_getpgrp()
309 extern int		_ast_getpgrp(void);
310 
311 #undef	extern
312 
313 /*
314  * and finally, standard interfaces hijacked by ast
315  * _ATS_STD_I delays headers that require <ast_map.h>
316  */
317 
318 #include <ast_map.h>
319 
320 #undef	_AST_STD_I
321 
322 #if _REGEX_H < 0
323 #undef	_REGEX_H
324 #include <regex.h>
325 #endif
326 
327 #endif
328