__fpurge.c 798 B

12345678910111213141516171819202122232425262728293031323334
  1. /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
  2. *
  3. * GNU Library General Public License (LGPL) version 2 or later.
  4. *
  5. * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
  6. */
  7. #include "_stdio.h"
  8. #include <stdio_ext.h>
  9. /* Solaris function --
  10. * Discard all buffered data whether reading or writing.
  11. */
  12. void __fpurge(register FILE * __restrict stream)
  13. {
  14. __STDIO_STREAM_VALIDATE(stream);
  15. __STDIO_STREAM_DISABLE_GETC(stream);
  16. __STDIO_STREAM_DISABLE_PUTC(stream);
  17. __STDIO_STREAM_INIT_BUFREAD_BUFPOS(stream);
  18. stream->__ungot[1] = 0;
  19. #ifdef __STDIO_MBSTATE
  20. __INIT_MBSTATE(&(stream->__state));
  21. #endif
  22. #ifdef __UCLIBC_HAS_WCHAR__
  23. stream->__ungot_width[0] = 0;
  24. #endif
  25. stream->__modeflags &= ~(__MASK_READING|__FLAG_WRITING);
  26. __STDIO_STREAM_VALIDATE(stream);
  27. }