diff options
Diffstat (limited to 'clientloop.c')
-rw-r--r-- | clientloop.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/clientloop.c b/clientloop.c index 91a200663..cc25ca550 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * clientloop.c | 3 | * clientloop.c |
4 | * | 4 | * |
5 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 5 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
6 | * | 6 | * |
7 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 7 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
8 | * All rights reserved | 8 | * All rights reserved |
9 | * | 9 | * |
10 | * | 10 | * |
11 | * Created: Sat Sep 23 12:23:57 1995 ylo | 11 | * Created: Sat Sep 23 12:23:57 1995 ylo |
12 | * | 12 | * |
13 | * The main loop for the interactive session (client side). | 13 | * The main loop for the interactive session (client side). |
14 | * | 14 | * |
15 | * SSH2 support added by Markus Friedl. | 15 | * SSH2 support added by Markus Friedl. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "includes.h" | 18 | #include "includes.h" |
19 | RCSID("$Id: clientloop.c,v 1.10 2000/04/12 10:17:39 damien Exp $"); | 19 | RCSID("$Id: clientloop.c,v 1.11 2000/04/16 01:18:41 damien Exp $"); |
20 | 20 | ||
21 | #include "xmalloc.h" | 21 | #include "xmalloc.h" |
22 | #include "ssh.h" | 22 | #include "ssh.h" |
@@ -83,7 +83,7 @@ int session_ident = -1; | |||
83 | 83 | ||
84 | /* Returns the user\'s terminal to normal mode if it had been put in raw mode. */ | 84 | /* Returns the user\'s terminal to normal mode if it had been put in raw mode. */ |
85 | 85 | ||
86 | void | 86 | void |
87 | leave_raw_mode() | 87 | leave_raw_mode() |
88 | { | 88 | { |
89 | if (!in_raw_mode) | 89 | if (!in_raw_mode) |
@@ -97,7 +97,7 @@ leave_raw_mode() | |||
97 | 97 | ||
98 | /* Puts the user\'s terminal in raw mode. */ | 98 | /* Puts the user\'s terminal in raw mode. */ |
99 | 99 | ||
100 | void | 100 | void |
101 | enter_raw_mode() | 101 | enter_raw_mode() |
102 | { | 102 | { |
103 | struct termios tio; | 103 | struct termios tio; |
@@ -123,7 +123,7 @@ enter_raw_mode() | |||
123 | 123 | ||
124 | /* Restores stdin to blocking mode. */ | 124 | /* Restores stdin to blocking mode. */ |
125 | 125 | ||
126 | void | 126 | void |
127 | leave_non_blocking() | 127 | leave_non_blocking() |
128 | { | 128 | { |
129 | if (in_non_blocking_mode) { | 129 | if (in_non_blocking_mode) { |
@@ -135,7 +135,7 @@ leave_non_blocking() | |||
135 | 135 | ||
136 | /* Puts stdin terminal in non-blocking mode. */ | 136 | /* Puts stdin terminal in non-blocking mode. */ |
137 | 137 | ||
138 | void | 138 | void |
139 | enter_non_blocking() | 139 | enter_non_blocking() |
140 | { | 140 | { |
141 | in_non_blocking_mode = 1; | 141 | in_non_blocking_mode = 1; |
@@ -148,7 +148,7 @@ enter_non_blocking() | |||
148 | * flag indicating that the window has changed. | 148 | * flag indicating that the window has changed. |
149 | */ | 149 | */ |
150 | 150 | ||
151 | void | 151 | void |
152 | window_change_handler(int sig) | 152 | window_change_handler(int sig) |
153 | { | 153 | { |
154 | received_window_change_signal = 1; | 154 | received_window_change_signal = 1; |
@@ -160,7 +160,7 @@ window_change_handler(int sig) | |||
160 | * signals must be trapped to restore terminal modes. | 160 | * signals must be trapped to restore terminal modes. |
161 | */ | 161 | */ |
162 | 162 | ||
163 | void | 163 | void |
164 | signal_handler(int sig) | 164 | signal_handler(int sig) |
165 | { | 165 | { |
166 | if (in_raw_mode) | 166 | if (in_raw_mode) |
@@ -177,7 +177,7 @@ signal_handler(int sig) | |||
177 | * available resolution. | 177 | * available resolution. |
178 | */ | 178 | */ |
179 | 179 | ||
180 | double | 180 | double |
181 | get_current_time() | 181 | get_current_time() |
182 | { | 182 | { |
183 | struct timeval tv; | 183 | struct timeval tv; |
@@ -191,7 +191,7 @@ get_current_time() | |||
191 | * not appear to wake up when redirecting from /dev/null. | 191 | * not appear to wake up when redirecting from /dev/null. |
192 | */ | 192 | */ |
193 | 193 | ||
194 | void | 194 | void |
195 | client_check_initial_eof_on_stdin() | 195 | client_check_initial_eof_on_stdin() |
196 | { | 196 | { |
197 | int len; | 197 | int len; |
@@ -245,7 +245,7 @@ client_check_initial_eof_on_stdin() | |||
245 | * connection. | 245 | * connection. |
246 | */ | 246 | */ |
247 | 247 | ||
248 | void | 248 | void |
249 | client_make_packets_from_stdin_data() | 249 | client_make_packets_from_stdin_data() |
250 | { | 250 | { |
251 | unsigned int len; | 251 | unsigned int len; |
@@ -276,7 +276,7 @@ client_make_packets_from_stdin_data() | |||
276 | * appropriate. | 276 | * appropriate. |
277 | */ | 277 | */ |
278 | 278 | ||
279 | void | 279 | void |
280 | client_check_window_change() | 280 | client_check_window_change() |
281 | { | 281 | { |
282 | struct winsize ws; | 282 | struct winsize ws; |
@@ -313,7 +313,7 @@ client_check_window_change() | |||
313 | * one of the file descriptors). | 313 | * one of the file descriptors). |
314 | */ | 314 | */ |
315 | 315 | ||
316 | void | 316 | void |
317 | client_wait_until_can_do_something(fd_set * readset, fd_set * writeset) | 317 | client_wait_until_can_do_something(fd_set * readset, fd_set * writeset) |
318 | { | 318 | { |
319 | /*debug("client_wait_until_can_do_something"); */ | 319 | /*debug("client_wait_until_can_do_something"); */ |
@@ -380,7 +380,7 @@ client_wait_until_can_do_something(fd_set * readset, fd_set * writeset) | |||
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | void | 383 | void |
384 | client_suspend_self() | 384 | client_suspend_self() |
385 | { | 385 | { |
386 | struct winsize oldws, newws; | 386 | struct winsize oldws, newws; |
@@ -425,7 +425,7 @@ client_suspend_self() | |||
425 | enter_raw_mode(); | 425 | enter_raw_mode(); |
426 | } | 426 | } |
427 | 427 | ||
428 | void | 428 | void |
429 | client_process_net_input(fd_set * readset) | 429 | client_process_net_input(fd_set * readset) |
430 | { | 430 | { |
431 | int len; | 431 | int len; |
@@ -468,7 +468,7 @@ client_process_net_input(fd_set * readset) | |||
468 | } | 468 | } |
469 | } | 469 | } |
470 | 470 | ||
471 | void | 471 | void |
472 | client_process_input(fd_set * readset) | 472 | client_process_input(fd_set * readset) |
473 | { | 473 | { |
474 | int len, pid; | 474 | int len, pid; |
@@ -657,7 +657,7 @@ Supported escape sequences:\r\n\ | |||
657 | } | 657 | } |
658 | } | 658 | } |
659 | 659 | ||
660 | void | 660 | void |
661 | client_process_output(fd_set * writeset) | 661 | client_process_output(fd_set * writeset) |
662 | { | 662 | { |
663 | int len; | 663 | int len; |
@@ -717,7 +717,7 @@ client_process_output(fd_set * writeset) | |||
717 | * preparatory phase. | 717 | * preparatory phase. |
718 | */ | 718 | */ |
719 | 719 | ||
720 | void | 720 | void |
721 | client_process_buffered_input_packets() | 721 | client_process_buffered_input_packets() |
722 | { | 722 | { |
723 | dispatch_run(DISPATCH_NONBLOCK, &quit_pending); | 723 | dispatch_run(DISPATCH_NONBLOCK, &quit_pending); |
@@ -730,7 +730,7 @@ client_process_buffered_input_packets() | |||
730 | * character for terminating or suspending the session. | 730 | * character for terminating or suspending the session. |
731 | */ | 731 | */ |
732 | 732 | ||
733 | int | 733 | int |
734 | client_loop(int have_pty, int escape_char_arg) | 734 | client_loop(int have_pty, int escape_char_arg) |
735 | { | 735 | { |
736 | extern Options options; | 736 | extern Options options; |
@@ -953,7 +953,7 @@ client_input_exit_status(int type, int plen) | |||
953 | quit_pending = 1; | 953 | quit_pending = 1; |
954 | } | 954 | } |
955 | 955 | ||
956 | void | 956 | void |
957 | client_init_dispatch_20() | 957 | client_init_dispatch_20() |
958 | { | 958 | { |
959 | dispatch_init(&dispatch_protocol_error); | 959 | dispatch_init(&dispatch_protocol_error); |
@@ -966,7 +966,7 @@ client_init_dispatch_20() | |||
966 | dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request); | 966 | dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request); |
967 | dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); | 967 | dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); |
968 | } | 968 | } |
969 | void | 969 | void |
970 | client_init_dispatch_13() | 970 | client_init_dispatch_13() |
971 | { | 971 | { |
972 | dispatch_init(NULL); | 972 | dispatch_init(NULL); |
@@ -983,14 +983,14 @@ client_init_dispatch_13() | |||
983 | dispatch_set(SSH_SMSG_STDOUT_DATA, &client_input_stdout_data); | 983 | dispatch_set(SSH_SMSG_STDOUT_DATA, &client_input_stdout_data); |
984 | dispatch_set(SSH_SMSG_X11_OPEN, &x11_input_open); | 984 | dispatch_set(SSH_SMSG_X11_OPEN, &x11_input_open); |
985 | } | 985 | } |
986 | void | 986 | void |
987 | client_init_dispatch_15() | 987 | client_init_dispatch_15() |
988 | { | 988 | { |
989 | client_init_dispatch_13(); | 989 | client_init_dispatch_13(); |
990 | dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof); | 990 | dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof); |
991 | dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, & channel_input_oclose); | 991 | dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, & channel_input_oclose); |
992 | } | 992 | } |
993 | void | 993 | void |
994 | client_init_dispatch() | 994 | client_init_dispatch() |
995 | { | 995 | { |
996 | if (compat20) | 996 | if (compat20) |
@@ -1027,6 +1027,7 @@ client_input_channel_req(int id, void *arg) | |||
1027 | } else if (strcmp(rtype, "exit-status") == 0) { | 1027 | } else if (strcmp(rtype, "exit-status") == 0) { |
1028 | success = 1; | 1028 | success = 1; |
1029 | exit_status = packet_get_int(); | 1029 | exit_status = packet_get_int(); |
1030 | packet_done(); | ||
1030 | } | 1031 | } |
1031 | if (reply) { | 1032 | if (reply) { |
1032 | packet_start(success ? | 1033 | packet_start(success ? |