mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-12-28 04:52:07 +00:00
- 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
@ -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
Block a user