103a78d15Sespie /* Copyright (C) 1991,92,93,94,95,97,98,99,2000,2001 Free Software Foundation, Inc. 203a78d15Sespie This file is part of the GNU IO Library. 303a78d15Sespie Written by Per Bothner <bothner@cygnus.com>. 403a78d15Sespie 503a78d15Sespie This library is free software; you can redistribute it and/or 603a78d15Sespie modify it under the terms of the GNU General Public License as 703a78d15Sespie published by the Free Software Foundation; either version 2, or (at 803a78d15Sespie your option) any later version. 903a78d15Sespie 1003a78d15Sespie This library is distributed in the hope that it will be useful, but 1103a78d15Sespie WITHOUT ANY WARRANTY; without even the implied warranty of 1203a78d15Sespie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1303a78d15Sespie General Public License for more details. 1403a78d15Sespie 1503a78d15Sespie You should have received a copy of the GNU General Public License 1603a78d15Sespie along with this library; see the file COPYING. If not, write to 1703a78d15Sespie the Free Software Foundation, 59 Temple Place - Suite 330, Boston, 1803a78d15Sespie MA 02111-1307, USA. 1903a78d15Sespie 2003a78d15Sespie As a special exception, if you link this library with files 2103a78d15Sespie compiled with a GNU compiler to produce an executable, this does 2203a78d15Sespie not cause the resulting executable to be covered by the GNU General 2303a78d15Sespie Public License. This exception does not however invalidate any 2403a78d15Sespie other reasons why the executable file might be covered by the GNU 2503a78d15Sespie General Public License. */ 2603a78d15Sespie 2703a78d15Sespie #ifndef _IO_STDIO_H 2803a78d15Sespie #define _IO_STDIO_H 2903a78d15Sespie 3003a78d15Sespie #include <_G_config.h> 3103a78d15Sespie /* ALL of these should be defined in _G_config.h */ 3203a78d15Sespie #define _IO_pos_t _G_fpos_t /* obsolete */ 3303a78d15Sespie #define _IO_fpos_t _G_fpos_t 3403a78d15Sespie #define _IO_fpos64_t _G_fpos64_t 3503a78d15Sespie #define _IO_size_t _G_size_t 3603a78d15Sespie #define _IO_ssize_t _G_ssize_t 3703a78d15Sespie #define _IO_off_t _G_off_t 3803a78d15Sespie #define _IO_off64_t _G_off64_t 3903a78d15Sespie #define _IO_pid_t _G_pid_t 4003a78d15Sespie #define _IO_uid_t _G_uid_t 4103a78d15Sespie #define _IO_iconv_t _G_iconv_t 4203a78d15Sespie #define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT 4303a78d15Sespie #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE 4403a78d15Sespie #define _IO_BUFSIZ _G_BUFSIZ 4503a78d15Sespie #define _IO_va_list _G_va_list 4603a78d15Sespie #define _IO_wint_t _G_wint_t 4703a78d15Sespie 4803a78d15Sespie #ifdef _G_NEED_STDARG_H 4903a78d15Sespie /* This define avoids name pollution if we're using GNU stdarg.h */ 5003a78d15Sespie # define __need___va_list 5103a78d15Sespie # include <stdarg.h> 5203a78d15Sespie # ifdef __GNUC_VA_LIST 5303a78d15Sespie # undef _IO_va_list 5403a78d15Sespie # define _IO_va_list __gnuc_va_list 5503a78d15Sespie # endif /* __GNUC_VA_LIST */ 5603a78d15Sespie #endif 5703a78d15Sespie 5803a78d15Sespie #ifndef __THROW 5903a78d15Sespie # ifdef __cplusplus 6003a78d15Sespie # define __THROW throw () 6103a78d15Sespie # else 6203a78d15Sespie # define __THROW 6303a78d15Sespie # endif 6403a78d15Sespie #endif /* not __THROW */ 6503a78d15Sespie 6603a78d15Sespie #ifndef __P 6703a78d15Sespie # define __P(p) p __THROW 6803a78d15Sespie #endif /* not __P */ 6903a78d15Sespie 7003a78d15Sespie #ifndef __PMT 7103a78d15Sespie # define __PMT(p) p 7203a78d15Sespie #endif /* not __PMT */ 7303a78d15Sespie 7403a78d15Sespie /* For backward compatibility */ 7503a78d15Sespie #ifndef _PARAMS 7603a78d15Sespie # define _PARAMS(protos) __P(protos) 7703a78d15Sespie #endif /*!_PARAMS*/ 7803a78d15Sespie 7903a78d15Sespie #ifndef __STDC__ 8003a78d15Sespie # ifndef const 8103a78d15Sespie # define const 8203a78d15Sespie # endif 8303a78d15Sespie #endif 8403a78d15Sespie #define _IO_UNIFIED_JUMPTABLES 1 8503a78d15Sespie #ifndef _G_HAVE_PRINTF_FP 8603a78d15Sespie # define _IO_USE_DTOA 1 8703a78d15Sespie #endif 8803a78d15Sespie 8903a78d15Sespie #ifndef EOF 9003a78d15Sespie # define EOF (-1) 9103a78d15Sespie #endif 9203a78d15Sespie #ifndef NULL 9303a78d15Sespie # if defined __GNUG__ && \ 9403a78d15Sespie (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) 9503a78d15Sespie # define NULL (__null) 9603a78d15Sespie # else 9703a78d15Sespie # if !defined(__cplusplus) 9803a78d15Sespie # define NULL ((void*)0) 9903a78d15Sespie # else 10003a78d15Sespie # define NULL (0) 10103a78d15Sespie # endif 10203a78d15Sespie # endif 10303a78d15Sespie #endif 10403a78d15Sespie 10503a78d15Sespie #define _IOS_INPUT 1 10603a78d15Sespie #define _IOS_OUTPUT 2 10703a78d15Sespie #define _IOS_ATEND 4 10803a78d15Sespie #define _IOS_APPEND 8 10903a78d15Sespie #define _IOS_TRUNC 16 11003a78d15Sespie #define _IOS_NOCREATE 32 11103a78d15Sespie #define _IOS_NOREPLACE 64 11203a78d15Sespie #define _IOS_BIN 128 11303a78d15Sespie 11403a78d15Sespie /* Magic numbers and bits for the _flags field. 11503a78d15Sespie The magic numbers use the high-order bits of _flags; 11603a78d15Sespie the remaining bits are available for variable flags. 11703a78d15Sespie Note: The magic numbers must all be negative if stdio 11803a78d15Sespie emulation is desired. */ 11903a78d15Sespie 12003a78d15Sespie #define _IO_MAGIC 0xFBAD0000 /* Magic number */ 12103a78d15Sespie #define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */ 12203a78d15Sespie #define _IO_MAGIC_MASK 0xFFFF0000 12303a78d15Sespie #define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */ 12403a78d15Sespie #define _IO_UNBUFFERED 2 12503a78d15Sespie #define _IO_NO_READS 4 /* Reading not allowed */ 12603a78d15Sespie #define _IO_NO_WRITES 8 /* Writing not allowd */ 12703a78d15Sespie #define _IO_EOF_SEEN 0x10 12803a78d15Sespie #define _IO_ERR_SEEN 0x20 12903a78d15Sespie #define _IO_DELETE_DONT_CLOSE 0x40 /* Don't call close(_fileno) on cleanup. */ 13003a78d15Sespie #define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/ 13103a78d15Sespie #define _IO_IN_BACKUP 0x100 13203a78d15Sespie #define _IO_LINE_BUF 0x200 13303a78d15Sespie #define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */ 13403a78d15Sespie #define _IO_CURRENTLY_PUTTING 0x800 13503a78d15Sespie #define _IO_IS_APPENDING 0x1000 13603a78d15Sespie #define _IO_IS_FILEBUF 0x2000 13703a78d15Sespie #define _IO_BAD_SEEN 0x4000 13803a78d15Sespie #define _IO_USER_LOCK 0x8000 13903a78d15Sespie 14003a78d15Sespie /* These are "formatting flags" matching the iostream fmtflags enum values. */ 14103a78d15Sespie #define _IO_SKIPWS 01 14203a78d15Sespie #define _IO_LEFT 02 14303a78d15Sespie #define _IO_RIGHT 04 14403a78d15Sespie #define _IO_INTERNAL 010 14503a78d15Sespie #define _IO_DEC 020 14603a78d15Sespie #define _IO_OCT 040 14703a78d15Sespie #define _IO_HEX 0100 14803a78d15Sespie #define _IO_SHOWBASE 0200 14903a78d15Sespie #define _IO_SHOWPOINT 0400 15003a78d15Sespie #define _IO_UPPERCASE 01000 15103a78d15Sespie #define _IO_SHOWPOS 02000 15203a78d15Sespie #define _IO_SCIENTIFIC 04000 15303a78d15Sespie #define _IO_FIXED 010000 15403a78d15Sespie #define _IO_UNITBUF 020000 15503a78d15Sespie #define _IO_STDIO 040000 15603a78d15Sespie #define _IO_DONT_CLOSE 0100000 15703a78d15Sespie #define _IO_BOOLALPHA 0200000 15803a78d15Sespie 15903a78d15Sespie 16003a78d15Sespie struct _IO_jump_t; struct _IO_FILE; 16103a78d15Sespie 16203a78d15Sespie /* Handle lock. */ 16303a78d15Sespie #ifdef _IO_MTSAFE_IO 16403a78d15Sespie # if defined __GLIBC__ && __GLIBC__ >= 2 16503a78d15Sespie # if __GLIBC_MINOR__ == 0 16603a78d15Sespie # include <stdio-lock.h> 16703a78d15Sespie # else 16803a78d15Sespie # include <bits/stdio-lock.h> 16903a78d15Sespie # endif 17003a78d15Sespie # else 17103a78d15Sespie /*# include <comthread.h>*/ 17203a78d15Sespie # endif 17303a78d15Sespie #else 17403a78d15Sespie typedef void _IO_lock_t; 17503a78d15Sespie #endif 17603a78d15Sespie 17703a78d15Sespie 17803a78d15Sespie /* A streammarker remembers a position in a buffer. */ 17903a78d15Sespie 18003a78d15Sespie struct _IO_marker { 18103a78d15Sespie struct _IO_marker *_next; 18203a78d15Sespie struct _IO_FILE *_sbuf; 18303a78d15Sespie /* If _pos >= 0 18403a78d15Sespie it points to _buf->Gbase()+_pos. FIXME comment */ 18503a78d15Sespie /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */ 18603a78d15Sespie int _pos; 18703a78d15Sespie #if 0 18803a78d15Sespie void set_streampos(streampos sp) { _spos = sp; } 18903a78d15Sespie void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); } 19003a78d15Sespie public: 19103a78d15Sespie streammarker(streambuf *sb); 19203a78d15Sespie ~streammarker(); 19303a78d15Sespie int saving() { return _spos == -2; } 19403a78d15Sespie int delta(streammarker&); 19503a78d15Sespie int delta(); 19603a78d15Sespie #endif 19703a78d15Sespie }; 19803a78d15Sespie 19903a78d15Sespie /* This is the structure from the libstdc++ codecvt class. */ 20003a78d15Sespie enum __codecvt_result 20103a78d15Sespie { 20203a78d15Sespie __codecvt_ok, 20303a78d15Sespie __codecvt_partial, 20403a78d15Sespie __codecvt_error, 20503a78d15Sespie __codecvt_noconv 20603a78d15Sespie }; 20703a78d15Sespie 208*c2fb3212Sespie #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) 20903a78d15Sespie /* The order of the elements in the following struct must match the order 21003a78d15Sespie of the virtual functions in the libstdc++ codecvt class. */ 21103a78d15Sespie struct _IO_codecvt 21203a78d15Sespie { 21303a78d15Sespie void (*__codecvt_destr) (struct _IO_codecvt *); 21403a78d15Sespie enum __codecvt_result (*__codecvt_do_out) (struct _IO_codecvt *, 21503a78d15Sespie __c_mbstate_t *, 21603a78d15Sespie const wchar_t *, 21703a78d15Sespie const wchar_t *, 21803a78d15Sespie const wchar_t **, char *, 21903a78d15Sespie char *, char **); 22003a78d15Sespie enum __codecvt_result (*__codecvt_do_unshift) (struct _IO_codecvt *, 22103a78d15Sespie __c_mbstate_t *, char *, 22203a78d15Sespie char *, char **); 22303a78d15Sespie enum __codecvt_result (*__codecvt_do_in) (struct _IO_codecvt *, 22403a78d15Sespie __c_mbstate_t *, 22503a78d15Sespie const char *, const char *, 22603a78d15Sespie const char **, wchar_t *, 22703a78d15Sespie wchar_t *, wchar_t **); 22803a78d15Sespie int (*__codecvt_do_encoding) (struct _IO_codecvt *); 22903a78d15Sespie int (*__codecvt_do_always_noconv) (struct _IO_codecvt *); 23003a78d15Sespie int (*__codecvt_do_length) (struct _IO_codecvt *, __c_mbstate_t *, 23103a78d15Sespie const char *, const char *, _IO_size_t); 23203a78d15Sespie int (*__codecvt_do_max_length) (struct _IO_codecvt *); 23303a78d15Sespie 23403a78d15Sespie _IO_iconv_t __cd_in; 23503a78d15Sespie _IO_iconv_t __cd_out; 23603a78d15Sespie }; 23703a78d15Sespie 23803a78d15Sespie /* Extra data for wide character streams. */ 23903a78d15Sespie struct _IO_wide_data 24003a78d15Sespie { 24103a78d15Sespie wchar_t *_IO_read_ptr; /* Current read pointer */ 24203a78d15Sespie wchar_t *_IO_read_end; /* End of get area. */ 24303a78d15Sespie wchar_t *_IO_read_base; /* Start of putback+get area. */ 24403a78d15Sespie wchar_t *_IO_write_base; /* Start of put area. */ 24503a78d15Sespie wchar_t *_IO_write_ptr; /* Current put pointer. */ 24603a78d15Sespie wchar_t *_IO_write_end; /* End of put area. */ 24703a78d15Sespie wchar_t *_IO_buf_base; /* Start of reserve area. */ 24803a78d15Sespie wchar_t *_IO_buf_end; /* End of reserve area. */ 24903a78d15Sespie /* The following fields are used to support backing up and undo. */ 25003a78d15Sespie wchar_t *_IO_save_base; /* Pointer to start of non-current get area. */ 25103a78d15Sespie wchar_t *_IO_backup_base; /* Pointer to first valid character of 25203a78d15Sespie backup area */ 25303a78d15Sespie wchar_t *_IO_save_end; /* Pointer to end of non-current get area. */ 25403a78d15Sespie 255*c2fb3212Sespie #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) 25603a78d15Sespie __c_mbstate_t _IO_state; 25703a78d15Sespie __c_mbstate_t _IO_last_state; 25803a78d15Sespie #endif 25903a78d15Sespie struct _IO_codecvt _codecvt; 26003a78d15Sespie 26103a78d15Sespie wchar_t _shortbuf[1]; 26203a78d15Sespie 263*c2fb3212Sespie #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) 26403a78d15Sespie struct _IO_jump_t *_wide_vtable; 26503a78d15Sespie #endif 26603a78d15Sespie }; 26703a78d15Sespie #else /* !(defined _LIBC || defined _GLIBCPP_USE_WCHAR_T) */ 26803a78d15Sespie /* Because _IO_no_init unconditionally takes a `_IO_wide_data*' as its 26903a78d15Sespie last parameter we must still define this type. We intentionally 27003a78d15Sespie leave it incomplete to prevent any use of this type when we are not 27103a78d15Sespie supporting wide characters. */ 27203a78d15Sespie struct _IO_wide_data; 27303a78d15Sespie #endif /* !(defined _LIBC || defined _GLIBCPP_USE_WCHAR_T) */ 27403a78d15Sespie 27503a78d15Sespie struct _IO_FILE { 27603a78d15Sespie int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ 27703a78d15Sespie #define _IO_file_flags _flags 27803a78d15Sespie 27903a78d15Sespie /* The following pointers correspond to the C++ streambuf protocol. */ 28003a78d15Sespie /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */ 28103a78d15Sespie char* _IO_read_ptr; /* Current read pointer */ 28203a78d15Sespie char* _IO_read_end; /* End of get area. */ 28303a78d15Sespie char* _IO_read_base; /* Start of putback+get area. */ 28403a78d15Sespie char* _IO_write_base; /* Start of put area. */ 28503a78d15Sespie char* _IO_write_ptr; /* Current put pointer. */ 28603a78d15Sespie char* _IO_write_end; /* End of put area. */ 28703a78d15Sespie char* _IO_buf_base; /* Start of reserve area. */ 28803a78d15Sespie char* _IO_buf_end; /* End of reserve area. */ 28903a78d15Sespie /* The following fields are used to support backing up and undo. */ 29003a78d15Sespie char *_IO_save_base; /* Pointer to start of non-current get area. */ 29103a78d15Sespie char *_IO_backup_base; /* Pointer to first valid character of backup area */ 29203a78d15Sespie char *_IO_save_end; /* Pointer to end of non-current get area. */ 29303a78d15Sespie 29403a78d15Sespie struct _IO_marker *_markers; 29503a78d15Sespie 29603a78d15Sespie struct _IO_FILE *_chain; 29703a78d15Sespie 29803a78d15Sespie int _fileno; 29903a78d15Sespie int _blksize; 30003a78d15Sespie _IO_off_t _old_offset; /* This used to be _offset but it's too small. */ 30103a78d15Sespie 30203a78d15Sespie #define __HAVE_COLUMN /* temporary */ 30303a78d15Sespie /* 1+column number of pbase(); 0 is unknown. */ 30403a78d15Sespie unsigned short _cur_column; 30503a78d15Sespie signed char _vtable_offset; 30603a78d15Sespie char _shortbuf[1]; 30703a78d15Sespie 30803a78d15Sespie /* char* _save_gptr; char* _save_egptr; */ 30903a78d15Sespie 31003a78d15Sespie _IO_lock_t *_lock; 31103a78d15Sespie #ifdef _IO_USE_OLD_IO_FILE 31203a78d15Sespie }; 31303a78d15Sespie 31403a78d15Sespie struct _IO_FILE_complete 31503a78d15Sespie { 31603a78d15Sespie struct _IO_FILE _file; 31703a78d15Sespie #endif 31803a78d15Sespie #if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001 31903a78d15Sespie _IO_off64_t _offset; 320*c2fb3212Sespie # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) 32103a78d15Sespie /* Wide character stream stuff. */ 32203a78d15Sespie struct _IO_codecvt *_codecvt; 32303a78d15Sespie struct _IO_wide_data *_wide_data; 32403a78d15Sespie # else 32503a78d15Sespie void *__pad1; 32603a78d15Sespie void *__pad2; 32703a78d15Sespie # endif 32803a78d15Sespie int _mode; 32903a78d15Sespie /* Make sure we don't get into trouble again. */ 33003a78d15Sespie char _unused2[15 * sizeof (int) - 2 * sizeof (void *)]; 33103a78d15Sespie #endif 33203a78d15Sespie }; 33303a78d15Sespie 33403a78d15Sespie #ifndef __cplusplus 33503a78d15Sespie typedef struct _IO_FILE _IO_FILE; 33603a78d15Sespie #endif 33703a78d15Sespie 33803a78d15Sespie struct _IO_FILE_plus; 33903a78d15Sespie 34003a78d15Sespie extern struct _IO_FILE_plus _IO_2_1_stdin_; 34103a78d15Sespie extern struct _IO_FILE_plus _IO_2_1_stdout_; 34203a78d15Sespie extern struct _IO_FILE_plus _IO_2_1_stderr_; 34303a78d15Sespie #ifndef _LIBC 34403a78d15Sespie #define _IO_stdin ((_IO_FILE*)(&_IO_2_1_stdin_)) 34503a78d15Sespie #define _IO_stdout ((_IO_FILE*)(&_IO_2_1_stdout_)) 34603a78d15Sespie #define _IO_stderr ((_IO_FILE*)(&_IO_2_1_stderr_)) 34703a78d15Sespie #else 34803a78d15Sespie extern _IO_FILE *_IO_stdin; 34903a78d15Sespie extern _IO_FILE *_IO_stdout; 35003a78d15Sespie extern _IO_FILE *_IO_stderr; 35103a78d15Sespie #endif 35203a78d15Sespie 35303a78d15Sespie 35403a78d15Sespie /* Functions to do I/O and file management for a stream. */ 35503a78d15Sespie 35603a78d15Sespie /* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF. 35703a78d15Sespie Return number of bytes read. */ 35803a78d15Sespie typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes); 35903a78d15Sespie 36003a78d15Sespie /* Write N bytes pointed to by BUF to COOKIE. Write all N bytes 36103a78d15Sespie unless there is an error. Return number of bytes written, or -1 if 36203a78d15Sespie there is an error without writing anything. If the file has been 36303a78d15Sespie opened for append (__mode.__append set), then set the file pointer 36403a78d15Sespie to the end of the file and then do the write; if not, just write at 36503a78d15Sespie the current file pointer. */ 36603a78d15Sespie typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf, 36703a78d15Sespie size_t __n); 36803a78d15Sespie 36903a78d15Sespie /* Move COOKIE's file position to *POS bytes from the 37003a78d15Sespie beginning of the file (if W is SEEK_SET), 37103a78d15Sespie the current position (if W is SEEK_CUR), 37203a78d15Sespie or the end of the file (if W is SEEK_END). 37303a78d15Sespie Set *POS to the new file position. 37403a78d15Sespie Returns zero if successful, nonzero if not. */ 37503a78d15Sespie typedef int __io_seek_fn (void *__cookie, _IO_off64_t *__pos, int __w); 37603a78d15Sespie 37703a78d15Sespie /* Close COOKIE. */ 37803a78d15Sespie typedef int __io_close_fn (void *__cookie); 37903a78d15Sespie 38003a78d15Sespie 38103a78d15Sespie #ifdef _GNU_SOURCE 38203a78d15Sespie /* User-visible names for the above. */ 38303a78d15Sespie typedef __io_read_fn cookie_read_function_t; 38403a78d15Sespie typedef __io_write_fn cookie_write_function_t; 38503a78d15Sespie typedef __io_seek_fn cookie_seek_function_t; 38603a78d15Sespie typedef __io_close_fn cookie_close_function_t; 38703a78d15Sespie 38803a78d15Sespie /* The structure with the cookie function pointers. */ 38903a78d15Sespie typedef struct 39003a78d15Sespie { 39103a78d15Sespie __io_read_fn *read; /* Read bytes. */ 39203a78d15Sespie __io_write_fn *write; /* Write bytes. */ 39303a78d15Sespie __io_seek_fn *seek; /* Seek/tell file position. */ 39403a78d15Sespie __io_close_fn *close; /* Close file. */ 39503a78d15Sespie } _IO_cookie_io_functions_t; 39603a78d15Sespie typedef _IO_cookie_io_functions_t cookie_io_functions_t; 39703a78d15Sespie 39803a78d15Sespie struct _IO_cookie_file; 39903a78d15Sespie 40003a78d15Sespie /* Initialize one of those. */ 40103a78d15Sespie extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write, 40203a78d15Sespie void *__cookie, _IO_cookie_io_functions_t __fns); 40303a78d15Sespie #endif 40403a78d15Sespie 40503a78d15Sespie 40603a78d15Sespie #ifdef __cplusplus 40703a78d15Sespie extern "C" { 40803a78d15Sespie #endif 40903a78d15Sespie 41003a78d15Sespie extern int __underflow (_IO_FILE *) __THROW; 41103a78d15Sespie extern int __uflow (_IO_FILE *) __THROW; 41203a78d15Sespie extern int __overflow (_IO_FILE *, int) __THROW; 41303a78d15Sespie extern _IO_wint_t __wunderflow (_IO_FILE *) __THROW; 41403a78d15Sespie extern _IO_wint_t __wuflow (_IO_FILE *) __THROW; 41503a78d15Sespie extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t) __THROW; 41603a78d15Sespie 41703a78d15Sespie #define _IO_getc_unlocked(_fp) \ 41803a78d15Sespie ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow (_fp) \ 41903a78d15Sespie : *(unsigned char *) (_fp)->_IO_read_ptr++) 42003a78d15Sespie #define _IO_peekc_unlocked(_fp) \ 42103a78d15Sespie ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \ 42203a78d15Sespie && __underflow (_fp) == EOF ? EOF \ 42303a78d15Sespie : *(unsigned char *) (_fp)->_IO_read_ptr) 42403a78d15Sespie #define _IO_putc_unlocked(_ch, _fp) \ 42503a78d15Sespie (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \ 42603a78d15Sespie ? __overflow (_fp, (unsigned char) (_ch)) \ 42703a78d15Sespie : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch))) 42803a78d15Sespie 42903a78d15Sespie #define _IO_getwc_unlocked(_fp) \ 43003a78d15Sespie ((_fp)->_wide_data->_IO_read_ptr >= (_fp)->_wide_data->_IO_read_end \ 43103a78d15Sespie ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++) 43203a78d15Sespie #define _IO_putwc_unlocked(_wch, _fp) \ 43303a78d15Sespie ((_fp)->_wide_data->_IO_write_ptr >= (_fp)->_wide_data->_IO_write_end \ 43403a78d15Sespie ? __woverflow (_fp, _wch) \ 43503a78d15Sespie : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch))) 43603a78d15Sespie 43703a78d15Sespie #define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0) 43803a78d15Sespie #define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0) 43903a78d15Sespie 44003a78d15Sespie extern int _IO_getc (_IO_FILE *__fp) __THROW; 44103a78d15Sespie extern int _IO_putc (int __c, _IO_FILE *__fp) __THROW; 44203a78d15Sespie extern int _IO_feof (_IO_FILE *__fp) __THROW; 44303a78d15Sespie extern int _IO_ferror (_IO_FILE *__fp) __THROW; 44403a78d15Sespie 44503a78d15Sespie extern int _IO_peekc_locked (_IO_FILE *__fp) __THROW; 44603a78d15Sespie 44703a78d15Sespie /* This one is for Emacs. */ 44803a78d15Sespie #define _IO_PENDING_OUTPUT_COUNT(_fp) \ 44903a78d15Sespie ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base) 45003a78d15Sespie 45103a78d15Sespie extern void _IO_flockfile (_IO_FILE *) __THROW; 45203a78d15Sespie extern void _IO_funlockfile (_IO_FILE *) __THROW; 45303a78d15Sespie extern int _IO_ftrylockfile (_IO_FILE *) __THROW; 45403a78d15Sespie 45503a78d15Sespie #ifdef _IO_MTSAFE_IO 45603a78d15Sespie # define _IO_peekc(_fp) _IO_peekc_locked (_fp) 45703a78d15Sespie #else 45803a78d15Sespie # define _IO_peekc(_fp) _IO_peekc_unlocked (_fp) 45903a78d15Sespie # define _IO_flockfile(_fp) /**/ 46003a78d15Sespie # define _IO_funlockfile(_fp) /**/ 46103a78d15Sespie # define _IO_ftrylockfile(_fp) /**/ 46203a78d15Sespie # define _IO_cleanup_region_start(_fct, _fp) /**/ 46303a78d15Sespie # define _IO_cleanup_region_end(_Doit) /**/ 46403a78d15Sespie #endif /* !_IO_MTSAFE_IO */ 46503a78d15Sespie 46603a78d15Sespie extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict, 46703a78d15Sespie _IO_va_list, int *__restrict) __THROW; 46803a78d15Sespie extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict, 46903a78d15Sespie _IO_va_list) __THROW; 47003a78d15Sespie extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t) __THROW; 47103a78d15Sespie extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t) __THROW; 47203a78d15Sespie 47303a78d15Sespie extern _IO_off64_t _IO_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW; 47403a78d15Sespie extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int) __THROW; 47503a78d15Sespie 47603a78d15Sespie extern void _IO_free_backup_area (_IO_FILE *) __THROW; 47703a78d15Sespie 478*c2fb3212Sespie #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) 47903a78d15Sespie extern _IO_wint_t _IO_getwc (_IO_FILE *__fp) __THROW; 48003a78d15Sespie extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp) __THROW; 48103a78d15Sespie extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW; 48203a78d15Sespie # if __GNUC__ >= 2 48303a78d15Sespie /* A special optimized version of the function above. It optimizes the 48403a78d15Sespie case of initializing an unoriented byte stream. */ 48503a78d15Sespie # define _IO_fwide(__fp, __mode) \ 48603a78d15Sespie ({ int __result = (__mode); \ 48703a78d15Sespie if (__result < 0) \ 48803a78d15Sespie { \ 48903a78d15Sespie if ((__fp)->_mode == 0) \ 49003a78d15Sespie /* We know that all we have to do is to set the flag. */ \ 49103a78d15Sespie (__fp)->_mode = -1; \ 49203a78d15Sespie __result = (__fp)->_mode; \ 49303a78d15Sespie } \ 49403a78d15Sespie else \ 49503a78d15Sespie __result = _IO_fwide (__fp, __result); \ 49603a78d15Sespie __result; }) 49703a78d15Sespie # endif 49803a78d15Sespie 49903a78d15Sespie extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict, 50003a78d15Sespie _IO_va_list, int *__restrict) __THROW; 50103a78d15Sespie extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict, 50203a78d15Sespie _IO_va_list) __THROW; 50303a78d15Sespie extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t) __THROW; 50403a78d15Sespie extern void _IO_free_wbackup_area (_IO_FILE *) __THROW; 50503a78d15Sespie #endif 50603a78d15Sespie 50703a78d15Sespie #ifdef __cplusplus 50803a78d15Sespie } 50903a78d15Sespie #endif 51003a78d15Sespie 51103a78d15Sespie #endif /* _IO_STDIO_H */ 512