home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / ANSI Headers / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-27  |  3.8 KB  |  134 lines  |  [TEXT/MMCC]

  1. /* stdio.h standard header */
  2. #ifndef _STDIO
  3. #define _STDIO
  4. #ifndef _YVALS
  5. #include <yvals.h>
  6. #endif
  7.  
  8. #if __MWERKS__
  9. #pragma options align=mac68k
  10. #endif
  11.  
  12.         /* macros */
  13. #ifndef NULL
  14. #define NULL         _NULL
  15. #endif
  16. #define _IOFBF        0
  17. #define _IOLBF        1
  18. #define _IONBF        2
  19. #if !__MWERKS__
  20. #define BUFSIZ        512
  21. #else
  22. #define BUFSIZ        4096
  23. #endif
  24. #define EOF            (-1)
  25. #define FILENAME_MAX    _FNAMAX
  26. #define FOPEN_MAX        _FOPMAX
  27. #define L_tmpnam        _TNAMAX
  28. #define TMP_MAX            32
  29. #define SEEK_SET    0
  30. #define SEEK_CUR    1
  31. #define SEEK_END    2
  32. #define stdin        (&_Stdin)
  33. #define stdout        (&_Stdout)
  34. #define stderr        (&_Stderr)
  35.         /* type definitions */
  36. #ifndef _SIZET
  37. #define _SIZET
  38. typedef _Sizet size_t;
  39. #endif
  40. typedef _Fpost fpos_t;
  41. typedef struct _Filet {
  42.     unsigned short _Mode;
  43.     short _Handle;
  44.     unsigned char *_Buf, *_Bend, *_Next;
  45.     unsigned char *_Rend, *_Wend, *_Rback;
  46.     _Wchart *_WRback, _WBack[2];
  47.     unsigned char *_Rsave, *_WRend, *_WWend;
  48.     struct _Mbstatet _Wstate;
  49.     char *_Tmpnam;
  50.     unsigned char _Back[2], _Cbuf;
  51.     } FILE;
  52.         /* declarations */
  53. _C_LIB_DECL
  54. extern FILE _Stdin, _Stdout, _Stderr;
  55. void clearerr(FILE *); int fclose(FILE *); int feof(FILE *);
  56. int ferror(FILE *); int fflush(FILE *); int fgetc(FILE *);
  57. int fgetpos(FILE *, fpos_t *);
  58. char *fgets(char *, int, FILE *);
  59. FILE *fopen(const char *, const char *);
  60. int fprintf(FILE *, const char *, ...);
  61. int fputc(int, FILE *); int fputs(const char *, FILE *);
  62. size_t fread(void *, size_t, size_t, FILE *);
  63. FILE *freopen(const char *, const char *, FILE *);
  64. int fscanf(FILE *, const char *, ...);
  65. int fseek(FILE *, long, int);
  66. int fsetpos(FILE *, const fpos_t *); long ftell(FILE *);
  67. size_t fwrite(const void *, size_t, size_t, FILE *);
  68. char *gets(char *);
  69. void perror(const char *); int printf(const char *, ...);
  70. int puts(const char *); int remove(const char *);
  71. int rename(const char *, const char *);
  72. void rewind(FILE *); int scanf(const char *, ...);
  73. void setbuf(FILE *, char *);
  74. int setvbuf(FILE *, char *, int, size_t);
  75. int sprintf(char *, const char *, ...);
  76. int sscanf(const char *, const char *, ...);
  77. FILE *tmpfile(void); char *tmpnam(char *);
  78. int ungetc(int, FILE *);
  79. int vfprintf(FILE *, const char *, _Va_list);
  80. int vprintf(const char *, _Va_list);
  81. int vsprintf(char *, const char *, _Va_list);
  82. long _Fgpos(FILE *, fpos_t *);
  83. int _Flocale(FILE *, const char *, int);
  84. void _Fsetlocale(FILE *, int);
  85. int _Fspos(FILE *, const fpos_t *, long, int);
  86. extern FILE *_Files[FOPEN_MAX];
  87. _END_C_LIB_DECL
  88. #ifdef __cplusplus
  89.         /* inlines, for C++ */
  90. inline int getc(FILE *_Str)  {return ((_Str->_Next
  91.     < _Str->_Rend ? *_Str->_Next++ : fgetc(_Str))); }
  92. inline int getchar()  {return ((_Files[0]->_Next
  93.     < _Files[0]->_Rend ? *_Files[0]->_Next++ : fgetc(_Files[0]))); }
  94. /*
  95. inline int putc(int _C, FILE *_Str)  {return ((_Str->_Next
  96.     < _Str->_Wend ? (*_Str->_Next++ = _C) : fputc(_C, _Str))); }
  97. inline int putchar(int _C)  {return ((_Files[1]->_Next
  98.     < _Files[1]->_Wend ? (*_Files[1]->_Next++ = _C)
  99.         : fputc(_C, _Files[1]))); }
  100. */
  101. #else
  102.         /* declarations and macro overrides, for C */
  103. int getc(FILE *); int getchar(void);
  104. int putc(int, FILE *); int putchar(int);
  105. #define getc(str)    ((str)->_Next < (str)->_Rend \
  106.     ? *(str)->_Next++ : (fgetc)(str))
  107. #define getchar()    (_Files[0]->_Next < _Files[0]->_Rend \
  108.     ? *_Files[0]->_Next++ : (fgetc)(_Files[0]))
  109. /*
  110. #define putc(c, str)    ((str)->_Next < (str)->_Wend \
  111.     ? (*(str)->_Next++ = c) : (fputc)(c, str))
  112. #define putchar(c)    (_Files[1]->_Next < _Files[1]->_Wend \
  113.     ? (*_Files[1]->_Next++ = c) : (fputc)(c, _Files[1]))
  114. */
  115. #endif /* __cplusplus */
  116.  
  117. #if __MWERKS__
  118. #pragma options align=reset
  119. #endif
  120.  
  121. #endif /* _STDIO */
  122.  
  123. /*
  124.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  125.  * Consult your license regarding permissions and restrictions.
  126.  */
  127.  
  128. /* Change log:
  129.  *94June04 PlumHall baseline
  130.  *94Sept30 Applied diffs for Thu Aug 25 23:13:15 1994
  131.  *94Oct07 Inserted MW changes.
  132.  *94Oct12mm Set MWs BUFSIZ to 4096
  133.  */
  134.