libio.h
001: 
002: 
003: <bothner@cygnus.com>
004: 
005: 
006: 
007: 
008: 
009: 
010: 
011: 
012: 
013: 
014: 
015: 
016: 
017: 
018: 
019: 
020: 
021: 
022: 
023: 
024: 
025: 
026: 
027: 
028: 
029: #ifndef _IO_STDIO_H
030: #define _IO_STDIO_H
031: 
032: #include <_G_config.h>
033: 
034: #define _IO_pos_t _G_fpos_t 
035: #define _IO_fpos_t _G_fpos_t
036: #define _IO_fpos64_t _G_fpos64_t
037: #define _IO_size_t _G_size_t
038: #define _IO_ssize_t _G_ssize_t
039: #define _IO_off_t _G_off_t
040: #define _IO_off64_t _G_off64_t
041: #define _IO_pid_t _G_pid_t
042: #define _IO_uid_t _G_uid_t
043: #define _IO_iconv_t _G_iconv_t
044: #define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
045: #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
046: #define _IO_BUFSIZ _G_BUFSIZ
047: #define _IO_va_list _G_va_list
048: #define _IO_wint_t _G_wint_t
049: 
050: #ifdef _G_NEED_STDARG_H
051: 
052: # define __need___va_list
053: # include <stdarg.h>
054: # ifdef __GNUC_VA_LIST
055: #  undef _IO_va_list
056: #  define _IO_va_list __gnuc_va_list
057: # endif 
058: #endif
059: 
060: #ifndef __P
061: # if _G_HAVE_SYS_CDEFS
062: #  include <sys/cdefs.h>
063: # else
064: #  ifdef __STDC__
065: #   define __P(p) p
066: #   define __PMT(p) p
067: #  else
068: #   define __P(p) ()
069: #   define __PMT(p) ()
070: #  endif
071: # endif
072: #endif 
073: 
074: 
075: #ifndef _PARAMS
076: # define _PARAMS(protos) __P(protos)
077: #endif 
078: 
079: #ifndef __STDC__
080: # ifndef const
081: #  define const
082: # endif
083: #endif
084: #define _IO_UNIFIED_JUMPTABLES 1
085: #ifndef _G_HAVE_PRINTF_FP
086: # define _IO_USE_DTOA 1
087: #endif
088: 
089: #ifndef EOF
090: # define EOF (-1)
091: #endif
092: #ifndef NULL
093: # if defined __GNUG__ && \
094:     (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
095: #  define NULL (__null)
096: # else
097: #  if !defined(__cplusplus)
098: #   define NULL ((void*)0)
099: #  else
100: #   define NULL (0)
101: #  endif
102: # endif
103: #endif
104: 
105: #define _IOS_INPUT      1
106: #define _IOS_OUTPUT     2
107: #define _IOS_ATEND      4
108: #define _IOS_APPEND     8
109: #define _IOS_TRUNC      16
110: #define _IOS_NOCREATE   32
111: #define _IOS_NOREPLACE  64
112: #define _IOS_BIN        128
113: 
114: 
115: 
116: 
117: 
118: 
119: 
120: #define _IO_MAGIC 0xFBAD0000 
121: #define _OLD_STDIO_MAGIC 0xFABC0000 
122: #define _IO_MAGIC_MASK 0xFFFF0000
123: #define _IO_USER_BUF 1 
124: #define _IO_UNBUFFERED 2
125: #define _IO_NO_READS 4 
126: #define _IO_NO_WRITES 8 
127: #define _IO_EOF_SEEN 0x10
128: #define _IO_ERR_SEEN 0x20
129: #define _IO_DELETE_DONT_CLOSE 0x40 
130: #define _IO_LINKED 0x80 
131: #define _IO_IN_BACKUP 0x100
132: #define _IO_LINE_BUF 0x200
133: #define _IO_TIED_PUT_GET 0x400 
134: #define _IO_CURRENTLY_PUTTING 0x800
135: #define _IO_IS_APPENDING 0x1000
136: #define _IO_IS_FILEBUF 0x2000
137: #define _IO_BAD_SEEN 0x4000
138: #define _IO_USER_LOCK 0x8000
139: 
140: #define _IO_FLAGS2_MMAP 1
141: #define _IO_FLAGS2_NOTCANCEL 2
142: #ifdef _LIBC
143: # define _IO_FLAGS2_FORTIFY 4
144: #endif
145: #define _IO_FLAGS2_USER_WBUF 8
146: #ifdef _LIBC
147: # define _IO_FLAGS2_SCANF_STD 16
148: # define _IO_FLAGS2_NOCLOSE 32
149: # define _IO_FLAGS2_CLOEXEC 64
150: #endif
151: 
152: 
153: #define _IO_SKIPWS 01
154: #define _IO_LEFT 02
155: #define _IO_RIGHT 04
156: #define _IO_INTERNAL 010
157: #define _IO_DEC 020
158: #define _IO_OCT 040
159: #define _IO_HEX 0100
160: #define _IO_SHOWBASE 0200
161: #define _IO_SHOWPOINT 0400
162: #define _IO_UPPERCASE 01000
163: #define _IO_SHOWPOS 02000
164: #define _IO_SCIENTIFIC 04000
165: #define _IO_FIXED 010000
166: #define _IO_UNITBUF 020000
167: #define _IO_STDIO 040000
168: #define _IO_DONT_CLOSE 0100000
169: #define _IO_BOOLALPHA 0200000
170: 
171: 
172: struct _IO_jump_t;  struct _IO_FILE;
173: 
174: 
175: #ifdef _IO_MTSAFE_IO
176: # if defined __GLIBC__ && __GLIBC__ >= 2
177: #  include <bits/stdio-lock.h>
178: # else
179: 
180: # endif
181: #else
182: typedef void _IO_lock_t;
183: #endif
184: 
185: 
186: 
187: 
188: struct _IO_marker {
189:   struct _IO_marker *_next;
190:   struct _IO_FILE *_sbuf;
191:   
192: FIXME
193:   FIXME
194:   int _pos;
195: #if 0
196:     void set_streampos(streampos sp) { _spos = sp; }
197:     void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
198:   public:
199:     streammarker(streambuf *sb);
200:     ~streammarker();
201:     int saving() { return  _spos == -2; }
202:     int delta(streammarker&);
203:     int delta();
204: #endif
205: };
206: 
207: 
208: enum __codecvt_result
209: {
210:   __codecvt_ok,
211:   __codecvt_partial,
212:   __codecvt_error,
213:   __codecvt_noconv
214: };
215: 
216: #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
217: 
218: 
219: struct _IO_codecvt
220: {
221:   void (*__codecvt_destr) (struct _IO_codecvt *);
222:   enum __codecvt_result (*__codecvt_do_out) (struct _IO_codecvt *,
223:                                              __mbstate_t *,
224:                                              const wchar_t *,
225:                                              const wchar_t *,
226:                                              const wchar_t **, char *,
227:                                              char *, char **);
228:   enum __codecvt_result (*__codecvt_do_unshift) (struct _IO_codecvt *,
229:                                                  __mbstate_t *, char *,
230:                                                  char *, char **);
231:   enum __codecvt_result (*__codecvt_do_in) (struct _IO_codecvt *,
232:                                             __mbstate_t *,
233:                                             const char *, const char *,
234:                                             const char **, wchar_t *,
235:                                             wchar_t *, wchar_t **);
236:   int (*__codecvt_do_encoding) (struct _IO_codecvt *);
237:   int (*__codecvt_do_always_noconv) (struct _IO_codecvt *);
238:   int (*__codecvt_do_length) (struct _IO_codecvt *, __mbstate_t *,
239:                               const char *, const char *, _IO_size_t);
240:   int (*__codecvt_do_max_length) (struct _IO_codecvt *);
241: 
242:   _IO_iconv_t __cd_in;
243:   _IO_iconv_t __cd_out;
244: };
245: 
246: 
247: struct _IO_wide_data
248: {
249:   wchar_t *_IO_read_ptr;        
250:   wchar_t *_IO_read_end;        
251:   wchar_t *_IO_read_base;       
252:   wchar_t *_IO_write_base;      
253:   wchar_t *_IO_write_ptr;       
254:   wchar_t *_IO_write_end;       
255:   wchar_t *_IO_buf_base;        
256:   wchar_t *_IO_buf_end;         
257:   
258:   wchar_t *_IO_save_base;       
259:   wchar_t *_IO_backup_base;     
260: 
261:   wchar_t *_IO_save_end;        
262: 
263:   __mbstate_t _IO_state;
264:   __mbstate_t _IO_last_state;
265:   struct _IO_codecvt _codecvt;
266: 
267:   wchar_t _shortbuf[1];
268: 
269:   const struct _IO_jump_t *_wide_vtable;
270: };
271: #endif
272: 
273: struct _IO_FILE {
274:   int _flags;           
275: #define _IO_file_flags _flags
276: 
277:   
278:   
279:   char* _IO_read_ptr;   
280:   char* _IO_read_end;   
281:   char* _IO_read_base;  
282:   char* _IO_write_base; 
283:   char* _IO_write_ptr;  
284:   char* _IO_write_end;  
285:   char* _IO_buf_base;   
286:   char* _IO_buf_end;    
287:   
288:   char *_IO_save_base; 
289:   char *_IO_backup_base;  
290:   char *_IO_save_end; 
291: 
292:   struct _IO_marker *_markers;
293: 
294:   struct _IO_FILE *_chain;
295: 
296:   int _fileno;
297: #if 0
298:   int _blksize;
299: #else
300:   int _flags2;
301: #endif
302:   _IO_off_t _old_offset; 
303: 
304: #define __HAVE_COLUMN 
305:   
306:   unsigned short _cur_column;
307:   signed char _vtable_offset;
308:   char _shortbuf[1];
309: 
310:   
311: 
312:   _IO_lock_t *_lock;
313: #ifdef _IO_USE_OLD_IO_FILE
314: };
315: 
316: struct _IO_FILE_complete
317: {
318:   struct _IO_FILE _file;
319: #endif
320: #if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001
321:   _IO_off64_t _offset;
322: # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
323:   
324:   struct _IO_codecvt *_codecvt;
325:   struct _IO_wide_data *_wide_data;
326:   struct _IO_FILE *_freeres_list;
327:   void *_freeres_buf;
328:   size_t _freeres_size;
329: # else
330:   void *__pad1;
331:   void *__pad2;
332:   void *__pad3;
333:   void *__pad4;
334:   size_t __pad5;
335: # endif
336:   int _mode;
337:   
338:   char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
339: #endif
340: };
341: 
342: #ifndef __cplusplus
343: typedef struct _IO_FILE _IO_FILE;
344: #endif
345: 
346: struct _IO_FILE_plus;
347: 
348: extern struct _IO_FILE_plus _IO_2_1_stdin_;
349: extern struct _IO_FILE_plus _IO_2_1_stdout_;
350: extern struct _IO_FILE_plus _IO_2_1_stderr_;
351: #ifndef _LIBC
352: #define _IO_stdin ((_IO_FILE*)(&_IO_2_1_stdin_))
353: #define _IO_stdout ((_IO_FILE*)(&_IO_2_1_stdout_))
354: #define _IO_stderr ((_IO_FILE*)(&_IO_2_1_stderr_))
355: #else
356: extern _IO_FILE *_IO_stdin attribute_hidden;
357: extern _IO_FILE *_IO_stdout attribute_hidden;
358: extern _IO_FILE *_IO_stderr attribute_hidden;
359: #endif
360: 
361: 
362: 
363: 
364: 
365: 
366: typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
367: 
368: 
369: 
370: 
371: 
372: 
373: 
374: typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf,
375:                                  size_t __n);
376: 
377: 
378: 
379: 
380: 
381: 
382: 
383: typedef int __io_seek_fn (void *__cookie, _IO_off64_t *__pos, int __w);
384: 
385: 
386: typedef int __io_close_fn (void *__cookie);
387: 
388: 
389: #ifdef _GNU_SOURCE
390: 
391: typedef __io_read_fn cookie_read_function_t;
392: typedef __io_write_fn cookie_write_function_t;
393: typedef __io_seek_fn cookie_seek_function_t;
394: typedef __io_close_fn cookie_close_function_t;
395: 
396: 
397: typedef struct
398: {
399:   __io_read_fn *read;           
400:   __io_write_fn *write;         
401:   __io_seek_fn *seek;           
402:   __io_close_fn *close;         
403: } _IO_cookie_io_functions_t;
404: typedef _IO_cookie_io_functions_t cookie_io_functions_t;
405: 
406: struct _IO_cookie_file;
407: 
408: 
409: extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
410:                              void *__cookie, _IO_cookie_io_functions_t __fns);
411: #endif
412: 
413: 
414: #ifdef __cplusplus
415: extern "C" {
416: #endif
417: 
418: extern int __underflow (_IO_FILE *);
419: extern int __uflow (_IO_FILE *);
420: extern int __overflow (_IO_FILE *, int);
421: #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
422: extern _IO_wint_t __wunderflow (_IO_FILE *);
423: extern _IO_wint_t __wuflow (_IO_FILE *);
424: extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
425: #endif
426: 
427: #if  __GNUC__ >= 3
428: # define _IO_BE(expr, res) __builtin_expect ((expr), res)
429: #else
430: # define _IO_BE(expr, res) (expr)
431: #endif
432: 
433: #define _IO_getc_unlocked(_fp) \
434:        (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
435:         ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
436: #define _IO_peekc_unlocked(_fp) \
437:        (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
438:           && __underflow (_fp) == EOF ? EOF \
439:         : *(unsigned char *) (_fp)->_IO_read_ptr)
440: #define _IO_putc_unlocked(_ch, _fp) \
441:    (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \
442:     ? __overflow (_fp, (unsigned char) (_ch)) \
443:     : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
444: 
445: #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
446: # define _IO_getwc_unlocked(_fp) \
447:   (_IO_BE ((_fp)->_wide_data == NULL                                    \
448:            || ((_fp)->_wide_data->_IO_read_ptr                          \
449:                >= (_fp)->_wide_data->_IO_read_end), 0)                  \
450:    ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++)
451: # define _IO_putwc_unlocked(_wch, _fp) \
452:   (_IO_BE ((_fp)->_wide_data == NULL                                    \
453:            || ((_fp)->_wide_data->_IO_write_ptr                         \
454:                >= (_fp)->_wide_data->_IO_write_end), 0)                 \
455:    ? __woverflow (_fp, _wch)                                            \
456:    : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))
457: #endif
458: 
459: #define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
460: #define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
461: 
462: extern int _IO_getc (_IO_FILE *__fp);
463: extern int _IO_putc (int __c, _IO_FILE *__fp);
464: extern int _IO_feof (_IO_FILE *__fp) __THROW;
465: extern int _IO_ferror (_IO_FILE *__fp) __THROW;
466: 
467: extern int _IO_peekc_locked (_IO_FILE *__fp);
468: 
469: 
470: #define _IO_PENDING_OUTPUT_COUNT(_fp)   \
471:         ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)
472: 
473: extern void _IO_flockfile (_IO_FILE *) __THROW;
474: extern void _IO_funlockfile (_IO_FILE *) __THROW;
475: extern int _IO_ftrylockfile (_IO_FILE *) __THROW;
476: 
477: #ifdef _IO_MTSAFE_IO
478: # define _IO_peekc(_fp) _IO_peekc_locked (_fp)
479: # define _IO_flockfile(_fp) \
480:   if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp)
481: # define _IO_funlockfile(_fp) \
482:   if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)
483: #else
484: # define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)
485: # define _IO_flockfile(_fp) 
486: 
487: # define _IO_ftrylockfile(_fp) 
488: 
489: # define _IO_cleanup_region_end(_Doit) 
490: 
491: 
492: extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
493:                         _IO_va_list, int *__restrict);
494: extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
495:                          _IO_va_list);
496: extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t);
497: extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t);
498: 
499: extern _IO_off64_t _IO_seekoff (_IO_FILE *, _IO_off64_t, int, int);
500: extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int);
501: 
502: extern void _IO_free_backup_area (_IO_FILE *) __THROW;
503: 
504: #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
505: extern _IO_wint_t _IO_getwc (_IO_FILE *__fp);
506: extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp);
507: extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW;
508: # if __GNUC__ >= 2
509: 
510: 
511: #  if defined _LIBC && defined SHARED
512: #   include <shlib-compat.h>
513: #   if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
514: #    define _IO_fwide_maybe_incompatible \
515:   (__builtin_expect (&_IO_stdin_used == NULL, 0))
516: extern const int _IO_stdin_used;
517: weak_extern (_IO_stdin_used);
518: #   endif
519: #  endif
520: #  ifndef _IO_fwide_maybe_incompatible
521: #   define _IO_fwide_maybe_incompatible (0)
522: #  endif
523: 
524: 
525: #  define _IO_fwide(__fp, __mode) \
526:   ({ int __result = (__mode);                                                 \
527:      if (__result < 0 && ! _IO_fwide_maybe_incompatible)                      \
528:        {                                                                      \
529:          if ((__fp)->_mode == 0)                                              \
530:                      \
531:            (__fp)->_mode = -1;                                                \
532:          __result = (__fp)->_mode;                                            \
533:        }                                                                      \
534:      else if (__builtin_constant_p (__mode) && (__mode) == 0)                 \
535:        __result = _IO_fwide_maybe_incompatible ? -1 : (__fp)->_mode;          \
536:      else                                                                     \
537:        __result = _IO_fwide (__fp, __result);                                 \
538:      __result; })
539: # endif
540: 
541: extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict,
542:                          _IO_va_list, int *__restrict);
543: extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict,
544:                           _IO_va_list);
545: extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t);
546: extern void _IO_free_wbackup_area (_IO_FILE *) __THROW;
547: #endif
548: 
549: #ifdef __LDBL_COMPAT
550: # include <bits/libio-ldbl.h>
551: #endif
552: 
553: #ifdef __cplusplus
554: }
555: #endif
556: 
557: #endif 
558: 
      
      
      
      
   
      
      
         
            
            © Andrew Scott 2006 -
            2025, 
            All Rights Reserved