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#ifndef _STDHDR_H
25da2e3ebchin#define _STDHDR_H	1
26da2e3ebchin
27da2e3ebchin#ifndef _NO_LARGEFILE64_SOURCE
28da2e3ebchin#define _NO_LARGEFILE64_SOURCE	1
29da2e3ebchin#endif
30da2e3ebchin#undef	_LARGEFILE64_SOURCE
31da2e3ebchin
32da2e3ebchin#define _ast_fseeko	______fseeko
33da2e3ebchin#define _ast_ftello	______ftello
34da2e3ebchin#include "sfhdr.h"
35da2e3ebchin#undef	_ast_fseeko
36da2e3ebchin#undef	_ast_ftello
37da2e3ebchin
38da2e3ebchin#include "stdio.h"
39da2e3ebchin
40da2e3ebchin#define SF_MB		010000
41da2e3ebchin#define SF_WC		020000
42da2e3ebchin
43da2e3ebchin#if _UWIN
44da2e3ebchin
45da2e3ebchin#define STDIO_TRANSFER	1
46da2e3ebchin
47da2e3ebchintypedef int (*Fun_f)();
48da2e3ebchin
49da2e3ebchintypedef struct Funvec_s
50da2e3ebchin{
51da2e3ebchin	const char*	name;
52da2e3ebchin	Fun_f		vec[2];
53da2e3ebchin} Funvec_t;
54da2e3ebchin
55da2e3ebchinextern int	_stdfun(Sfio_t*, Funvec_t*);
56da2e3ebchin
57da2e3ebchin#define STDIO_INT(p,n,t,f,a) \
58da2e3ebchin	{ \
59da2e3ebchin		typedef t (*_s_f)f; \
60da2e3ebchin		int		_i; \
61da2e3ebchin		static Funvec_t	_v = { n }; \
62da2e3ebchin		if ((_i = _stdfun(p, &_v)) < 0) \
63da2e3ebchin			return -1; \
64da2e3ebchin		else if (_i > 0) \
65da2e3ebchin			return ((_s_f)_v.vec[_i])a; \
66da2e3ebchin	}
67da2e3ebchin
68da2e3ebchin#define STDIO_PTR(p,n,t,f,a) \
69da2e3ebchin	{ \
70da2e3ebchin		typedef t (*_s_f)f; \
71da2e3ebchin		int		_i; \
72da2e3ebchin		static Funvec_t	_v = { n }; \
73da2e3ebchin		if ((_i = _stdfun(p, &_v)) < 0) \
74da2e3ebchin			return 0; \
75da2e3ebchin		else if (_i > 0) \
76da2e3ebchin			return ((_s_f)_v.vec[_i])a; \
77da2e3ebchin	}
78da2e3ebchin
79da2e3ebchin#define STDIO_VOID(p,n,t,f,a) \
80da2e3ebchin	{ \
81da2e3ebchin		typedef t (*_s_f)f; \
82da2e3ebchin		int		_i; \
83da2e3ebchin		static Funvec_t	_v = { n }; \
84da2e3ebchin		if ((_i = _stdfun(p, &_v)) < 0) \
85da2e3ebchin			return; \
86da2e3ebchin		else if (_i > 0) \
87da2e3ebchin		{ \
88da2e3ebchin			((_s_f)_v.vec[_i])a; \
89da2e3ebchin			return; \
90da2e3ebchin		} \
91da2e3ebchin	}
92da2e3ebchin
93da2e3ebchin#else
94da2e3ebchin
95da2e3ebchin#define STDIO_INT(p,n,t,f,a)
96da2e3ebchin#define STDIO_PTR(p,n,t,f,a)
97da2e3ebchin#define STDIO_VOID(p,n,t,f,a)
98da2e3ebchin
99da2e3ebchin#endif
100da2e3ebchin
101da2e3ebchin#define FWIDE(f,r) \
102da2e3ebchin	do \
103da2e3ebchin	{ \
104da2e3ebchin		if (fwide(f, 0) < 0) \
105da2e3ebchin			return r; \
106da2e3ebchin		f->bits |= SF_WC; \
107da2e3ebchin	} while (0)
108da2e3ebchin
109da2e3ebchin#ifdef __EXPORT__
110da2e3ebchin#define extern	__EXPORT__
111da2e3ebchin#endif
112da2e3ebchin
113da2e3ebchinextern int		sfdcwide(Sfio_t*);
114da2e3ebchin
115da2e3ebchin#endif
116