]> diplodocus.org Git - nmh/blob - sbr/discard.c
Wrapped #include of config.h with #ifdef HAVE_CONFIG_H, just in case someone ever...
[nmh] / sbr / discard.c
1
2 /*
3 * discard.c -- discard output on a file pointer
4 *
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
8 */
9
10 #include <h/mh.h>
11
12 #include <termios.h>
13
14 #ifdef SCO_5_STDIO
15 # define _ptr __ptr
16 # define _cnt __cnt
17 # define _base __base
18 # define _filbuf(fp) ((fp)->__cnt = 0, __filbuf(fp))
19 #endif
20
21
22 void
23 discard (FILE *io)
24 {
25 if (io == NULL)
26 return;
27
28 tcflush (fileno(io), TCOFLUSH);
29
30 #if defined(_FSTDIO) || defined(__DragonFly__)
31 fpurge (io);
32 #else
33 # ifdef LINUX_STDIO
34 io->_IO_write_ptr = io->_IO_write_base;
35 # else
36 if ((io->_ptr = io->_base))
37 io->_cnt = 0;
38 # endif
39 #endif
40 }
41