summaryrefslogtreecommitdiff
path: root/LibC/termios.cpp
blob: be70fc668568fb4671f1b87c086f0eb1086e3f72 (plain)
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
43
44
45
46
47
48
49
50
51
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <termios.h>

extern "C" {

int tcgetattr(int fd, struct termios* t)
{
    return ioctl(fd, TCGETS, t);
}

int tcsetattr(int fd, int optional_actions, const struct termios* t)
{
    switch (optional_actions) {
    case TCSANOW:
        return ioctl(fd, TCSETS, t);
    case TCSADRAIN:
        return ioctl(fd, TCSETSW, t);
    case TCSAFLUSH:
        return ioctl(fd, TCSETSF, t);
    }
    errno = EINVAL;
    return -1;
}

int tcflow(int fd, int action)
{
    (void)fd;
    (void)action;
    ASSERT_NOT_REACHED();
}

int tcflush(int fd, int queue_selector)
{
    (void)fd;
    (void)queue_selector;
    ASSERT_NOT_REACHED();
}

speed_t cfgetispeed(const struct termios* tp)
{
    return tp->c_ispeed;
}

speed_t cfgetospeed(const struct termios* tp)
{
    return tp->c_ospeed;
}
}