iolib.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. /*
  10. * pANS stdio -- definitions
  11. * The following names are defined in the pANS:
  12. * FILE fpos_t _IOFBF _IOLBF _IONBF
  13. * BUFSIZ EOF FOPEN_MAX FILENAME_MAX L_tmpnam
  14. * SEEK_CUR SEEK_END SEEK_SET TMP_MAX stderr
  15. * stdin stdout remove rename tmpfile
  16. * tmpnam fclose fflush fopen freopen
  17. * setbuf setvbuf fprintf fscanf printf
  18. * scanf sprintf sscanf vfprintf vprintf
  19. * vsprintf fgetc fgets fputc fputs
  20. * getc getchar gets putc putchar
  21. * puts ungetc fread fwrite fgetpos
  22. * fseek fsetpos ftell rewind clearerr
  23. * feof ferror perror
  24. *
  25. * (But plan9 version omits remove and rename, because they are in libc)
  26. */
  27. #include <u.h>
  28. #include <libc.h>
  29. #undef END
  30. #include "Stdio.h"
  31. /*
  32. * Flag bits
  33. */
  34. #define BALLOC 1 /* did stdio malloc fd->buf? */
  35. #define LINEBUF 2 /* is stream line buffered? */
  36. #define STRING 4 /* output to string, instead of file */
  37. #define APPEND 8 /* append mode output */
  38. /*
  39. * States
  40. */
  41. #define CLOSED 0 /* file not open */
  42. #define OPEN 1 /* file open, but no I/O buffer allocated yet */
  43. #define RDWR 2 /* open, buffer allocated, ok to read or write */
  44. #define RD 3 /* open, buffer allocated, ok to read but not write */
  45. #define WR 4 /* open, buffer allocated, ok to write but not read */
  46. #define ERR 5 /* open, but an uncleared error occurred */
  47. #define END 6 /* open, but at eof */
  48. int _IO_setvbuf(FILE *);
  49. /* half hearted attempt to make multi threaded */
  50. extern QLock _stdiolk;