Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-12-16 22:19:59 +0300
committerSimon Tatham <anakin@pobox.com>2004-12-16 22:19:59 +0300
commit5ea746b15d173ab75f10ae661432eb57a5a22c20 (patch)
tree1f8fe4c9a8d818a5b143eedf1acd351ba3ec78e5 /psftp.c
parentf1585f8f46fda41bb7707e507760d48e963c24b9 (diff)
Implement the `close' command, which terminates an SFTP session but
does not quit PSFTP, so you can then issue another `open' to connect to somewhere else. This has apparently been trivial for some time, for exactly the same reasons that `reuse-windows' was so easy, but it hadn't occurred to me to actually do it until now. [originally from svn r4994]
Diffstat (limited to 'psftp.c')
-rw-r--r--psftp.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/psftp.c b/psftp.c
index 8dcee0e2..b1cfe16d 100644
--- a/psftp.c
+++ b/psftp.c
@@ -767,6 +767,23 @@ int sftp_cmd_quit(struct sftp_command *cmd)
return -1;
}
+int sftp_cmd_close(struct sftp_command *cmd)
+{
+ if (back == NULL) {
+ printf("psftp: not connected to a host; use \"open host.name\"\n");
+ return 0;
+ }
+
+ if (back != NULL && back->socket(backhandle) != NULL) {
+ char ch;
+ back->special(backhandle, TS_EOF);
+ sftp_recvdata(&ch, 1);
+ }
+ do_sftp_cleanup();
+
+ return 0;
+}
+
/*
* List a directory. If no arguments are given, list pwd; otherwise
* list the directory given in words[1].
@@ -1632,6 +1649,14 @@ static struct sftp_cmd_lookup {
sftp_cmd_chmod
},
{
+ "close", TRUE, "finish your SFTP session but do not quit PSFTP",
+ "\n"
+ " Terminates your SFTP session, but does not quit the PSFTP\n"
+ " program. You can then use \"open\" to start another SFTP\n"
+ " session, to the same server or to a different one.\n",
+ sftp_cmd_close
+ },
+ {
"del", TRUE, "delete a file",
" <filename>\n"
" Delete a file.\n",
@@ -2579,12 +2604,10 @@ int psftp_main(int argc, char *argv[])
back->special(backhandle, TS_EOF);
sftp_recvdata(&ch, 1);
}
+ do_sftp_cleanup();
random_save_seed();
cmdline_cleanup();
console_provide_logctx(NULL);
- do_sftp_cleanup();
- backhandle = NULL;
- back = NULL;
sk_cleanup();
return 0;