Last change
on this file was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.1 KB
|
Line | |
---|
1 | /* libc/sys/linux/termios.c - Terminal control */ |
---|
2 | |
---|
3 | /* Written 2000 by Werner Almesberger */ |
---|
4 | |
---|
5 | |
---|
6 | #include <errno.h> |
---|
7 | #include <sys/types.h> |
---|
8 | #include <sys/termios.h> |
---|
9 | #include <sys/ioctl.h> |
---|
10 | |
---|
11 | |
---|
12 | int |
---|
13 | tcgetattr(int fd,struct termios *termios_p) |
---|
14 | { |
---|
15 | return ioctl(fd,TCGETS,termios_p); |
---|
16 | } |
---|
17 | |
---|
18 | |
---|
19 | int |
---|
20 | tcsetattr(int fd,int optional_actions,const struct termios *termios_p) |
---|
21 | { |
---|
22 | int cmd; |
---|
23 | |
---|
24 | switch (optional_actions) { |
---|
25 | case TCSANOW: |
---|
26 | cmd = TCSETS; |
---|
27 | break; |
---|
28 | case TCSADRAIN: |
---|
29 | cmd = TCSETSW; |
---|
30 | break; |
---|
31 | case TCSAFLUSH: |
---|
32 | cmd = TCSETSF; |
---|
33 | break; |
---|
34 | default: |
---|
35 | errno = EINVAL; |
---|
36 | return -1; |
---|
37 | } |
---|
38 | return ioctl(fd,cmd,termios_p); |
---|
39 | } |
---|
40 | |
---|
41 | #if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 4 |
---|
42 | pid_t |
---|
43 | tcgetpgrp(int fd) |
---|
44 | { |
---|
45 | int p; |
---|
46 | |
---|
47 | if (ioctl(fd,TIOCGPGRP,&p) < 0) |
---|
48 | return (pid_t)-1; |
---|
49 | return (pid_t)p; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | int |
---|
54 | tcsetpgrp(int fd, pid_t pid) |
---|
55 | { |
---|
56 | int p = (int)pid; |
---|
57 | return ioctl(fd,TIOCSPGRP,&p); |
---|
58 | } |
---|
59 | #endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 4 */ |
---|
60 | |
---|
61 | int |
---|
62 | tcflow (int fd, int action) |
---|
63 | { |
---|
64 | return ioctl (fd, TCXONC, action); |
---|
65 | } |
---|
66 | |
---|
67 | int |
---|
68 | tcflush (int fd, int queue_selector) |
---|
69 | { |
---|
70 | return ioctl (fd, TCFLSH, queue_selector); |
---|
71 | } |
---|
72 | |
---|
Note: See
TracBrowser
for help on using the repository browser.