__towrite.c 458 B

123456789101112131415161718192021222324
  1. #include "stdio_impl.h"
  2. int __towrite(FILE *f)
  3. {
  4. f->mode |= f->mode-1;
  5. if (f->flags & (F_NOWR)) {
  6. f->flags |= F_ERR;
  7. return EOF;
  8. }
  9. /* Clear read buffer (easier than summoning nasal demons) */
  10. f->rpos = f->rend = 0;
  11. /* Activate write through the buffer. */
  12. f->wpos = f->wbase = f->buf;
  13. f->wend = f->buf + f->buf_size;
  14. return 0;
  15. }
  16. /* Link flush-on-exit code iff any stdio write functions are linked. */
  17. void __fflush_on_exit()
  18. {
  19. fflush(0);
  20. }