diff 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
line wrap: on
line diff
--- a/cli-session.c	Fri Jul 30 12:29:53 2004 +0000
+++ b/cli-session.c	Sun Aug 01 08:54:01 2004 +0000
@@ -9,10 +9,13 @@
 #include "channel.h"
 #include "random.h"
 #include "service.h"
+#include "runopts.h"
+#include "chansession.h"
 
 static void cli_remoteclosed();
 static void cli_sessionloop();
 static void cli_session_init();
+static void cli_finished();
 
 struct clientsession cli_ses; /* GLOBAL */
 
@@ -163,6 +166,12 @@
 			cli_ses.state = SESSION_RUNNING;
 			return;
 
+		case SESSION_RUNNING:
+			if (ses.chancount < 1) {
+				cli_finished();
+			}
+			return;
+
 		/* XXX more here needed */
 
 
@@ -174,6 +183,26 @@
 
 }
 
+void cli_session_cleanup() {
+
+	if (!sessinitdone) {
+		return;
+	}
+	cli_tty_cleanup();
+
+}
+
+static void cli_finished() {
+
+	cli_session_cleanup();
+	common_session_cleanup();
+	fprintf(stderr, "Connection to %s@%s:%s closed.\n", cli_opts.username,
+			cli_opts.remotehost, cli_opts.remoteport);
+	exit(EXIT_SUCCESS);
+}
+
+
+
 /* called when the remote side closes the connection */
 static void cli_remoteclosed() {