1use libc::{c_int,pid_t};
4
5#[link(name = "c")]
6extern "C" {
7 pub fn tcgetattr(fd: c_int, termios_p: *mut ::os::target::termios) -> c_int;
8 pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios_p: *const ::os::target::termios) -> c_int;
9 pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int;
10 pub fn tcdrain(fd: c_int) -> c_int;
11 pub fn tcflush(fd: c_int, queue_selector: c_int) -> c_int;
12 pub fn tcflow(fd: c_int, action: c_int) -> c_int;
13 #[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
14 pub fn cfmakeraw(termios_p: *mut ::os::target::termios);
15 pub fn cfgetispeed(termios_p: *const ::os::target::termios) -> ::os::target::speed_t;
16 pub fn cfgetospeed(termios_p: *const ::os::target::termios) -> ::os::target::speed_t;
17 pub fn cfsetispeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int;
18 pub fn cfsetospeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int;
19 #[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
20 pub fn cfsetspeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int;
21 pub fn tcgetsid(fd: c_int) -> pid_t;
22}
23
24#[cfg(any(target_os = "solaris", target_os = "illumos"))]
25#[no_mangle]
26pub unsafe extern "C" fn cfmakeraw(termios: *mut ::os::target::termios) {
27 use ::os::target::{IMAXBEL, IGNBRK, BRKINT, PARMRK, ISTRIP, INLCR, IGNCR, ICRNL, IXON};
28 use ::os::target::{OPOST, ECHO, ECHONL, ICANON, ISIG, IEXTEN, CSIZE, PARENB, CS8};
29 use ::os::target::{VMIN, VTIME};
30
31 (*termios).c_iflag &= !(IMAXBEL | IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
33 (*termios).c_oflag &= !OPOST;
34 (*termios).c_lflag &= !(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
35 (*termios).c_cflag &= !(CSIZE | PARENB);
36 (*termios).c_cflag |= CS8;
37 (*termios).c_cc[VMIN] = 1;
38 (*termios).c_cc[VTIME] = 0;
39}
40
41#[cfg(any(target_os = "solaris", target_os = "illumos"))]
42#[no_mangle]
43pub unsafe extern "C" fn cfsetspeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int {
44 match cfsetispeed(termios_p, speed) {
45 0 => cfsetospeed(termios_p, speed),
46 err => err,
47 }
48}