diff options
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/Makefile.inc | 6 | ||||
-rw-r--r-- | lib/libc/gen/Symbol.map | 1 | ||||
-rw-r--r-- | lib/libc/gen/tcsetattr.3 | 17 | ||||
-rw-r--r-- | lib/libc/gen/termios.c | 19 |
4 files changed, 37 insertions, 6 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 32888dd..d55bc46 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -180,9 +180,9 @@ MLINKS+=syslog.3 closelog.3 syslog.3 openlog.3 syslog.3 setlogmask.3 \ syslog.3 vsyslog.3 MLINKS+=tcsendbreak.3 tcdrain.3 tcsendbreak.3 tcflow.3 tcsendbreak.3 tcflush.3 MLINKS+=tcsetattr.3 cfgetispeed.3 tcsetattr.3 cfgetospeed.3 \ - tcsetattr.3 cfmakeraw.3 tcsetattr.3 cfsetispeed.3 \ - tcsetattr.3 cfsetospeed.3 tcsetattr.3 cfsetspeed.3 \ - tcsetattr.3 tcgetattr.3 + tcsetattr.3 cfmakeraw.3 tcsetattr.3 cfmakesane.3 \ + tcsetattr.3 cfsetispeed.3 tcsetattr.3 cfsetospeed.3 \ + tcsetattr.3 cfsetspeed.3 tcsetattr.3 tcgetattr.3 MLINKS+=ttyname.3 isatty.3 ttyname.3 ttyname_r.3 MLINKS+=tzset.3 tzsetwall.3 MLINKS+=unvis.3 strunvis.3 unvis.3 strunvisx.3 diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index dd375b0..f9abab5 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -358,6 +358,7 @@ FBSD_1.1 { FBSD_1.2 { basename_r; + cfmakesane; endutxent; getpagesizes; getutxent; diff --git a/lib/libc/gen/tcsetattr.3 b/lib/libc/gen/tcsetattr.3 index 01628d3..9be012e 100644 --- a/lib/libc/gen/tcsetattr.3 +++ b/lib/libc/gen/tcsetattr.3 @@ -38,6 +38,7 @@ .Nm cfsetospeed , .Nm cfsetspeed , .Nm cfmakeraw , +.Nm cfmakesane , .Nm tcgetattr , .Nm tcsetattr .Nd manipulating the termios structure @@ -57,6 +58,8 @@ .Fn cfsetspeed "struct termios *t" "speed_t speed" .Ft void .Fn cfmakeraw "struct termios *t" +.Ft void +.Fn cfmakesane "struct termios *t" .Ft int .Fn tcgetattr "int fd" "struct termios *t" .Ft int @@ -64,6 +67,7 @@ .Sh DESCRIPTION The .Fn cfmakeraw , +.Fn cfmakesane , .Fn tcgetattr and .Fn tcsetattr @@ -180,14 +184,20 @@ The .Fn cfmakeraw function sets the flags stored in the termios structure to a state disabling all input and output processing, giving a -.Dq raw I/O path . +.Dq raw I/O path , +while the +.Fn cfmakesane +function sets them to a state similar to those of a newly created +terminal device. It should be noted that there is no function to reverse this effect. This is because there are a variety of processing options that could be re-enabled and the correct method is for an application to snapshot the current terminal state using the function .Fn tcgetattr , -setting raw mode with +setting raw or sane mode with .Fn cfmakeraw +or +.Fn cfmakesane and the subsequent .Fn tcsetattr , and then using another @@ -316,7 +326,8 @@ functions are expected to be compliant with the .St -p1003.1-88 specification. The -.Fn cfmakeraw +.Fn cfmakeraw , +.Fn cfmakesane and .Fn cfsetspeed functions, diff --git a/lib/libc/gen/termios.c b/lib/libc/gen/termios.c index fc21757..7e9f169 100644 --- a/lib/libc/gen/termios.c +++ b/lib/libc/gen/termios.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include <sys/time.h> #include <errno.h> +#include <string.h> +#define TTYDEFCHARS #include <termios.h> #include <unistd.h> #include "un-namespace.h" @@ -173,6 +175,23 @@ cfmakeraw(struct termios *t) t->c_cc[VTIME] = 0; } +/* + * Obtain a termios structure which is similar to the one provided by + * the kernel. + */ +void +cfmakesane(struct termios *t) +{ + + t->c_cflag = TTYDEF_CFLAG; + t->c_iflag = TTYDEF_IFLAG; + t->c_lflag = TTYDEF_LFLAG; + t->c_oflag = TTYDEF_OFLAG; + t->c_ispeed = TTYDEF_SPEED; + t->c_ospeed = TTYDEF_SPEED; + memcpy(&t->c_cc, ttydefchars, sizeof ttydefchars); +} + int tcsendbreak(int fd, int len __unused) { |