home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / newlibs / cclib.lzh / stdio.h < prev    next >
C/C++ Source or Header  |  1989-09-25  |  4KB  |  174 lines

  1. #ifndef STDIO_H
  2. #define STDIO_H 1
  3.  
  4. #ifndef NULL
  5. #define NULL 0L
  6. #endif
  7. #define EOF -1
  8.  
  9. /* size of the buffer for buffered files... */
  10. #define BUFSIZ 1024L
  11.  
  12. #define _BUSY (1<<0)
  13. #define _ALLBUF (1<<1)
  14. #define _DIRTY (1<<2)
  15. #define _EOF (1<<3)
  16. #define _IOERR (1<<4)
  17. #define _TEMP (1<<5)
  18.  
  19. /* Flags for setvbuf */
  20. #define _IOFBF 1L
  21. #define _IOLBF 2L
  22. #define _IONBF 3L
  23. /* errors from setvbuf */
  24. #define HASBUF 1L
  25. #define NOBUFMEM 2L
  26.  
  27. /* seek positions */
  28. #define SEEK_SET 0L
  29. #define SEEK_CUR 1L
  30. #define SEEK_END 2L
  31.  
  32. typedef struct
  33. {
  34. long _unit;        /* token returned by open -> FileDesc */
  35. char *_bp;        /* position in character buffer */
  36. char *_bend;        /* end of buffer */
  37. char *_buff;        /* start */
  38. char _flags;        /* open mode  */
  39. char _bytbuf;        /* single character buffer (non-bufered files) */
  40. short _buflen;        /* # characters in buffer */
  41. char *_tmpname;     /* temporary file name */
  42. } FILE;
  43.  
  44. extern FILE *stdin, *stdout, *stderr;
  45.  
  46. /* use function calls instead, if NOMACROS is defined */
  47. #ifndef NOMACROS
  48. #define getchar() agetc(stdin)
  49. #define putchar(c) aputc(c, stdout)
  50. #else
  51. short getchar();
  52. short putchar();
  53. #endif
  54.  
  55. /* macros... */
  56. #define feof(STREAM) ( ((FILE *)STREAM)->_flags&_EOF )
  57. #define ferror(STREAM) ( ((FILE *)STREAM)->_flags&_IOERR )
  58. #define clearerr(STREAM) ( ((FILE *)STREAM)->_flags &= ~(_IOERR|_EOF) )
  59. #define fileno(STREAM) ( ((FILE *)STREAM)->_unit )
  60. #define rewind(STREAM) (fseek((FILE *)STREAM, 0L, SEEK_SET))
  61. #define remove(NAME) ( unlink((char *)NAME) )
  62. #define setbuf(STREAM,BUFFER)\
  63.  (setvbuf(STREAM,BUFFER,BUFFER ? _IOFBF : _IONBF,BUFSIZ))
  64. #define fgetc(STREAM) ((int)agetc(STREAM))
  65. #define fputc(CH,STREAM) ((int)aputc((int)CH,STREAM))
  66.  
  67. /* The name of the C DLL is here. */
  68. #define CCLIBNAME "CClib.library"
  69.  
  70. /* The only practical limit to the number of
  71.  * opened files is the amount of memory in the
  72.  * computer.
  73.  */
  74. #define FOPEN_MAX 2147483647L
  75.  
  76. /* the length of a temporary file name */
  77. #define L_tmpnam    30
  78. #define TMP_MAX FOPEN_MAX
  79.  
  80. /* The theoretical maximum of the number of
  81.  * characters in a file is 107 but the current
  82.  * limit is set to 30. This doesn't include
  83.  * the path name.
  84.  */
  85. #define FILENAME_MAX 107
  86.  
  87. typedef unsigned long size_t;
  88. typedef long fpos_t;
  89.  
  90. #ifdef ANSIC
  91.  
  92. #ifndef STDARG_H
  93. #include "stdarg.h"
  94. #endif
  95.  
  96. FILE *fopen(char *,char *);
  97. FILE *freopen(char *, char *, FILE *);
  98. long fflush(FILE *);
  99. long fclose(FILE *);
  100. long unlink(char *);
  101. long rename(char *,char *);
  102. FILE *tmpfile(void);
  103. char *tmpnam(char *);
  104. long setvbuf(FILE *,char *,long,size_t);
  105. long fprintf(FILE *, char *, ...);
  106. long printf(char *, ...);
  107. long sprintf(char *, char *, ...);
  108. long vprintf(char *,va_list);
  109. long vfprintf(FILE *,char *,va_list);
  110. long vsprintf(char *,char *,va_list);
  111. long fscanf(FILE *, char *, ...);
  112. long scanf(char *, ...);
  113. long sscanf(char *, char *, ...);
  114. char *fgets(char *, long, FILE *);
  115. long fputs(char *, FILE *);
  116. short getc(FILE *);
  117. char *gets(char *);
  118. short putc(short ,FILE *);
  119. short aputc(short, FILE *);
  120. short agetc(FILE *);
  121. short puts(char *);
  122. short ungetc(short,FILE *);
  123. size_t fread(void *,size_t,size_t,FILE *);
  124. size_t fwrite(void *,size_t,size_t,FILE *);
  125. long fseek(FILE *,long,long);
  126. long ftell(FILE *);
  127. long fgetpos(FILE *,fpos_t *);
  128. long fsetpos(FILE *,fpos_t *);
  129. long perror(char *);
  130.  
  131.  
  132. #else
  133.  
  134. FILE *fopen();
  135. FILE *freopen();
  136. long fflush();
  137. long fclose();
  138. long unlink();
  139. long rename();
  140. FILE *tmpfile();
  141. char *tmpnam();
  142. long setvbuf();
  143. long fprintf();
  144. long printf();
  145. long sprintf();
  146. long vprintf();
  147. long vfprintf();
  148. long vsprintf();
  149. long fscanf();
  150. long scanf();
  151. long sscanf();
  152. char *fgets();
  153. long fputs();
  154. short getc();
  155. char *gets();
  156. short putc();
  157. short aputc();
  158. short agetc();
  159. short puts();
  160. short ungetc();
  161. size_t fread();
  162. size_t fwrite();
  163. long fseek();
  164. long ftell();
  165. long fgetpos();
  166. long fsetpos();
  167. long perror();
  168.  
  169.  
  170. #endif
  171.  
  172. #endif
  173.  
  174.