summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/tcflush.c
blob: 40d3c1e67ddd10f9efe6ecdc73b2efb1aefd18c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 *  tcflush() - POSIX 1003.1b 7.2.2 - Line Control Functions
 *
 *  COPYRIGHT (c) 1989-2010.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <sys/fcntl.h>
#include <termios.h>
#include <stdint.h>
#include <sys/ioccom.h>
#include <rtems/libio.h>
#include <rtems/libio_.h>
#include <rtems/seterr.h>

int tcflush( int fd, int which )
{
  int com;

  switch (which) {
  case TCIFLUSH:
    com = FREAD;
    break;
  case TCOFLUSH:
    com = FWRITE;
    break;
  case TCIOFLUSH:
    com = FREAD | FWRITE;
    break;
  default:
    rtems_set_errno_and_return_minus_one( EINVAL );
  }
  return ioctl( fd, TIOCFLUSH, &com );
}