home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / libg++-2.5.3-bin.lha / lib / g++-include / libio.h < prev    next >
C/C++ Source or Header  |  1994-02-21  |  8KB  |  259 lines

  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. /* This is part of the iostream library.
  26.    Copyright (C) 1991, 1992 Per Bothner. */
  27.  
  28. #ifndef _IO_STDIO_H
  29. #define _IO_STDIO_H
  30. #ifdef __GNUG__
  31. #pragma interface
  32. #endif
  33.  
  34. #if 1
  35. #include <_G_config.h>
  36. #define _IO_pos_t _G_fpos_t /* obsolete */
  37. #define _IO_fpos_t _G_fpos_t
  38. #define _IO_size_t _G_size_t
  39. #define _IO_ssize_t _G_ssize_t
  40. #define _IO_off_t _G_off_t
  41. #define _IO_pid_t _G_pid_t
  42. #define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
  43. #define _IO_BUFSIZ _G_BUFSIZ
  44. #define _IO_va_list _G_va_list
  45.  
  46. #ifdef _G_NEED_STDARG_H
  47. /* This define avoids name pollution if we're using GNU stdarg.h */
  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 /* __GNUC_VA_LIST */
  54. #endif
  55.  
  56. #else
  57. #include <_IO_config.h>
  58. typedef _IO_fpos_t _IO_pos_t;
  59. #endif
  60.  
  61. #ifndef _PARAMS
  62. #ifdef __STDC__
  63. #define _PARAMS(paramlist) paramlist
  64. #else
  65. #define _PARAMS(paramlist) ()
  66. #endif
  67. #endif /*!_PARAMS*/
  68. #ifndef __STDC__
  69. #define const
  70. #endif
  71. #define USE_DTOA
  72.  
  73. #if 0
  74. #ifdef _IO_NEED_STDARG_H
  75. #include <stdarg.h>
  76. #endif
  77. #endif
  78.  
  79. #ifndef EOF
  80. #define EOF (-1)
  81. #endif
  82. #ifndef NULL
  83. #if !defined(__cplusplus) || defined(__GNUC__)
  84. #define NULL ((void*)0)
  85. #else
  86. #define NULL (0)
  87. #endif
  88. #endif
  89.  
  90. #define _IOS_INPUT    1
  91. #define _IOS_OUTPUT    2
  92. #define _IOS_ATEND    4
  93. #define _IOS_APPEND    8
  94. #define _IOS_TRUNC    16
  95. #define _IOS_NOCREATE    32
  96. #define _IOS_NOREPLACE    64
  97. #define _IOS_BIN    128
  98.  
  99. /* Magic numbers and bits for the _flags field.
  100.    The magic numbers use the high-order bits of _flags;
  101.    the remaining bits are abailable for variable flags.
  102.    Note: The magic numbers must all be negative if stdio
  103.    emulation is desired. */
  104.  
  105. #define _IO_MAGIC 0xFBAD0000 /* Magic number */
  106. #define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */
  107. #define _IO_MAGIC_MASK 0xFFFF0000
  108. #define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */
  109. #define _IO_UNBUFFERED 2
  110. #define _IO_NO_READS 4 /* Reading not allowed */
  111. #define _IO_NO_WRITES 8 /* Writing not allowd */
  112. #define _IO_EOF_SEEN 0x10
  113. #define _IO_ERR_SEEN 0x20
  114. #define _IO_DELETE_DONT_CLOSE 0x40
  115. #define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/
  116. #define _IO_IN_BACKUP 0x100
  117. #define _IO_LINE_BUF 0x200
  118. #define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */
  119. #define _IO_CURRENTLY_PUTTING 0x800
  120. #define _IO_IS_APPENDING 0x1000
  121. #define _IO_IS_FILEBUF 0x2000
  122.  
  123. /* These are "formatting flags" matching the iostream fmtflags enum values. */
  124. #define _IO_SKIPWS 01
  125. #define _IO_LEFT 02
  126. #define _IO_RIGHT 04
  127. #define _IO_INTERNAL 010
  128. #define _IO_DEC 020
  129. #define _IO_OCT 040
  130. #define _IO_HEX 0100
  131. #define _IO_SHOWBASE 0200
  132. #define _IO_SHOWPOINT 0400
  133. #define _IO_UPPERCASE 01000
  134. #define _IO_SHOWPOS 02000
  135. #define _IO_SCIENTIFIC 04000
  136. #define _IO_FIXED 010000
  137. #define _IO_UNITBUF 020000
  138. #define _IO_STDIO 040000
  139. #define _IO_DONT_CLOSE 0100000
  140.  
  141. /* A streammarker remembers a position in a buffer. */
  142.  
  143. struct _IO_jump_t;  struct _IO_FILE;
  144.  
  145. struct _IO_marker {
  146.   struct _IO_marker *_next;
  147.   struct _IO_FILE *_sbuf;
  148.   /* If _pos >= 0
  149.  it points to _buf->Gbase()+_pos. FIXME comment */
  150.   /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */
  151.   int _pos;
  152. #if 0
  153.     void set_streampos(streampos sp) { _spos = sp; }
  154.     void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
  155.   public:
  156.     streammarker(streambuf *sb);
  157.     ~streammarker();
  158.     int saving() { return  _spos == -2; }
  159.     int delta(streammarker&);
  160.     int delta();
  161. #endif
  162. };
  163.  
  164. struct _IO_FILE {
  165.   int _flags;        /* High-order word is _IO_MAGIC; rest is flags. */
  166. #define _IO_file_flags _flags
  167.  
  168.   /* The following pointers correspond to the C++ streambuf protocol. */
  169.   char* _IO_read_ptr;    /* Current read pointer */
  170.   char* _IO_read_end;    /* End of get area. */
  171.   char* _IO_read_base;    /* Start of putback+get area. */
  172.   char* _IO_write_base;    /* Start of put area. */
  173.   char* _IO_write_ptr;    /* Current put pointer. */
  174.   char* _IO_write_end;    /* End of put area. */
  175.   char* _IO_buf_base;    /* Start of reserve area. */
  176.   char* _IO_buf_end;    /* End of reserve area. */
  177.   /* The following fields are used to support backing up and undo. */
  178.   char *_IO_save_base; /* Pointer to start of non-current get area. */
  179.   char *_IO_backup_base;  /* Pointer to first valid character of backup area */
  180.   char *_IO_save_end; /* Pointer to end of non-current get area. */
  181.  
  182. /* These names are temporary aliases. TODO */
  183. #define _other_gbase _IO_save_base
  184. #define _aux_limit _IO_backup_base
  185. #define _other_egptr _IO_save_end
  186.  
  187.   struct _IO_marker *_markers;
  188.   
  189.   struct _IO_FILE *_chain;
  190.   
  191.   struct _IO_jump_t *_jumps; /* Jump table */
  192.   
  193.   int _fileno;
  194.   int _blksize;
  195.   _IO_off_t _offset;
  196.   
  197. #define __HAVE_COLUMN /* temporary */
  198.   /* 1+column number of pbase(); 0 is unknown. */
  199.   unsigned short _cur_column;
  200.   char _unused;
  201.   char _shortbuf[1];
  202.   
  203.   /*  char* _save_gptr;  char* _save_egptr; */
  204. };
  205.  
  206. #ifndef __cplusplus
  207. typedef struct _IO_FILE _IO_FILE;
  208. #endif
  209.  
  210. /* We always allocate an extra word following an _IO_FILE.
  211.    This is for compatibility with C++ streambuf; the word can
  212.    be used to smash to a pointer to a virtual function table. */
  213.  
  214. struct _IO_FILE_plus {
  215.   _IO_FILE _file;
  216.   const void *_vtable;
  217. };
  218.  
  219. extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_;
  220. #define _IO_stdin (&_IO_stdin_._file)
  221. #define _IO_stdout (&_IO_stdout_._file)
  222. #define _IO_stderr (&_IO_stderr_._file)
  223.  
  224. #ifdef __cplusplus
  225. extern "C" {
  226. #endif
  227.  
  228. extern int __underflow _PARAMS((_IO_FILE*));
  229. extern int __overflow _PARAMS((_IO_FILE*, int));
  230.  
  231. extern unsigned __adjust_column _PARAMS((unsigned start, const char *line, int count));
  232.  
  233. #define _IO_getc(_fp) \
  234.        ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \
  235.       && __underflow(_fp) == EOF ? EOF \
  236.     : *(unsigned char*)(_fp)->_IO_read_ptr++)
  237. #define _IO_peekc(_fp) \
  238.        ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \
  239.       && __underflow(_fp) == EOF ? EOF \
  240.     : *(unsigned char*)(_fp)->_IO_read_ptr)
  241.  
  242. #define _IO_putc(_ch, _fp) \
  243.    (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
  244.     ? __overflow(_fp, (unsigned char)_ch) \
  245.     : (unsigned char)(*(_fp)->_IO_write_ptr++ = _ch))
  246.  
  247. extern int _IO_vfscanf _PARAMS((_IO_FILE*, const char*, _IO_va_list, int*));
  248. extern int _IO_vfprintf _PARAMS((_IO_FILE*, const char*, _IO_va_list));
  249. extern _IO_ssize_t _IO_padn _PARAMS((_IO_FILE *, int, _IO_ssize_t));
  250. extern _IO_size_t _IO_sgetn _PARAMS((_IO_FILE *, void*, _IO_size_t));
  251.  
  252. extern void _IO_free_backup_area _PARAMS((_IO_FILE*));
  253.  
  254. #ifdef __cplusplus
  255. }
  256. #endif
  257.  
  258. #endif /* _IO_STDIO_H */
  259.