stdio.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. #define BUFSIZ 1024
  6. #define _NFILES 20
  7. #define NULL 0
  8. #define EOF (-1)
  9. #define CMASK 0377
  10. #define IO_READMODE 1
  11. #define IO_WRITEMODE 2
  12. #define IO_UNBUFF 4
  13. #define IO_EOF 8
  14. #define IO_ERR 16
  15. #define IO_MYBUF 32
  16. #define IO_PERPRINTF 64
  17. #ifndef FILE
  18. extern struct _io_buf {
  19. int _fd;
  20. int _count;
  21. int _flags;
  22. unsigned char *_buf;
  23. unsigned char *_ptr;
  24. } *_io_table[_NFILES], _stdin, _stdout, _stderr;
  25. #endif /* FILE */
  26. #define FILE struct _io_buf
  27. #define stdin (&_stdin)
  28. #define stdout (&_stdout)
  29. #define stderr (&_stderr)
  30. #define getchar() getc(stdin)
  31. #define putchar(c) putc(c,stdout)
  32. #define getc(p) (--(p)->_count >= 0 ? (int) (*(p)->_ptr++) : \
  33. _fillbuf(p))
  34. #define putc(c, p) (--(p)->_count >= 0 ? \
  35. (int) (*(p)->_ptr++ = (c)) : \
  36. _flushbuf((c),(p)))
  37. #define feof(p) (((p)->_flags & IO_EOF) != 0)
  38. #define ferror(p) (((p)->_flags & IO_ERR) != 0)
  39. #define fileno(p) ((p)->_fd)
  40. #define io_testflag(p,x) ((p)->_flags & (x))
  41. /* If you want a stream to be flushed after each printf use:
  42. *
  43. * io_perprintf(stream);
  44. *
  45. * If you want to stop with this kind of buffering use:
  46. *
  47. * io_noperprintf(stream);
  48. */
  49. #define io_noperprintf(p) ((p)->_flags &= ~IO_PERPRINTF)
  50. #define io_perprintf(p) ((p)->_flags |= IO_PERPRINTF)
  51. extern FILE *fopen(), *fdopen(), *freopen(), *popen();
  52. extern long ftell();
  53. extern setbuf(), rewind();
  54. extern char *fgets(), *gets();