diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-04-13 00:00:14 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-04-13 00:00:14 +0000 |
commit | 63667f6568d0667b91aea46f77d54311dcffb53a (patch) | |
tree | 8c6ac90b5d25a71cc96b1cb624edfd8271927aa2 /sftp-int.c | |
parent | 19066a112baff6107781dc337b27e557f43098c2 (diff) | |
download | openssh-git-63667f6568d0667b91aea46f77d54311dcffb53a.tar.gz |
- mouring@cvs.openbsd.org 2001/04/12 23:17:54
[sftp-int.c sftp-int.h sftp.1 sftp.c]
Add support for:
sftp [user@]host[:file [file]] - Fetch remote file(s)
sftp [user@]host[:dir[/]] - Start in remote dir/
OK deraadt@
Diffstat (limited to 'sftp-int.c')
-rw-r--r-- | sftp-int.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -26,7 +26,7 @@ /* XXX: recursive operations */ #include "includes.h" -RCSID("$OpenBSD: sftp-int.c,v 1.34 2001/04/11 07:06:22 djm Exp $"); +RCSID("$OpenBSD: sftp-int.c,v 1.35 2001/04/12 23:17:54 mouring Exp $"); #include "buffer.h" #include "xmalloc.h" @@ -856,9 +856,10 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd) } void -interactive_loop(int fd_in, int fd_out) +interactive_loop(int fd_in, int fd_out, char *file1, char *file2) { char *pwd; + char *dir = NULL; char cmd[2048]; version = do_init(fd_in, fd_out); @@ -869,6 +870,25 @@ interactive_loop(int fd_in, int fd_out) if (pwd == NULL) fatal("Need cwd"); + if (file1 != NULL) { + dir = xstrdup(file1); + dir = make_absolute(dir, pwd); + + if (remote_is_dir(fd_in, fd_out, dir) && file2 == NULL) { + printf("Changing to: %s\n", dir); + snprintf(cmd, sizeof cmd, "cd \"%s\"", dir); + parse_dispatch_command(fd_in, fd_out, cmd, &pwd); + } else { + if (file2 == NULL) + snprintf(cmd, sizeof cmd, "get %s", dir); + else + snprintf(cmd, sizeof cmd, "get %s %s", dir, + file2); + + parse_dispatch_command(fd_in, fd_out, cmd, &pwd); + return; + } + } setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(infile, NULL, _IOLBF, 0); |