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