version 1.61, 2001/04/08 11:27:33 |
version 1.62, 2001/04/14 16:33:20 |
|
|
#include "clientloop.h" |
#include "clientloop.h" |
#include "authfd.h" |
#include "authfd.h" |
#include "atomicio.h" |
#include "atomicio.h" |
|
#include "sshtty.h" |
|
|
/* import options */ |
/* import options */ |
extern Options options; |
extern Options options; |
|
|
*/ |
*/ |
static volatile int received_window_change_signal = 0; |
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. */ |
/* Flag indicating whether the user\'s terminal is in non-blocking mode. */ |
static int in_non_blocking_mode = 0; |
static int in_non_blocking_mode = 0; |
|
|
|
|
/*XXX*/ |
/*XXX*/ |
extern Kex *xxx_kex; |
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. */ |
/* Restores stdin to blocking mode. */ |
|
|
void |
void |
|
|
void |
void |
signal_handler(int sig) |
signal_handler(int sig) |
{ |
{ |
if (in_raw_mode) |
if (in_raw_mode()) |
leave_raw_mode(); |
leave_raw_mode(); |
if (in_non_blocking_mode) |
if (in_non_blocking_mode) |
leave_non_blocking(); |
leave_non_blocking(); |
|
|
error("client_channel_closed: id %d != session_ident %d", |
error("client_channel_closed: id %d != session_ident %d", |
id, session_ident); |
id, session_ident); |
session_closed = 1; |
session_closed = 1; |
if (in_raw_mode) |
if (in_raw_mode()) |
leave_raw_mode(); |
leave_raw_mode(); |
} |
} |
|
|