Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FreeBSD support #3

Merged
merged 2 commits into from
Oct 16, 2015
Merged

Add FreeBSD support #3

merged 2 commits into from
Oct 16, 2015

Conversation

valpackett
Copy link
Contributor

Should also add OpenBSD and NetBSD, but I don't have them running on anything right now…

@dcuddeback
Copy link
Owner

Nice! Thanks for doing this.

@@ -106,7 +111,8 @@ 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,OFILL,NLDLY,NL0,NL1,CRDLY,CR0,CR1,CR2,CR3,TABDLY,TAB0,TAB1,TAB2,TAB3,BSDLY,BS0,BS1,VTDLY,VT0,VT1,FFDLY,FF0,FF1}; // output modes
#[cfg(any(target_os = "linux", target_os = "macos"))] pub use ::os::target::{OPOST,ONLCR,OCRNL,ONOCR,ONLRET,OFILL,NLDLY,NL0,NL1,CRDLY,CR0,CR1,CR2,CR3,TABDLY,TAB0,TAB1,TAB2,TAB3,BSDLY,BS0,BS1,VTDLY,VT0,VT1,FFDLY,FF0,FF1}; // output modes
#[cfg(target_os = "freebsd")] pub use ::os::target::{OPOST,ONLCR,TABDLY,TAB0,TAB3,ONOEOT,OCRNL,ONOCR,ONLRET}; // output modes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way the crate is organized, the constants exported here are supposed to be fairly cross platform. It was previously exporting just the POSIX-defined constants, but I didn't realize that BSD doesn't define some of them. I doubt any of the other constants are in common use, so I think it would be best to remove the other constants here for all OS's so that the interface remains the same on all platforms. The others will still be accessible through termios::os. At least then it's clear for a user when they're using a constant that won't compile on all platforms. This will be a breaking change, but I can bump the version to v0.2.

@valpackett
Copy link
Contributor Author

Makes sense!

Here's man termios from different operating systems:

FreeBSD:

           OPOST   /* enable following output processing */
           ONLCR   /* map NL to CR-NL (ala CRMOD) */
           OCRNL   /* map CR to NL */
           TABDLY  /* tab delay mask */
           TAB0    /* no tab delay and expansion */
           TAB3    /* expand tabs to spaces */
           ONOEOT  /* discard EOT's ‘^D’ on output) */
           ONOCR   /* do not transmit CRs on column 0 */
           ONLRET  /* on the terminal NL performs the CR function */

OpenBSD:

           OPOST    /* enable following output processing */
           ONLCR    /* map NL to CR-NL (ala CRMOD) */
           OXTABS   /* expand tabs to spaces */
           ONOEOT   /* discard EOT's (^D) on output */
           OCRNL    /* map CR to NL */
           OLCUC    /* translate lower case to upper case */
           ONOCR    /* No CR output at column 0 */
           ONLRET   /* NL performs the CR function */ 

NetBSD:

          OPOST      /* enable following output processing */
          ONLCR      /* map NL to CR-NL (ala CRMOD) */
          OCRNL      /* map CR to NL */
          OXTABS     /* expand tabs to spaces */
          ONOEOT     /* discard EOT's (^D) on output */
          ONOCR      /* do not transmit CRs on column 0 */
          ONLRET     /* on the terminal NL performs the CR function */ 

OS X:

           OPOST     /* enable following output processing */
           ONLCR     /* map NL to CR-NL (ala CRMOD) */
           OXTABS    /* expand tabs to spaces */
           ONOEOT    /* discard EOT's `^D' on output) */
           OCRNL     /* map CR to NL */
           OLCUC     /* translate lower case to upper case */
           ONOCR     /* No CR output at column 0 */
           ONLRET    /* NL performs CR function */

The least common subset seems to be OPOST, ONLCR, OCRNL, ONOEOT, ONOCR, ONLRET.

And OXTABS which is named TAB3 on FreeBSD for some reason :D

@dcuddeback
Copy link
Owner

Looks great. Thanks!

dcuddeback added a commit that referenced this pull request Oct 16, 2015
@dcuddeback dcuddeback merged commit c224ff4 into dcuddeback:master Oct 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants