1da2e3ebchin/***********************************************************************
2da2e3ebchin*                                                                      *
3da2e3ebchin*               This software is part of the ast package               *
43e14f97Roger A. Faulkner*          Copyright (c) 1985-2010 AT&T Intellectual Property          *
5da2e3ebchin*                      and is licensed under the                       *
6da2e3ebchin*                  Common Public License, Version 1.0                  *
77c2fbfbApril Chin*                    by AT&T Intellectual Property                     *
8da2e3ebchin*                                                                      *
9da2e3ebchin*                A copy of the License is available at                 *
10da2e3ebchin*            http://www.opensource.org/licenses/cpl1.0.txt             *
11da2e3ebchin*         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12da2e3ebchin*                                                                      *
13da2e3ebchin*              Information and Software Systems Research               *
14da2e3ebchin*                            AT&T Research                             *
15da2e3ebchin*                           Florham Park NJ                            *
16da2e3ebchin*                                                                      *
17da2e3ebchin*                 Glenn Fowler <gsf@research.att.com>                  *
18da2e3ebchin*                  David Korn <dgk@research.att.com>                   *
19da2e3ebchin*                   Phong Vo <kpv@research.att.com>                    *
20da2e3ebchin*                                                                      *
21da2e3ebchin***********************************************************************/
22da2e3ebchin#pragma prototyped
23da2e3ebchin/*
24da2e3ebchin * Advanced Software Technology Library
25da2e3ebchin * AT&T Research
26da2e3ebchin *
27da2e3ebchin * a union of standard headers that works
28da2e3ebchin * with local extensions enabled
29da2e3ebchin * and local omission compensation
30da2e3ebchin */
31da2e3ebchin
32da2e3ebchin#ifndef _AST_STD_H
33da2e3ebchin#define _AST_STD_H		1
34da2e3ebchin#define _AST_STD_I		1
35da2e3ebchin
36da2e3ebchin#include <ast_common.h>
37da2e3ebchin
38da2e3ebchin#if _BLD_ast
39da2e3ebchin#define _BLD_cdt	1
40da2e3ebchin#define _BLD_sfio	1
41da2e3ebchin#if !_UWIN
42da2e3ebchin#define _BLD_vmalloc	1
43da2e3ebchin#endif
44da2e3ebchin#endif
45da2e3ebchin
46da2e3ebchin#ifdef	_SFSTDIO_H
47da2e3ebchin#define _SKIP_SFSTDIO_H
48da2e3ebchin#else
49da2e3ebchin#define _SFSTDIO_H
50da2e3ebchin#ifndef FILE
51da2e3ebchin#ifndef _SFIO_H
52da2e3ebchinstruct _sfio_s;
53da2e3ebchin#endif
54da2e3ebchin#define FILE		struct _sfio_s
55da2e3ebchin#ifndef	__FILE_typedef
56da2e3ebchin#define __FILE_typedef	1
57da2e3ebchin#endif
58da2e3ebchin#ifndef _FILEDEFED
59da2e3ebchin#define _FILEDEFED	1
60da2e3ebchin#endif
61da2e3ebchin#endif
62da2e3ebchin#endif
63da2e3ebchin
64da2e3ebchin#include <ast_lib.h>
65da2e3ebchin#include <ast_sys.h>
66da2e3ebchin#include <ast_getopt.h>	/* <stdlib.h> does this */
67da2e3ebchin#include <ast_fcntl.h>
68da2e3ebchin#include <ast_limits.h>
69da2e3ebchin#include <ast_botch.h>
70da2e3ebchin
71da2e3ebchin#ifdef	_SKIP_SFSTDIO_H
72da2e3ebchin#undef	_SKIP_SFSTDIO_H
73da2e3ebchin#else
74da2e3ebchin#undef	_SFSTDIO_H
75da2e3ebchin#undef	FILE
76da2e3ebchin#endif
77da2e3ebchin
78da2e3ebchin/* locale stuff */
79da2e3ebchin
80da2e3ebchin#if !_hdr_locale
81da2e3ebchin
82da2e3ebchinstruct lconv
83da2e3ebchin{
84da2e3ebchin	char*	decimal_point;
85da2e3ebchin	char*	thousands_sep;
86da2e3ebchin	char*	grouping;
87da2e3ebchin	char*	int_curr_symbol;
88da2e3ebchin	char*	currency_symbol;
89da2e3ebchin	char*	mon_decimal_point;
90da2e3ebchin	char*	mon_thousands_sep;
91da2e3ebchin	char*	mon_grouping;
92da2e3ebchin	char*	positive_sign;
93da2e3ebchin	char*	negative_sign;
94da2e3ebchin	char	int_frac_digits;
95da2e3ebchin	char	frac_digits;
96da2e3ebchin	char	p_cs_precedes;
97da2e3ebchin	char	p_sep_by_space;
98da2e3ebchin	char	n_cs_precedes;
99da2e3ebchin	char	n_sep_by_space;
100da2e3ebchin	char	p_sign_posn;
101da2e3ebchin	char	n_sign_posn;
102da2e3ebchin};
103da2e3ebchin
104da2e3ebchin#endif
105da2e3ebchin
106da2e3ebchin#if _BLD_ast && defined(__EXPORT__)
107da2e3ebchin#define extern		__EXPORT__
108da2e3ebchin#endif
109da2e3ebchin
11034f9b3eRoland Mainz#if !_UWIN /* for ast54 compatibility */
11134f9b3eRoland Mainz
1127c2fbfbApril Chin#undef	getenv
1137c2fbfbApril Chin#define getenv		_ast_getenv
1147c2fbfbApril Chin
11534f9b3eRoland Mainz#undef	setenviron
11634f9b3eRoland Mainz#define setenviron	_ast_setenviron
11734f9b3eRoland Mainz
11834f9b3eRoland Mainzextern char*		getenv(const char*);
11934f9b3eRoland Mainz
12034f9b3eRoland Mainz#endif
12134f9b3eRoland Mainz
122da2e3ebchin#undef	localeconv
123da2e3ebchin#define localeconv	_ast_localeconv
124da2e3ebchin
125da2e3ebchin#undef	setlocale
126da2e3ebchin#define setlocale	_ast_setlocale
127da2e3ebchin
128da2e3ebchin#undef	strerror
129da2e3ebchin#define strerror	_ast_strerror
130da2e3ebchin
131da2e3ebchinextern struct lconv*	localeconv(void);
1327c2fbfbApril Chinextern char*		setenviron(const char*);
133da2e3ebchinextern char*		setlocale(int, const char*);
134da2e3ebchinextern char*		strerror(int);
135da2e3ebchin
136da2e3ebchin#define AST_MESSAGE_SET		3	/* see <mc.h> mcindex()		*/
137da2e3ebchin
138da2e3ebchin/*
139da2e3ebchin * maintain this order when adding categories
140da2e3ebchin */
141da2e3ebchin
142da2e3ebchin#define AST_LC_ALL		0
143da2e3ebchin#define AST_LC_COLLATE		1
144da2e3ebchin#define AST_LC_CTYPE		2
145da2e3ebchin#define AST_LC_MESSAGES		3
146da2e3ebchin#define AST_LC_MONETARY		4
147da2e3ebchin#define AST_LC_NUMERIC		5
148da2e3ebchin#define AST_LC_TIME		6
149da2e3ebchin#define AST_LC_IDENTIFICATION	7
150da2e3ebchin#define AST_LC_ADDRESS		8
151da2e3ebchin#define AST_LC_NAME		9
152da2e3ebchin#define AST_LC_TELEPHONE	10
153da2e3ebchin#define AST_LC_XLITERATE	11
154da2e3ebchin#define AST_LC_MEASUREMENT	12
155da2e3ebchin#define AST_LC_PAPER		13
156da2e3ebchin#define AST_LC_COUNT		14
15734f9b3eRoland Mainz#define AST_LC_LANG		255
158da2e3ebchin
1593e14f97Roger A. Faulkner#define AST_LC_internal		1
1603e14f97Roger A. Faulkner#define AST_LC_setenv		(1L<<27)
161da2e3ebchin#define AST_LC_find		(1L<<28)
162da2e3ebchin#define AST_LC_debug		(1L<<29)
163da2e3ebchin#define AST_LC_setlocale	(1L<<30)
164da2e3ebchin#define AST_LC_translate	(1L<<31)
165da2e3ebchin
166da2e3ebchin#ifndef LC_ALL
167da2e3ebchin#define LC_ALL			(-AST_LC_ALL)
168da2e3ebchin#endif
169da2e3ebchin#ifndef LC_COLLATE
170da2e3ebchin#define LC_COLLATE		(-AST_LC_COLLATE)
171da2e3ebchin#endif
172da2e3ebchin#ifndef LC_CTYPE
173da2e3ebchin#define LC_CTYPE		(-AST_LC_CTYPE)
174da2e3ebchin#endif
175da2e3ebchin#ifndef LC_MESSAGES
176da2e3ebchin#define LC_MESSAGES		(-AST_LC_MESSAGES)
177da2e3ebchin#endif
178da2e3ebchin#ifndef LC_MONETARY
179da2e3ebchin#define LC_MONETARY		(-AST_LC_MONETARY)
180da2e3ebchin#endif
181da2e3ebchin#ifndef LC_NUMERIC
182da2e3ebchin#define LC_NUMERIC		(-AST_LC_NUMERIC)
183da2e3ebchin#endif
184da2e3ebchin#ifndef LC_TIME
185da2e3ebchin#define LC_TIME			(-AST_LC_TIME)
186da2e3ebchin#endif
187da2e3ebchin#ifndef LC_ADDRESS
188da2e3ebchin#define LC_ADDRESS		(-AST_LC_ADDRESS)
189da2e3ebchin#endif
190da2e3ebchin#ifndef LC_IDENTIFICATION
191da2e3ebchin#define LC_IDENTIFICATION	(-AST_LC_IDENTIFICATION)
192da2e3ebchin#endif
193da2e3ebchin#ifndef LC_NAME
194da2e3ebchin#define LC_NAME			(-AST_LC_NAME)
195da2e3ebchin#endif
196da2e3ebchin#ifndef LC_TELEPHONE
197da2e3ebchin#define LC_TELEPHONE		(-AST_LC_TELEPHONE)
198da2e3ebchin#endif
199da2e3ebchin#ifndef LC_XLITERATE
200da2e3ebchin#define LC_XLITERATE		(-AST_LC_XLITERATE)
201da2e3ebchin#endif
202da2e3ebchin#ifndef LC_MEASUREMENT
203da2e3ebchin#define LC_MEASUREMENT		(-AST_LC_MEASUREMENT)
204da2e3ebchin#endif
205da2e3ebchin#ifndef LC_PAPER
206da2e3ebchin#define LC_PAPER		(-AST_LC_PAPER)
207da2e3ebchin#endif
20834f9b3eRoland Mainz#ifndef LC_LANG
20934f9b3eRoland Mainz#define LC_LANG			(-AST_LC_LANG)
21034f9b3eRoland Mainz#endif
211da2e3ebchin
212da2e3ebchin#undef	extern
213da2e3ebchin
214da2e3ebchin#undef	strcoll
215da2e3ebchin#if _std_strcoll
216da2e3ebchin#define strcoll		_ast_info.collate
217da2e3ebchin#else
218da2e3ebchin#define strcoll		strcmp
219da2e3ebchin#endif
220da2e3ebchin
221da2e3ebchintypedef struct
222da2e3ebchin{
223da2e3ebchin
224da2e3ebchin	char*		id;
225da2e3ebchin
226da2e3ebchin	struct
227da2e3ebchin	{
228da2e3ebchin	uint32_t	serial;
229da2e3ebchin	uint32_t	set;
230da2e3ebchin	}		locale;
231da2e3ebchin
232da2e3ebchin	long		tmp_long;
233da2e3ebchin	size_t		tmp_size;
234da2e3ebchin	short		tmp_short;
235da2e3ebchin	char		tmp_char;
236da2e3ebchin	wchar_t		tmp_wchar;
237da2e3ebchin
238da2e3ebchin	int		(*collate)(const char*, const char*);
239da2e3ebchin
240da2e3ebchin	int		tmp_int;
241da2e3ebchin	void*		tmp_pointer;
242da2e3ebchin
243da2e3ebchin	int		mb_cur_max;
244da2e3ebchin	int		(*mb_len)(const char*, size_t);
245da2e3ebchin	int		(*mb_towc)(wchar_t*, const char*, size_t);
246da2e3ebchin	size_t		(*mb_xfrm)(char*, const char*, size_t);
247da2e3ebchin	int		(*mb_width)(wchar_t);
248da2e3ebchin	int		(*mb_conv)(char*, wchar_t);
249da2e3ebchin
250da2e3ebchin	uint32_t	env_serial;
25134f9b3eRoland Mainz	uint32_t	mb_sync;
2523e14f97Roger A. Faulkner	uint32_t	version;
253da2e3ebchin
2543e14f97Roger A. Faulkner	char		pad[936];
255da2e3ebchin
256da2e3ebchin} _Ast_info_t;
257da2e3ebchin
258da2e3ebchin#if _BLD_ast && defined(__EXPORT__)
259da2e3ebchin#define extern		extern __EXPORT__
260da2e3ebchin#endif
261da2e3ebchin#if !_BLD_ast && defined(__IMPORT__)
262da2e3ebchin#define extern		extern __IMPORT__
263da2e3ebchin#endif
264da2e3ebchin
265da2e3ebchinextern _Ast_info_t	_ast_info;
266da2e3ebchin
267da2e3ebchin#undef	extern
268da2e3ebchin
269da2e3ebchin/* largefile hackery -- ast uses the large versions by default */
270da2e3ebchin
271da2e3ebchin#if _typ_off64_t
272da2e3ebchin#undef	off_t
273da2e3ebchin#define off_t		off64_t
274da2e3ebchin#endif
275da2e3ebchin#if !defined(ftruncate) && _lib_ftruncate64
276da2e3ebchin#define ftruncate	ftruncate64
277da2e3ebchinextern int		ftruncate64(int, off64_t);
278da2e3ebchin#endif
279da2e3ebchin#if !defined(lseek) && _lib_lseek64
280da2e3ebchin#define lseek		lseek64
281da2e3ebchinextern off64_t		lseek64(int, off64_t, int);
282da2e3ebchin#endif
283da2e3ebchin#if !defined(truncate) && _lib_truncate64
284da2e3ebchin#define truncate	truncate64
285da2e3ebchinextern int		truncate64(const char*, off64_t);
286da2e3ebchin#endif
287da2e3ebchin
288da2e3ebchin/* direct macro access for bsd crossover */
289da2e3ebchin
290da2e3ebchin#if !defined(__cplusplus)
291da2e3ebchin
292da2e3ebchin#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
293da2e3ebchin#define memcpy(t,f,n)	(bcopy(f,t,n),(t))
294da2e3ebchin#endif
295da2e3ebchin
296da2e3ebchin#if !defined(memzero) && !defined(_lib_memzero)
297da2e3ebchin#if defined(_lib_memset) || !defined(_lib_bzero)
298da2e3ebchin#define memzero(b,n)	memset(b,0,n)
299da2e3ebchin#else
300da2e3ebchin#define memzero(b,n)	(bzero(b,n),(b))
301da2e3ebchin#endif
302da2e3ebchin#endif
303da2e3ebchin
304da2e3ebchin#endif
305da2e3ebchin
306da2e3ebchin#if !defined(remove)
307da2e3ebchinextern int		remove(const char*);
308da2e3ebchin#endif
309da2e3ebchin
310da2e3ebchin#if !defined(rename)
311da2e3ebchinextern int		rename(const char*, const char*);
312da2e3ebchin#endif
313da2e3ebchin
314da2e3ebchin#if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index)
315da2e3ebchin#define strchr(s,c)	index(s,c)
316da2e3ebchin#endif
317da2e3ebchin
318da2e3ebchin#if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex)
319da2e3ebchin#define strrchr(s,c)	rindex(s,c)
320da2e3ebchin#endif
321da2e3ebchin
322da2e3ebchin/* and now introducing prototypes botched by the standard(s) */
323da2e3ebchin
324da2e3ebchin#if _BLD_ast && defined(__EXPORT__)
325da2e3ebchin#define extern		__EXPORT__
326da2e3ebchin#endif
327da2e3ebchin
328da2e3ebchin#undef	getpgrp
329da2e3ebchin#define	getpgrp()	_ast_getpgrp()
330da2e3ebchinextern int		_ast_getpgrp(void);
331da2e3ebchin
332da2e3ebchin#undef	extern
333da2e3ebchin
334da2e3ebchin/*
335da2e3ebchin * and finally, standard interfaces hijacked by ast
3363e14f97Roger A. Faulkner * _AST_STD_I delays headers that require <ast_map.h>
337da2e3ebchin */
338da2e3ebchin
339da2e3ebchin#include <ast_map.h>
340da2e3ebchin
341da2e3ebchin#undef	_AST_STD_I
342da2e3ebchin
3437c2fbfbApril Chin#if _AST_GETOPT_H < 0
3447c2fbfbApril Chin#undef	_AST_GETOPT_H
3457c2fbfbApril Chin#include <ast_getopt.h>
3467c2fbfbApril Chin#endif
3477c2fbfbApril Chin
3487c2fbfbApril Chin#if _GETOPT_H < 0
3497c2fbfbApril Chin#undef	_GETOPT_H
3507c2fbfbApril Chin#include <getopt.h>
3517c2fbfbApril Chin#endif
3527c2fbfbApril Chin
353da2e3ebchin#if _REGEX_H < 0
354da2e3ebchin#undef	_REGEX_H
355da2e3ebchin#include <regex.h>
356da2e3ebchin#endif
357da2e3ebchin
358da2e3ebchin#endif
359