From ae8e2d30db561a556ee0a82dce0dcda3d6f82623 Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Sat, 14 Apr 2001 23:13:02 +0000 Subject: - stevesk@cvs.openbsd.org 2001/04/14 16:33:20 [clientloop.c packet.h session.c ssh.c ttymodes.c ttymodes.h] protocol 2 tty modes support; ok markus@ --- clientloop.c | 56 ++++---------------------------------------------------- 1 file changed, 4 insertions(+), 52 deletions(-) (limited to 'clientloop.c') diff --git a/clientloop.c b/clientloop.c index 94d2ec60..24ea0dec 100644 --- a/clientloop.c +++ b/clientloop.c @@ -59,7 +59,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: clientloop.c,v 1.61 2001/04/08 11:27:33 markus Exp $"); +RCSID("$OpenBSD: clientloop.c,v 1.62 2001/04/14 16:33:20 stevesk Exp $"); #include "ssh.h" #include "ssh1.h" @@ -79,6 +79,7 @@ RCSID("$OpenBSD: clientloop.c,v 1.61 2001/04/08 11:27:33 markus Exp $"); #include "clientloop.h" #include "authfd.h" #include "atomicio.h" +#include "sshtty.h" /* import options */ extern Options options; @@ -101,15 +102,6 @@ extern char *host; */ static volatile int received_window_change_signal = 0; -/* Terminal modes, as saved by enter_raw_mode. */ -static struct termios saved_tio; - -/* - * Flag indicating whether we are in raw mode. This is used by - * enter_raw_mode and leave_raw_mode. - */ -static int in_raw_mode = 0; - /* Flag indicating whether the user\'s terminal is in non-blocking mode. */ static int in_non_blocking_mode = 0; @@ -136,46 +128,6 @@ int session_ident = -1; /*XXX*/ extern Kex *xxx_kex; -/* Returns the user\'s terminal to normal mode if it had been put in raw mode. */ - -void -leave_raw_mode(void) -{ - if (!in_raw_mode) - return; - in_raw_mode = 0; - if (tcsetattr(fileno(stdin), TCSADRAIN, &saved_tio) < 0) - perror("tcsetattr"); - - fatal_remove_cleanup((void (*) (void *)) leave_raw_mode, NULL); -} - -/* Puts the user\'s terminal in raw mode. */ - -void -enter_raw_mode(void) -{ - struct termios tio; - - if (tcgetattr(fileno(stdin), &tio) < 0) - perror("tcgetattr"); - saved_tio = tio; - tio.c_iflag |= IGNPAR; - tio.c_iflag &= ~(ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXANY | IXOFF); - tio.c_lflag &= ~(ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHONL); -#ifdef IEXTEN - tio.c_lflag &= ~IEXTEN; -#endif /* IEXTEN */ - tio.c_oflag &= ~OPOST; - tio.c_cc[VMIN] = 1; - tio.c_cc[VTIME] = 0; - if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) < 0) - perror("tcsetattr"); - in_raw_mode = 1; - - fatal_add_cleanup((void (*) (void *)) leave_raw_mode, NULL); -} - /* Restores stdin to blocking mode. */ void @@ -218,7 +170,7 @@ window_change_handler(int sig) void signal_handler(int sig) { - if (in_raw_mode) + if (in_raw_mode()) leave_raw_mode(); if (in_non_blocking_mode) leave_non_blocking(); @@ -796,7 +748,7 @@ client_channel_closed(int id, void *arg) error("client_channel_closed: id %d != session_ident %d", id, session_ident); session_closed = 1; - if (in_raw_mode) + if (in_raw_mode()) leave_raw_mode(); } -- cgit v1.2.3