summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tty.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2012-03-17 21:27:51 +0000
committernicm <nicm@openbsd.org>2012-03-17 21:27:51 +0000
commit9bbd68f04a8ae151bdb16f89b5e2cdfb3d0d19dc (patch)
tree4957dcf6bfaba1b18f3508419c389353eae2bd33 /usr.bin/tmux/tty.c
parenthvctl(4) is a driver for the "hvctl" Logical Domain Channel that allows the (diff)
downloadwireguard-openbsd-9bbd68f04a8ae151bdb16f89b5e2cdfb3d0d19dc.tar.xz
wireguard-openbsd-9bbd68f04a8ae151bdb16f89b5e2cdfb3d0d19dc.zip
Break out termios initialization into a separate function, from George
Nachman.
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r--usr.bin/tmux/tty.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index eca6afa841c..91108068b5c 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.126 2012/03/17 19:29:46 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.127 2012/03/17 21:27:51 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -175,18 +175,19 @@ tty_error_callback(
}
void
-tty_start_tty(struct tty *tty)
+tty_init_termios(int fd, struct termios *orig_tio, struct bufferevent *bufev)
{
struct termios tio;
- if (tty->fd == -1 || tcgetattr(tty->fd, &tty->tio) != 0)
+ if (fd == -1 || tcgetattr(fd, orig_tio) != 0)
return;
- setblocking(tty->fd, 0);
+ setblocking(fd, 0);
- bufferevent_enable(tty->event, EV_READ|EV_WRITE);
+ if (bufev != NULL)
+ bufferevent_enable(bufev, EV_READ|EV_WRITE);
- memcpy(&tio, &tty->tio, sizeof tio);
+ memcpy(&tio, orig_tio, sizeof tio);
tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR|IGNCR|IMAXBEL|ISTRIP);
tio.c_iflag |= IGNBRK;
tio.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONLRET);
@@ -194,8 +195,14 @@ tty_start_tty(struct tty *tty)
ECHOPRT|ECHOKE|ECHOCTL|ISIG);
tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 0;
- if (tcsetattr(tty->fd, TCSANOW, &tio) == 0)
- tcflush(tty->fd, TCIOFLUSH);
+ if (tcsetattr(fd, TCSANOW, &tio) == 0)
+ tcflush(fd, TCIOFLUSH);
+}
+
+void
+tty_start_tty(struct tty *tty)
+{
+ tty_init_termios(tty->fd, &tty->tio, tty->event);
tty_putcode(tty, TTYC_SMCUP);