stdio.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* $Id$ */
  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. #ifndef _STDIO_H
  7. #define _STDIO_H
  8. #define BUFSIZ 1024
  9. #ifdef __vax
  10. #define _NBF 8
  11. #endif
  12. #ifdef __mc68020
  13. #define _NBF 8
  14. #endif
  15. #ifndef _NBF
  16. #define _NBF 1
  17. #endif
  18. #define _BUFSIZ (_NBF * BUFSIZ)
  19. #define _NFILES 20
  20. #define NULL 0
  21. #define EOF (-1)
  22. #define IO_READMODE 1
  23. #define IO_WRITEMODE 2
  24. #define IO_UNBUFF 4
  25. #define IO_EOF 8
  26. #define IO_ERR 16
  27. #define IO_MYBUF 32
  28. #define IO_PERPRINTF 64
  29. #ifndef FILE
  30. extern struct _io_buf {
  31. int _count;
  32. int _flags;
  33. unsigned char *_buf;
  34. unsigned char *_ptr;
  35. int _bufsiz;
  36. int _fd;
  37. } *_io_table[_NFILES], _stdin, _stdout, _stderr;
  38. #endif /* FILE */
  39. #define FILE struct _io_buf
  40. #define stdin (&_stdin)
  41. #define stdout (&_stdout)
  42. #define stderr (&_stderr)
  43. #define getchar() getc(stdin)
  44. #define putchar(c) putc(c,stdout)
  45. #define getc(p) (--(p)->_count >= 0 ? (int) (*(p)->_ptr++) : \
  46. _fillbuf(p))
  47. #define putc(c, p) (--(p)->_count >= 0 ? \
  48. (int) (*(p)->_ptr++ = (c)) : \
  49. _flushbuf((c),(p)))
  50. #define feof(p) (((p)->_flags & IO_EOF) != 0)
  51. #define ferror(p) (((p)->_flags & IO_ERR) != 0)
  52. #define fileno(p) ((p)->_fd)
  53. #define io_testflag(p,x) ((p)->_flags & (x))
  54. /* If you want a stream to be flushed after each printf use:
  55. *
  56. * io_perprintf(stream);
  57. *
  58. * If you want to stop with this kind of buffering use:
  59. *
  60. * io_noperprintf(stream);
  61. */
  62. #define io_noperprintf(p) ((p)->_flags &= ~IO_PERPRINTF)
  63. #define io_perprintf(p) ((p)->_flags |= IO_PERPRINTF)
  64. extern FILE *fopen(), *fdopen(), *freopen(), *popen();
  65. extern long ftell();
  66. extern setbuf(), rewind();
  67. extern char *fgets(), *gets();
  68. #endif /* _STDIO_H */