home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / mntinc16 / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-29  |  5.4 KB  |  188 lines

  1. /*
  2.  *
  3.  *    STDIO.H        Standard i/o include file
  4.  *
  5.  */
  6.  
  7. #ifndef _STDIO_H
  8. #define    _STDIO_H
  9.  
  10. #ifndef _COMPILER_H
  11. #include <compiler.h>
  12. #endif
  13.  
  14. #ifndef _SIZE_T
  15. #define _SIZE_T __SIZE_TYPEDEF__
  16. typedef _SIZE_T size_t;
  17. #endif
  18.  
  19. /*
  20.  *    CONSTANTS:
  21.  */
  22.  
  23. #define    _NFILE        (20)        /* maximum number of open streams */
  24. #define FOPEN_MAX    _NFILE
  25. #define    FILENAME_MAX    (128)        /* maximum filename size */
  26.  
  27. #ifndef NULL
  28. #define NULL        __NULL
  29. #endif
  30.  
  31. #define    BUFSIZ        ((size_t)1024)    /* default buffer size */
  32.             /* change here must be reflected in crt0.c too */
  33.  
  34. #define    EOF        (-1)        /* end-of-file indicator */
  35. #ifndef __STRICT_ANSI__
  36. # ifndef _POSIX_SOURCE
  37. #define    EOS        '\0'        /* end-of-string indicator */
  38. # endif
  39. #endif
  40.  
  41. #ifndef SEEK_SET
  42. /* lseek() origins */
  43. #define    SEEK_SET    0        /* from beginning of file */
  44. #define    SEEK_CUR    1        /* from current location */
  45. #define    SEEK_END    2        /* from end of file */
  46. #endif
  47.  
  48. /* FILE structure flags */
  49. #define    _IOREAD        0x0001        /* file may be read from */
  50. #define    _IOWRT        0x0002        /* file may be written to */
  51. #define    _IOBIN        0x0004        /* file is in "binary" mode */
  52. #define    _IODEV        0x0008        /* file is a character device */
  53. #define    _IORW        0x0080        /* file is open for update (r+w) */
  54. #define    _IOFBF        0x0100        /* i/o is fully buffered */
  55. #define    _IOLBF        0x0200        /* i/o is line buffered */
  56. #define    _IONBF        0x0400        /* i/o is not buffered */
  57. #define    _IOMYBUF    0x0800        /* standard buffer */
  58. #define    _IOEOF        0x1000        /* EOF has been reached */
  59. #define    _IOERR        0x4000        /* an error has occured */
  60. #define _IOSTRING    0x8000        /* really a string buffer   */
  61.  
  62. typedef    struct            /* FILE structure */
  63.     {
  64.     long        _cnt;        /* # of bytes in buffer */
  65.     unsigned char    *_ptr;        /* current buffer pointer */
  66.     unsigned char    *_base;        /* base of file buffer */
  67.     unsigned int    _flag;        /* file status flags */
  68.     int        _file;        /* file handle */
  69.     long        _bsiz;        /* buffer size */
  70.     unsigned char    _ch;        /* tiny buffer, for "unbuffered" i/o */
  71.     }
  72.     FILE;
  73.  
  74. /* object of type capable of recording uniquely every position in a file */
  75. typedef unsigned long fpos_t;
  76.  
  77. #define    L_tmpnam    128
  78. #define    TMP_MAX        100
  79.  
  80. extern    FILE    _iob[];
  81.  
  82. /* standard streams */
  83. #define stdin    (&_iob[0])
  84. #define stdout    (&_iob[1])
  85. #define stderr    (&_iob[2])
  86.  
  87. /* stream macros */
  88. #define clearerr(fp)    ((void) ((fp)->_flag &= ~(_IOERR|_IOEOF)))
  89. #define feof(fp)    ((fp)->_flag & _IOEOF)
  90. #define ferror(fp)    ((fp)->_flag & _IOERR)
  91. #define fileno(fp)    ((fp)->_file)
  92.  
  93.  
  94. /* function definitions */
  95.  
  96. __EXTERN int    remove    __PROTO((const char *));
  97. __EXTERN int    rename    __PROTO((const char *, const char *));
  98. __EXTERN char *    tmpnam    __PROTO((char *));
  99. __EXTERN FILE *    tmpfile    __PROTO((void));
  100.  
  101. __EXTERN int    fclose    __PROTO((FILE *));
  102. __EXTERN int    fflush    __PROTO((FILE *));
  103.  
  104. __EXTERN FILE *    fopen    __PROTO((const char *, const char *));
  105. __EXTERN FILE *    freopen    __PROTO((const char *, const char *, FILE *));
  106.  
  107. __EXTERN void    setbuf    __PROTO((FILE *, char *));
  108. __EXTERN int    setvbuf    __PROTO((FILE *, char *, int, size_t));
  109.  
  110. #ifdef __SRC__
  111. __EXTERN int    fscanf    __PROTO((FILE *, const char *, char *));
  112. __EXTERN int    scanf    __PROTO((const char *, char *));
  113. __EXTERN int     sscanf    __PROTO((const char *, const char *, int));
  114. #else
  115. __EXTERN int    fscanf    __PROTO((FILE *, const char *, ...));
  116. __EXTERN int    scanf    __PROTO((const char *, ...));
  117. __EXTERN int    sscanf    __PROTO((const char *, const char *, ...));
  118. #endif
  119.  
  120. __EXTERN int    fprintf    __PROTO((FILE *, const char *, ...));
  121. __EXTERN int    printf    __PROTO((const char *, ...));
  122. __EXTERN int    sprintf    __PROTO((char *, const char *, ...));
  123.  
  124. __EXTERN int     vfprintf __PROTO((FILE *, const char *, __VA_LIST__));
  125. __EXTERN int     vprintf     __PROTO((const char *, __VA_LIST__));
  126. __EXTERN int     vsprintf __PROTO((char *, const char *, __VA_LIST__));
  127.  
  128. __EXTERN int    fgetc    __PROTO((FILE *));
  129. __EXTERN char    *fgets    __PROTO((char *, int, FILE *));
  130. __EXTERN char    *gets    __PROTO((char *));
  131. __EXTERN int    fputc    __PROTO((int c, FILE *));
  132. __EXTERN int    fputs    __PROTO((const char *, FILE *));
  133. __EXTERN int    puts    __PROTO((const char *));
  134. __EXTERN int     fungetc    __PROTO((int, FILE *));
  135.  
  136. __EXTERN size_t    fread    __PROTO((void *, size_t, size_t, FILE *));
  137. __EXTERN size_t    fwrite    __PROTO((const void *, size_t, size_t, FILE *));
  138.  
  139. __EXTERN int    fgetpos    __PROTO((FILE *, fpos_t *));
  140. __EXTERN int    fsetpos    __PROTO((FILE *, fpos_t *));
  141.  
  142. __EXTERN int    fseek    __PROTO((FILE *, long, int));
  143. __EXTERN long    ftell    __PROTO((FILE *));
  144. __EXTERN void    rewind    __PROTO((FILE *));
  145.  
  146. __EXTERN void    perror    __PROTO((const char *));
  147.  
  148. #ifndef __STRICT_ANSI__
  149. __EXTERN FILE    *fdopen    __PROTO((int, const char *));
  150. __EXTERN FILE    *popen    __PROTO((const char *, const char *));
  151. __EXTERN int    pclose    __PROTO((FILE *));
  152.  
  153. # ifndef _POSIX_SOURCE
  154. __EXTERN void    _binmode    __PROTO((int));        /* ++jrb */
  155. __EXTERN long     getl    __PROTO((FILE *));
  156. __EXTERN long     putl    __PROTO((long, FILE *));
  157. __EXTERN short     getw    __PROTO((FILE *));
  158. __EXTERN short     putw    __PROTO((short, FILE *));
  159. # endif
  160.  
  161. #endif /* __STRICT_ANSI__ */
  162.  
  163.  
  164. /* aliases */
  165.  
  166. __EXTERN int    _filbuf    __PROTO((FILE *));    /* needed for getc */
  167.  
  168. #ifdef __GNUC_INLINE__
  169. #define getc(__fp) \
  170. ({   int __c; \
  171.     do { \
  172.     __c = (--__fp->_cnt >= 0) ? ((int)*__fp->_ptr++) : _filbuf(__fp); \
  173.     } while ((!(__fp->_flag & _IOBIN)) && (__c == '\r')); \
  174.     __c; \
  175. })
  176. #else
  177. #define    getc(fp)        fgetc(fp)
  178. #endif
  179.  
  180. #define    ungetc            fungetc
  181. #define    putc            fputc
  182. #define    getchar()        getc(stdin)
  183. #define    ungetchar(c)        fungetc((c),stdin)
  184. #define    putchar(c)        fputc((c),stdout)
  185.  
  186.  
  187. #endif /* _STDIO_H */
  188.