home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gccdist / gcc / include / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-20  |  3.4 KB  |  122 lines

  1. /*
  2.  *    This defines a VAX-11 "C" runtime compatible stdio interface
  3.  */
  4. #ifndef __STDIO_DEFINED
  5. #define __STDIO_DEFINED
  6.  
  7. #include <sys/types.h>
  8.  
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12.  
  13. /*
  14.  *    The maximum number of files we can have open at a time
  15.  */
  16. #define _NFILE 20
  17.  
  18. /*
  19.  *    STDIO buffer size (sure wish it could be 1Kb)
  20.  */
  21. #ifndef BUFSIZ
  22. #define BUFSIZ 512
  23. #endif
  24. /*
  25.  *    This is what the VAX-11 "C" runtime stdio FILE structure looks like
  26.  */
  27. struct    _iobuf     {
  28.     int    _cnt;            /* # of characters in the buffer */
  29.     char    *_ptr;            /* Pointer into the buffer     */
  30.     char    *_base;            /* Pointer to start of buffer     */
  31.     char    _flag;            /* STDIO flags             */
  32. #define    _IOREAD        01            /* Open for reading     */
  33. #define    _IOWRT        02            /* Open for writing     */
  34. #define    _IONBF        04            /* No buffer         */
  35. #define    _IOMYBUF    010            /* Using "my" buffer     */
  36. #define    _IOEOF        020            /* At End Of File     */
  37. #define    _IOERR        040            /* I/O error has occured */
  38. #define    _IOSTRG        0100            /* Doing I/O to a string */
  39. #define    _IORW        0200            /* Open for read/write     */
  40.     char    _file;            /* File descriptor         */
  41.     };
  42.  
  43. /*
  44.  *    Instead of passing around pointers to _iobuf structures, VAX-11 "C"
  45.  *    passes around pointers to pointers.
  46.  */
  47. typedef struct _iobuf *FILE;
  48. typedef struct {unsigned : 32; unsigned : 32;} fpos_t;
  49.  
  50. /*
  51.  *    Also, stdin/stdout/stderr need to be defined
  52.  *    [We also use a hack here that makes the GCC assembler modify
  53.  *     the psect attributes to match those of the VAX-11 "C" runtime]
  54.  */
  55. extern FILE *stdin __asm("_$$PsectAttributes_NOSHR$$stdin");
  56. extern FILE *stdout __asm("_$$PsectAttributes_NOSHR$$stdout");
  57. extern FILE *stderr __asm("_$$PsectAttributes_NOSHR$$stderr");
  58.  
  59. /*
  60.  *    Define NULL and EOF
  61.  */
  62. #ifndef NULL  /* in case stddef.h defines it */
  63. #define    NULL        0
  64. #endif
  65. #define    EOF        (-1)
  66.  
  67. /*
  68.  *    Define the stdio macros
  69.  */
  70. #define getc(p)        fgetc(p)
  71. #define getchar()    fgetc(stdin)
  72. #define putc(x,p)    fputc(x,p)
  73. #define putchar(x)    fputc(x,stdout)
  74. #define feof(p)        (((*p)->_flag&_IOEOF)!=0)
  75. #define ferror(p)    (((*p)->_flag&_IOERR)!=0)
  76. #define fileno(p)    ((*p)->_file)
  77. #define clearerr(p)    ((*p)->_flag &= ~(_IOERR|_IOEOF))
  78. /*
  79.  *    Declare stdio routines
  80.  */
  81. extern    int    fclose(FILE*);
  82. extern    FILE*  fdopen(int, const char*);
  83. extern    int    fflush(FILE*);
  84. extern    int    fgetc(FILE*);
  85. extern    char*  fgets(char*, int, FILE *);
  86. extern    FILE*  fopen(const char*, const char*);
  87. extern    int    fputc(int, FILE*);
  88. extern    int    fputs(const char*, FILE*);
  89. extern    size_t fread(void*, size_t, size_t, FILE*);
  90. extern    FILE*  freopen(const char*, const char*, FILE*, ...);
  91. extern    int    fscanf(FILE *, const char *, ...);
  92. extern    int    fseek(FILE*, long, int);
  93. extern    long   ftell(FILE *);
  94. extern    size_t fwrite(const void*, size_t, size_t, FILE*);
  95. extern    char*  gets(char*);
  96. extern    int    getw(FILE*);
  97. extern    int    pclose(FILE*);
  98. extern    void   perror(const char*);
  99. extern    FILE*  popen(const char*, const char*);
  100. extern    int    printf(const char*, ...);
  101. extern    int    puts(const char*);
  102. extern    int    putw(int, FILE*);
  103. extern    int    rewind(FILE*);
  104. extern    int    scanf(const char *, ...);
  105. extern    void   setbuf(FILE*, char*);
  106. extern    void   setbuffer(FILE*, char*, int);
  107. extern    int    setlinebuf(FILE*);
  108. extern    int    setvbuf(FILE*, char*, int, size_t);
  109. extern    int    sscanf(const char *, const char *, ...);
  110. extern    FILE*  tmpfile();
  111. extern    int    ungetc(int, FILE*);
  112.  
  113. extern    int    fprintf(FILE*, const char*, ...);
  114. extern    int    sprintf(char *, const char*, ...);
  115.  
  116.  
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120.  
  121. #endif    __STDIO_DEFINED
  122.