/* XXX: recursive operations */
#include "includes.h"
-RCSID("$OpenBSD: sftp-int.c,v 1.32 2001/03/23 13:10:57 markus Exp $");
+RCSID("$OpenBSD: sftp-int.c,v 1.36 2001/04/15 08:43:46 markus Exp $");
#include "buffer.h"
#include "xmalloc.h"
{ "dir", I_LS },
{ "exit", I_QUIT },
{ "get", I_GET },
+ { "mget", I_GET },
{ "help", I_HELP },
{ "lcd", I_LCHDIR },
{ "lchdir", I_LCHDIR },
{ "lumask", I_LUMASK },
{ "mkdir", I_MKDIR },
{ "put", I_PUT },
+ { "mput", I_PUT },
{ "pwd", I_PWD },
{ "quit", I_QUIT },
{ "rename", I_RENAME },
void
local_do_shell(const char *args)
{
- int ret, status;
+ int status;
char *shell;
pid_t pid;
/* XXX: child has pipe fds to ssh subproc open - issue? */
if (args) {
debug3("Executing %s -c \"%s\"", shell, args);
- ret = execl(shell, shell, "-c", args, NULL);
+ execl(shell, shell, "-c", args, NULL);
} else {
debug3("Executing %s", shell);
- ret = execl(shell, shell, NULL);
+ execl(shell, shell, NULL);
}
fprintf(stderr, "Couldn't execute \"%s\": %s\n", shell,
strerror(errno));
break;
case I_PUT:
err = process_put(in, out, path1, path2, *pwd, pflag);
- break;
- case I_RENAME:
+ break;
+ case I_RENAME:
path1 = make_absolute(path1, *pwd);
path2 = make_absolute(path2, *pwd);
err = do_rename(in, out, path1, path2);
}
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);
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);