blob: c17ecf4c0c7c17702ad969b52383b627eb95b319 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* 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
8#include "_stdio.h"
9#include <stdio_ext.h>
10
11/* Solaris function --
12 * Discard all buffered data whether reading or writing.
13 */
14
15void __fpurge(register FILE * __restrict stream)
16{
17 __STDIO_STREAM_VALIDATE(stream);
18
19 __STDIO_STREAM_DISABLE_GETC(stream);
20 __STDIO_STREAM_DISABLE_PUTC(stream);
21 __STDIO_STREAM_INIT_BUFREAD_BUFPOS(stream);
22 stream->__ungot[1] = 0;
23
24#ifdef __STDIO_MBSTATE
25 __INIT_MBSTATE(&(stream->__state));
26#endif
27#ifdef __UCLIBC_HAS_WCHAR__
28 stream->__ungot_width[0] = 0;
29#endif
30
31 stream->__modeflags &= ~(__MASK_READING|__FLAG_WRITING);
32
33 __STDIO_STREAM_VALIDATE(stream);
34}