summaryrefslogtreecommitdiff
path: root/sftp-int.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-01-10 21:43:24 +1100
committerDamien Miller <djm@mindrot.org>2003-01-10 21:43:24 +1100
commit62d57f605a84b8d80803a36a612a37a5137a9963 (patch)
treed8299282efb2b5216109b302d9e369b67c3e69cd /sftp-int.c
parent956f3fb28b93420e87a51d1611029accebb2e43b (diff)
- fgsch@cvs.openbsd.org 2003/01/10 08:19:07
[scp.c sftp.1 sftp.c sftp-client.c sftp-int.c] sftp progress meter support. original diffs by Nils Nordman <nino at nforced dot com> via markus@, merged to -current by me, djm@ ok.
Diffstat (limited to 'sftp-int.c')
-rw-r--r--sftp-int.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sftp-int.c b/sftp-int.c
index f2c8fa6dc..88b0530ab 100644
--- a/sftp-int.c
+++ b/sftp-int.c
@@ -25,7 +25,7 @@
25/* XXX: recursive operations */ 25/* XXX: recursive operations */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: sftp-int.c,v 1.51 2003/01/08 23:53:26 djm Exp $"); 28RCSID("$OpenBSD: sftp-int.c,v 1.52 2003/01/10 08:19:07 fgsch Exp $");
29 29
30#include "buffer.h" 30#include "buffer.h"
31#include "xmalloc.h" 31#include "xmalloc.h"
@@ -47,6 +47,9 @@ extern size_t copy_buffer_len;
47/* Number of concurrent outstanding requests */ 47/* Number of concurrent outstanding requests */
48extern int num_requests; 48extern int num_requests;
49 49
50/* This is set to 0 if the progressmeter is not desired. */
51int showprogress = 1;
52
50/* Seperators for interactive commands */ 53/* Seperators for interactive commands */
51#define WHITESPACE " \t\r\n" 54#define WHITESPACE " \t\r\n"
52 55
@@ -73,6 +76,7 @@ extern int num_requests;
73#define I_SHELL 20 76#define I_SHELL 20
74#define I_SYMLINK 21 77#define I_SYMLINK 21
75#define I_VERSION 22 78#define I_VERSION 22
79#define I_PROGRESS 23
76 80
77struct CMD { 81struct CMD {
78 const char *c; 82 const char *c;
@@ -100,6 +104,7 @@ const struct CMD cmds[] = {
100 { "ls", I_LS }, 104 { "ls", I_LS },
101 { "lumask", I_LUMASK }, 105 { "lumask", I_LUMASK },
102 { "mkdir", I_MKDIR }, 106 { "mkdir", I_MKDIR },
107 { "progress", I_PROGRESS },
103 { "put", I_PUT }, 108 { "put", I_PUT },
104 { "mput", I_PUT }, 109 { "mput", I_PUT },
105 { "pwd", I_PWD }, 110 { "pwd", I_PWD },
@@ -132,6 +137,7 @@ help(void)
132 printf("ls [path] Display remote directory listing\n"); 137 printf("ls [path] Display remote directory listing\n");
133 printf("lumask umask Set local umask to 'umask'\n"); 138 printf("lumask umask Set local umask to 'umask'\n");
134 printf("mkdir path Create remote directory\n"); 139 printf("mkdir path Create remote directory\n");
140 printf("preogress Toggle display of progress meter\n");
135 printf("put local-path [remote-path] Upload file\n"); 141 printf("put local-path [remote-path] Upload file\n");
136 printf("pwd Display remote working directory\n"); 142 printf("pwd Display remote working directory\n");
137 printf("exit Quit sftp\n"); 143 printf("exit Quit sftp\n");
@@ -425,7 +431,6 @@ process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd, int pflag)
425 err = -1; 431 err = -1;
426 goto out; 432 goto out;
427 } 433 }
428 printf("Fetching %s to %s\n", g.gl_pathv[0], abs_dst);
429 err = do_download(conn, g.gl_pathv[0], abs_dst, pflag); 434 err = do_download(conn, g.gl_pathv[0], abs_dst, pflag);
430 goto out; 435 goto out;
431 } 436 }
@@ -507,7 +512,6 @@ process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd, int pflag)
507 } 512 }
508 abs_dst = make_absolute(abs_dst, pwd); 513 abs_dst = make_absolute(abs_dst, pwd);
509 } 514 }
510 printf("Uploading %s to %s\n", g.gl_pathv[0], abs_dst);
511 err = do_upload(conn, g.gl_pathv[0], abs_dst, pflag); 515 err = do_upload(conn, g.gl_pathv[0], abs_dst, pflag);
512 goto out; 516 goto out;
513 } 517 }
@@ -810,6 +814,7 @@ parse_args(const char **cpp, int *pflag, int *lflag, int *iflag,
810 case I_LPWD: 814 case I_LPWD:
811 case I_HELP: 815 case I_HELP:
812 case I_VERSION: 816 case I_VERSION:
817 case I_PROGRESS:
813 break; 818 break;
814 default: 819 default:
815 fatal("Command not implemented"); 820 fatal("Command not implemented");
@@ -1015,6 +1020,13 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1015 case I_VERSION: 1020 case I_VERSION:
1016 printf("SFTP protocol version %u\n", sftp_proto_version(conn)); 1021 printf("SFTP protocol version %u\n", sftp_proto_version(conn));
1017 break; 1022 break;
1023 case I_PROGRESS:
1024 showprogress = !showprogress;
1025 if (showprogress)
1026 printf("Progress meter enabled\n");
1027 else
1028 printf("Progress meter disabled\n");
1029 break;
1018 default: 1030 default:
1019 fatal("%d is not implemented", cmdnum); 1031 fatal("%d is not implemented", cmdnum);
1020 } 1032 }