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