1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | #ifndef _IO_STDIO_H |
29 | #define _IO_STDIO_H |
30 | |
31 | #include <_G_config.h> |
32 | |
33 | #define _IO_fpos_t _G_fpos_t |
34 | #define _IO_fpos64_t _G_fpos64_t |
35 | #define _IO_size_t size_t |
36 | #define _IO_ssize_t __ssize_t |
37 | #define _IO_off_t __off_t |
38 | #define _IO_off64_t __off64_t |
39 | #define _IO_pid_t __pid_t |
40 | #define _IO_uid_t __uid_t |
41 | #define _IO_iconv_t _G_iconv_t |
42 | #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE |
43 | #define _IO_BUFSIZ _G_BUFSIZ |
44 | #define _IO_va_list _G_va_list |
45 | #define _IO_wint_t wint_t |
46 | |
47 | |
48 | #define __need___va_list |
49 | #include <stdarg.h> |
50 | #ifdef __GNUC_VA_LIST |
51 | # undef _IO_va_list |
52 | # define _IO_va_list __gnuc_va_list |
53 | #endif |
54 | |
55 | #ifndef __P |
56 | # include <sys/cdefs.h> |
57 | #endif |
58 | |
59 | #define _IO_UNIFIED_JUMPTABLES 1 |
60 | |
61 | #ifndef EOF |
62 | # define EOF (-1) |
63 | #endif |
64 | #ifndef NULL |
65 | # if defined __GNUG__ && \ |
66 | (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) |
67 | # define NULL (__null) |
68 | # else |
69 | # if !defined(__cplusplus) |
70 | # define NULL ((void*)0) |
71 | # else |
72 | # define NULL (0) |
73 | # endif |
74 | # endif |
75 | #endif |
76 | |
77 | #define _IOS_INPUT 1 |
78 | #define _IOS_OUTPUT 2 |
79 | #define _IOS_ATEND 4 |
80 | #define _IOS_APPEND 8 |
81 | #define _IOS_TRUNC 16 |
82 | #define _IOS_NOCREATE 32 |
83 | #define _IOS_NOREPLACE 64 |
84 | #define _IOS_BIN 128 |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | #define _IO_MAGIC 0xFBAD0000 |
93 | #define _OLD_STDIO_MAGIC 0xFABC0000 |
94 | #define _IO_MAGIC_MASK 0xFFFF0000 |
95 | #define _IO_USER_BUF 1 |
96 | #define _IO_UNBUFFERED 2 |
97 | #define _IO_NO_READS 4 |
98 | #define _IO_NO_WRITES 8 |
99 | #define _IO_EOF_SEEN 0x10 |
100 | #define _IO_ERR_SEEN 0x20 |
101 | #define _IO_DELETE_DONT_CLOSE 0x40 |
102 | #define _IO_LINKED 0x80 |
103 | #define _IO_IN_BACKUP 0x100 |
104 | #define _IO_LINE_BUF 0x200 |
105 | #define _IO_TIED_PUT_GET 0x400 |
106 | #define _IO_CURRENTLY_PUTTING 0x800 |
107 | #define _IO_IS_APPENDING 0x1000 |
108 | #define _IO_IS_FILEBUF 0x2000 |
109 | #define _IO_BAD_SEEN 0x4000 |
110 | #define _IO_USER_LOCK 0x8000 |
111 | |
112 | #define _IO_FLAGS2_MMAP 1 |
113 | #define _IO_FLAGS2_NOTCANCEL 2 |
114 | #ifdef _LIBC |
115 | # define _IO_FLAGS2_FORTIFY 4 |
116 | #endif |
117 | #define _IO_FLAGS2_USER_WBUF 8 |
118 | #ifdef _LIBC |
119 | # define _IO_FLAGS2_SCANF_STD 16 |
120 | # define _IO_FLAGS2_NOCLOSE 32 |
121 | # define _IO_FLAGS2_CLOEXEC 64 |
122 | #endif |
123 | |
124 | |
125 | #define _IO_SKIPWS 01 |
126 | #define _IO_LEFT 02 |
127 | #define _IO_RIGHT 04 |
128 | #define _IO_INTERNAL 010 |
129 | #define _IO_DEC 020 |
130 | #define _IO_OCT 040 |
131 | #define _IO_HEX 0100 |
132 | #define _IO_SHOWBASE 0200 |
133 | #define _IO_SHOWPOINT 0400 |
134 | #define _IO_UPPERCASE 01000 |
135 | #define _IO_SHOWPOS 02000 |
136 | #define _IO_SCIENTIFIC 04000 |
137 | #define _IO_FIXED 010000 |
138 | #define _IO_UNITBUF 020000 |
139 | #define _IO_STDIO 040000 |
140 | #define _IO_DONT_CLOSE 0100000 |
141 | #define _IO_BOOLALPHA 0200000 |
142 | |
143 | |
144 | struct _IO_jump_t; struct _IO_FILE; |
145 | |
146 | |
147 | #ifdef _IO_MTSAFE_IO |
148 | |
149 | #else |
150 | typedef void _IO_lock_t; |
151 | #endif |
152 | |
153 | |
154 | |
155 | |
156 | struct _IO_marker { |
157 | struct _IO_marker *_next; |
158 | struct _IO_FILE *_sbuf; |
159 | |
160 | |
161 | |
162 | int _pos; |
163 | #if 0 |
164 | void set_streampos(streampos sp) { _spos = sp; } |
165 | void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); } |
166 | public: |
167 | streammarker(streambuf *sb); |
168 | ~streammarker(); |
169 | int saving() { return _spos == -2; } |
170 | int delta(streammarker&); |
171 | int delta(); |
172 | #endif |
173 | }; |
174 | |
175 | |
176 | enum __codecvt_result |
177 | { |
178 | __codecvt_ok, |
179 | __codecvt_partial, |
180 | __codecvt_error, |
181 | __codecvt_noconv |
182 | }; |
183 | |
184 | #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
185 | |
186 | |
187 | struct _IO_codecvt |
188 | { |
189 | void (*__codecvt_destr) (struct _IO_codecvt *); |
190 | enum __codecvt_result (*__codecvt_do_out) (struct _IO_codecvt *, |
191 | __mbstate_t *, |
192 | const wchar_t *, |
193 | const wchar_t *, |
194 | const wchar_t **, char *, |
195 | char *, char **); |
196 | enum __codecvt_result (*__codecvt_do_unshift) (struct _IO_codecvt *, |
197 | __mbstate_t *, char *, |
198 | char *, char **); |
199 | enum __codecvt_result (*__codecvt_do_in) (struct _IO_codecvt *, |
200 | __mbstate_t *, |
201 | const char *, const char *, |
202 | const char **, wchar_t *, |
203 | wchar_t *, wchar_t **); |
204 | int (*__codecvt_do_encoding) (struct _IO_codecvt *); |
205 | int (*__codecvt_do_always_noconv) (struct _IO_codecvt *); |
206 | int (*__codecvt_do_length) (struct _IO_codecvt *, __mbstate_t *, |
207 | const char *, const char *, _IO_size_t); |
208 | int (*__codecvt_do_max_length) (struct _IO_codecvt *); |
209 | |
210 | _IO_iconv_t __cd_in; |
211 | _IO_iconv_t __cd_out; |
212 | }; |
213 | |
214 | |
215 | struct _IO_wide_data |
216 | { |
217 | wchar_t *_IO_read_ptr; |
218 | wchar_t *_IO_read_end; |
219 | wchar_t *_IO_read_base; |
220 | wchar_t *_IO_write_base; |
221 | wchar_t *_IO_write_ptr; |
222 | wchar_t *_IO_write_end; |
223 | wchar_t *_IO_buf_base; |
224 | wchar_t *_IO_buf_end; |
225 | |
226 | wchar_t *_IO_save_base; |
227 | wchar_t *_IO_backup_base; |
228 | |
229 | wchar_t *_IO_save_end; |
230 | |
231 | __mbstate_t _IO_state; |
232 | __mbstate_t _IO_last_state; |
233 | struct _IO_codecvt _codecvt; |
234 | |
235 | wchar_t _shortbuf[1]; |
236 | |
237 | const struct _IO_jump_t *_wide_vtable; |
238 | }; |
239 | #endif |
240 | |
241 | struct _IO_FILE { |
242 | int _flags; |
243 | #define _IO_file_flags _flags |
244 | |
245 | |
246 | |
247 | char* _IO_read_ptr; |
248 | char* _IO_read_end; |
249 | char* _IO_read_base; |
250 | char* _IO_write_base; |
251 | char* _IO_write_ptr; |
252 | char* _IO_write_end; |
253 | char* _IO_buf_base; |
254 | char* _IO_buf_end; |
255 | |
256 | char *_IO_save_base; |
257 | char *_IO_backup_base; |
258 | char *_IO_save_end; |
259 | |
260 | struct _IO_marker *_markers; |
261 | |
262 | struct _IO_FILE *_chain; |
263 | |
264 | int _fileno; |
265 | #if 0 |
266 | int _blksize; |
267 | #else |
268 | int _flags2; |
269 | #endif |
270 | _IO_off_t _old_offset; |
271 | |
272 | #define __HAVE_COLUMN |
273 | |
274 | unsigned short _cur_column; |
275 | signed char _vtable_offset; |
276 | char _shortbuf[1]; |
277 | |
278 | |
279 | |
280 | _IO_lock_t *_lock; |
281 | #ifdef _IO_USE_OLD_IO_FILE |
282 | }; |
283 | |
284 | struct _IO_FILE_complete |
285 | { |
286 | struct _IO_FILE _file; |
287 | #endif |
288 | #if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001 |
289 | _IO_off64_t _offset; |
290 | # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
291 | |
292 | struct _IO_codecvt *_codecvt; |
293 | struct _IO_wide_data *_wide_data; |
294 | struct _IO_FILE *_freeres_list; |
295 | void *_freeres_buf; |
296 | # else |
297 | void *__pad1; |
298 | void *__pad2; |
299 | void *__pad3; |
300 | void *__pad4; |
301 | # endif |
302 | size_t __pad5; |
303 | int _mode; |
304 | |
305 | char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; |
306 | #endif |
307 | }; |
308 | |
309 | #ifndef __cplusplus |
310 | typedef struct _IO_FILE _IO_FILE; |
311 | #endif |
312 | |
313 | struct _IO_FILE_plus; |
314 | |
315 | extern struct _IO_FILE_plus _IO_2_1_stdin_; |
316 | extern struct _IO_FILE_plus _IO_2_1_stdout_; |
317 | extern struct _IO_FILE_plus _IO_2_1_stderr_; |
318 | #ifndef _LIBC |
319 | #define _IO_stdin ((_IO_FILE*)(&_IO_2_1_stdin_)) |
320 | #define _IO_stdout ((_IO_FILE*)(&_IO_2_1_stdout_)) |
321 | #define _IO_stderr ((_IO_FILE*)(&_IO_2_1_stderr_)) |
322 | #else |
323 | extern _IO_FILE *_IO_stdin attribute_hidden; |
324 | extern _IO_FILE *_IO_stdout attribute_hidden; |
325 | extern _IO_FILE *_IO_stderr attribute_hidden; |
326 | #endif |
327 | |
328 | |
329 | |
330 | |
331 | |
332 | |
333 | typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes); |
334 | |
335 | |
336 | |
337 | |
338 | |
339 | |
340 | |
341 | typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf, |
342 | size_t __n); |
343 | |
344 | |
345 | |
346 | |
347 | |
348 | |
349 | |
350 | typedef int __io_seek_fn (void *__cookie, _IO_off64_t *__pos, int __w); |
351 | |
352 | |
353 | typedef int __io_close_fn (void *__cookie); |
354 | |
355 | |
356 | #ifdef _GNU_SOURCE |
357 | |
358 | typedef __io_read_fn cookie_read_function_t; |
359 | typedef __io_write_fn cookie_write_function_t; |
360 | typedef __io_seek_fn cookie_seek_function_t; |
361 | typedef __io_close_fn cookie_close_function_t; |
362 | |
363 | |
364 | typedef struct |
365 | { |
366 | __io_read_fn *read; |
367 | __io_write_fn *write; |
368 | __io_seek_fn *seek; |
369 | __io_close_fn *close; |
370 | } _IO_cookie_io_functions_t; |
371 | typedef _IO_cookie_io_functions_t cookie_io_functions_t; |
372 | |
373 | struct _IO_cookie_file; |
374 | |
375 | |
376 | extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write, |
377 | void *__cookie, _IO_cookie_io_functions_t __fns); |
378 | #endif |
379 | |
380 | |
381 | #ifdef __cplusplus |
382 | extern "C" { |
383 | #endif |
384 | |
385 | extern int __underflow (_IO_FILE *); |
386 | extern int __uflow (_IO_FILE *); |
387 | extern int __overflow (_IO_FILE *, int); |
388 | #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
389 | extern _IO_wint_t __wunderflow (_IO_FILE *); |
390 | extern _IO_wint_t __wuflow (_IO_FILE *); |
391 | extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t); |
392 | #endif |
393 | |
394 | #if __GNUC__ >= 3 |
395 | # define _IO_BE(expr, res) __builtin_expect ((expr), res) |
396 | #else |
397 | # define _IO_BE(expr, res) (expr) |
398 | #endif |
399 | |
400 | #define _IO_getc_unlocked(_fp) \ |
401 | (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \ |
402 | ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++) |
403 | #define _IO_peekc_unlocked(_fp) \ |
404 | (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \ |
405 | && __underflow (_fp) == EOF ? EOF \ |
406 | : *(unsigned char *) (_fp)->_IO_read_ptr) |
407 | #define _IO_putc_unlocked(_ch, _fp) \ |
408 | (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \ |
409 | ? __overflow (_fp, (unsigned char) (_ch)) \ |
410 | : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch))) |
411 | |
412 | #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
413 | # define _IO_getwc_unlocked(_fp) \ |
414 | (_IO_BE ((_fp)->_wide_data == NULL \ |
415 | || ((_fp)->_wide_data->_IO_read_ptr \ |
416 | >= (_fp)->_wide_data->_IO_read_end), 0) \ |
417 | ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++) |
418 | # define _IO_putwc_unlocked(_wch, _fp) \ |
419 | (_IO_BE ((_fp)->_wide_data == NULL \ |
420 | || ((_fp)->_wide_data->_IO_write_ptr \ |
421 | >= (_fp)->_wide_data->_IO_write_end), 0) \ |
422 | ? __woverflow (_fp, _wch) \ |
423 | : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch))) |
424 | #endif |
425 | |
426 | #define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0) |
427 | #define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0) |
428 | |
429 | extern int _IO_getc (_IO_FILE *__fp); |
430 | extern int _IO_putc (int __c, _IO_FILE *__fp); |
431 | extern int _IO_feof (_IO_FILE *__fp) __THROW; |
432 | extern int _IO_ferror (_IO_FILE *__fp) __THROW; |
433 | |
434 | extern int _IO_peekc_locked (_IO_FILE *__fp); |
435 | |
436 | |
437 | #define _IO_PENDING_OUTPUT_COUNT(_fp) \ |
438 | ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base) |
439 | |
440 | extern void _IO_flockfile (_IO_FILE *) __THROW; |
441 | extern void _IO_funlockfile (_IO_FILE *) __THROW; |
442 | extern int _IO_ftrylockfile (_IO_FILE *) __THROW; |
443 | |
444 | #ifdef _IO_MTSAFE_IO |
445 | # define _IO_peekc(_fp) _IO_peekc_locked (_fp) |
446 | # define _IO_flockfile(_fp) \ |
447 | if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp) |
448 | # define _IO_funlockfile(_fp) \ |
449 | if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp) |
450 | #else |
451 | # define _IO_peekc(_fp) _IO_peekc_unlocked (_fp) |
452 | # define _IO_flockfile(_fp) |
453 | # define _IO_funlockfile(_fp) |
454 | # define _IO_ftrylockfile(_fp) |
455 | # define _IO_cleanup_region_start(_fct, _fp) |
456 | # define _IO_cleanup_region_end(_Doit) |
457 | #endif |
458 | |
459 | extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict, |
460 | _IO_va_list, int *__restrict); |
461 | extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict, |
462 | _IO_va_list); |
463 | extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t); |
464 | extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t); |
465 | |
466 | extern _IO_off64_t _IO_seekoff (_IO_FILE *, _IO_off64_t, int, int); |
467 | extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int); |
468 | |
469 | extern void _IO_free_backup_area (_IO_FILE *) __THROW; |
470 | |
471 | #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
472 | extern _IO_wint_t _IO_getwc (_IO_FILE *__fp); |
473 | extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp); |
474 | extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW; |
475 | # if __GNUC__ >= 2 |
476 | |
477 | |
478 | # if defined _LIBC && defined SHARED |
479 | # include <shlib-compat.h> |
480 | # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) |
481 | # define _IO_fwide_maybe_incompatible \ |
482 | (__builtin_expect (&_IO_stdin_used == NULL, 0)) |
483 | extern const int _IO_stdin_used; |
484 | weak_extern (_IO_stdin_used); |
485 | # endif |
486 | # endif |
487 | # ifndef _IO_fwide_maybe_incompatible |
488 | # define _IO_fwide_maybe_incompatible (0) |
489 | # endif |
490 | |
491 | |
492 | # define _IO_fwide(__fp, __mode) \ |
493 | ({ int __result = (__mode); \ |
494 | if (__result < 0 && ! _IO_fwide_maybe_incompatible) \ |
495 | { \ |
496 | if ((__fp)->_mode == 0) \ |
497 | \ |
498 | (__fp)->_mode = -1; \ |
499 | __result = (__fp)->_mode; \ |
500 | } \ |
501 | else if (__builtin_constant_p (__mode) && (__mode) == 0) \ |
502 | __result = _IO_fwide_maybe_incompatible ? -1 : (__fp)->_mode; \ |
503 | else \ |
504 | __result = _IO_fwide (__fp, __result); \ |
505 | __result; }) |
506 | # endif |
507 | |
508 | extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict, |
509 | _IO_va_list, int *__restrict); |
510 | extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict, |
511 | _IO_va_list); |
512 | extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t); |
513 | extern void _IO_free_wbackup_area (_IO_FILE *) __THROW; |
514 | #endif |
515 | |
516 | #ifdef __LDBL_COMPAT |
517 | # include <bits/libio-ldbl.h> |
518 | #endif |
519 | |
520 | #ifdef __cplusplus |
521 | } |
522 | #endif |
523 | |
524 | #endif |
525 | |