home *** CD-ROM | disk | FTP | other *** search
/ ANews 3 / AnewsCD3.iso / DP / Programmation / GCC / gcc_include / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-20  |  4.1 KB  |  116 lines

  1. /*    standard input output for ansic.library        */
  2. /*    (c)Copyright 1992 Davide Pasetto         */
  3.  
  4. #ifndef    _STDIO_H
  5. #define _STDIO_H
  6.  
  7. #include    <sys/types.h>
  8. #include    <sys/file.h>
  9.  
  10. /* FILE structure flags */
  11.  
  12. #define _IOREAD     0x0001        /* file may be read from */
  13. #define _IOWRT        0x0002        /* file may be written to */
  14. #define _IORW        0x0003        /* file may be read from and write to */
  15. #define _IOLAST        0x0004        /* last io was read:0 or write:1 */
  16.  
  17. #define _IOLBF        0x0008        /* i/o is line buffered */
  18. #define _IOMYBUF    0x0020        /* i/o is buffered */
  19. #define _IOFBF        _IOMYBUF    /* this is an alias */
  20.  
  21. #define _IOEOF        0x0040        /* EOF has been reached */
  22. #define _IOERR        0x0080        /* an error has occured */
  23.  
  24. #define _IOSTRG     0x0100        /* this is a dummy file from sscanf */
  25. #define _IOSMALLBUF    0x0200        /* i/o has small buffer */
  26. #define _IONBF          _IOSMALLBUF     /* i/o is not buffered */
  27.  
  28. typedef struct                    /* FILE structure for buffered I/O */
  29.     {
  30.     unsigned char    *_ptr;        /* current buffer pointer */
  31.     unsigned char    *_base;     /* base of file buffer */
  32.     unsigned int    _flag;        /* file status flags */
  33.     int                _cnt;        /* # of bytes in buffer */
  34.     int                _file;        /* file handle */
  35.     int                _bufsiz;    /* buffer size */
  36.     unsigned char   *_name;         /* if not NULL delete file */
  37.     unsigned char    _ch;        /* tiny buffer, for "unbuffered" i/o */
  38.     }
  39.     FILE;
  40.  
  41. /* standard defines */
  42.  
  43. #define EOF        -1        /* end of file indicator */
  44. #define BUFSIZ        1024        /* default buffer size */
  45. #define BUFSIZ_2    128        /* low memory default buffer size */
  46. #define EOS        0        /* end-of-string indicator */
  47. #define EXIT_FAILURE    20        /* failure return value for exit() */
  48. #define EXIT_SUCCESS    0        /* success return value for exit() */
  49. #define    FILENAME_MAX    30        /* actually max 30 chars on the amiga */
  50. #define FOPEN_MAX    50        /* this is the max level 1 file number */
  51.  
  52. #ifndef ERROR
  53. #define ERROR        -1        /* general error condition */
  54. #endif
  55.  
  56. #define    L_tmpnam    24        /* length of tmpname generated string */
  57. #define TMP_MAX        99999        /* max number of temporary file names */
  58.  
  59. /* lseek() origins */
  60.  
  61. #define SEEK_SET    0        /* from beginning of file */
  62. #define SEEK_CUR    1        /* from current location */
  63. #define SEEK_END    2        /* from end of file */
  64.  
  65. /* stdio functions prototypes */
  66.  
  67. #ifdef    __cplusplus
  68. extern "C" {
  69. #endif
  70.  
  71. extern    FILE    *stdin,*stdout,*stderr;
  72. extern    void    _exit();
  73. extern    FILE    *tmpfile(void);
  74. extern    FILE    *fopen(char *,char *),*fdopen(int,char *),*freopen(char *,char *,FILE *);
  75. extern    char    *gets(char *),*fgets(char *,int,FILE *);
  76. extern    int    _filbuf(FILE *),_flsbuf(int,FILE *);
  77. extern    int    getw(FILE *),puts(char *),putw(int,FILE *);
  78. extern    int    rename(char *,char *),setbuffer(FILE *,char *,int);
  79. extern    int    setlinebuf(FILE *),strout(int,char *,int,FILE *,int);
  80. extern    int    ungetc(int,FILE *),fputs(const char *,FILE *);
  81. extern    int    fread(void *,size_t,size_t,FILE *),fseek(FILE *,long,int);
  82. extern    int    fwrite(void *,size_t,size_t,FILE *),fclose(FILE *),fflush(FILE *);
  83. extern    void    perror(const char *),rewind(FILE *),setbuf(FILE *,char *);
  84. extern    long    ftell(FILE *);
  85. extern    char    *tmpnam();
  86.  
  87. extern    long    scanf(const char *,...),fscanf(FILE *,const char *,...),sscanf(const char *,const char *,...);
  88. extern    int        sprintf(char *,const char *,...),printf(const char *,...),fprintf(FILE *,const char *,...);
  89. extern    int        vfprintf(FILE *,const char *,char *);
  90. extern    int        vsprintf(char *,const char *,char *);
  91.  
  92. #ifdef    __cplusplus
  93. }
  94. #endif
  95.  
  96. /* stream macros */
  97.  
  98. #define clearerr(iop)    ((void) ((iop)->_flag &= ~(_IOERR|_IOEOF)))
  99. #define feof(iop)    ((iop)->_flag & _IOEOF)
  100. #define ferror(iop)    ((iop)->_flag & _IOERR)
  101. #define fileno(iop)    ((iop)->_file)
  102. #define fexists        access(f,0x00)
  103. #define exists(f)    access(f,0x00)
  104. #define fungetc        ungetc
  105. #define ungetchar(c)    ungetc((c),stdin)
  106. #define getc(iop)    fgetc(iop)
  107. #define getchar()    fgetc(stdin)
  108. #define    fgetc(iop)    ((!((iop)->_cnt) || ((iop)->_flag & _IOLAST)) ? _filbuf(iop) : (((iop)->_cnt)-- , *(((iop)->_ptr)++) & 0xff))
  109. #define putchar(c)    fputc((c),stdout)
  110. #define putc        fputc
  111. #define fputc(c,iop)    ((!(iop->_cnt) || !(iop->_flag & _IOLAST)) ? _flsbuf(c,iop) : (*((iop->_ptr)++) = c, (iop->_cnt)-- , 1))
  112. #define fgetpos(iop,p)    ((*p=ftell(iop))==-1 ? 1 : 0)
  113. #define    fsetpos(iop,p)    (fseek(iop,SEEK_SET,*p))
  114.  
  115. #endif    /* _STDIO_H */
  116.