home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c017 / 7.ddi / GPPLIB.ZIP / STDIO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-17  |  4.9 KB  |  152 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of GNU CC.
  7.  
  8. GNU CC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY.  No author or distributor
  10. accepts responsibility to anyone for the consequences of using it
  11. or for whether it serves any particular purpose or works at all,
  12. unless he says so in writing.  Refer to the GNU CC General Public
  13. License for full details.
  14.  
  15. Everyone is granted permission to copy, modify and redistribute
  16. GNU CC, but only under the conditions described in the
  17. GNU CC General Public License.   A copy of this license is
  18. supposed to have been given to you along with GNU CC so you
  19. can know your rights and responsibilities.  It should be in a
  20. file named COPYING.  Among other things, the copyright notice
  21. and this notice must be preserved on all copies.  
  22. */
  23.  
  24. /*
  25.  *  Please check the following before installing this file:
  26.  *
  27.  *  If you are running AT&T System V or similar systems in which
  28.  *  there is no _bufsiz field in _iobuf, then comment out the
  29.  *  #define HAVE_BUFSIZ line below.
  30.  *
  31.  *  Check whether your libc.a sprintf function returns
  32.  *  an int (as do most) versus a char* (BSD), and (un)comment
  33.  *  the corresponding SPRINTF_RETURNS_INT line.
  34.  *
  35.  *  Check the value of BUFSIZ against the one in your /usr/include/stdio.h.
  36.  *
  37.  *  Carefully check the fields and order of _iobuf declaration against
  38.  *  the one in your /usr/include/stdio.h. Xenix-based systems
  39.  *  may need some re-ordering of _iobuf. fields.
  40.  *
  41.  *  Note that some _IOXXX #defines may not be present in your 
  42.  *  /usr/include/stdio.h. This is ok, so long as the ones that
  43.  *  are present in both are set to the same values.
  44.  *
  45.  *  Some of the prototypes refer to functions that may not be
  46.  *  present in your libc.a. This is ok so long as you do not
  47.  *  actually call such functions.
  48.  *
  49.  */
  50.  
  51. #ifndef FILE
  52.  
  53. /* check and possibly comment out the following */
  54. #define HAVE_BUFSIZ 
  55. #define SPRINTF_RETURNS_INT
  56.  
  57. /* check and possibly redefine the following */
  58. #define BUFSIZ  1024            
  59.  
  60. extern  struct  _iobuf {
  61.     int      _cnt;
  62.     char*    _ptr;
  63.     char*    _base;
  64. #   ifdef HAVE_BUFSIZ
  65.     int     _bufsiz;
  66.     short   _flag;
  67. #   else
  68.     char    _flag;
  69. #   endif
  70.     char    _file;
  71. } _iob[];
  72.  
  73. #define FILE     struct _iobuf
  74.  
  75. #define _IOFBF    00000
  76. #define _IOREAD   00001
  77. #define _IOWRT    00002
  78. #define _IONBF    00004
  79. #define _IOMYBUF  00010
  80. #define _IOEOF    00020
  81. #define _IOERR    00040
  82. #define _IOSTRG   00100
  83. #define _IOLBF    00200
  84. #define _IORW     00400
  85. #define _IOAPPEND 01000
  86.  
  87. #define EOF       (-1)
  88.  
  89. #ifndef NULL
  90. #define NULL      0
  91. #endif
  92.  
  93. #define stdin     (&_iob[0])
  94. #define stdout    (&_iob[1])
  95. #define stderr    (&_iob[2])
  96.  
  97. #define getc(p) (--(p)->_cnt>=0?(int)(*(unsigned char*)(p)->_ptr++):_filbuf(p))
  98. #define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):_flsbuf((unsigned)(x),p))
  99.  
  100. #define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
  101. #define getchar()   getc(stdin)
  102. #define putchar(x)  putc(x,stdout)
  103. #define feof(p)     (((p)->_flag&_IOEOF)!=0)
  104. #define ferror(p)   (((p)->_flag&_IOERR)!=0)
  105. #define fileno(p)   ((p)->_file)
  106.  
  107. extern int    _doprnt(const char*, void*, FILE*);
  108. extern int    _doscan(FILE*, const char*, void*);
  109. extern int    _filbuf(FILE*);
  110. extern int    _flsbuf(unsigned, FILE*);
  111. extern int    fclose(FILE*);
  112. extern FILE*  fdopen(int, const char*);
  113. extern int    fflush(FILE*);
  114. extern int    fgetc(FILE*);
  115. extern char*  fgets(char*, int, FILE *);
  116. extern FILE*  fopen(const char*, const char*);
  117. extern int    fprintf(FILE*, const char* ...);
  118. extern int    fputc(int, FILE*);
  119. extern int    fputs(const char*, FILE*);
  120. extern int    fread(void*, int, int, FILE*);
  121. extern FILE*  freopen(const char*, const char*, FILE*);
  122. extern int    fscanf(FILE*, const char* ...);
  123. extern int    fseek(FILE*, long, int);
  124. extern long   ftell(FILE *);
  125. extern int    fwrite(const void*, int, int, FILE*);
  126. extern char*  gets(char*);
  127. extern int    getw(FILE*);
  128. extern int    pclose(FILE*);
  129. extern FILE*  popen(const char*, const char*);
  130. extern int    printf(const char* ...);
  131. extern void   puts(const char*);
  132. extern int    putw(int, FILE*);
  133. extern int    scanf(const char* ...);
  134. extern void   setbuf(FILE*, char*);
  135. extern void   setbuffer(FILE*, char*, int);
  136. extern void   setlinebuf(FILE*);
  137. extern void   setvbuf(FILE*, char*, int, int);
  138. extern int    sscanf(char*, const char* ...);
  139. extern FILE*  tmpfile();
  140. extern int    ungetc(int, FILE*);
  141. extern int    vfprintf(FILE*, const char*, void* ap);
  142. extern int    vprintf(const char*, void* ap);
  143. extern int    vsprintf(char*, const char*, void* ap);
  144.  
  145. #ifdef SPRINTF_RETURNS_INT
  146. extern int    sprintf(char*, const char* ...);
  147. #else
  148. extern char*  sprintf(char*, const char* ...);
  149. #endif
  150.  
  151. #endif // FILE
  152.