summaryrefslogtreecommitdiff
path: root/sftp-int.c
diff options
context:
space:
mode:
authormouring <mouring>2001-04-13 00:00:14 +0000
committermouring <mouring>2001-04-13 00:00:14 +0000
commit98adff8c9f8c222f70a231a82edf6a2728bbb5a8 (patch)
tree36fb47348fa0e8023bfb0c8347994bfb1652923b /sftp-int.c
parent1da736867dc34fd8b041253da3faae1b44df2a0f (diff)
downloadopenssh-98adff8c9f8c222f70a231a82edf6a2728bbb5a8.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.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/sftp-int.c b/sftp-int.c
index bbc97a1a..8ec504db 100644
--- a/sftp-int.c
+++ b/sftp-int.c
@@ -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);