- markus@cvs.openbsd.org 2002/12/13 15:20:52
[scp.c] 1) include stalling time in total time 2) truncate filenames to 45 instead of 20 characters 3) print rate instead of progress bar, no more stars 4) scale output to tty width based on a patch from Niels; ok fries@ lebel@ fgs@ millert@
This commit is contained in:
parent
1d568f9fce
commit
40b9503563
17
ChangeLog
17
ChangeLog
|
@ -20,17 +20,17 @@
|
|||
[auth-krb5.c auth1.c hostfile.h monitor_wrap.c sftp-client.c sftp-int.c ssh-add.c ssh-rsa.c
|
||||
sshconnect.c]
|
||||
KNF
|
||||
- markus@cvs.openbsd.org 2002/11/21 23:04:33
|
||||
- markus@cvs.openbsd.org 2002/11/21 23:04:33
|
||||
[ssh.c]
|
||||
debug->debug2
|
||||
- stevesk@cvs.openbsd.org 2002/11/24 21:46:24
|
||||
- stevesk@cvs.openbsd.org 2002/11/24 21:46:24
|
||||
[ssh-keysign.8]
|
||||
typo: "the the"
|
||||
- wcobb@cvs.openbsd.org 2002/11/26 00:45:03
|
||||
[scp.c ssh-keygen.c]
|
||||
Remove unnecessary fflush(stderr) calls, stderr is unbuffered by default.
|
||||
ok markus@
|
||||
- stevesk@cvs.openbsd.org 2002/11/26 02:35:30
|
||||
- stevesk@cvs.openbsd.org 2002/11/26 02:35:30
|
||||
[ssh-keygen.1]
|
||||
remove outdated statement; ok markus@ deraadt@
|
||||
- stevesk@cvs.openbsd.org 2002/11/26 02:38:54
|
||||
|
@ -48,7 +48,7 @@
|
|||
[scp.c]
|
||||
use roundup() similar to rcp/util.c and avoid problems with strange
|
||||
filesystem block sizes, noted by tjr@freebsd.org; ok djm@
|
||||
- djm@cvs.openbsd.org 2002/12/06 05:20:02
|
||||
- djm@cvs.openbsd.org 2002/12/06 05:20:02
|
||||
[sftp.1]
|
||||
Fix cut'n'paste error, spotted by matthias.riese@b-novative.de; ok deraadt@
|
||||
- millert@cvs.openbsd.org 2002/12/09 16:50:30
|
||||
|
@ -68,6 +68,13 @@
|
|||
- markus@cvs.openbsd.org 2002/12/13 10:03:15
|
||||
[channels.c misc.c sshconnect2.c]
|
||||
cleanup debug messages, more useful information for the client user.
|
||||
- markus@cvs.openbsd.org 2002/12/13 15:20:52
|
||||
[scp.c]
|
||||
1) include stalling time in total time
|
||||
2) truncate filenames to 45 instead of 20 characters
|
||||
3) print rate instead of progress bar, no more stars
|
||||
4) scale output to tty width
|
||||
based on a patch from Niels; ok fries@ lebel@ fgs@ millert@
|
||||
|
||||
20021205
|
||||
- (djm) PERL-free fixpaths from stuge-openssh-unix-dev@cdy.org
|
||||
|
@ -903,4 +910,4 @@
|
|||
save auth method before monitor_reset_key_state(); bugzilla bug #284;
|
||||
ok provos@
|
||||
|
||||
$Id: ChangeLog,v 1.2534 2002/12/23 02:44:36 mouring Exp $
|
||||
$Id: ChangeLog,v 1.2535 2002/12/23 02:53:08 mouring Exp $
|
||||
|
|
65
scp.c
65
scp.c
|
@ -75,7 +75,7 @@
|
|||
*/
|
||||
|
||||
#include "includes.h"
|
||||
RCSID("$OpenBSD: scp.c,v 1.95 2002/12/05 11:08:35 markus Exp $");
|
||||
RCSID("$OpenBSD: scp.c,v 1.96 2002/12/13 15:20:52 markus Exp $");
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "atomicio.h"
|
||||
|
@ -1119,13 +1119,19 @@ foregroundproc(void)
|
|||
void
|
||||
progressmeter(int flag)
|
||||
{
|
||||
static const char spaces[] = " "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" ";
|
||||
static const char prefixes[] = " KMGTP";
|
||||
static struct timeval lastupdate;
|
||||
static off_t lastsize;
|
||||
struct timeval now, td, wait;
|
||||
off_t cursize, abbrevsize;
|
||||
off_t cursize, abbrevsize, bytespersec;
|
||||
double elapsed;
|
||||
int ratio, barlength, i, remaining;
|
||||
int ratio, remaining, i, ai, bi, nspaces;
|
||||
char buf[512];
|
||||
|
||||
if (flag == -1) {
|
||||
|
@ -1145,45 +1151,44 @@ progressmeter(int flag)
|
|||
} else
|
||||
ratio = 100;
|
||||
|
||||
snprintf(buf, sizeof(buf), "\r%-20.20s %3d%% ", curfile, ratio);
|
||||
|
||||
barlength = getttywidth() - 51;
|
||||
if (barlength > 0) {
|
||||
i = barlength * ratio / 100;
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
|
||||
"|%.*s%*s|", i,
|
||||
"*******************************************************"
|
||||
"*******************************************************"
|
||||
"*******************************************************"
|
||||
"*******************************************************"
|
||||
"*******************************************************"
|
||||
"*******************************************************"
|
||||
"*******************************************************",
|
||||
barlength - i, "");
|
||||
}
|
||||
i = 0;
|
||||
abbrevsize = cursize;
|
||||
while (abbrevsize >= 100000 && i < sizeof(prefixes)) {
|
||||
i++;
|
||||
for (ai = 0; abbrevsize >= 10000 && ai < sizeof(prefixes); ai++)
|
||||
abbrevsize >>= 10;
|
||||
}
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %5lu %c%c ",
|
||||
(unsigned long) abbrevsize, prefixes[i],
|
||||
prefixes[i] == ' ' ? ' ' : 'B');
|
||||
|
||||
timersub(&now, &lastupdate, &wait);
|
||||
if (cursize > lastsize) {
|
||||
lastupdate = now;
|
||||
lastsize = cursize;
|
||||
if (wait.tv_sec >= STALLTIME) {
|
||||
start.tv_sec += wait.tv_sec;
|
||||
start.tv_usec += wait.tv_usec;
|
||||
}
|
||||
wait.tv_sec = 0;
|
||||
}
|
||||
timersub(&now, &start, &td);
|
||||
elapsed = td.tv_sec + (td.tv_usec / 1000000.0);
|
||||
|
||||
bytespersec = 0;
|
||||
if (statbytes > 0) {
|
||||
bytespersec = statbytes;
|
||||
if (elapsed > 0.0)
|
||||
bytespersec /= elapsed;
|
||||
}
|
||||
for (bi = 1; bytespersec >= 1024000 && bi < sizeof(prefixes); bi++)
|
||||
bytespersec >>= 10;
|
||||
|
||||
nspaces = MIN(getttywidth() - 79, sizeof(spaces) - 1);
|
||||
|
||||
snprintf(buf, sizeof(buf),
|
||||
"\r%-45.45s%.*s%3d%% %4lld%c%c %3lld.%01d%cB/s",
|
||||
curfile,
|
||||
nspaces,
|
||||
spaces,
|
||||
ratio,
|
||||
(long long)abbrevsize,
|
||||
prefixes[ai],
|
||||
ai == 0 ? ' ' : 'B',
|
||||
(long long)(bytespersec / 1024),
|
||||
(int)((bytespersec % 1024) * 10 / 1024),
|
||||
prefixes[bi]
|
||||
);
|
||||
|
||||
if (flag != 1 &&
|
||||
(statbytes <= 0 || elapsed <= 0.0 || cursize > totalbytes)) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
|
||||
|
|
Loading…
Reference in New Issue