termios-0.3.0/.gitignore01006440001750000175000000000024132021402750013375 0ustar0000000000000000/target /Cargo.lock termios-0.3.0/.travis.yml01006440001750000175000000000077132021402750013526 0ustar0000000000000000language: rust rust: - 1.0.0 - stable - beta - nightly termios-0.3.0/Cargo.toml.orig01006440001750000175000000000703132110673160014304 0ustar0000000000000000[package] name = "termios" version = "0.3.0" authors = ["David Cuddeback "] description = "Safe bindings for the termios library." license = "MIT" homepage = "https://github.com/dcuddeback/termios-rs" repository = "https://github.com/dcuddeback/termios-rs" documentation = "http://dcuddeback.github.io/termios-rs/termios/" readme = "README.md" keywords = ["termios", "tty", "terminal", "posix"] [dependencies] libc = "0.2" termios-0.3.0/Cargo.toml0000644000000017260007541 0ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g. crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "termios" version = "0.3.0" authors = ["David Cuddeback "] description = "Safe bindings for the termios library." homepage = "https://github.com/dcuddeback/termios-rs" documentation = "http://dcuddeback.github.io/termios-rs/termios/" readme = "README.md" keywords = ["termios", "tty", "terminal", "posix"] license = "MIT" repository = "https://github.com/dcuddeback/termios-rs" [dependencies.libc] version = "0.2" termios-0.3.0/LICENSE01006440001750000175000000002043132021402750012415 0ustar0000000000000000Copyright (c) 2015 David Cuddeback Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. termios-0.3.0/README.md01006440001750000175000000003457132110673160012705 0ustar0000000000000000# Termios Rust Bindings The `termios` crate provides safe bindings for the Rust programming language to the [terminal I/O interface](http://pubs.opengroup.org/onlinepubs/009695399/basedefs/termios.h.html) implemented by Unix operating systems. The safe bindings are a small wrapper around the raw C functions, which converts integer return values to `std::io::Result` to indicate success or failure. * [Documentation](http://dcuddeback.github.io/termios-rs/termios/) ## Dependencies In order to use the `termios` crate, you must have a native `libc` library that implements the termios API. This should be available on any Unix operating system. This library contains the termios definitions for the following platforms: * Linux (x86_64, armv6l) * OS X (x86_64) * FreeBSD (amd64) * OpenBSD (amd64) * DragonFly BSD (x86_64) ## Usage Add `termios` as a dependency in `Cargo.toml`: ```toml [dependencies] termios = "0.3" ``` Import the `termios` crate and any symbols needed from `termios`. You may also need `std::os::unix::io::RawFd` for file descriptors and `std::io::Result` to propagate errors. ```rust extern crate termios; use std::io; use std::os::unix::io::RawFd; use termios::*; fn setup_fd(fd: RawFd) -> io::Result<()> { let mut termios = try!(Termios::from_fd(fd)); termios.c_iflag = IGNPAR | IGNBRK; termios.c_oflag = 0; termios.c_cflag = CS8 | CREAD | CLOCAL; termios.c_lflag = 0; try!(cfsetspeed(&mut termios, B9600)); try!(tcsetattr(fd, TCSANOW, &termios)); try!(tcflush(fd, TCIOFLUSH)); Ok(()) } ``` ## Contributors * [dcuddeback](https://github.com/dcuddeback/) * [conradkleinespel](https://github.com/conradkleinespel) * [myfreeweb](https://github.com/myfreeweb) * [qbit](https://github.com/qbit) ## License Copyright © 2015 David Cuddeback Distributed under the [MIT License](LICENSE). termios-0.3.0/src/ffi.rs01006440001750000175000000002071132110673160013316 0ustar0000000000000000//! Unsafe FFI bindings. use libc::{c_int,pid_t}; #[link(name = "c")] extern "C" { pub fn tcgetattr(fd: c_int, termios_p: *mut ::os::target::termios) -> c_int; pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios_p: *const ::os::target::termios) -> c_int; pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int; pub fn tcdrain(fd: c_int) -> c_int; pub fn tcflush(fd: c_int, queue_selector: c_int) -> c_int; pub fn tcflow(fd: c_int, action: c_int) -> c_int; pub fn cfmakeraw(termios_p: *mut ::os::target::termios); pub fn cfgetispeed(termios_p: *const ::os::target::termios) -> ::os::target::speed_t; pub fn cfgetospeed(termios_p: *const ::os::target::termios) -> ::os::target::speed_t; pub fn cfsetispeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int; pub fn cfsetospeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int; pub fn cfsetspeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int; pub fn tcgetsid(fd: c_int) -> pid_t; } termios-0.3.0/src/lib.rs01006440001750000175000000043372132110673160013331 0ustar0000000000000000//! The `termios` crate provides Rust bindings for the POSIX termios API that is implemented on //! Unix operating systems. The termios API is defined in the [IEEE Std 1003.1 ("POSIX.1") //! specification](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/termios.h.html). //! //! ## Getting Started //! //! The termios API operates on file descriptors that are associated with terminal devices, e.g., //! `/dev/tty*`. When used with other file descriptors, termios functions return an error. All //! functions that are part of the POSIX standard are included in the `termios` crate. Where file //! descriptors are expected, the type `std::os::unix::io::RawFd` is used, and integer error codes //! are translated to `std::io::Result`. //! //! A major feature of the termios API is configuring a terminal device's parameters. The POSIX //! standard defines a `termios` structure that contains the parameters and several functions for //! manipulating the parameters. The `termios` crate defines a safe constructor that returns a //! [`Termios`](struct.Termios.html) struct populated with the parameters of an open terminal //! device: //! //! ```no_run //! use termios::*; //! # let fd = 1; //! let mut termios = Termios::from_fd(fd).unwrap(); //! ``` //! //! The [`Termios`](struct.Termios.html) struct provides access to the fields defined in the POSIX //! standard (`c_iflag`, `c_oflag`, `c_cflag`, `c_lflag`, and `c_cc`): //! //! ```no_run //! # use termios::*; //! # let fd = 1; //! # let mut termios = Termios::from_fd(fd).unwrap(); //! termios.c_cflag |= CREAD | CLOCAL; //! termios.c_lflag &= !(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ISIG | IEXTEN); //! termios.c_oflag &= !OPOST; //! termios.c_iflag &= !(INLCR | IGNCR | ICRNL | IGNBRK); //! //! termios.c_cc[VMIN] = 0; //! termios.c_cc[VTIME] = 0; //! ``` //! //! The [`Termios`](struct.Termios.html) struct can also be manipulated using any of the standard //! termios API functions: //! //! ```no_run //! # use termios::*; //! # let fd = 1; //! # let mut termios = Termios::from_fd(fd).unwrap(); //! cfgetispeed(&termios); //! cfgetospeed(&termios); //! cfsetispeed(&mut termios, B9600).unwrap(); //! cfsetospeed(&mut termios, B9600).unwrap(); //! tcsetattr(fd, TCSANOW, &termios).unwrap(); //! ``` //! //! ## Portability //! //! The `termios` crate is organized in a way to help write portable code, while also allowing //! access to OS-specific functionality when necessary. //! //! The crate root contains types, constants, and function definitions that are common across Unix //! operating systems. Most of the definitions in the crate root are from the POSIX standard; //! however, support for the standard may differ across operating systems. A couple functions in //! the crate root are not part of the POSIX standard, but are included in the crate root because //! they are widely available across Unix operating systems. //! //! To write portable code, import the `termios` crate and use only the definitions from the crate //! root. //! //! ### OS-Specific Extensions //! //! Each operating system may define extensions to the POSIX API. To make it clear when code //! depends on OS-specific definitions, any non-standard definitions are exported in the //! `termios::os` module. Programs that depend on OS-specific functionality must explicity opt-in. //! When writing portable code that depends on OS-specific definitions, it will often be necessary //! to use `#[cfg(...)]` attributes to support alternative implementations. The following is an //! example of a portable function that sets the maximum speed on a `Termios` struct. //! //! ```no_run //! use std::io; //! use termios::{Termios,cfsetspeed}; //! //! #[cfg(target_os = "linux")] //! fn set_fastest_speed(termios: &mut Termios) -> io::Result<()> { //! cfsetspeed(termios, termios::os::linux::B4000000) //! } //! //! #[cfg(target_os = "macos")] //! fn set_fastest_speed(termios: &mut Termios) -> io::Result<()> { //! cfsetspeed(termios, termios::os::macos::B230400) //! } //! //! #[cfg(target_os = "freebsd")] //! fn set_fastest_speed(termios: &mut Termios) -> io::Result<()> { //! cfsetspeed(termios, termios::os::freebsd::B921600) //! } //! //! #[cfg(target_os = "openbsd")] //! fn set_fastest_speed(termios: &mut Termios) -> io::Result<()> { //! cfsetspeed(termios, termios::os::openbsd::B921600) //! } //! //! #[cfg(target_os = "dragonfly")] //! fn set_fastest_speed(termios: &mut Termios) -> io::Result<()> { //! cfsetspeed(termios, termios::os::dragonfly::B230400) //! } //! //! # let fd = 1; //! let mut termios = Termios::from_fd(fd).unwrap(); //! set_fastest_speed(&mut termios).unwrap(); //! ``` extern crate libc; use std::io; use std::mem; use std::ops::{Deref,DerefMut}; use std::os::unix::io::RawFd; use libc::{c_int,pid_t}; pub use ::os::target::{cc_t,speed_t,tcflag_t}; // types pub use ::os::target::{VEOF,VEOL,VERASE,VINTR,VKILL,VMIN,VQUIT,VSTART,VSTOP,VSUSP,VTIME}; // c_cc subscripts pub use ::os::target::{BRKINT,ICRNL,IGNBRK,IGNCR,IGNPAR,INLCR,INPCK,ISTRIP,IXANY,IXOFF,IXON,PARMRK}; // input modes pub use ::os::target::{OPOST,ONLCR,OCRNL,ONOCR,ONLRET}; // output modes pub use ::os::target::{B0,B50,B75,B110,B134,B150,B200,B300,B600,B1200,B1800,B2400,B4800,B9600,B19200,B38400}; // baud rate selection pub use ::os::target::{CSIZE,CS5,CS6,CS7,CS8,CSTOPB,CREAD,PARENB,PARODD,HUPCL,CLOCAL}; // control modes pub use ::os::target::{ECHO,ECHOE,ECHOK,ECHONL,ICANON,IEXTEN,ISIG,NOFLSH,TOSTOP}; // local modes pub use ::os::target::{TCSANOW,TCSADRAIN,TCSAFLUSH}; // attribute selection pub use ::os::target::{TCIFLUSH,TCIOFLUSH,TCOFLUSH,TCIOFF,TCION,TCOOFF,TCOON}; // line control pub mod ffi; pub mod os; /// Unix terminal I/O control structure. /// /// The `Termios` structure is a thin wrapper for the OS-specific `termios` struct. The only safe /// way to obtain a `Termios` structure is to fill one from a file descriptor with /// [`Termios::from_fd()`](#method.from_fd), after which it can be treated just like the POSIX /// `termios` struct. It provides access to the standard fields of the `termios` struct (`c_iflag`, /// `c_oflag`, `c_cflag`, `c_lflag`, and `c_cc`) through the `Deref` and `DerefMut` traits. /// /// ## Example /// /// The following is an example of how one might setup a file descriptor for a serial port: /// /// ```no_run /// use std::io; /// use std::os::unix::io::RawFd; /// /// fn setup_serial(fd: RawFd) -> io::Result<()> { /// use termios::*; /// /// let mut termios = try!(Termios::from_fd(fd)); /// /// termios.c_cflag |= CREAD | CLOCAL; /// termios.c_lflag &= !(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ISIG | IEXTEN); /// termios.c_oflag &= !OPOST; /// termios.c_iflag &= !(INLCR | IGNCR | ICRNL | IGNBRK); /// /// termios.c_cc[VMIN] = 0; /// termios.c_cc[VTIME] = 0; /// /// try!(cfsetspeed(&mut termios, B9600)); /// try!(tcsetattr(fd, TCSANOW, &mut termios)); /// /// Ok(()) /// } /// ``` #[derive(Debug,Copy,Clone,Eq,PartialEq)] pub struct Termios { inner: ::os::target::termios } impl Termios { /// Creates a `Termios` structure based on the current settings of a file descriptor. /// /// `fd` must be an open file descriptor for a terminal device. pub fn from_fd(fd: RawFd) -> io::Result { let mut termios = unsafe { mem::uninitialized() }; match tcgetattr(fd, &mut termios) { Ok(_) => Ok(termios), Err(err) => Err(err) } } fn inner(&self) -> &::os::target::termios { &self.inner } fn inner_mut(&mut self) -> &mut ::os::target::termios { &mut self.inner } } impl Deref for Termios { type Target = ::os::target::termios; fn deref(&self) -> &::os::target::termios { self.inner() } } impl DerefMut for Termios { fn deref_mut(&mut self) -> &mut ::os::target::termios { self.inner_mut() } } /// Gets the input baud rate stored in a `Termios` structure. /// /// # Examples /// /// ``` /// # use std::mem; /// # use termios::{Termios,B9600,cfsetispeed,cfgetispeed}; /// # let mut termios = unsafe { mem::uninitialized() }; /// cfsetispeed(&mut termios, B9600).unwrap(); /// assert_eq!(cfgetispeed(&termios), B9600); /// ``` pub fn cfgetispeed(termios: &Termios) -> speed_t { unsafe { ffi::cfgetispeed(termios.inner()) } } /// Gets the output baud rate stored in a `Termios` structure. /// /// # Examples /// /// ``` /// # use std::mem; /// # use termios::{Termios,B9600,cfsetospeed,cfgetospeed}; /// # let mut termios = unsafe { mem::uninitialized() }; /// cfsetospeed(&mut termios, B9600).unwrap(); /// assert_eq!(cfgetospeed(&termios), B9600); /// ``` pub fn cfgetospeed(termios: &Termios) -> speed_t { unsafe { ffi::cfgetospeed(termios.inner()) } } /// Sets the input baud rate. /// /// This function only sets the necessary values on the given `Termios` structure. The settings are /// applied by a subsequent call to [`tcsetattr()`](fn.tcsetattr.html). /// /// # Parameters /// /// * `termios` should be a mutable reference to a `Termios` structure. /// * `speed` should be one of the baud rate constants: /// - `B0` /// - `B50` /// - `B75` /// - `B110` /// - `B134` /// - `B150` /// - `B200` /// - `B300` /// - `B600` /// - `B1200` /// - `B1800` /// - `B2400` /// - `B4800` /// - `B9600` /// - `B19200` /// - `B38400` /// - any OS-specific baud rate defined in [`termios::os`](os/index.html). /// /// A value of `B0` for `speed` sets the input baud rate to be the same as the output baud rate. /// /// # Examples /// /// ``` /// # use std::mem; /// # use termios::{Termios,B9600,cfsetispeed,cfgetispeed}; /// # let mut termios = unsafe { mem::uninitialized() }; /// cfsetispeed(&mut termios, B9600).unwrap(); /// assert_eq!(cfgetispeed(&termios), B9600); /// ``` pub fn cfsetispeed(termios: &mut Termios, speed: speed_t) -> io::Result<()> { io_result(unsafe { ffi::cfsetispeed(termios.inner_mut(), speed) }) } /// Sets the output baud rate. /// /// This function only sets the necessary values on the given `Termios` structure. The settings are /// applied on a successful call to [`tcsetattr()`](fn.tcsetattr.html). /// /// # Parameters /// /// * `termios` should be a mutable reference to a `Termios` structure. /// * `speed` should be one of the baud rate constants: /// - `B0` (hang up) /// - `B50` /// - `B75` /// - `B110` /// - `B134` /// - `B150` /// - `B200` /// - `B300` /// - `B600` /// - `B1200` /// - `B1800` /// - `B2400` /// - `B4800` /// - `B9600` /// - `B19200` /// - `B38400` /// - any OS-specific baud rate defined in [`termios::os`](os/index.html). /// /// A value of `B0` for `speed` deasserts the modem control lines when applied with /// [`tcsetattr()`](fn.tcsetattr.html). This normally has the effect of disconnecting the line. /// /// # Examples /// /// ``` /// # use std::mem; /// # use termios::{Termios,B9600,cfsetospeed,cfgetospeed}; /// # let mut termios = unsafe { mem::uninitialized() }; /// cfsetospeed(&mut termios, B9600).unwrap(); /// assert_eq!(cfgetospeed(&termios), B9600); /// ``` pub fn cfsetospeed(termios: &mut Termios, speed: speed_t) -> io::Result<()> { io_result(unsafe { ffi::cfsetospeed(termios.inner_mut(), speed) }) } /// Sets input and output baud rates. /// /// This function only sets the necessary values on the given `Termios` structure. The settings are /// applied on a successful call to [`tcsetattr()`](fn.tcsetattr.html). /// /// # Parameters /// /// * `termios` should be a mutable reference to a `Termios` structure. /// * `speed` should be one of the baud rate constants: /// - `B0` /// - `B50` /// - `B75` /// - `B110` /// - `B134` /// - `B150` /// - `B200` /// - `B300` /// - `B600` /// - `B1200` /// - `B1800` /// - `B2400` /// - `B4800` /// - `B9600` /// - `B19200` /// - `B38400` /// - any OS-specific baud rate defined in [`termios::os`](os/index.html). /// /// # Examples /// /// ``` /// # use std::mem; /// # use termios::{Termios,B9600,cfsetspeed,cfgetispeed,cfgetospeed}; /// # let mut termios = unsafe { mem::uninitialized() }; /// cfsetspeed(&mut termios, B9600).unwrap(); /// assert_eq!(cfgetispeed(&termios), B9600); /// assert_eq!(cfgetospeed(&termios), B9600); /// ``` /// /// # Portability /// /// This function is not part of the IEEE Std 1003.1 ("POSIX.1") specification, but it is available /// on Linux, BSD, and OS X. pub fn cfsetspeed(termios: &mut Termios, speed: speed_t) -> io::Result<()> { io_result(unsafe { ffi::cfsetspeed(termios.inner_mut(), speed) }) } /// Sets flags to disable all input and output processing. /// /// This function only sets the necessary values on the given `Termios` structure. The settings are /// applied on a successful call to [`tcsetattr()`](fn.tcsetattr.html). /// /// # Portability /// /// This function is not part of the IEEE Std 1003.1 ("POSIX.1") specification, but it is available /// on Linux, BSD, and OS X. pub fn cfmakeraw(termios: &mut Termios) { unsafe { ffi::cfmakeraw(termios.inner_mut()) }; } /// Blocks until all output written to the file descriptor is transmitted. /// /// # Parameters /// /// * `fd` should be an open file descriptor associated with a terminal. pub fn tcdrain(fd: RawFd) -> io::Result<()> { io_result(unsafe { ffi::tcdrain(fd) }) } /// Suspends or restarts transmission or reception of data. /// /// # Parameters /// /// * `fd` should be an open file descriptor associated with a terminal. /// * `action` should be one of the following constants: /// - `TCOOFF` suspends output. /// - `TCOON` restarts output. /// - `TCIOFF` transmits a STOP character, intended to cause the remote device to stop /// transmitting. /// - `TCION` transmits a START character, intended to cause the remote device to resume /// transmitting. pub fn tcflow(fd: RawFd, action: c_int) -> io::Result<()> { io_result(unsafe { ffi::tcflow(fd, action) }) } /// Discards data waiting in the terminal device's buffers. /// /// `tcflush()` discards data that has been written to the device by an application but has not yet /// been transmitted by the hardware or data that has been received by the hardware but has not yet /// been read by an application. /// /// # Parameters /// /// * `fd` should be an open file descriptor associated with a terminal. /// * `queue_selector` should be one of: /// - `TCIFLUSH` to discard data received but not read. /// - `TCOFLUSH` to discard data written but not transmitted. /// - `TCIOFLUSH` to discard both data received but not read and data written but not /// transmitted. pub fn tcflush(fd: RawFd, queue_selector: c_int) -> io::Result<()> { io_result(unsafe { ffi::tcflush(fd, queue_selector) }) } /// Populates a `Termios` structure with parameters associated with a terminal. /// /// Upon successful completion, the `Termios` structure referred to by the `termios` parameter will /// contain the parameters associated with the terminal device referred to by `fd`. /// /// # Parameters /// /// * `fd` should be an open file descriptor associated with a terminal. /// * `termios` should be a mutable reference to the `Termios` structure that will hold the /// terminal device's parameters. pub fn tcgetattr(fd: RawFd, termios: &mut Termios) -> io::Result<()> { io_result(unsafe { ffi::tcgetattr(fd, termios.inner_mut()) }) } /// Sets a terminal device's parameters. /// /// `tcsetattr()` returns successfully if it was able to perform any of the requested actions, even /// if other requested actions could not be performed. It will set all attributes that the /// implementation supports and leave others unchanged. The `Termios` structure will not be updated /// to reflect the changes that were applied. /// /// In order to determine which parameters were applied to the terminal device, an application /// should use [`tcgetattr()`](fn.tcgetattr.html) to obtain the latest state of the terminal /// device. In particular, when attempting to change baud rates, [`tcgetattr()`](fn.tcgetattr.html) /// can be used to determine which baud rates were actually selected. /// /// If none of the requested actions could be performed, then `tcsetattr()` returns an error. /// /// # Parameters /// /// * `fd` should be an open file descriptor associated with a terminal. /// * `action` should be one of the constants: /// - `TCSANOW` applies the change immediately. /// - `TCSADRAIN` applies the change after all output previously written to `fd` is transmitted. /// This mode should be used when changing parameters that affect output. /// - `TCSAFLUSH` applies the change after all output previously written to `fd` is transmitted. /// All data received but not read is discarded before applying the change. /// * `termios` should be a mutable reference to a `Termios` structure containing the parameters to /// apply to the terminal device. pub fn tcsetattr(fd: RawFd, action: c_int, termios: &Termios) -> io::Result<()> { io_result(unsafe { ffi::tcsetattr(fd, action, termios.inner()) }) } /// Returns the process group ID of the controlling terminal's session. /// /// # Parameters /// /// * `fd` should be an open file descriptor associated with a controlling terminal. pub fn tcgetsid(fd: RawFd) -> pid_t { unsafe { ffi::tcgetsid(fd) } } /// Transmits data to generate a break condition. /// /// If the terminal device is using asynchronous data transmission, `tcsendbreak()` transmits a /// continuous stream of zero bits for a specific duration. /// /// # Parameters /// /// * `fd` should be an open file descriptor associated with a terminal. /// * `duration` controls the duration of the transmitted zero bits. A value of 0 causes a /// transmission between 0.25 and 0.5 seconds. A value other than 0 causes a transmission for an /// implementation-defined period of time. pub fn tcsendbreak(fd: RawFd, duration: c_int) -> io::Result<()> { io_result(unsafe { ffi::tcsendbreak(fd, duration) }) } #[inline] fn io_result(result: c_int) -> io::Result<()> { match result { 0 => Ok(()), _ => Err(io::Error::last_os_error()) } } termios-0.3.0/src/os/dragonfly.rs01006440001750000175000000011435132110673160015164 0ustar0000000000000000#![allow(non_camel_case_types)] use libc::{c_int,c_uint,c_uchar}; pub type cc_t = c_uchar; pub type speed_t = c_uint; pub type tcflag_t = c_uint; #[derive(Debug,Copy,Clone,Eq,PartialEq)] #[repr(C)] pub struct termios { pub c_iflag: tcflag_t, pub c_oflag: tcflag_t, pub c_cflag: tcflag_t, pub c_lflag: tcflag_t, pub c_cc: [cc_t; NCCS], c_ispeed: speed_t, c_ospeed: speed_t } pub const NCCS: usize = 20; // c_cc characters pub const VEOF: usize = 0; pub const VEOL: usize = 1; pub const VEOL2: usize = 2; pub const VERASE: usize = 3; pub const VWERASE: usize = 4; pub const VKILL: usize = 5; pub const VREPRINT: usize = 6; pub const VERASE2: usize = 7; pub const VINTR: usize = 8; pub const VQUIT: usize = 9; pub const VSUSP: usize = 10; pub const VDSUSP: usize = 11; pub const VSTART: usize = 12; pub const VSTOP: usize = 13; pub const VLNEXT: usize = 14; pub const VDISCARD: usize = 15; pub const VMIN: usize = 16; pub const VTIME: usize = 17; pub const VSTATUS: usize = 18; pub const VCHECKPT: usize = 19; // c_iflag bits pub const IGNBRK: tcflag_t = 0x00000001; pub const BRKINT: tcflag_t = 0x00000002; pub const IGNPAR: tcflag_t = 0x00000004; pub const PARMRK: tcflag_t = 0x00000008; pub const INPCK: tcflag_t = 0x00000010; pub const ISTRIP: tcflag_t = 0x00000020; pub const INLCR: tcflag_t = 0x00000040; pub const IGNCR: tcflag_t = 0x00000080; pub const ICRNL: tcflag_t = 0x00000100; pub const IXON: tcflag_t = 0x00000200; pub const IXOFF: tcflag_t = 0x00000400; pub const IXANY: tcflag_t = 0x00000800; pub const IMAXBEL: tcflag_t = 0x00002000; // c_oflag bits pub const OPOST: tcflag_t = 0x00000001; pub const ONLCR: tcflag_t = 0x00000002; pub const OXTABS: tcflag_t = 0x00000004; pub const ONOEOT: tcflag_t = 0x00000008; pub const OCRNL: tcflag_t = 0x00000010; pub const ONOCR: tcflag_t = 0x00000020; pub const ONLRET: tcflag_t = 0x00000040; // c_cflag bits pub const CIGNORE: tcflag_t = 0x00000001; pub const CSIZE: tcflag_t = 0x00000300; pub const CS5: tcflag_t = 0x00000000; pub const CS6: tcflag_t = 0x00000100; pub const CS7: tcflag_t = 0x00000200; pub const CS8: tcflag_t = 0x00000300; pub const CSTOPB: tcflag_t = 0x00000400; pub const CREAD: tcflag_t = 0x00000800; pub const PARENB: tcflag_t = 0x00001000; pub const PARODD: tcflag_t = 0x00002000; pub const HUPCL: tcflag_t = 0x00004000; pub const CLOCAL: tcflag_t = 0x00008000; pub const CCTS_OFLOW: tcflag_t = 0x00010000; pub const CRTSCTS: tcflag_t = CCTS_OFLOW | CRTS_IFLOW; pub const CRTS_IFLOW: tcflag_t = 0x00020000; pub const CDTR_IFLOW: tcflag_t = 0x00040000; pub const CDSR_OFLOW: tcflag_t = 0x00080000; pub const CCAR_OFLOW: tcflag_t = 0x00100000; pub const MDMBUF: tcflag_t = 0x00100000; // c_lflag bits pub const ECHOKE: tcflag_t = 0x00000001; pub const ECHOE: tcflag_t = 0x00000002; pub const ECHOK: tcflag_t = 0x00000004; pub const ECHO: tcflag_t = 0x00000008; pub const ECHONL: tcflag_t = 0x00000010; pub const ECHOPRT: tcflag_t = 0x00000020; pub const ECHOCTL: tcflag_t = 0x00000040; pub const ISIG: tcflag_t = 0x00000080; pub const ICANON: tcflag_t = 0x00000100; pub const ALTWERASE: tcflag_t = 0x00000200; pub const IEXTEN: tcflag_t = 0x00000400; pub const EXTPROC: tcflag_t = 0x00000800; pub const TOSTOP: tcflag_t = 0x00400000; pub const FLUSHO: tcflag_t = 0x00800000; pub const NOKERNINFO: tcflag_t = 0x02000000; pub const PENDIN: tcflag_t = 0x20000000; pub const NOFLSH: tcflag_t = 0x80000000; // baud rates pub const B0: speed_t = 0; pub const B50: speed_t = 50; pub const B75: speed_t = 75; pub const B110: speed_t = 110; pub const B134: speed_t = 134; pub const B150: speed_t = 150; pub const B200: speed_t = 200; pub const B300: speed_t = 300; pub const B600: speed_t = 600; pub const B1200: speed_t = 1200; pub const B1800: speed_t = 1800; pub const B2400: speed_t = 2400; pub const B4800: speed_t = 4800; pub const B9600: speed_t = 9600; pub const B19200: speed_t = 19200; pub const B38400: speed_t = 38400; pub const B7200: speed_t = 7200; pub const B14400: speed_t = 14400; pub const B28800: speed_t = 28800; pub const B57600: speed_t = 57600; pub const B76800: speed_t = 76800; pub const B115200: speed_t = 115200; pub const B230400: speed_t = 230400; pub const EXTA: speed_t = 19200; pub const EXTB: speed_t = 38400; // tcsetattr() pub const TCSANOW: c_int = 0; pub const TCSADRAIN: c_int = 1; pub const TCSAFLUSH: c_int = 2; pub const TCSASOFT: c_int = 0x10; // tcflush() pub const TCIFLUSH: c_int = 1; pub const TCOFLUSH: c_int = 2; pub const TCIOFLUSH: c_int = 3; // tcflow() pub const TCOOFF: c_int = 1; pub const TCOON: c_int = 2; pub const TCIOFF: c_int = 3; pub const TCION: c_int = 4; termios-0.3.0/src/os/freebsd.rs01006440001750000175000000011674132110673160014616 0ustar0000000000000000#![allow(non_camel_case_types)] use libc::{c_int,c_uint,c_uchar}; pub type cc_t = c_uchar; pub type speed_t = c_uint; pub type tcflag_t = c_uint; #[derive(Debug,Copy,Clone,Eq,PartialEq)] #[repr(C)] pub struct termios { pub c_iflag: tcflag_t, pub c_oflag: tcflag_t, pub c_cflag: tcflag_t, pub c_lflag: tcflag_t, pub c_cc: [cc_t; NCCS], c_ispeed: speed_t, c_ospeed: speed_t } pub const NCCS: usize = 20; // c_cc characters pub const VEOF: usize = 0; pub const VEOL: usize = 1; pub const VEOL2: usize = 2; pub const VERASE: usize = 3; pub const VWERASE: usize = 4; pub const VKILL: usize = 5; pub const VREPRINT: usize = 6; pub const VERASE2: usize = 7; pub const VINTR: usize = 8; pub const VQUIT: usize = 9; pub const VSUSP: usize = 10; pub const VDSUSP: usize = 11; pub const VSTART: usize = 12; pub const VSTOP: usize = 13; pub const VLNEXT: usize = 14; pub const VDISCARD: usize = 15; pub const VMIN: usize = 16; pub const VTIME: usize = 17; pub const VSTATUS: usize = 18; // c_iflag bits pub const IGNBRK: tcflag_t = 0x00000001; pub const BRKINT: tcflag_t = 0x00000002; pub const IGNPAR: tcflag_t = 0x00000004; pub const PARMRK: tcflag_t = 0x00000008; pub const INPCK: tcflag_t = 0x00000010; pub const ISTRIP: tcflag_t = 0x00000020; pub const INLCR: tcflag_t = 0x00000040; pub const IGNCR: tcflag_t = 0x00000080; pub const ICRNL: tcflag_t = 0x00000100; pub const IXON: tcflag_t = 0x00000200; pub const IXOFF: tcflag_t = 0x00000400; pub const IXANY: tcflag_t = 0x00000800; pub const IMAXBEL: tcflag_t = 0x00002000; // c_oflag bits pub const OPOST: tcflag_t = 0x00000001; pub const ONLCR: tcflag_t = 0x00000002; pub const TABDLY: tcflag_t = 0x00000004; pub const TAB0: tcflag_t = 0x00000000; pub const TAB3: tcflag_t = 0x00000004; pub const OXTABS: tcflag_t = TAB3; pub const ONOEOT: tcflag_t = 0x00000008; pub const OCRNL: tcflag_t = 0x00000010; pub const ONOCR: tcflag_t = 0x00000020; pub const ONLRET: tcflag_t = 0x00000040; // c_cflag bits pub const CIGNORE: tcflag_t = 0x00000001; pub const CSIZE: tcflag_t = 0x00000300; pub const CS5: tcflag_t = 0x00000000; pub const CS6: tcflag_t = 0x00000100; pub const CS7: tcflag_t = 0x00000200; pub const CS8: tcflag_t = 0x00000300; pub const CSTOPB: tcflag_t = 0x00000400; pub const CREAD: tcflag_t = 0x00000800; pub const PARENB: tcflag_t = 0x00001000; pub const PARODD: tcflag_t = 0x00002000; pub const HUPCL: tcflag_t = 0x00004000; pub const CLOCAL: tcflag_t = 0x00008000; pub const CCTS_OFLOW: tcflag_t = 0x00010000; pub const CRTSCTS: tcflag_t = CCTS_OFLOW | CRTS_IFLOW; pub const CRTS_IFLOW: tcflag_t = 0x00020000; pub const CDTR_IFLOW: tcflag_t = 0x00040000; pub const CDSR_OFLOW: tcflag_t = 0x00080000; pub const CCAR_OFLOW: tcflag_t = 0x00100000; pub const MDMBUF: tcflag_t = CCAR_OFLOW; // c_lflag bits pub const ECHOKE: tcflag_t = 0x00000001; pub const ECHOE: tcflag_t = 0x00000002; pub const ECHOK: tcflag_t = 0x00000004; pub const ECHO: tcflag_t = 0x00000008; pub const ECHONL: tcflag_t = 0x00000010; pub const ECHOPRT: tcflag_t = 0x00000020; pub const ECHOCTL: tcflag_t = 0x00000040; pub const ISIG: tcflag_t = 0x00000080; pub const ICANON: tcflag_t = 0x00000100; pub const ALTWERASE: tcflag_t = 0x00000200; pub const IEXTEN: tcflag_t = 0x00000400; pub const EXTPROC: tcflag_t = 0x00000800; pub const TOSTOP: tcflag_t = 0x00400000; pub const FLUSHO: tcflag_t = 0x00800000; pub const NOKERNINFO: tcflag_t = 0x02000000; pub const PENDIN: tcflag_t = 0x20000000; pub const NOFLSH: tcflag_t = 0x80000000; // baud rates pub const B0: speed_t = 0; pub const B50: speed_t = 50; pub const B75: speed_t = 75; pub const B110: speed_t = 110; pub const B134: speed_t = 134; pub const B150: speed_t = 150; pub const B200: speed_t = 200; pub const B300: speed_t = 300; pub const B600: speed_t = 600; pub const B1200: speed_t = 1200; pub const B1800: speed_t = 1800; pub const B2400: speed_t = 2400; pub const B4800: speed_t = 4800; pub const B9600: speed_t = 9600; pub const B19200: speed_t = 19200; pub const B38400: speed_t = 38400; pub const B7200: speed_t = 7200; pub const B14400: speed_t = 14400; pub const B28800: speed_t = 28800; pub const B57600: speed_t = 57600; pub const B76800: speed_t = 76800; pub const B115200: speed_t = 115200; pub const B230400: speed_t = 230400; pub const B460800: speed_t = 460800; pub const B921600: speed_t = 921600; pub const EXTA: speed_t = 19200; pub const EXTB: speed_t = 38400; // tcflow() pub const TCOOFF: c_int = 1; pub const TCOON: c_int = 2; pub const TCIOFF: c_int = 3; pub const TCION: c_int = 4; // tcflush() pub const TCIFLUSH: c_int = 1; pub const TCOFLUSH: c_int = 2; pub const TCIOFLUSH: c_int = 3; // tcsetattr() pub const TCSANOW: c_int = 0; pub const TCSADRAIN: c_int = 1; pub const TCSAFLUSH: c_int = 2; pub const TCSASOFT: c_int = 0x10; termios-0.3.0/src/os/linux.rs01006440001750000175000000013364132110673160014341 0ustar0000000000000000#![allow(non_camel_case_types)] use libc::{c_int,c_uint,c_uchar}; pub type cc_t = c_uchar; pub type speed_t = c_uint; pub type tcflag_t = c_uint; #[derive(Debug,Copy,Clone,Eq,PartialEq)] #[repr(C)] pub struct termios { pub c_iflag: tcflag_t, pub c_oflag: tcflag_t, pub c_cflag: tcflag_t, pub c_lflag: tcflag_t, c_line: cc_t, pub c_cc: [cc_t; NCCS], c_ispeed: speed_t, c_ospeed: speed_t } pub const NCCS: usize = 32; // c_cc characters pub const VINTR: usize = 0; pub const VQUIT: usize = 1; pub const VERASE: usize = 2; pub const VKILL: usize = 3; pub const VEOF: usize = 4; pub const VTIME: usize = 5; pub const VMIN: usize = 6; pub const VSWTC: usize = 7; pub const VSTART: usize = 8; pub const VSTOP: usize = 9; pub const VSUSP: usize = 10; pub const VEOL: usize = 11; pub const VREPRINT: usize = 12; pub const VDISCARD: usize = 13; pub const VWERASE: usize = 14; pub const VLNEXT: usize = 15; pub const VEOL2: usize = 16; // c_iflag bits pub const IGNBRK: tcflag_t = 0o000001; pub const BRKINT: tcflag_t = 0o000002; pub const IGNPAR: tcflag_t = 0o000004; pub const PARMRK: tcflag_t = 0o000010; pub const INPCK: tcflag_t = 0o000020; pub const ISTRIP: tcflag_t = 0o000040; pub const INLCR: tcflag_t = 0o000100; pub const IGNCR: tcflag_t = 0o000200; pub const ICRNL: tcflag_t = 0o000400; pub const IUCLC: tcflag_t = 0o001000; pub const IXON: tcflag_t = 0o002000; pub const IXANY: tcflag_t = 0o004000; pub const IXOFF: tcflag_t = 0o010000; pub const IMAXBEL: tcflag_t = 0o020000; pub const IUTF8: tcflag_t = 0o040000; // c_oflag bits pub const OPOST: tcflag_t = 0o000001; pub const OLCUC: tcflag_t = 0o000002; pub const ONLCR: tcflag_t = 0o000004; pub const OCRNL: tcflag_t = 0o000010; pub const ONOCR: tcflag_t = 0o000020; pub const ONLRET: tcflag_t = 0o000040; pub const OFILL: tcflag_t = 0o000100; pub const OFDEL: tcflag_t = 0o000200; pub const NLDLY: tcflag_t = 0o000400; pub const NL0: tcflag_t = 0o000000; pub const NL1: tcflag_t = 0o000400; pub const CRDLY: tcflag_t = 0o003000; pub const CR0: tcflag_t = 0o000000; pub const CR1: tcflag_t = 0o001000; pub const CR2: tcflag_t = 0o002000; pub const CR3: tcflag_t = 0o003000; pub const TABDLY: tcflag_t = 0o014000; pub const TAB0: tcflag_t = 0o000000; pub const TAB1: tcflag_t = 0o004000; pub const TAB2: tcflag_t = 0o010000; pub const TAB3: tcflag_t = 0o014000; pub const BSDLY: tcflag_t = 0o020000; pub const BS0: tcflag_t = 0o000000; pub const BS1: tcflag_t = 0o020000; pub const FFDLY: tcflag_t = 0o100000; pub const FF0: tcflag_t = 0o000000; pub const FF1: tcflag_t = 0o100000; pub const VTDLY: tcflag_t = 0o040000; pub const VT0: tcflag_t = 0o000000; pub const VT1: tcflag_t = 0o040000; pub const XTABS: tcflag_t = 0o014000; // c_cflag bits pub const CBAUD: tcflag_t = 0o010017; pub const CSIZE: tcflag_t = 0o000060; pub const CS5: tcflag_t = 0o000000; pub const CS6: tcflag_t = 0o000020; pub const CS7: tcflag_t = 0o000040; pub const CS8: tcflag_t = 0o000060; pub const CSTOPB: tcflag_t = 0o000100; pub const CREAD: tcflag_t = 0o000200; pub const PARENB: tcflag_t = 0o000400; pub const PARODD: tcflag_t = 0o001000; pub const HUPCL: tcflag_t = 0o002000; pub const CLOCAL: tcflag_t = 0o004000; pub const CBAUDEX: tcflag_t = 0o010000; pub const CIBAUD: tcflag_t = 0o02003600000; pub const CMSPAR: tcflag_t = 0o10000000000; pub const CRTSCTS: tcflag_t = 0o20000000000; // c_lflag bits pub const ISIG: tcflag_t = 0o000001; pub const ICANON: tcflag_t = 0o000002; pub const XCASE: tcflag_t = 0o000004; pub const ECHO: tcflag_t = 0o000010; pub const ECHOE: tcflag_t = 0o000020; pub const ECHOK: tcflag_t = 0o000040; pub const ECHONL: tcflag_t = 0o000100; pub const NOFLSH: tcflag_t = 0o000200; pub const TOSTOP: tcflag_t = 0o000400; pub const ECHOCTL: tcflag_t = 0o001000; pub const ECHOPRT: tcflag_t = 0o002000; pub const ECHOKE: tcflag_t = 0o004000; pub const FLUSHO: tcflag_t = 0o010000; pub const PENDIN: tcflag_t = 0o040000; pub const IEXTEN: tcflag_t = 0o100000; pub const EXTPROC: tcflag_t = 0o200000; // baud rates pub const B0: speed_t = 0o000000; pub const B50: speed_t = 0o000001; pub const B75: speed_t = 0o000002; pub const B110: speed_t = 0o000003; pub const B134: speed_t = 0o000004; pub const B150: speed_t = 0o000005; pub const B200: speed_t = 0o000006; pub const B300: speed_t = 0o000007; pub const B600: speed_t = 0o000010; pub const B1200: speed_t = 0o000011; pub const B1800: speed_t = 0o000012; pub const B2400: speed_t = 0o000013; pub const B4800: speed_t = 0o000014; pub const B9600: speed_t = 0o000015; pub const B19200: speed_t = 0o000016; pub const B38400: speed_t = 0o000017; pub const EXTA: speed_t = B19200; pub const EXTB: speed_t = B38400; pub const B57600: speed_t = 0o010001; pub const B115200: speed_t = 0o010002; pub const B230400: speed_t = 0o010003; pub const B460800: speed_t = 0o010004; pub const B500000: speed_t = 0o010005; pub const B576000: speed_t = 0o010006; pub const B921600: speed_t = 0o010007; pub const B1000000: speed_t = 0o010010; pub const B1152000: speed_t = 0o010011; pub const B1500000: speed_t = 0o010012; pub const B2000000: speed_t = 0o010013; pub const B2500000: speed_t = 0o010014; pub const B3000000: speed_t = 0o010015; pub const B3500000: speed_t = 0o010016; pub const B4000000: speed_t = 0o010017; // tcflow() pub const TCOOFF: c_int = 0; pub const TCOON: c_int = 1; pub const TCIOFF: c_int = 2; pub const TCION: c_int = 3; // tcflush() pub const TCIFLUSH: c_int = 0; pub const TCOFLUSH: c_int = 1; pub const TCIOFLUSH: c_int = 2; // tcsetattr() pub const TCSANOW: c_int = 0; pub const TCSADRAIN: c_int = 1; pub const TCSAFLUSH: c_int = 2; termios-0.3.0/src/os/macos.rs01006440001750000175000000013502132110673160014276 0ustar0000000000000000#![allow(non_camel_case_types)] use libc::{c_int,c_uchar,c_ulong}; pub type tcflag_t = c_ulong; pub type cc_t = c_uchar; pub type speed_t = c_ulong; #[derive(Debug,Copy,Clone,Eq,PartialEq)] #[repr(C)] pub struct termios { pub c_iflag: tcflag_t, pub c_oflag: tcflag_t, pub c_cflag: tcflag_t, pub c_lflag: tcflag_t, pub c_cc: [cc_t; NCCS], c_ispeed: speed_t, c_ospeed: speed_t } pub const NCCS: usize = 20; // c_cc characters pub const VEOF: usize = 0; pub const VEOL: usize = 1; pub const VEOL2: usize = 2; pub const VERASE: usize = 3; pub const VWERASE: usize = 4; pub const VKILL: usize = 5; pub const VREPRINT: usize = 6; pub const VINTR: usize = 8; pub const VQUIT: usize = 9; pub const VSUSP: usize = 10; pub const VDSUSP: usize = 11; pub const VSTART: usize = 12; pub const VSTOP: usize = 13; pub const VLNEXT: usize = 14; pub const VDISCARD: usize = 15; pub const VMIN: usize = 16; pub const VTIME: usize = 17; pub const VSTATUS: usize = 18; // c_iflag bits pub const IGNBRK: tcflag_t = 0x00000001; pub const BRKINT: tcflag_t = 0x00000002; pub const IGNPAR: tcflag_t = 0x00000004; pub const PARMRK: tcflag_t = 0x00000008; pub const INPCK: tcflag_t = 0x00000010; pub const ISTRIP: tcflag_t = 0x00000020; pub const INLCR: tcflag_t = 0x00000040; pub const IGNCR: tcflag_t = 0x00000080; pub const ICRNL: tcflag_t = 0x00000100; pub const IXON: tcflag_t = 0x00000200; pub const IXOFF: tcflag_t = 0x00000400; pub const IXANY: tcflag_t = 0x00000800; pub const IMAXBEL: tcflag_t = 0x00002000; pub const IUTF8: tcflag_t = 0x00004000; // c_oflag bits pub const OPOST: tcflag_t = 0x00000001; pub const ONLCR: tcflag_t = 0x00000002; pub const OXTABS: tcflag_t = 0x00000004; pub const ONOEOT: tcflag_t = 0x00000008; pub const OCRNL: tcflag_t = 0x00000010; pub const ONOCR: tcflag_t = 0x00000020; pub const ONLRET: tcflag_t = 0x00000040; pub const OFILL: tcflag_t = 0x00000080; pub const NLDLY: tcflag_t = 0x00000300; pub const TABDLY: tcflag_t = 0x00000c04; pub const CRDLY: tcflag_t = 0x00003000; pub const FFDLY: tcflag_t = 0x00004000; pub const BSDLY: tcflag_t = 0x00008000; pub const VTDLY: tcflag_t = 0x00010000; pub const OFDEL: tcflag_t = 0x00020000; pub const NL0: tcflag_t = 0x00000000; pub const NL1: tcflag_t = 0x00000100; pub const NL2: tcflag_t = 0x00000200; pub const NL3: tcflag_t = 0x00000300; pub const TAB0: tcflag_t = 0x00000000; pub const TAB1: tcflag_t = 0x00000400; pub const TAB2: tcflag_t = 0x00000800; pub const TAB3: tcflag_t = 0x00000004; pub const CR0: tcflag_t = 0x00000000; pub const CR1: tcflag_t = 0x00001000; pub const CR2: tcflag_t = 0x00002000; pub const CR3: tcflag_t = 0x00003000; pub const FF0: tcflag_t = 0x00000000; pub const FF1: tcflag_t = 0x00004000; pub const BS0: tcflag_t = 0x00000000; pub const BS1: tcflag_t = 0x00008000; pub const VT0: tcflag_t = 0x00000000; pub const VT1: tcflag_t = 0x00010000; // c_cflag bits pub const CIGNORE: tcflag_t = 0x00000001; pub const CSIZE: tcflag_t = 0x00000300; pub const CS5: tcflag_t = 0x00000000; pub const CS6: tcflag_t = 0x00000100; pub const CS7: tcflag_t = 0x00000200; pub const CS8: tcflag_t = 0x00000300; pub const CSTOPB: tcflag_t = 0x00000400; pub const CREAD: tcflag_t = 0x00000800; pub const PARENB: tcflag_t = 0x00001000; pub const PARODD: tcflag_t = 0x00002000; pub const HUPCL: tcflag_t = 0x00004000; pub const CLOCAL: tcflag_t = 0x00008000; pub const CCTS_OFLOW: tcflag_t = 0x00010000; pub const CRTSCTS: tcflag_t = CCTS_OFLOW | CRTS_IFLOW; pub const CRTS_IFLOW: tcflag_t = 0x00020000; pub const CDTR_IFLOW: tcflag_t = 0x00040000; pub const CDSR_OFLOW: tcflag_t = 0x00080000; pub const CCAR_OFLOW: tcflag_t = 0x00100000; pub const MDMBUF: tcflag_t = 0x00100000; // c_lflag bits pub const ECHOKE: tcflag_t = 0x00000001; pub const ECHOE: tcflag_t = 0x00000002; pub const ECHOK: tcflag_t = 0x00000004; pub const ECHO: tcflag_t = 0x00000008; pub const ECHONL: tcflag_t = 0x00000010; pub const ECHOPRT: tcflag_t = 0x00000020; pub const ECHOCTL: tcflag_t = 0x00000040; pub const ISIG: tcflag_t = 0x00000080; pub const ICANON: tcflag_t = 0x00000100; pub const ALTWERASE: tcflag_t = 0x00000200; pub const IEXTEN: tcflag_t = 0x00000400; pub const EXTPROC: tcflag_t = 0x00000800; pub const TOSTOP: tcflag_t = 0x00400000; pub const FLUSHO: tcflag_t = 0x00800000; pub const NOKERNINFO: tcflag_t = 0x02000000; pub const PENDIN: tcflag_t = 0x20000000; pub const NOFLSH: tcflag_t = 0x80000000; // baud speeds pub const B0: speed_t = 0; pub const B50: speed_t = 50; pub const B75: speed_t = 75; pub const B110: speed_t = 110; pub const B134: speed_t = 134; pub const B150: speed_t = 150; pub const B200: speed_t = 200; pub const B300: speed_t = 300; pub const B600: speed_t = 600; pub const B1200: speed_t = 1200; pub const B1800: speed_t = 1800; pub const B2400: speed_t = 2400; pub const B4800: speed_t = 4800; pub const B9600: speed_t = 9600; pub const B19200: speed_t = 19200; pub const B38400: speed_t = 38400; pub const B7200: speed_t = 7200; pub const B14400: speed_t = 14400; pub const B28800: speed_t = 28800; pub const B57600: speed_t = 57600; pub const B76800: speed_t = 76800; pub const B115200: speed_t = 115200; pub const B230400: speed_t = 230400; pub const EXTA: speed_t = 19200; pub const EXTB: speed_t = 38400; // tcflow() pub const TCOOFF: c_int = 1; pub const TCOON: c_int = 2; pub const TCIOFF: c_int = 3; pub const TCION: c_int = 4; // tcflush() pub const TCIFLUSH: c_int = 1; pub const TCOFLUSH: c_int = 2; pub const TCIOFLUSH: c_int = 3; // tcsetattr() pub const TCSANOW: c_int = 0; pub const TCSADRAIN: c_int = 1; pub const TCSAFLUSH: c_int = 2; pub const TCSASOFT: c_int = 0x10; termios-0.3.0/src/os/mod.rs01006440001750000175000000001075132110673160013755 0ustar0000000000000000//! OS-specific definitions. #[cfg(target_os = "linux")] pub use self::linux as target; #[cfg(target_os = "macos")] pub use self::macos as target; #[cfg(target_os = "freebsd")] pub use self::freebsd as target; #[cfg(target_os = "openbsd")] pub use self::openbsd as target; #[cfg(target_os = "dragonfly")] pub use self::dragonfly as target; #[cfg(target_os = "linux")] pub mod linux; #[cfg(target_os = "macos")] pub mod macos; #[cfg(target_os = "freebsd")] pub mod freebsd; #[cfg(target_os = "openbsd")] pub mod openbsd; #[cfg(target_os = "dragonfly")] pub mod dragonfly; termios-0.3.0/src/os/openbsd.rs01006440001750000175000000011106132110673160014624 0ustar0000000000000000#![allow(non_camel_case_types)] use libc::{c_int,c_uint,c_uchar}; pub type cc_t = c_uchar; pub type speed_t = c_uint; pub type tcflag_t = c_uint; #[derive(Debug,Copy,Clone,Eq,PartialEq)] #[repr(C)] pub struct termios { pub c_iflag: tcflag_t, pub c_oflag: tcflag_t, pub c_cflag: tcflag_t, pub c_lflag: tcflag_t, pub c_cc: [cc_t; NCCS], c_ispeed: speed_t, c_ospeed: speed_t } pub const NCCS: usize = 20; // c_cc characters pub const VEOF: usize = 0; pub const VEOL: usize = 1; pub const VEOL2: usize = 2; pub const VERASE: usize = 3; pub const VWERASE: usize = 4; pub const VKILL: usize = 5; pub const VREPRINT: usize = 6; pub const VERASE2: usize = 7; pub const VINTR: usize = 8; pub const VQUIT: usize = 9; pub const VSUSP: usize = 10; pub const VSTART: usize = 12; pub const VSTOP: usize = 13; pub const VLNEXT: usize = 14; pub const VDISCARD: usize = 15; pub const VMIN: usize = 16; pub const VTIME: usize = 17; // c_iflag bits pub const IGNBRK: tcflag_t = 0x00000001; pub const BRKINT: tcflag_t = 0x00000002; pub const IGNPAR: tcflag_t = 0x00000004; pub const PARMRK: tcflag_t = 0x00000008; pub const INPCK: tcflag_t = 0x00000010; pub const ISTRIP: tcflag_t = 0x00000020; pub const INLCR: tcflag_t = 0x00000040; pub const IGNCR: tcflag_t = 0x00000080; pub const ICRNL: tcflag_t = 0x00000100; pub const IXON: tcflag_t = 0x00000200; pub const IXOFF: tcflag_t = 0x00000400; pub const IXANY: tcflag_t = 0x00000800; pub const IMAXBEL: tcflag_t = 0x00002000; // c_oflag bits pub const OPOST: tcflag_t = 0x00000001; pub const ONLCR: tcflag_t = 0x00000002; pub const TAB3: tcflag_t = 0x00000004; pub const OXTABS: tcflag_t = TAB3; pub const ONOEOT: tcflag_t = 0x00000008; pub const OCRNL: tcflag_t = 0x00000010; pub const ONOCR: tcflag_t = 0x00000040; pub const ONLRET: tcflag_t = 0x00000080; // c_cflag bits pub const CIGNORE: tcflag_t = 0x00000001; pub const CSIZE: tcflag_t = 0x00000300; pub const CS5: tcflag_t = 0x00000000; pub const CS6: tcflag_t = 0x00000100; pub const CS7: tcflag_t = 0x00000200; pub const CS8: tcflag_t = 0x00000300; pub const CSTOPB: tcflag_t = 0x00000400; pub const CREAD: tcflag_t = 0x00000800; pub const PARENB: tcflag_t = 0x00001000; pub const PARODD: tcflag_t = 0x00002000; pub const HUPCL: tcflag_t = 0x00004000; pub const CLOCAL: tcflag_t = 0x00008000; pub const CRTSCTS: tcflag_t = 0x00010000; pub const CRTS_IFLOW: tcflag_t = CRTSCTS; pub const CCTS_OFLOW: tcflag_t = CRTSCTS; pub const MDMBUF: tcflag_t = 0x00100000; // c_lflag bits pub const ECHOKE: tcflag_t = 0x00000001; pub const ECHOE: tcflag_t = 0x00000002; pub const ECHOK: tcflag_t = 0x00000004; pub const ECHO: tcflag_t = 0x00000008; pub const ECHONL: tcflag_t = 0x00000010; pub const ECHOPRT: tcflag_t = 0x00000020; pub const ECHOCTL: tcflag_t = 0x00000040; pub const ISIG: tcflag_t = 0x00000080; pub const ICANON: tcflag_t = 0x00000100; pub const ALTWERASE: tcflag_t = 0x00000200; pub const IEXTEN: tcflag_t = 0x00000400; pub const EXTPROC: tcflag_t = 0x00000800; pub const TOSTOP: tcflag_t = 0x00400000; pub const FLUSHO: tcflag_t = 0x00800000; pub const NOKERNINFO: tcflag_t = 0x02000000; pub const PENDIN: tcflag_t = 0x20000000; pub const NOFLSH: tcflag_t = 0x80000000; // baud rates pub const B0: speed_t = 0; pub const B50: speed_t = 50; pub const B75: speed_t = 75; pub const B110: speed_t = 110; pub const B134: speed_t = 134; pub const B150: speed_t = 150; pub const B200: speed_t = 200; pub const B300: speed_t = 300; pub const B600: speed_t = 600; pub const B1200: speed_t = 1200; pub const B1800: speed_t = 1800; pub const B2400: speed_t = 2400; pub const B4800: speed_t = 4800; pub const B9600: speed_t = 9600; pub const B19200: speed_t = 19200; pub const B38400: speed_t = 38400; pub const B7200: speed_t = 7200; pub const B14400: speed_t = 14400; pub const B28800: speed_t = 28800; pub const B57600: speed_t = 57600; pub const B76800: speed_t = 76800; pub const B115200: speed_t = 115200; pub const B230400: speed_t = 230400; pub const EXTA: speed_t = 19200; pub const EXTB: speed_t = 38400; // tcflow() pub const TCOOFF: c_int = 1; pub const TCOON: c_int = 2; pub const TCIOFF: c_int = 3; pub const TCION: c_int = 4; // tcflush() pub const TCIFLUSH: c_int = 1; pub const TCOFLUSH: c_int = 2; pub const TCIOFLUSH: c_int = 3; // tcsetattr() pub const TCSANOW: c_int = 0; pub const TCSADRAIN: c_int = 1; pub const TCSAFLUSH: c_int = 2; pub const TCSASOFT: c_int = 0x10;