]> diplodocus.org Git - nmh/blob - sbr/discard.c
Sigh. I put the documentation about the -tls switch in the long description,
[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 #ifdef HAVE_TERMIOS_H
13 # include <termios.h>
14 #else
15 # ifdef HAVE_TERMIO_H
16 # include <termio.h>
17 # else
18 # include <sgtty.h>
19 # endif
20 #endif
21
22 #ifdef SCO_5_STDIO
23 # define _ptr __ptr
24 # define _cnt __cnt
25 # define _base __base
26 # define _filbuf(fp) ((fp)->__cnt = 0, __filbuf(fp))
27 #endif
28
29
30 void
31 discard (FILE *io)
32 {
33 #ifndef HAVE_TERMIOS_H
34 # ifdef HAVE_TERMIO_H
35 struct termio tio;
36 # else
37 struct sgttyb tio;
38 # endif
39 #endif
40
41 if (io == NULL)
42 return;
43
44 #ifdef HAVE_TERMIOS_H
45 tcflush (fileno(io), TCOFLUSH);
46 #else
47 # ifdef HAVE_TERMIO_H
48 if (ioctl (fileno(io), TCGETA, &tio) != -1)
49 ioctl (fileno(io), TCSETA, &tio);
50 # else
51 if (ioctl (fileno(io), TIOCGETP, (char *) &tio) != -1)
52 ioctl (fileno(io), TIOCSETP, (char *) &tio);
53 # endif
54 #endif
55
56 #if defined(_FSTDIO) || defined(__DragonFly__)
57 fpurge (io);
58 #else
59 # ifdef LINUX_STDIO
60 io->_IO_write_ptr = io->_IO_write_base;
61 # else
62 if ((io->_ptr = io->_base))
63 io->_cnt = 0;
64 # endif
65 #endif
66 }
67