ast_std.h revision 3e14f97f673e8a630f076077de35afdd43dc1587
1/***********************************************************************
2*                                                                      *
3*               This software is part of the ast package               *
4*          Copyright (c) 1985-2010 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
52struct _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
82struct 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
118extern 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
131extern struct lconv*	localeconv(void);
132extern char*		setenviron(const char*);
133extern char*		setlocale(int, const char*);
134extern 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_internal		1
160#define AST_LC_setenv		(1L<<27)
161#define AST_LC_find		(1L<<28)
162#define AST_LC_debug		(1L<<29)
163#define AST_LC_setlocale	(1L<<30)
164#define AST_LC_translate	(1L<<31)
165
166#ifndef LC_ALL
167#define LC_ALL			(-AST_LC_ALL)
168#endif
169#ifndef LC_COLLATE
170#define LC_COLLATE		(-AST_LC_COLLATE)
171#endif
172#ifndef LC_CTYPE
173#define LC_CTYPE		(-AST_LC_CTYPE)
174#endif
175#ifndef LC_MESSAGES
176#define LC_MESSAGES		(-AST_LC_MESSAGES)
177#endif
178#ifndef LC_MONETARY
179#define LC_MONETARY		(-AST_LC_MONETARY)
180#endif
181#ifndef LC_NUMERIC
182#define LC_NUMERIC		(-AST_LC_NUMERIC)
183#endif
184#ifndef LC_TIME
185#define LC_TIME			(-AST_LC_TIME)
186#endif
187#ifndef LC_ADDRESS
188#define LC_ADDRESS		(-AST_LC_ADDRESS)
189#endif
190#ifndef LC_IDENTIFICATION
191#define LC_IDENTIFICATION	(-AST_LC_IDENTIFICATION)
192#endif
193#ifndef LC_NAME
194#define LC_NAME			(-AST_LC_NAME)
195#endif
196#ifndef LC_TELEPHONE
197#define LC_TELEPHONE		(-AST_LC_TELEPHONE)
198#endif
199#ifndef LC_XLITERATE
200#define LC_XLITERATE		(-AST_LC_XLITERATE)
201#endif
202#ifndef LC_MEASUREMENT
203#define LC_MEASUREMENT		(-AST_LC_MEASUREMENT)
204#endif
205#ifndef LC_PAPER
206#define LC_PAPER		(-AST_LC_PAPER)
207#endif
208#ifndef LC_LANG
209#define LC_LANG			(-AST_LC_LANG)
210#endif
211
212#undef	extern
213
214#undef	strcoll
215#if _std_strcoll
216#define strcoll		_ast_info.collate
217#else
218#define strcoll		strcmp
219#endif
220
221typedef struct
222{
223
224	char*		id;
225
226	struct
227	{
228	uint32_t	serial;
229	uint32_t	set;
230	}		locale;
231
232	long		tmp_long;
233	size_t		tmp_size;
234	short		tmp_short;
235	char		tmp_char;
236	wchar_t		tmp_wchar;
237
238	int		(*collate)(const char*, const char*);
239
240	int		tmp_int;
241	void*		tmp_pointer;
242
243	int		mb_cur_max;
244	int		(*mb_len)(const char*, size_t);
245	int		(*mb_towc)(wchar_t*, const char*, size_t);
246	size_t		(*mb_xfrm)(char*, const char*, size_t);
247	int		(*mb_width)(wchar_t);
248	int		(*mb_conv)(char*, wchar_t);
249
250	uint32_t	env_serial;
251	uint32_t	mb_sync;
252	uint32_t	version;
253
254	char		pad[936];
255
256} _Ast_info_t;
257
258#if _BLD_ast && defined(__EXPORT__)
259#define extern		extern __EXPORT__
260#endif
261#if !_BLD_ast && defined(__IMPORT__)
262#define extern		extern __IMPORT__
263#endif
264
265extern _Ast_info_t	_ast_info;
266
267#undef	extern
268
269/* largefile hackery -- ast uses the large versions by default */
270
271#if _typ_off64_t
272#undef	off_t
273#define off_t		off64_t
274#endif
275#if !defined(ftruncate) && _lib_ftruncate64
276#define ftruncate	ftruncate64
277extern int		ftruncate64(int, off64_t);
278#endif
279#if !defined(lseek) && _lib_lseek64
280#define lseek		lseek64
281extern off64_t		lseek64(int, off64_t, int);
282#endif
283#if !defined(truncate) && _lib_truncate64
284#define truncate	truncate64
285extern int		truncate64(const char*, off64_t);
286#endif
287
288/* direct macro access for bsd crossover */
289
290#if !defined(__cplusplus)
291
292#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
293#define memcpy(t,f,n)	(bcopy(f,t,n),(t))
294#endif
295
296#if !defined(memzero) && !defined(_lib_memzero)
297#if defined(_lib_memset) || !defined(_lib_bzero)
298#define memzero(b,n)	memset(b,0,n)
299#else
300#define memzero(b,n)	(bzero(b,n),(b))
301#endif
302#endif
303
304#endif
305
306#if !defined(remove)
307extern int		remove(const char*);
308#endif
309
310#if !defined(rename)
311extern int		rename(const char*, const char*);
312#endif
313
314#if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index)
315#define strchr(s,c)	index(s,c)
316#endif
317
318#if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex)
319#define strrchr(s,c)	rindex(s,c)
320#endif
321
322/* and now introducing prototypes botched by the standard(s) */
323
324#if _BLD_ast && defined(__EXPORT__)
325#define extern		__EXPORT__
326#endif
327
328#undef	getpgrp
329#define	getpgrp()	_ast_getpgrp()
330extern int		_ast_getpgrp(void);
331
332#undef	extern
333
334/*
335 * and finally, standard interfaces hijacked by ast
336 * _AST_STD_I delays headers that require <ast_map.h>
337 */
338
339#include <ast_map.h>
340
341#undef	_AST_STD_I
342
343#if _AST_GETOPT_H < 0
344#undef	_AST_GETOPT_H
345#include <ast_getopt.h>
346#endif
347
348#if _GETOPT_H < 0
349#undef	_GETOPT_H
350#include <getopt.h>
351#endif
352
353#if _REGEX_H < 0
354#undef	_REGEX_H
355#include <regex.h>
356#endif
357
358#endif
359