Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/include/stdio.h

  • Property svn:executable set to *
1/*
2 * Copyright (c) 2000, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*-
24 * Copyright (c) 1990, 1993
25 *The Regents of the University of California. All rights reserved.
26 *
27 * This code is derived from software contributed to Berkeley by
28 * Chris Torek.
29 *
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
32 * are met:
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. All advertising materials mentioning features or use of this software
39 * must display the following acknowledgement:
40 *This product includes software developed by the University of
41 *California, Berkeley and its contributors.
42 * 4. Neither the name of the University nor the names of its contributors
43 * may be used to endorse or promote products derived from this software
44 * without specific prior written permission.
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * SUCH DAMAGE.
57 *
58 *@(#)stdio.h8.5 (Berkeley) 4/29/95
59 */
60
61#ifndef_STDIO_H_
62#define_STDIO_H_
63
64#include <sys/types.h>
65#include <sys/cdefs.h>
66#include <Availability.h>
67
68#include <_types.h>
69
70#ifndef _VA_LIST
71#define _VA_LIST
72/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
73 * __gnuc_va_list and include <stdarg.h> */
74typedef __darwin_va_listva_list;
75#endif
76
77#ifndef_SIZE_T
78#define_SIZE_T
79typedef__darwin_size_tsize_t;
80#endif
81
82#ifndef NULL
83#define NULL __DARWIN_NULL
84#endif /* ! NULL */
85
86typedef __darwin_off_tfpos_t;
87
88#define_FSTDIO/* Define for new stdio with functions. */
89
90/*
91 * NB: to fit things in six character monocase externals, the stdio
92 * code uses the prefix `__s' for stdio objects, typically followed
93 * by a three-character attempt at a mnemonic.
94 */
95
96/* stdio buffers */
97struct __sbuf {
98unsigned char*_base;
99int_size;
100};
101
102/* hold a buncha junk that would grow the ABI */
103struct __sFILEX;
104
105/*
106 * stdio state variables.
107 *
108 * The following always hold:
109 *
110 *if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
111 *_lbfsize is -_bf._size, else _lbfsize is 0
112 *if _flags&__SRD, _w is 0
113 *if _flags&__SWR, _r is 0
114 *
115 * This ensures that the getc and putc macros (or inline functions) never
116 * try to write or read from a file that is in `read' or `write' mode.
117 * (Moreover, they can, and do, automatically switch from read mode to
118 * write mode, and back, on "r+" and "w+" files.)
119 *
120 * _lbfsize is used only to make the inline line-buffered output stream
121 * code as compact as possible.
122 *
123 * _ub, _up, and _ur are used when ungetc() pushes back more characters
124 * than fit in the current _bf, or when ungetc() pushes back a character
125 * that does not match the previous one in _bf. When this happens,
126 * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
127 * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
128 *
129 * NB: see WARNING above before changing the layout of this structure!
130 */
131typedefstruct __sFILE {
132unsigned char *_p;/* current position in (some) buffer */
133int_r;/* read space left for getc() */
134int_w;/* write space left for putc() */
135short_flags;/* flags, below; this FILE is free if 0 */
136short_file;/* fileno, if Unix descriptor, else -1 */
137struct__sbuf _bf;/* the buffer (at least 1 byte, if !NULL) */
138int_lbfsize;/* 0 or -_bf._size, for inline putc */
139
140/* operations */
141void*_cookie;/* cookie passed to io functions */
142int(*_close)(void *);
143int(*_read) (void *, char *, int);
144fpos_t(*_seek) (void *, fpos_t, int);
145int(*_write)(void *, const char *, int);
146
147/* separate buffer for long sequences of ungetc() */
148struct__sbuf _ub;/* ungetc buffer */
149struct __sFILEX *_extra; /* additions to FILE to not break ABI */
150int_ur;/* saved _r when _r is counting ungetc data */
151
152/* tricks to meet minimum requirements even when malloc() fails */
153unsigned char _ubuf[3];/* guarantee an ungetc() buffer */
154unsigned char _nbuf[1];/* guarantee a getc() buffer */
155
156/* separate buffer for fgetln() when line crosses buffer boundary */
157struct__sbuf _lb;/* buffer for fgetln() */
158
159/* Unix stdio files get aligned to block boundaries on fseek() */
160int_blksize;/* stat.st_blksize (may be != _bf._size) */
161fpos_t_offset;/* current lseek offset (see WARNING) */
162} FILE;
163
164__BEGIN_DECLS
165extern FILE *__stdinp;
166extern FILE *__stdoutp;
167extern FILE *__stderrp;
168__END_DECLS
169
170#define__SLBF0x0001/* line buffered */
171#define__SNBF0x0002/* unbuffered */
172#define__SRD0x0004/* OK to read */
173#define__SWR0x0008/* OK to write */
174/* RD and WR are never simultaneously asserted */
175#define__SRW0x0010/* open for reading & writing */
176#define__SEOF0x0020/* found EOF */
177#define__SERR0x0040/* found error */
178#define__SMBF0x0080/* _buf is from malloc */
179#define__SAPP0x0100/* fdopen()ed in append mode */
180#define__SSTR0x0200/* this is an sprintf/snprintf string */
181#define__SOPT0x0400/* do fseek() optimisation */
182#define__SNPT0x0800/* do not do fseek() optimisation */
183#define__SOFF0x1000/* set iff _offset is in fact correct */
184#define__SMOD0x2000/* true => fgetln modified _p text */
185#define __SALC 0x4000/* allocate string space dynamically */
186#define __SIGN 0x8000/* ignore this file in _fwalk */
187
188/*
189 * The following three definitions are for ANSI C, which took them
190 * from System V, which brilliantly took internal interface macros and
191 * made them official arguments to setvbuf(), without renaming them.
192 * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
193 *
194 * Although numbered as their counterparts above, the implementation
195 * does not rely on this.
196 */
197#define_IOFBF0/* setvbuf should set fully buffered */
198#define_IOLBF1/* setvbuf should set line buffered */
199#define_IONBF2/* setvbuf should set unbuffered */
200
201#defineBUFSIZ1024/* size of buffer used by setbuf */
202#defineEOF(-1)
203
204/* must be == _POSIX_STREAM_MAX <limits.h> */
205#defineFOPEN_MAX20/* must be <= OPEN_MAX <sys/syslimits.h> */
206#defineFILENAME_MAX1024/* must be <= PATH_MAX <sys/syslimits.h> */
207
208/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
209#ifndef _ANSI_SOURCE
210#defineP_tmpdir"/var/tmp/"
211#endif
212#defineL_tmpnam1024/* XXX must be == PATH_MAX */
213#defineTMP_MAX308915776
214
215#ifndef SEEK_SET
216#defineSEEK_SET0/* set file offset to offset */
217#endif
218#ifndef SEEK_CUR
219#defineSEEK_CUR1/* set file offset to current plus offset */
220#endif
221#ifndef SEEK_END
222#defineSEEK_END2/* set file offset to EOF plus offset */
223#endif
224
225#definestdin__stdinp
226#definestdout__stdoutp
227#definestderr__stderrp
228
229#ifdef _DARWIN_UNLIMITED_STREAMS
230#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_3_2
231#error "_DARWIN_UNLIMITED_STREAMS specified, but -miphoneos-version-min version does not support it."
232#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6
233#error "_DARWIN_UNLIMITED_STREAMS specified, but -mmacosx-version-min version does not support it."
234#endif
235#endif
236
237/* ANSI-C */
238
239__BEGIN_DECLS
240int fclose(FILE *);
241int feof(FILE *);
242int ferror(FILE *);
243int fflush(FILE *);
244int fgetc(FILE *);
245int fgetpos(FILE * __restrict, fpos_t *);
246char *fgets(char * __restrict, int, FILE *);
247FILE*fopen(const char * __restrict, const char * __restrict) ;
248int fprintf(FILE * __restrict, const char * __restrict, ...);
249int fputc(int, FILE *);
250int fputs(const char * __restrict, FILE * __restrict);
251size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
252FILE*fdopen(int, const char *);
253
254int fscanf(FILE * __restrict, const char * __restrict, ...) __scanflike(2, 3);
255int fseek(FILE *, long, int);
256int fsetpos(FILE *, const fpos_t *);
257long ftell(FILE *);
258size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict) ;
259
260int printf(const char * __restrict, ...) __printflike(1, 2);
261int putc(int, FILE *);
262int putchar(int);
263void puts(const char *);
264int ungetc(int , FILE *);
265int ungetchar(int );
266int sprintf(char * __restrict, const char * __restrict, ...) __printflike(2, 3);
267int ungetc(int, FILE *);
268int vfprintf(FILE * __restrict, const char * __restrict, va_list) __printflike(2, 0);
269__END_DECLS
270
271/* Additional functionality provided by:
272 * POSIX.1-1988
273 */
274#if __DARWIN_C_LEVEL >= 198808L
275__BEGIN_DECLS
276int fileno(FILE *);
277__END_DECLS
278#endif /* __DARWIN_C_LEVEL >= 198808L */
279
280
281/* Additional functionality provided by:
282 * POSIX.1c-1995,
283 * POSIX.1i-1995,
284 * and the omnibus ISO/IEC 9945-1: 1996
285 */
286
287#if __DARWIN_C_LEVEL >= 199506L
288#define__sfeof(p)(((p)->_flags & __SEOF) != 0)
289#define__sferror(p)(((p)->_flags & __SERR) != 0)
290#define__sclearerr(p)((void)((p)->_flags &= ~(__SERR|__SEOF)))
291#define__sfileno(p)((p)->_file)
292#endif /* __DARWIN_C_LEVEL >= 199506L */
293
294
295
296/* Additional functionality provided by:
297 * POSIX.1-2001
298 * ISO C99
299 */
300
301#if __DARWIN_C_LEVEL >= 200112L
302#ifndef_OFF_T
303#define_OFF_T
304typedef__darwin_off_toff_t;
305#endif
306
307__BEGIN_DECLS
308int fseeko(FILE *, off_t, int);
309off_t ftello(FILE *);
310__END_DECLS
311#endif /* __DARWIN_C_LEVEL >= 200112L */
312
313#if __DARWIN_C_LEVEL >= 200112L || defined(_C99_SOURCE) || defined(__cplusplus)
314__BEGIN_DECLS
315int snprintf(char * __restrict, size_t, const char * __restrict, ...) __printflike(3, 4);
316int vsnprintf(char * __restrict, size_t, const char * __restrict, va_list) __printflike(3, 0);
317__END_DECLS
318#endif /* __DARWIN_C_LEVEL >= 200112L || defined(_C99_SOURCE) || defined(__cplusplus) */
319
320/* Additional functionality provided by:
321 * POSIX.1-2008
322 */
323
324#if __DARWIN_C_LEVEL >= 200809L
325#ifndef _SSIZE_T
326#define _SSIZE_T
327typedef __darwin_ssize_t ssize_t;
328#endif
329
330#endif /* __DARWIN_C_LEVEL >= 200809L */
331
332
333
334/*
335 * Stdio function-access interface.
336 */
337#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
338#definefileno_unlocked(p)__sfileno(p)
339#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
340
341
342#endif /* _STDIO_H_ */
343

Archive Download this file

Revision: 2182