Rev 4921 | Rev 5963 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* |
2 | * Copyright (c) 1990 The Regents of the University of California. |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms are permitted |
||
6 | * provided that the above copyright notice and this paragraph are |
||
7 | * duplicated in all such forms and that any documentation, |
||
8 | * advertising materials, and other materials related to such |
||
9 | * distribution and use acknowledge that the software was developed |
||
10 | * by the University of California, Berkeley. The name of the |
||
11 | * University may not be used to endorse or promote products derived |
||
12 | * from this software without specific prior written permission. |
||
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
||
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
||
15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
||
16 | * |
||
17 | * @(#)stdio.h 5.3 (Berkeley) 3/15/86 |
||
18 | */ |
||
19 | |||
20 | /* |
||
21 | * NB: to fit things in six character monocase externals, the |
||
22 | * stdio code uses the prefix `__s' for stdio objects, typically |
||
23 | * followed by a three-character attempt at a mnemonic. |
||
24 | */ |
||
25 | |||
26 | #ifndef _STDIO_H_ |
||
27 | #define _STDIO_H_ |
||
28 | |||
29 | #include "_ansi.h" |
||
30 | |||
31 | #define _FSTDIO /* ``function stdio'' */ |
||
32 | |||
33 | #define __need_size_t |
||
4921 | Serge | 34 | #define __need_NULL |
4349 | Serge | 35 | #include |
36 | |||
37 | #define __need___va_list |
||
38 | #include |
||
39 | |||
40 | /* |
||
41 | * |
||
42 | * They must be defined there because struct _reent needs them (and we don't |
||
43 | * want reent.h to include this file. |
||
44 | */ |
||
45 | |||
46 | #include |
||
47 | #include |
||
48 | |||
49 | _BEGIN_STD_C |
||
50 | |||
51 | typedef __FILE FILE; |
||
52 | |||
53 | #ifdef __CYGWIN__ |
||
54 | typedef _fpos64_t fpos_t; |
||
55 | #else |
||
56 | typedef _fpos_t fpos_t; |
||
57 | #ifdef __LARGE64_FILES |
||
58 | typedef _fpos64_t fpos64_t; |
||
59 | #endif |
||
60 | #endif /* !__CYGWIN__ */ |
||
61 | |||
62 | #include |
||
63 | |||
64 | #define __SLBF 0x0001 /* line buffered */ |
||
65 | #define __SNBF 0x0002 /* unbuffered */ |
||
66 | #define __SRD 0x0004 /* OK to read */ |
||
67 | #define __SWR 0x0008 /* OK to write */ |
||
68 | /* RD and WR are never simultaneously asserted */ |
||
69 | #define __SRW 0x0010 /* open for reading & writing */ |
||
70 | #define __SEOF 0x0020 /* found EOF */ |
||
71 | #define __SERR 0x0040 /* found error */ |
||
72 | #define __SMBF 0x0080 /* _buf is from malloc */ |
||
73 | #define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */ |
||
74 | #define __SSTR 0x0200 /* this is an sprintf/snprintf string */ |
||
75 | #define __SOPT 0x0400 /* do fseek() optimisation */ |
||
76 | #define __SNPT 0x0800 /* do not do fseek() optimisation */ |
||
77 | #define __SOFF 0x1000 /* set iff _offset is in fact correct */ |
||
78 | #define __SORD 0x2000 /* true => stream orientation (byte/wide) decided */ |
||
79 | #if defined(__CYGWIN__) |
||
80 | # define __SCLE 0x4000 /* convert line endings CR/LF <-> NL */ |
||
81 | #endif |
||
82 | #define __SL64 0x8000 /* is 64-bit offset large file */ |
||
83 | |||
84 | /* _flags2 flags */ |
||
85 | #define __SWID 0x2000 /* true => stream orientation wide, false => byte, only valid if __SORD in _flags is true */ |
||
86 | |||
87 | /* |
||
88 | * The following three definitions are for ANSI C, which took them |
||
89 | * from System V, which stupidly took internal interface macros and |
||
90 | * made them official arguments to setvbuf(), without renaming them. |
||
91 | * Hence, these ugly _IOxxx names are *supposed* to appear in user code. |
||
92 | * |
||
93 | * Although these happen to match their counterparts above, the |
||
94 | * implementation does not rely on that (so these could be renumbered). |
||
95 | */ |
||
96 | #define _IOFBF 0 /* setvbuf should set fully buffered */ |
||
97 | #define _IOLBF 1 /* setvbuf should set line buffered */ |
||
98 | #define _IONBF 2 /* setvbuf should set unbuffered */ |
||
99 | |||
100 | #define EOF (-1) |
||
101 | |||
102 | #ifdef __BUFSIZ__ |
||
103 | #define BUFSIZ __BUFSIZ__ |
||
104 | #else |
||
5808 | serge | 105 | #define BUFSIZ 4096 |
4349 | Serge | 106 | #endif |
107 | |||
108 | #ifdef __FOPEN_MAX__ |
||
109 | #define FOPEN_MAX __FOPEN_MAX__ |
||
110 | #else |
||
111 | #define FOPEN_MAX 20 |
||
112 | #endif |
||
113 | |||
114 | #ifdef __FILENAME_MAX__ |
||
115 | #define FILENAME_MAX __FILENAME_MAX__ |
||
116 | #else |
||
117 | #define FILENAME_MAX 1024 |
||
118 | #endif |
||
119 | |||
120 | #ifdef __L_tmpnam__ |
||
121 | #define L_tmpnam __L_tmpnam__ |
||
122 | #else |
||
123 | #define L_tmpnam FILENAME_MAX |
||
124 | #endif |
||
125 | |||
126 | #ifndef __STRICT_ANSI__ |
||
127 | #define P_tmpdir "/tmp" |
||
128 | #endif |
||
129 | |||
130 | #ifndef SEEK_SET |
||
131 | #define SEEK_SET 0 /* set file offset to offset */ |
||
132 | #endif |
||
133 | #ifndef SEEK_CUR |
||
134 | #define SEEK_CUR 1 /* set file offset to current plus offset */ |
||
135 | #endif |
||
136 | #ifndef SEEK_END |
||
137 | #define SEEK_END 2 /* set file offset to EOF plus offset */ |
||
138 | #endif |
||
139 | |||
140 | #define TMP_MAX 26 |
||
141 | |||
142 | #define stdin (_REENT->_stdin) |
||
143 | #define stdout (_REENT->_stdout) |
||
144 | #define stderr (_REENT->_stderr) |
||
145 | |||
146 | #define _stdin_r(x) ((x)->_stdin) |
||
147 | #define _stdout_r(x) ((x)->_stdout) |
||
148 | #define _stderr_r(x) ((x)->_stderr) |
||
149 | |||
150 | /* |
||
151 | * Functions defined in ANSI C standard. |
||
152 | */ |
||
153 | |||
154 | #ifndef __VALIST |
||
155 | #ifdef __GNUC__ |
||
156 | #define __VALIST __gnuc_va_list |
||
157 | #else |
||
158 | #define __VALIST char* |
||
159 | #endif |
||
160 | #endif |
||
161 | |||
162 | FILE * _EXFUN(tmpfile, (void)); |
||
163 | char * _EXFUN(tmpnam, (char *)); |
||
164 | int _EXFUN(fclose, (FILE *)); |
||
165 | int _EXFUN(fflush, (FILE *)); |
||
4921 | Serge | 166 | FILE * _EXFUN(freopen, (const char *__restrict, const char *__restrict, FILE *__restrict)); |
167 | void _EXFUN(setbuf, (FILE *__restrict, char *__restrict)); |
||
168 | int _EXFUN(setvbuf, (FILE *__restrict, char *__restrict, int, size_t)); |
||
169 | int _EXFUN(fprintf, (FILE *__restrict, const char *__restrict, ...) |
||
4349 | Serge | 170 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
4921 | Serge | 171 | int _EXFUN(fscanf, (FILE *__restrict, const char *__restrict, ...) |
4349 | Serge | 172 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
4921 | Serge | 173 | int _EXFUN(printf, (const char *__restrict, ...) |
4349 | Serge | 174 | _ATTRIBUTE ((__format__ (__printf__, 1, 2)))); |
4921 | Serge | 175 | int _EXFUN(scanf, (const char *__restrict, ...) |
4349 | Serge | 176 | _ATTRIBUTE ((__format__ (__scanf__, 1, 2)))); |
4921 | Serge | 177 | int _EXFUN(sscanf, (const char *__restrict, const char *__restrict, ...) |
4349 | Serge | 178 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
4921 | Serge | 179 | int _EXFUN(vfprintf, (FILE *__restrict, const char *__restrict, __VALIST) |
4349 | Serge | 180 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
181 | int _EXFUN(vprintf, (const char *, __VALIST) |
||
182 | _ATTRIBUTE ((__format__ (__printf__, 1, 0)))); |
||
4921 | Serge | 183 | int _EXFUN(vsprintf, (char *__restrict, const char *__restrict, __VALIST) |
4349 | Serge | 184 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
185 | int _EXFUN(fgetc, (FILE *)); |
||
4921 | Serge | 186 | char * _EXFUN(fgets, (char *__restrict, int, FILE *__restrict)); |
4349 | Serge | 187 | int _EXFUN(fputc, (int, FILE *)); |
4921 | Serge | 188 | int _EXFUN(fputs, (const char *__restrict, FILE *__restrict)); |
4349 | Serge | 189 | int _EXFUN(getc, (FILE *)); |
190 | int _EXFUN(getchar, (void)); |
||
191 | char * _EXFUN(gets, (char *)); |
||
192 | int _EXFUN(putc, (int, FILE *)); |
||
193 | int _EXFUN(putchar, (int)); |
||
194 | int _EXFUN(puts, (const char *)); |
||
195 | int _EXFUN(ungetc, (int, FILE *)); |
||
4921 | Serge | 196 | size_t _EXFUN(fread, (_PTR __restrict, size_t _size, size_t _n, FILE *__restrict)); |
197 | size_t _EXFUN(fwrite, (const _PTR __restrict , size_t _size, size_t _n, FILE *)); |
||
4349 | Serge | 198 | #ifdef _COMPILING_NEWLIB |
199 | int _EXFUN(fgetpos, (FILE *, _fpos_t *)); |
||
200 | #else |
||
4921 | Serge | 201 | int _EXFUN(fgetpos, (FILE *__restrict, fpos_t *__restrict)); |
4349 | Serge | 202 | #endif |
203 | int _EXFUN(fseek, (FILE *, long, int)); |
||
204 | #ifdef _COMPILING_NEWLIB |
||
205 | int _EXFUN(fsetpos, (FILE *, const _fpos_t *)); |
||
206 | #else |
||
207 | int _EXFUN(fsetpos, (FILE *, const fpos_t *)); |
||
208 | #endif |
||
209 | long _EXFUN(ftell, ( FILE *)); |
||
210 | void _EXFUN(rewind, (FILE *)); |
||
211 | void _EXFUN(clearerr, (FILE *)); |
||
212 | int _EXFUN(feof, (FILE *)); |
||
213 | int _EXFUN(ferror, (FILE *)); |
||
214 | void _EXFUN(perror, (const char *)); |
||
215 | #ifndef _REENT_ONLY |
||
4921 | Serge | 216 | FILE * _EXFUN(fopen, (const char *__restrict _name, const char *__restrict _type)); |
217 | int _EXFUN(sprintf, (char *__restrict, const char *__restrict, ...) |
||
4349 | Serge | 218 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
219 | int _EXFUN(remove, (const char *)); |
||
220 | int _EXFUN(rename, (const char *, const char *)); |
||
4921 | Serge | 221 | #ifdef _COMPILING_NEWLIB |
222 | int _EXFUN(_rename, (const char *, const char *)); |
||
4349 | Serge | 223 | #endif |
4921 | Serge | 224 | #endif |
4349 | Serge | 225 | #if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K) |
226 | #ifdef _COMPILING_NEWLIB |
||
227 | int _EXFUN(fseeko, (FILE *, _off_t, int)); |
||
228 | _off_t _EXFUN(ftello, ( FILE *)); |
||
229 | #else |
||
230 | int _EXFUN(fseeko, (FILE *, off_t, int)); |
||
231 | off_t _EXFUN(ftello, ( FILE *)); |
||
232 | #endif |
||
233 | #endif |
||
234 | #if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) |
||
235 | #ifndef _REENT_ONLY |
||
236 | int _EXFUN(asiprintf, (char **, const char *, ...) |
||
237 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
||
238 | char * _EXFUN(asniprintf, (char *, size_t *, const char *, ...) |
||
239 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
||
4921 | Serge | 240 | char * _EXFUN(asnprintf, (char *__restrict, size_t *__restrict, const char *__restrict, ...) |
4349 | Serge | 241 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
4921 | Serge | 242 | int _EXFUN(asprintf, (char **__restrict, const char *__restrict, ...) |
4349 | Serge | 243 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
244 | #ifndef diprintf |
||
245 | int _EXFUN(diprintf, (int, const char *, ...) |
||
246 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
||
247 | #endif |
||
248 | int _EXFUN(fcloseall, (_VOID)); |
||
249 | int _EXFUN(fiprintf, (FILE *, const char *, ...) |
||
250 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
||
251 | int _EXFUN(fiscanf, (FILE *, const char *, ...) |
||
252 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
||
253 | int _EXFUN(iprintf, (const char *, ...) |
||
254 | _ATTRIBUTE ((__format__ (__printf__, 1, 2)))); |
||
255 | int _EXFUN(iscanf, (const char *, ...) |
||
256 | _ATTRIBUTE ((__format__ (__scanf__, 1, 2)))); |
||
257 | int _EXFUN(siprintf, (char *, const char *, ...) |
||
258 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
||
259 | int _EXFUN(siscanf, (const char *, const char *, ...) |
||
260 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
||
4921 | Serge | 261 | int _EXFUN(snprintf, (char *__restrict, size_t, const char *__restrict, ...) |
4349 | Serge | 262 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
263 | int _EXFUN(sniprintf, (char *, size_t, const char *, ...) |
||
264 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
||
265 | char * _EXFUN(tempnam, (const char *, const char *)); |
||
266 | int _EXFUN(vasiprintf, (char **, const char *, __VALIST) |
||
267 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
||
268 | char * _EXFUN(vasniprintf, (char *, size_t *, const char *, __VALIST) |
||
269 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
||
270 | char * _EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST) |
||
271 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
||
272 | int _EXFUN(vasprintf, (char **, const char *, __VALIST) |
||
273 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
||
274 | int _EXFUN(vdiprintf, (int, const char *, __VALIST) |
||
275 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
||
276 | int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST) |
||
277 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
||
278 | int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST) |
||
279 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
||
4921 | Serge | 280 | int _EXFUN(vfscanf, (FILE *__restrict, const char *__restrict, __VALIST) |
4349 | Serge | 281 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
282 | int _EXFUN(viprintf, (const char *, __VALIST) |
||
283 | _ATTRIBUTE ((__format__ (__printf__, 1, 0)))); |
||
284 | int _EXFUN(viscanf, (const char *, __VALIST) |
||
285 | _ATTRIBUTE ((__format__ (__scanf__, 1, 0)))); |
||
286 | int _EXFUN(vscanf, (const char *, __VALIST) |
||
287 | _ATTRIBUTE ((__format__ (__scanf__, 1, 0)))); |
||
288 | int _EXFUN(vsiprintf, (char *, const char *, __VALIST) |
||
289 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
||
290 | int _EXFUN(vsiscanf, (const char *, const char *, __VALIST) |
||
291 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
||
292 | int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST) |
||
293 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
||
4921 | Serge | 294 | int _EXFUN(vsnprintf, (char *__restrict, size_t, const char *__restrict, __VALIST) |
4349 | Serge | 295 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
4921 | Serge | 296 | int _EXFUN(vsscanf, (const char *__restrict, const char *__restrict, __VALIST) |
4349 | Serge | 297 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
298 | #endif /* !_REENT_ONLY */ |
||
299 | #endif /* !__STRICT_ANSI__ */ |
||
300 | |||
301 | /* |
||
302 | * Routines in POSIX 1003.1:2001. |
||
303 | */ |
||
304 | |||
305 | #ifndef __STRICT_ANSI__ |
||
306 | #ifndef _REENT_ONLY |
||
307 | FILE * _EXFUN(fdopen, (int, const char *)); |
||
308 | #endif |
||
309 | int _EXFUN(fileno, (FILE *)); |
||
310 | int _EXFUN(getw, (FILE *)); |
||
311 | int _EXFUN(pclose, (FILE *)); |
||
312 | FILE * _EXFUN(popen, (const char *, const char *)); |
||
313 | int _EXFUN(putw, (int, FILE *)); |
||
314 | void _EXFUN(setbuffer, (FILE *, char *, int)); |
||
315 | int _EXFUN(setlinebuf, (FILE *)); |
||
316 | int _EXFUN(getc_unlocked, (FILE *)); |
||
317 | int _EXFUN(getchar_unlocked, (void)); |
||
318 | void _EXFUN(flockfile, (FILE *)); |
||
319 | int _EXFUN(ftrylockfile, (FILE *)); |
||
320 | void _EXFUN(funlockfile, (FILE *)); |
||
321 | int _EXFUN(putc_unlocked, (int, FILE *)); |
||
322 | int _EXFUN(putchar_unlocked, (int)); |
||
323 | #endif /* ! __STRICT_ANSI__ */ |
||
324 | |||
325 | /* |
||
326 | * Routines in POSIX 1003.1:200x. |
||
327 | */ |
||
328 | |||
329 | #ifndef __STRICT_ANSI__ |
||
330 | # ifndef _REENT_ONLY |
||
331 | # ifndef dprintf |
||
4921 | Serge | 332 | int _EXFUN(dprintf, (int, const char *__restrict, ...) |
4349 | Serge | 333 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
334 | # endif |
||
4921 | Serge | 335 | FILE * _EXFUN(fmemopen, (void *__restrict, size_t, const char *__restrict)); |
4349 | Serge | 336 | /* getdelim - see __getdelim for now */ |
337 | /* getline - see __getline for now */ |
||
338 | FILE * _EXFUN(open_memstream, (char **, size_t *)); |
||
339 | #if defined (__CYGWIN__) |
||
340 | int _EXFUN(renameat, (int, const char *, int, const char *)); |
||
341 | #endif |
||
4921 | Serge | 342 | int _EXFUN(vdprintf, (int, const char *__restrict, __VALIST) |
4349 | Serge | 343 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
344 | # endif |
||
345 | #endif |
||
346 | |||
347 | /* |
||
348 | * Recursive versions of the above. |
||
349 | */ |
||
350 | |||
351 | int _EXFUN(_asiprintf_r, (struct _reent *, char **, const char *, ...) |
||
352 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
||
353 | char * _EXFUN(_asniprintf_r, (struct _reent *, char *, size_t *, const char *, ...) |
||
354 | _ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
||
4921 | Serge | 355 | char * _EXFUN(_asnprintf_r, (struct _reent *, char *__restrict, size_t *__restrict, const char *__restrict, ...) |
4349 | Serge | 356 | _ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
4921 | Serge | 357 | int _EXFUN(_asprintf_r, (struct _reent *, char **__restrict, const char *__restrict, ...) |
4349 | Serge | 358 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
359 | int _EXFUN(_diprintf_r, (struct _reent *, int, const char *, ...) |
||
360 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
||
4921 | Serge | 361 | int _EXFUN(_dprintf_r, (struct _reent *, int, const char *__restrict, ...) |
4349 | Serge | 362 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
363 | int _EXFUN(_fclose_r, (struct _reent *, FILE *)); |
||
364 | int _EXFUN(_fcloseall_r, (struct _reent *)); |
||
365 | FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *)); |
||
366 | int _EXFUN(_fflush_r, (struct _reent *, FILE *)); |
||
367 | int _EXFUN(_fgetc_r, (struct _reent *, FILE *)); |
||
4921 | Serge | 368 | char * _EXFUN(_fgets_r, (struct _reent *, char *__restrict, int, FILE *__restrict)); |
4349 | Serge | 369 | #ifdef _COMPILING_NEWLIB |
4921 | Serge | 370 | int _EXFUN(_fgetpos_r, (struct _reent *, FILE *__restrict, _fpos_t *__restrict)); |
4349 | Serge | 371 | int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const _fpos_t *)); |
372 | #else |
||
373 | int _EXFUN(_fgetpos_r, (struct _reent *, FILE *, fpos_t *)); |
||
374 | int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const fpos_t *)); |
||
375 | #endif |
||
376 | int _EXFUN(_fiprintf_r, (struct _reent *, FILE *, const char *, ...) |
||
377 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
||
378 | int _EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...) |
||
379 | _ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
||
4921 | Serge | 380 | FILE * _EXFUN(_fmemopen_r, (struct _reent *, void *__restrict, size_t, const char *__restrict)); |
381 | FILE * _EXFUN(_fopen_r, (struct _reent *, const char *__restrict, const char *__restrict)); |
||
382 | FILE * _EXFUN(_freopen_r, (struct _reent *, const char *__restrict, const char *__restrict, FILE *__restrict)); |
||
383 | int _EXFUN(_fprintf_r, (struct _reent *, FILE *__restrict, const char *__restrict, ...) |
||
4349 | Serge | 384 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
385 | int _EXFUN(_fpurge_r, (struct _reent *, FILE *)); |
||
386 | int _EXFUN(_fputc_r, (struct _reent *, int, FILE *)); |
||
4921 | Serge | 387 | int _EXFUN(_fputs_r, (struct _reent *, const char *__restrict, FILE *__restrict)); |
388 | size_t _EXFUN(_fread_r, (struct _reent *, _PTR __restrict, size_t _size, size_t _n, FILE *__restrict)); |
||
389 | int _EXFUN(_fscanf_r, (struct _reent *, FILE *__restrict, const char *__restrict, ...) |
||
4349 | Serge | 390 | _ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
391 | int _EXFUN(_fseek_r, (struct _reent *, FILE *, long, int)); |
||
392 | int _EXFUN(_fseeko_r,(struct _reent *, FILE *, _off_t, int)); |
||
393 | long _EXFUN(_ftell_r, (struct _reent *, FILE *)); |
||
394 | _off_t _EXFUN(_ftello_r,(struct _reent *, FILE *)); |
||
395 | void _EXFUN(_rewind_r, (struct _reent *, FILE *)); |
||
4921 | Serge | 396 | size_t _EXFUN(_fwrite_r, (struct _reent *, const _PTR __restrict, size_t _size, size_t _n, FILE *__restrict)); |
4349 | Serge | 397 | int _EXFUN(_getc_r, (struct _reent *, FILE *)); |
398 | int _EXFUN(_getc_unlocked_r, (struct _reent *, FILE *)); |
||
399 | int _EXFUN(_getchar_r, (struct _reent *)); |
||
400 | int _EXFUN(_getchar_unlocked_r, (struct _reent *)); |
||
401 | char * _EXFUN(_gets_r, (struct _reent *, char *)); |
||
402 | int _EXFUN(_iprintf_r, (struct _reent *, const char *, ...) |
||
403 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
||
404 | int _EXFUN(_iscanf_r, (struct _reent *, const char *, ...) |
||
405 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
||
406 | FILE * _EXFUN(_open_memstream_r, (struct _reent *, char **, size_t *)); |
||
407 | void _EXFUN(_perror_r, (struct _reent *, const char *)); |
||
4921 | Serge | 408 | int _EXFUN(_printf_r, (struct _reent *, const char *__restrict, ...) |
4349 | Serge | 409 | _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
410 | int _EXFUN(_putc_r, (struct _reent *, int, FILE *)); |
||
411 | int _EXFUN(_putc_unlocked_r, (struct _reent *, int, FILE *)); |
||
412 | int _EXFUN(_putchar_unlocked_r, (struct _reent *, int)); |
||
413 | int _EXFUN(_putchar_r, (struct _reent *, int)); |
||
414 | int _EXFUN(_puts_r, (struct _reent *, const char *)); |
||
415 | int _EXFUN(_remove_r, (struct _reent *, const char *)); |
||
416 | int _EXFUN(_rename_r, (struct _reent *, |
||
417 | const char *_old, const char *_new)); |
||
4921 | Serge | 418 | int _EXFUN(_scanf_r, (struct _reent *, const char *__restrict, ...) |
4349 | Serge | 419 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
420 | int _EXFUN(_siprintf_r, (struct _reent *, char *, const char *, ...) |
||
421 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
||
422 | int _EXFUN(_siscanf_r, (struct _reent *, const char *, const char *, ...) |
||
423 | _ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
||
424 | int _EXFUN(_sniprintf_r, (struct _reent *, char *, size_t, const char *, ...) |
||
425 | _ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
||
4921 | Serge | 426 | int _EXFUN(_snprintf_r, (struct _reent *, char *__restrict, size_t, const char *__restrict, ...) |
4349 | Serge | 427 | _ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
4921 | Serge | 428 | int _EXFUN(_sprintf_r, (struct _reent *, char *__restrict, const char *__restrict, ...) |
4349 | Serge | 429 | _ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
4921 | Serge | 430 | int _EXFUN(_sscanf_r, (struct _reent *, const char *__restrict, const char *__restrict, ...) |
4349 | Serge | 431 | _ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
432 | char * _EXFUN(_tempnam_r, (struct _reent *, const char *, const char *)); |
||
433 | FILE * _EXFUN(_tmpfile_r, (struct _reent *)); |
||
434 | char * _EXFUN(_tmpnam_r, (struct _reent *, char *)); |
||
435 | int _EXFUN(_ungetc_r, (struct _reent *, int, FILE *)); |
||
436 | int _EXFUN(_vasiprintf_r, (struct _reent *, char **, const char *, __VALIST) |
||
437 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
||
438 | char * _EXFUN(_vasniprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST) |
||
439 | _ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
||
440 | char * _EXFUN(_vasnprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST) |
||
441 | _ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
||
442 | int _EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST) |
||
443 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
||
444 | int _EXFUN(_vdiprintf_r, (struct _reent *, int, const char *, __VALIST) |
||
445 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
||
4921 | Serge | 446 | int _EXFUN(_vdprintf_r, (struct _reent *, int, const char *__restrict, __VALIST) |
4349 | Serge | 447 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
448 | int _EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST) |
||
449 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
||
450 | int _EXFUN(_vfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST) |
||
451 | _ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
||
4921 | Serge | 452 | int _EXFUN(_vfprintf_r, (struct _reent *, FILE *__restrict, const char *__restrict, __VALIST) |
4349 | Serge | 453 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
4921 | Serge | 454 | int _EXFUN(_vfscanf_r, (struct _reent *, FILE *__restrict, const char *__restrict, __VALIST) |
4349 | Serge | 455 | _ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
456 | int _EXFUN(_viprintf_r, (struct _reent *, const char *, __VALIST) |
||
457 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
||
458 | int _EXFUN(_viscanf_r, (struct _reent *, const char *, __VALIST) |
||
459 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
||
4921 | Serge | 460 | int _EXFUN(_vprintf_r, (struct _reent *, const char *__restrict, __VALIST) |
4349 | Serge | 461 | _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
4921 | Serge | 462 | int _EXFUN(_vscanf_r, (struct _reent *, const char *__restrict, __VALIST) |
4349 | Serge | 463 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
464 | int _EXFUN(_vsiprintf_r, (struct _reent *, char *, const char *, __VALIST) |
||
465 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
||
466 | int _EXFUN(_vsiscanf_r, (struct _reent *, const char *, const char *, __VALIST) |
||
467 | _ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
||
468 | int _EXFUN(_vsniprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST) |
||
469 | _ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
||
4921 | Serge | 470 | int _EXFUN(_vsnprintf_r, (struct _reent *, char *__restrict, size_t, const char *__restrict, __VALIST) |
4349 | Serge | 471 | _ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
4921 | Serge | 472 | int _EXFUN(_vsprintf_r, (struct _reent *, char *__restrict, const char *__restrict, __VALIST) |
4349 | Serge | 473 | _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
4921 | Serge | 474 | int _EXFUN(_vsscanf_r, (struct _reent *, const char *__restrict, const char *__restrict, __VALIST) |
4349 | Serge | 475 | _ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
476 | |||
477 | /* Other extensions. */ |
||
478 | |||
479 | int _EXFUN(fpurge, (FILE *)); |
||
480 | ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *)); |
||
481 | ssize_t _EXFUN(__getline, (char **, size_t *, FILE *)); |
||
482 | |||
483 | #ifdef __LARGE64_FILES |
||
484 | #if !defined(__CYGWIN__) || defined(_COMPILING_NEWLIB) |
||
485 | FILE * _EXFUN(fdopen64, (int, const char *)); |
||
486 | FILE * _EXFUN(fopen64, (const char *, const char *)); |
||
487 | FILE * _EXFUN(freopen64, (_CONST char *, _CONST char *, FILE *)); |
||
488 | _off64_t _EXFUN(ftello64, (FILE *)); |
||
489 | _off64_t _EXFUN(fseeko64, (FILE *, _off64_t, int)); |
||
490 | int _EXFUN(fgetpos64, (FILE *, _fpos64_t *)); |
||
491 | int _EXFUN(fsetpos64, (FILE *, const _fpos64_t *)); |
||
492 | FILE * _EXFUN(tmpfile64, (void)); |
||
493 | |||
494 | FILE * _EXFUN(_fdopen64_r, (struct _reent *, int, const char *)); |
||
495 | FILE * _EXFUN(_fopen64_r, (struct _reent *,const char *, const char *)); |
||
496 | FILE * _EXFUN(_freopen64_r, (struct _reent *, _CONST char *, _CONST char *, FILE *)); |
||
497 | _off64_t _EXFUN(_ftello64_r, (struct _reent *, FILE *)); |
||
498 | _off64_t _EXFUN(_fseeko64_r, (struct _reent *, FILE *, _off64_t, int)); |
||
499 | int _EXFUN(_fgetpos64_r, (struct _reent *, FILE *, _fpos64_t *)); |
||
500 | int _EXFUN(_fsetpos64_r, (struct _reent *, FILE *, const _fpos64_t *)); |
||
501 | FILE * _EXFUN(_tmpfile64_r, (struct _reent *)); |
||
502 | #endif /* !__CYGWIN__ */ |
||
503 | #endif /* __LARGE64_FILES */ |
||
504 | |||
505 | /* |
||
506 | * Routines internal to the implementation. |
||
507 | */ |
||
508 | |||
509 | int _EXFUN(__srget_r, (struct _reent *, FILE *)); |
||
510 | int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *)); |
||
511 | |||
512 | /* |
||
513 | * Stdio function-access interface. |
||
514 | */ |
||
515 | |||
516 | #ifndef __STRICT_ANSI__ |
||
517 | # ifdef __LARGE64_FILES |
||
518 | FILE *_EXFUN(funopen,(const _PTR __cookie, |
||
4921 | Serge | 519 | int (*__readfn)(_PTR __c, char *__buf, |
520 | _READ_WRITE_BUFSIZE_TYPE __n), |
||
521 | int (*__writefn)(_PTR __c, const char *__buf, |
||
522 | _READ_WRITE_BUFSIZE_TYPE __n), |
||
4349 | Serge | 523 | _fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence), |
524 | int (*__closefn)(_PTR __c))); |
||
525 | FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie, |
||
4921 | Serge | 526 | int (*__readfn)(_PTR __c, char *__buf, |
527 | _READ_WRITE_BUFSIZE_TYPE __n), |
||
528 | int (*__writefn)(_PTR __c, const char *__buf, |
||
529 | _READ_WRITE_BUFSIZE_TYPE __n), |
||
4349 | Serge | 530 | _fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence), |
531 | int (*__closefn)(_PTR __c))); |
||
532 | # else |
||
533 | FILE *_EXFUN(funopen,(const _PTR __cookie, |
||
4921 | Serge | 534 | int (*__readfn)(_PTR __cookie, char *__buf, |
535 | _READ_WRITE_BUFSIZE_TYPE __n), |
||
536 | int (*__writefn)(_PTR __cookie, const char *__buf, |
||
537 | _READ_WRITE_BUFSIZE_TYPE __n), |
||
4349 | Serge | 538 | fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence), |
539 | int (*__closefn)(_PTR __cookie))); |
||
540 | FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie, |
||
4921 | Serge | 541 | int (*__readfn)(_PTR __cookie, char *__buf, |
542 | _READ_WRITE_BUFSIZE_TYPE __n), |
||
543 | int (*__writefn)(_PTR __cookie, const char *__buf, |
||
544 | _READ_WRITE_BUFSIZE_TYPE __n), |
||
4349 | Serge | 545 | fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence), |
546 | int (*__closefn)(_PTR __cookie))); |
||
547 | # endif /* !__LARGE64_FILES */ |
||
548 | |||
549 | # define fropen(__cookie, __fn) funopen(__cookie, __fn, (int (*)())0, \ |
||
550 | (fpos_t (*)())0, (int (*)())0) |
||
551 | # define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \ |
||
552 | (fpos_t (*)())0, (int (*)())0) |
||
553 | |||
554 | typedef ssize_t cookie_read_function_t(void *__cookie, char *__buf, size_t __n); |
||
555 | typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf, |
||
556 | size_t __n); |
||
557 | # ifdef __LARGE64_FILES |
||
558 | typedef int cookie_seek_function_t(void *__cookie, _off64_t *__off, |
||
559 | int __whence); |
||
560 | # else |
||
561 | typedef int cookie_seek_function_t(void *__cookie, off_t *__off, int __whence); |
||
562 | # endif /* !__LARGE64_FILES */ |
||
563 | typedef int cookie_close_function_t(void *__cookie); |
||
564 | typedef struct |
||
565 | { |
||
566 | /* These four struct member names are dictated by Linux; hopefully, |
||
567 | they don't conflict with any macros. */ |
||
568 | cookie_read_function_t *read; |
||
569 | cookie_write_function_t *write; |
||
570 | cookie_seek_function_t *seek; |
||
571 | cookie_close_function_t *close; |
||
572 | } cookie_io_functions_t; |
||
573 | FILE *_EXFUN(fopencookie,(void *__cookie, |
||
574 | const char *__mode, cookie_io_functions_t __functions)); |
||
575 | FILE *_EXFUN(_fopencookie_r,(struct _reent *, void *__cookie, |
||
576 | const char *__mode, cookie_io_functions_t __functions)); |
||
577 | #endif /* ! __STRICT_ANSI__ */ |
||
578 | |||
579 | #ifndef __CUSTOM_FILE_IO__ |
||
580 | /* |
||
581 | * The __sfoo macros are here so that we can |
||
582 | * define function versions in the C library. |
||
583 | */ |
||
584 | #define __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++)) |
||
585 | |||
586 | #ifdef __SCLE |
||
587 | /* For a platform with CR/LF, additional logic is required by |
||
588 | __sgetc_r which would otherwise simply be a macro; therefore we |
||
589 | use an inlined function. The function is only meant to be inlined |
||
590 | in place as used and the function body should never be emitted. |
||
591 | |||
592 | There are two possible means to this end when compiling with GCC, |
||
593 | one when compiling with a standard C99 compiler, and for other |
||
594 | compilers we're just stuck. At the moment, this issue only |
||
595 | affects the Cygwin target, so we'll most likely be using GCC. */ |
||
596 | |||
597 | _ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p); |
||
598 | |||
599 | _ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p) |
||
600 | { |
||
601 | int __c = __sgetc_raw_r(__ptr, __p); |
||
602 | if ((__p->_flags & __SCLE) && (__c == '\r')) |
||
603 | { |
||
604 | int __c2 = __sgetc_raw_r(__ptr, __p); |
||
605 | if (__c2 == '\n') |
||
606 | __c = __c2; |
||
607 | else |
||
608 | ungetc(__c2, __p); |
||
609 | } |
||
610 | return __c; |
||
611 | } |
||
612 | #else |
||
613 | #define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p) |
||
614 | #endif |
||
615 | |||
616 | #ifdef _never /* __GNUC__ */ |
||
617 | /* If this inline is actually used, then systems using coff debugging |
||
618 | info get hopelessly confused. 21sept93 rich@cygnus.com. */ |
||
619 | _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { |
||
620 | if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) |
||
621 | return (*_p->_p++ = _c); |
||
622 | else |
||
623 | return (__swbuf_r(_ptr, _c, _p)); |
||
624 | } |
||
625 | #else |
||
626 | /* |
||
627 | * This has been tuned to generate reasonable code on the vax using pcc |
||
628 | */ |
||
629 | #define __sputc_raw_r(__ptr, __c, __p) \ |
||
630 | (--(__p)->_w < 0 ? \ |
||
631 | (__p)->_w >= (__p)->_lbfsize ? \ |
||
632 | (*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \ |
||
633 | (int)*(__p)->_p++ : \ |
||
634 | __swbuf_r(__ptr, '\n', __p) : \ |
||
635 | __swbuf_r(__ptr, (int)(__c), __p) : \ |
||
636 | (*(__p)->_p = (__c), (int)*(__p)->_p++)) |
||
637 | #ifdef __SCLE |
||
638 | #define __sputc_r(__ptr, __c, __p) \ |
||
639 | ((((__p)->_flags & __SCLE) && ((__c) == '\n')) \ |
||
640 | ? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \ |
||
641 | __sputc_raw_r((__ptr), (__c), (__p))) |
||
642 | #else |
||
643 | #define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p) |
||
644 | #endif |
||
645 | #endif |
||
646 | |||
647 | #define __sfeof(p) (((p)->_flags & __SEOF) != 0) |
||
648 | #define __sferror(p) (((p)->_flags & __SERR) != 0) |
||
649 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) |
||
650 | #define __sfileno(p) ((p)->_file) |
||
651 | |||
652 | #ifndef _REENT_SMALL |
||
653 | #define feof(p) __sfeof(p) |
||
654 | #define ferror(p) __sferror(p) |
||
655 | #define clearerr(p) __sclearerr(p) |
||
656 | #endif |
||
657 | |||
658 | #if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */ |
||
659 | #define fileno(p) __sfileno(p) |
||
660 | #endif |
||
661 | |||
662 | #ifndef __CYGWIN__ |
||
663 | #ifndef lint |
||
664 | #define getc(fp) __sgetc_r(_REENT, fp) |
||
665 | #define putc(x, fp) __sputc_r(_REENT, x, fp) |
||
666 | #endif /* lint */ |
||
667 | #endif /* __CYGWIN__ */ |
||
668 | |||
669 | #ifndef __STRICT_ANSI__ |
||
670 | /* fast always-buffered version, true iff error */ |
||
671 | #define fast_putc(x,p) (--(p)->_w < 0 ? \ |
||
672 | __swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0)) |
||
673 | |||
674 | #define L_cuserid 9 /* posix says it goes in stdio.h :( */ |
||
675 | #ifdef __CYGWIN__ |
||
676 | #define L_ctermid 16 |
||
677 | #endif |
||
678 | #endif |
||
679 | |||
680 | #endif /* !__CUSTOM_FILE_IO__ */ |
||
681 | |||
682 | #define getchar() getc(stdin) |
||
683 | #define putchar(x) putc(x, stdout) |
||
684 | |||
685 | _END_STD_C |
||
686 | |||
687 | #endif /* _STDIO_H_ */>>>-> |