source: trunk/third/nmh/sbr/discard.c @ 12455

Revision 12455, 1.0 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12454, which included commits to RCS files with non-trunk default branches.
Line 
1
2/*
3 * discard.c -- discard output on a file pointer
4 *
5 * $Id: discard.c,v 1.1.1.1 1999-02-07 18:14:08 danw Exp $
6 */
7
8#include <h/mh.h>
9
10#ifdef HAVE_TERMIOS_H
11# include <termios.h>
12#else
13# ifdef HAVE_TERMIO_H
14#  include <termio.h>
15# else
16#  include <sgtty.h>
17# endif
18#endif
19
20#ifdef SCO_5_STDIO
21# define _ptr  __ptr
22# define _cnt  __cnt
23# define _base __base
24# define _filbuf(fp)  ((fp)->__cnt = 0, __filbuf(fp))
25#endif
26
27
28void
29discard (FILE *io)
30{
31#ifndef HAVE_TERMIOS_H
32# ifdef HAVE_TERMIO_H
33    struct termio tio;
34# else
35    struct sgttyb tio;
36# endif
37#endif
38
39    if (io == NULL)
40        return;
41
42#ifdef HAVE_TERMIOS_H
43    tcflush (fileno(io), TCOFLUSH);
44#else
45# ifdef HAVE_TERMIO_H
46    if (ioctl (fileno(io), TCGETA, &tio) != -1)
47        ioctl (fileno(io), TCSETA, &tio);
48# else
49    if (ioctl (fileno(io), TIOCGETP, (char *) &tio) != -1)
50        ioctl (fileno(io), TIOCSETP, (char *) &tio);
51# endif
52#endif
53
54#ifdef _FSTDIO
55    fpurge (io);
56#else
57# ifdef LINUX_STDIO
58    io->_IO_write_ptr = io->_IO_write_base;
59# else
60    if ((io->_ptr = io->_base))
61        io->_cnt = 0;
62# endif
63#endif
64}
65
Note: See TracBrowser for help on using the repository browser.