comparison cli-session.c @ 40:b4874d772210

- Added terminal mode handling etc for the client, and window change - Refactored the terminal-mode handling for the server - Improved session closing for the client
author Matt Johnston <matt@ucc.asn.au>
date Sun, 01 Aug 2004 08:54:01 +0000
parents 0883c0906870
children 18eccbfb9641
comparison
equal deleted inserted replaced
39:0883c0906870 40:b4874d772210
7 #include "tcpfwd-direct.h" 7 #include "tcpfwd-direct.h"
8 #include "tcpfwd-remote.h" 8 #include "tcpfwd-remote.h"
9 #include "channel.h" 9 #include "channel.h"
10 #include "random.h" 10 #include "random.h"
11 #include "service.h" 11 #include "service.h"
12 #include "runopts.h"
13 #include "chansession.h"
12 14
13 static void cli_remoteclosed(); 15 static void cli_remoteclosed();
14 static void cli_sessionloop(); 16 static void cli_sessionloop();
15 static void cli_session_init(); 17 static void cli_session_init();
18 static void cli_finished();
16 19
17 struct clientsession cli_ses; /* GLOBAL */ 20 struct clientsession cli_ses; /* GLOBAL */
18 21
19 static const packettype cli_packettypes[] = { 22 static const packettype cli_packettypes[] = {
20 /* TYPE, AUTHREQUIRED, FUNCTION */ 23 /* TYPE, AUTHREQUIRED, FUNCTION */
161 cli_send_chansess_request(); 164 cli_send_chansess_request();
162 TRACE(("leave cli_sessionloop: cli_send_chansess_request")); 165 TRACE(("leave cli_sessionloop: cli_send_chansess_request"));
163 cli_ses.state = SESSION_RUNNING; 166 cli_ses.state = SESSION_RUNNING;
164 return; 167 return;
165 168
169 case SESSION_RUNNING:
170 if (ses.chancount < 1) {
171 cli_finished();
172 }
173 return;
174
166 /* XXX more here needed */ 175 /* XXX more here needed */
167 176
168 177
169 default: 178 default:
170 break; 179 break;
171 } 180 }
172 181
173 TRACE(("leave cli_sessionloop: fell out")); 182 TRACE(("leave cli_sessionloop: fell out"));
174 183
175 } 184 }
185
186 void cli_session_cleanup() {
187
188 if (!sessinitdone) {
189 return;
190 }
191 cli_tty_cleanup();
192
193 }
194
195 static void cli_finished() {
196
197 cli_session_cleanup();
198 common_session_cleanup();
199 fprintf(stderr, "Connection to %s@%s:%s closed.\n", cli_opts.username,
200 cli_opts.remotehost, cli_opts.remoteport);
201 exit(EXIT_SUCCESS);
202 }
203
204
176 205
177 /* called when the remote side closes the connection */ 206 /* called when the remote side closes the connection */
178 static void cli_remoteclosed() { 207 static void cli_remoteclosed() {
179 208
180 /* XXX TODO perhaps print a friendlier message if we get this but have 209 /* XXX TODO perhaps print a friendlier message if we get this but have