Annotation of GNUtools/libg++/libio/libioP.h, revision 1.1.1.1

1.1       root        1: /* 
                      2: Copyright (C) 1993 Free Software Foundation
                      3: 
                      4: This file is part of the GNU IO Library.  This library is free
                      5: software; you can redistribute it and/or modify it under the
                      6: terms of the GNU General Public License as published by the
                      7: Free Software Foundation; either version 2, or (at your option)
                      8: any later version.
                      9: 
                     10: This library is distributed in the hope that it will be useful,
                     11: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     13: GNU General Public License for more details.
                     14: 
                     15: You should have received a copy of the GNU General Public License
                     16: along with GNU CC; see the file COPYING.  If not, write to
                     17: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
                     18: 
                     19: As a special exception, if you link this library with files
                     20: compiled with a GNU compiler to produce an executable, this does not cause
                     21: the resulting executable to be covered by the GNU General Public License.
                     22: This exception does not however invalidate any other reasons why
                     23: the executable file might be covered by the GNU General Public License. */
                     24: 
                     25: #pragma cplusplus
                     26: #ifdef __cplusplus
                     27: extern "C" {
                     28: #endif
                     29: #include <errno.h>
                     30: #ifdef __cplusplus
                     31: }
                     32: #endif
                     33: 
                     34: #ifndef errno
                     35: extern int errno;
                     36: #endif
                     37: 
                     38: #include "iolibio.h"
                     39: 
                     40: #ifdef __cplusplus
                     41: extern "C" {
                     42: #endif
                     43: 
                     44: typedef enum _IO_seekflags_ {
                     45:   _IO_seek_set = 0,
                     46:   _IO_seek_cur = 1,
                     47:   _IO_seek_end = 2,
                     48: 
                     49:   /* These bits are ignored unless the _IO_FILE has independent
                     50:      read and write positions. */
                     51:   _IO_seek_not_in = 4, /* Don't move read posistion. */
                     52:   _IO_seek_not_out = 8,        /* Don't move write posistion. */
                     53:   _IO_seek_pos_ignored = 16 /* Result is ignored (except EOF) */
                     54: } _IO_seekflags;
                     55: 
                     56: typedef int (*_IO_overflow_t) _PARAMS((_IO_FILE*, int));
                     57: typedef int (*_IO_underflow_t) _PARAMS((_IO_FILE*));
                     58: typedef _IO_size_t (*_IO_xsputn_t) _PARAMS((_IO_FILE*,const void*,_IO_size_t));
                     59: typedef _IO_size_t (*_IO_xsgetn_t) _PARAMS((_IO_FILE*, void*, _IO_size_t));
                     60: typedef _IO_ssize_t (*_IO_read_t) _PARAMS((_IO_FILE*, void*, _IO_ssize_t));
                     61: typedef _IO_ssize_t (*_IO_write_t) _PARAMS((_IO_FILE*,const void*,_IO_ssize_t));
                     62: typedef int (*_IO_stat_t) _PARAMS((_IO_FILE*, void*));
                     63: typedef _IO_fpos_t (*_IO_seek_t) _PARAMS((_IO_FILE*, _IO_off_t, int));
                     64: typedef int (*_IO_doallocate_t) _PARAMS((_IO_FILE*));
                     65: typedef int (*_IO_pbackfail_t) _PARAMS((_IO_FILE*, int));
                     66: typedef int (*_IO_setbuf_t) _PARAMS((_IO_FILE*, char *, _IO_ssize_t));
                     67: typedef int (*_IO_sync_t) _PARAMS((_IO_FILE*));
                     68: typedef void (*_IO_finish_t) _PARAMS((_IO_FILE*)); /* finalize */
                     69: typedef int (*_IO_close_t) _PARAMS((_IO_FILE*)); /* finalize */
                     70: typedef _IO_fpos_t (*_IO_seekoff_t) _PARAMS((_IO_FILE*, _IO_off_t, _IO_seekflags));
                     71: 
                     72: /* The _IO_seek_cur and _IO_seek_end options are not allowed. */
                     73: typedef _IO_fpos_t (*_IO_seekpos_t) _PARAMS((_IO_FILE*, _IO_fpos_t, _IO_seekflags));
                     74: 
                     75: struct _IO_jump_t {
                     76:     _IO_overflow_t __overflow;
                     77:     _IO_underflow_t __underflow;
                     78:     _IO_xsputn_t __xsputn;
                     79:     _IO_xsgetn_t __xsgetn;
                     80:     _IO_read_t __read;
                     81:     _IO_write_t __write;
                     82:     _IO_doallocate_t __doallocate;
                     83:     _IO_pbackfail_t __pbackfail;
                     84:     _IO_setbuf_t __setbuf;
                     85:     _IO_sync_t __sync;
                     86:     _IO_finish_t __finish;
                     87:     _IO_close_t __close;
                     88:     _IO_stat_t __stat;
                     89:     _IO_seek_t __seek;
                     90:     _IO_seekoff_t __seekoff;
                     91:     _IO_seekpos_t __seekpos;
                     92: #if 0
                     93:     get_column;
                     94:     set_column;
                     95: #endif
                     96: };
                     97: 
                     98: /* Generic functions */
                     99: 
                    100: extern _IO_fpos_t _IO_seekoff _PARAMS((_IO_FILE*, _IO_off_t, _IO_seekflags));
                    101: extern _IO_fpos_t _IO_seekpos _PARAMS((_IO_FILE*, _IO_fpos_t, _IO_seekflags));
                    102: 
                    103: extern int _IO_switch_to_get_mode _PARAMS((_IO_FILE*));
                    104: extern void _IO_init _PARAMS((_IO_FILE*, int));
                    105: extern int _IO_sputbackc _PARAMS((_IO_FILE*, int));
                    106: extern int _IO_sungetc _PARAMS((_IO_FILE*));
                    107: extern void _IO_un_link _PARAMS((_IO_FILE*));
                    108: extern void _IO_link_in _PARAMS((_IO_FILE *));
                    109: extern void _IO_doallocbuf _PARAMS((_IO_FILE*));
                    110: extern void _IO_unsave_markers _PARAMS((_IO_FILE*));
                    111: extern void _IO_setb _PARAMS((_IO_FILE*, char*, char*, int));
                    112: extern unsigned _IO_adjust_column _PARAMS((unsigned, const char *, int));
                    113: #define _IO_sputn(__fp, __s, __n) (__fp->_jumps->__xsputn(__fp, __s, __n))
                    114: 
                    115: /* Marker-related function. */
                    116: 
                    117: extern void _IO_init_marker _PARAMS((struct _IO_marker *, _IO_FILE *));
                    118: extern void _IO_remove_marker _PARAMS((struct _IO_marker*));
                    119: extern int _IO_marker_difference _PARAMS((struct _IO_marker *, struct _IO_marker *));
                    120: extern int _IO_marker_delta _PARAMS((struct _IO_marker *));
                    121: extern int _IO_seekmark _PARAMS((_IO_FILE *, struct _IO_marker *, int));
                    122: 
                    123: /* Default jumptable functions. */
                    124: 
                    125: extern int _IO_default_underflow _PARAMS((_IO_FILE*));
                    126: extern int _IO_default_doallocate _PARAMS((_IO_FILE*));
                    127: extern void _IO_default_finish _PARAMS((_IO_FILE *));
                    128: extern int _IO_default_pbackfail _PARAMS((_IO_FILE*, int));
                    129: extern int _IO_default_setbuf _PARAMS((_IO_FILE *, char*, _IO_ssize_t));
                    130: extern _IO_size_t _IO_default_xsputn _PARAMS((_IO_FILE *, const void*, _IO_size_t));
                    131: extern _IO_size_t _IO_default_xsgetn _PARAMS((_IO_FILE *, void*, _IO_size_t));
                    132: extern _IO_fpos_t _IO_default_seekoff _PARAMS((_IO_FILE*, _IO_off_t, _IO_seekflags));
                    133: extern _IO_fpos_t _IO_default_seekpos _PARAMS((_IO_FILE*, _IO_fpos_t, _IO_seekflags));
                    134: extern _IO_ssize_t _IO_default_write _PARAMS((_IO_FILE*,const void*,_IO_ssize_t));
                    135: extern _IO_ssize_t _IO_default_read _PARAMS((_IO_FILE*, void*, _IO_ssize_t));
                    136: extern int _IO_default_stat _PARAMS((_IO_FILE*, void*));
                    137: extern _IO_fpos_t _IO_default_seek _PARAMS((_IO_FILE*, _IO_off_t, int));
                    138: extern int _IO_default_sync _PARAMS((_IO_FILE*));
                    139: #define _IO_default_close ((_IO_close_t)_IO_default_sync)
                    140: 
                    141: extern struct _IO_jump_t _IO_file_jumps;
                    142: extern struct _IO_jump_t _IO_proc_jumps;
                    143: extern struct _IO_jump_t _IO_str_jumps;
                    144: extern int _IO_do_write _PARAMS((_IO_FILE*, const char*, _IO_size_t));
                    145: extern int _IO_flush_all _PARAMS(());
                    146: extern void _IO_flush_all_linebuffered _PARAMS(());
                    147: 
                    148: #define _IO_do_flush(_f) \
                    149:   _IO_do_write(_f, _f->_IO_write_base, _f->_IO_write_ptr-_f->_IO_write_base)
                    150: #define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING)
                    151: #define _IO_mask_flags(fp, f, mask) \
                    152:        ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask)))
                    153: #define _IO_setg(fp, eb, g, eg)  ((fp)->_IO_read_base = (eb),\
                    154:        (fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg))
                    155: #define _IO_setp(__fp, __p, __ep) \
                    156:        ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr = __p, (__fp)->_IO_write_end = (__ep))
                    157: #define _IO_have_backup(fp) ((fp)->_other_gbase != NULL)
                    158: #define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP)
                    159: #define _IO_have_markers(fp) ((fp)->_markers != NULL)
                    160: #define _IO_blen(p) ((fp)->_IO_buf_end - (fp)->_IO_buf_base)
                    161: 
                    162: /* Jumptable functions for files. */
                    163: 
                    164: extern int _IO_file_doallocate _PARAMS((_IO_FILE*));
                    165: extern int _IO_file_setbuf _PARAMS((_IO_FILE *, char*, _IO_ssize_t));
                    166: extern _IO_fpos_t _IO_file_seekoff _PARAMS((_IO_FILE*, _IO_off_t, _IO_seekflags));
                    167: extern _IO_size_t _IO_file_xsputn _PARAMS((_IO_FILE*,const void*,_IO_size_t));
                    168: extern int _IO_file_stat _PARAMS((_IO_FILE*, void*));
                    169: extern int _IO_file_close _PARAMS((_IO_FILE*));
                    170: extern int _IO_file_underflow _PARAMS((_IO_FILE *));
                    171: extern int _IO_file_overflow _PARAMS((_IO_FILE *, int));
                    172: #define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0)
                    173: extern void _IO_file_init _PARAMS((_IO_FILE*));
                    174: extern _IO_FILE* _IO_file_attach _PARAMS((_IO_FILE*, int));
                    175: extern _IO_FILE* _IO_file_fopen _PARAMS((_IO_FILE*, const char*, const char*));
                    176: extern _IO_ssize_t _IO_file_write _PARAMS((_IO_FILE*,const void*,_IO_ssize_t));
                    177: extern _IO_ssize_t _IO_file_read _PARAMS((_IO_FILE*, void*, _IO_ssize_t));
                    178: extern int _IO_file_sync _PARAMS((_IO_FILE*));
                    179: extern int _IO_file_close_it _PARAMS((_IO_FILE*));
                    180: extern _IO_fpos_t _IO_file_seek _PARAMS((_IO_FILE *, _IO_off_t, int));
                    181: extern void _IO_file_finish _PARAMS((_IO_FILE*));
                    182: 
                    183: /* Other file functions. */
                    184: extern _IO_FILE* _IO_file_attach _PARAMS((_IO_FILE *, int));
                    185: 
                    186: /* Jumptable functions for proc_files. */
                    187: extern _IO_FILE* _IO_proc_open _PARAMS((_IO_FILE*, const char*, const char *));
                    188: extern int _IO_proc_close _PARAMS((_IO_FILE*));
                    189: 
                    190: /* Jumptable functions for strfiles. */
                    191: extern int _IO_str_underflow _PARAMS((_IO_FILE*));
                    192: extern int _IO_str_overflow _PARAMS((_IO_FILE *, int));
                    193: extern int _IO_str_pbackfail _PARAMS((_IO_FILE*, int));
                    194: extern _IO_fpos_t _IO_str_seekoff _PARAMS((_IO_FILE*,_IO_off_t,_IO_seekflags));
                    195: 
                    196: /* Other strfile functions */
                    197: extern void _IO_str_init_static _PARAMS((_IO_FILE *, char*, int, char*));
                    198: extern void _IO_str_init_readonly _PARAMS((_IO_FILE *, const char*, int));
                    199: extern _IO_ssize_t _IO_str_count _PARAMS ((_IO_FILE*));
                    200: 
                    201: extern _IO_size_t _IO_getline _PARAMS((_IO_FILE*,char*,_IO_size_t,int,int));
                    202: extern double _IO_strtod _PARAMS((const char *, char **));
                    203: extern char * _IO_dtoa _PARAMS((double __d, int __mode, int __ndigits,
                    204:                                int *__decpt, int *__sign, char **__rve));
                    205: extern int _IO_outfloat _PARAMS((double __value, _IO_FILE *__sb, int __type,
                    206:                                 int __width, int __precision, int __flags,
                    207:                                 int __sign_mode, int __fill));
                    208: 
                    209: extern _IO_FILE *_IO_list_all;
                    210: extern void (*_IO_cleanup_registration_needed)();
                    211: 
                    212: #ifndef EOF
                    213: #define EOF (-1)
                    214: #endif
                    215: #ifndef NULL
                    216: #if !defined(__cplusplus) || defined(__GNUC__)
                    217: #define NULL ((void*)0)
                    218: #else
                    219: #define NULL (0)
                    220: #endif
                    221: #endif
                    222: 
                    223: #define FREE_BUF(_B) free(_B)
                    224: #define ALLOC_BUF(_S) (char*)malloc(_S)
                    225: 
                    226: #ifndef OS_FSTAT
                    227: #define OS_FSTAT fstat
                    228: #endif
                    229: struct stat;
                    230: extern _IO_ssize_t _IO_read _PARAMS((int, void*, _IO_size_t));
                    231: extern _IO_ssize_t _IO_write _PARAMS((int, const void*, _IO_size_t));
                    232: extern _IO_off_t _IO_lseek _PARAMS((int, _IO_off_t, int));
                    233: extern int _IO_close _PARAMS((int));
                    234: extern int _IO_fstat _PARAMS((int, struct stat *));
                    235: 
                    236: /* Operations on _IO_fpos_t.
                    237:    Normally, these are trivial, but we provide hooks for configurations
                    238:    where an _IO_fpos_t is a struct.
                    239:    Note that _IO_off_t must be an integral type. */
                    240: 
                    241: /* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */
                    242: #ifndef _IO_pos_BAD
                    243: #define _IO_pos_BAD ((_IO_fpos_t)(-1))
                    244: #endif
                    245: /* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */
                    246: #ifndef _IO_pos_as_off
                    247: #define _IO_pos_as_off(__pos) ((_IO_off_t)(__pos))
                    248: #endif
                    249: /* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */
                    250: #ifndef _IO_pos_adjust
                    251: #define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta))
                    252: #endif
                    253: /* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */
                    254: #ifndef _IO_pos_0
                    255: #define _IO_pos_0 ((_IO_fpos_t)0)
                    256: #endif
                    257: 
                    258: #ifdef __cplusplus
                    259: }
                    260: #endif
                    261: 
                    262: #if defined(__STDC__) || defined(__cplusplus)
                    263: #define _IO_va_start(args, last) va_start(args, last)
                    264: #else
                    265: #define _IO_va_start(args, last) va_start(args)
                    266: #endif
                    267: 
                    268: #if 1
                    269: #define COERCE_FILE(FILE) /* Nothing */
                    270: #else
                    271: /* This is part of the kludge for binary compatibility with old stdio. */
                    272: #define COERCE_FILE(FILE) \
                    273:   (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \
                    274:     && (FILE) = *(FILE**)&((int*)fp)[1])
                    275: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.