summaryrefslogtreecommitdiff
path: root/sftp-int.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-04-13 00:00:14 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-04-13 00:00:14 +0000
commit63667f6568d0667b91aea46f77d54311dcffb53a (patch)
tree8c6ac90b5d25a71cc96b1cb624edfd8271927aa2 /sftp-int.c
parent19066a112baff6107781dc337b27e557f43098c2 (diff)
- 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);