stdio.h 1.6 KB

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