Fix autoconf check for mailspool world write permission
[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 #include <termios.h>
11
12
13 void
14 discard(FILE *io)
15 {
16         if (io == NULL)
17                 return;
18
19         tcflush(fileno(io), TCOFLUSH);
20
21 #if defined(_FSTDIO) || defined(__DragonFly__)
22         fpurge(io);
23 #else
24 # ifdef LINUX_STDIO
25         io->_IO_write_ptr = io->_IO_write_base;
26 # else
27         if ((io->_ptr = io->_base))
28                 io->_cnt = 0;
29 # endif
30 #endif
31 }