Skip to content

Commit bfb5e93

Browse files
authored
Merge pull request RustPython#3673 from fanninpm/more-termios-constants
Add some platform-dependent constants to termios
2 parents 4c0d49d + 4cd59d5 commit bfb5e93

File tree

1 file changed

+150
-8
lines changed

1 file changed

+150
-8
lines changed

stdlib/src/termios.rs

Lines changed: 150 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,159 @@ mod termios {
1010
use termios::Termios;
1111

1212
// TODO: more ioctl numbers
13+
// NOTE: B2500000, B3000000, B3500000, B4000000, and CIBAUD
14+
// are only available on specific architectures
15+
// TODO: supply these from <sys/ttydefaults.h> (please file an issue/PR upstream):
16+
// CDEL, CDSUSP, CEOF, CEOL, CEOL2, CEOT, CERASE, CESC, CFLUSH, CINTR, CKILL, CLNEXT,
17+
// CNUL, COMMON, CQUIT, CRPRNT, CSTART, CSTOP, CSUSP, CSWTCH, CWERASE
18+
// NOTE: the constant INIT_C_CC is most likely missing nowadays
19+
// TODO: supply these from <asm-generic/ioctl.h> (please file an issue/PR upstream):
20+
// IOCSIZE_MASK, IOCSIZE_SHIFT
21+
// TODO: supply NCC from <asm-generic/termios.h> (please file an issue/PR upstream)
22+
// NOTE: I have only found NSWTCH on cygwin, so please alert the RustPython maintainers if it
23+
// is present on your system
24+
// TODO: supply these from <bits/ioctl-types.h> or <linux/tty.h> (please file an issue/PR
25+
// upstream):
26+
// N_MOUSE, N_PPP, N_SLIP, N_STRIP, N_TTY
27+
// NOTE: some of these have incomplete coverage in rust libc (please file an issue/PR upstream)
28+
// TODO: possibly supply these from <asm-generic/ioctls.h> (please file an issue/PR upstream):
29+
// TCSBRKP, TIOCGICOUNT, TIOCGLCKTRMIOS, TIOCSERCONFIG, TIOCSERGETLSR, TIOCSERGETMULTI,
30+
// TIOCSERGSTRUCT, TIOCSERGWILD, TIOCSERSETMULTI, TIOCSERSWILD, TIOCSER_TEMT,
31+
// TIOCSLCKTRMIOS, TIOCSSERIAL, TIOCTTYGSTRUCT
32+
#[cfg(any(target_os = "illumos", target_os = "solaris"))]
1333
#[pyattr]
14-
use libc::{TIOCGWINSZ, TIOCSWINSZ};
34+
use libc::{CSTART, CSTOP, CSWTCH};
35+
#[cfg(any(
36+
target_os = "dragonfly",
37+
target_os = "freebsd",
38+
target_os = "macos",
39+
target_os = "netbsd",
40+
target_os = "openbsd"
41+
))]
42+
#[pyattr]
43+
use libc::{FIOASYNC, TIOCGETD, TIOCSETD};
44+
#[pyattr]
45+
use libc::{FIOCLEX, FIONBIO, TIOCGWINSZ, TIOCSWINSZ};
46+
#[cfg(any(
47+
target_os = "android",
48+
target_os = "dragonfly",
49+
target_os = "freebsd",
50+
target_os = "linux",
51+
target_os = "macos",
52+
target_os = "netbsd",
53+
target_os = "openbsd"
54+
))]
55+
#[pyattr]
56+
use libc::{
57+
FIONCLEX, FIONREAD, TIOCEXCL, TIOCMBIC, TIOCMBIS, TIOCMGET, TIOCMSET, TIOCM_CAR, TIOCM_CD,
58+
TIOCM_CTS, TIOCM_DSR, TIOCM_DTR, TIOCM_LE, TIOCM_RI, TIOCM_RNG, TIOCM_RTS, TIOCM_SR,
59+
TIOCM_ST, TIOCNXCL, TIOCSCTTY,
60+
};
61+
#[cfg(any(target_os = "android", target_os = "linux"))]
62+
#[pyattr]
63+
use libc::{
64+
IBSHIFT, TCFLSH, TCGETA, TCGETS, TCSBRK, TCSETA, TCSETAF, TCSETAW, TCSETS, TCSETSF,
65+
TCSETSW, TCXONC, TIOCGSERIAL, TIOCGSOFTCAR, TIOCINQ, TIOCLINUX, TIOCSSOFTCAR, XTABS,
66+
};
67+
#[cfg(any(
68+
target_os = "android",
69+
target_os = "dragonfly",
70+
target_os = "freebsd",
71+
target_os = "linux",
72+
target_os = "macos"
73+
))]
74+
#[pyattr]
75+
use libc::{TIOCCONS, TIOCGPGRP, TIOCOUTQ, TIOCSPGRP, TIOCSTI};
76+
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "macos"))]
77+
#[pyattr]
78+
use libc::{
79+
TIOCNOTTY, TIOCPKT, TIOCPKT_DATA, TIOCPKT_DOSTOP, TIOCPKT_FLUSHREAD, TIOCPKT_FLUSHWRITE,
80+
TIOCPKT_NOSTOP, TIOCPKT_START, TIOCPKT_STOP,
81+
};
82+
#[cfg(any(
83+
target_os = "android",
84+
target_os = "freebsd",
85+
target_os = "illumos",
86+
target_os = "linux",
87+
target_os = "macos",
88+
target_os = "openbsd",
89+
target_os = "solaris"
90+
))]
91+
#[pyattr]
92+
use termios::os::target::TAB3;
93+
#[cfg(any(
94+
target_os = "dragonfly",
95+
target_os = "freebsd",
96+
target_os = "macos",
97+
target_os = "netbsd",
98+
target_os = "openbsd"
99+
))]
100+
#[pyattr]
101+
use termios::os::target::TCSASOFT;
102+
#[cfg(any(target_os = "android", target_os = "linux"))]
103+
#[pyattr]
104+
use termios::os::target::{
105+
B1000000, B1152000, B1500000, B2000000, B2500000, B3000000, B3500000, B4000000, B500000,
106+
B576000, CBAUDEX,
107+
};
108+
#[cfg(any(
109+
target_os = "android",
110+
target_os = "freebsd",
111+
target_os = "illumos",
112+
target_os = "linux",
113+
target_os = "netbsd",
114+
target_os = "solaris"
115+
))]
116+
#[pyattr]
117+
use termios::os::target::{B460800, B921600};
118+
#[cfg(any(
119+
target_os = "android",
120+
target_os = "illumos",
121+
target_os = "linux",
122+
target_os = "macos",
123+
target_os = "solaris"
124+
))]
125+
#[pyattr]
126+
use termios::os::target::{
127+
BS0, BS1, BSDLY, CR0, CR1, CR2, CR3, CRDLY, FF0, FF1, FFDLY, NL0, NL1, NLDLY, OFDEL, OFILL,
128+
TAB1, TAB2, VT0, VT1, VTDLY,
129+
};
130+
#[cfg(any(
131+
target_os = "android",
132+
target_os = "illumos",
133+
target_os = "linux",
134+
target_os = "solaris"
135+
))]
136+
#[pyattr]
137+
use termios::os::target::{CBAUD, CIBAUD, IUCLC, OLCUC, XCASE};
138+
#[cfg(any(
139+
target_os = "android",
140+
target_os = "freebsd",
141+
target_os = "illumos",
142+
target_os = "linux",
143+
target_os = "macos",
144+
target_os = "solaris"
145+
))]
146+
#[pyattr]
147+
use termios::os::target::{TAB0, TABDLY};
148+
#[cfg(any(target_os = "android", target_os = "linux"))]
149+
#[pyattr]
150+
use termios::os::target::{VSWTC, VSWTC as VSWTCH};
151+
#[cfg(any(target_os = "illumos", target_os = "solaris"))]
152+
#[pyattr]
153+
use termios::os::target::{VSWTCH, VSWTCH as VSWTC};
15154
#[pyattr]
16155
use termios::{
17-
os::target::NCCS, B0, B110, B1200, B134, B150, B1800, B19200, B200, B2400, B300, B38400,
18-
B4800, B50, B600, B75, B9600, BRKINT, CLOCAL, CREAD, CS5, CS6, CS7, CS8, CSIZE, CSTOPB,
19-
ECHO, ECHOE, ECHOK, ECHONL, HUPCL, ICANON, ICRNL, IEXTEN, IGNBRK, IGNCR, IGNPAR, INLCR,
20-
INPCK, ISIG, ISTRIP, IXANY, IXOFF, IXON, NOFLSH, OCRNL, ONLCR, ONLRET, ONOCR, OPOST,
21-
PARENB, PARMRK, PARODD, TCIFLUSH, TCIOFF, TCIOFLUSH, TCION, TCOFLUSH, TCOOFF, TCOON,
22-
TCSADRAIN, TCSAFLUSH, TCSANOW, TOSTOP, VEOF, VEOL, VERASE, VINTR, VKILL, VMIN, VQUIT,
23-
VSTART, VSTOP, VSUSP, VTIME,
156+
os::target::{
157+
B115200, B230400, B57600, CRTSCTS, ECHOCTL, ECHOKE, ECHOPRT, EXTA, EXTB, FLUSHO,
158+
IMAXBEL, NCCS, PENDIN, VDISCARD, VEOL2, VLNEXT, VREPRINT, VWERASE,
159+
},
160+
B0, B110, B1200, B134, B150, B1800, B19200, B200, B2400, B300, B38400, B4800, B50, B600,
161+
B75, B9600, BRKINT, CLOCAL, CREAD, CS5, CS6, CS7, CS8, CSIZE, CSTOPB, ECHO, ECHOE, ECHOK,
162+
ECHONL, HUPCL, ICANON, ICRNL, IEXTEN, IGNBRK, IGNCR, IGNPAR, INLCR, INPCK, ISIG, ISTRIP,
163+
IXANY, IXOFF, IXON, NOFLSH, OCRNL, ONLCR, ONLRET, ONOCR, OPOST, PARENB, PARMRK, PARODD,
164+
TCIFLUSH, TCIOFF, TCIOFLUSH, TCION, TCOFLUSH, TCOOFF, TCOON, TCSADRAIN, TCSAFLUSH, TCSANOW,
165+
TOSTOP, VEOF, VEOL, VERASE, VINTR, VKILL, VMIN, VQUIT, VSTART, VSTOP, VSUSP, VTIME,
24166
};
25167

26168
#[pyfunction]

0 commit comments

Comments
 (0)