version 1.85, 2017/09/05 05:37:35 |
version 1.86, 2017/12/23 20:04:23 |
|
|
* with flag = 0 |
* with flag = 0 |
* - After the transfer, call with flag = 1 |
* - After the transfer, call with flag = 1 |
*/ |
*/ |
static struct timeval start; |
static struct timespec start; |
|
|
char *action; |
char *action; |
|
|
|
|
*/ |
*/ |
static const char prefixes[] = " KMGTP"; |
static const char prefixes[] = " KMGTP"; |
|
|
static struct timeval lastupdate; |
static struct timespec lastupdate; |
static off_t lastsize; |
static off_t lastsize; |
static char *title = NULL; |
static char *title = NULL; |
struct timeval now, td, wait; |
struct timespec now, td, wait; |
off_t cursize, abbrevsize; |
off_t cursize, abbrevsize; |
double elapsed; |
double elapsed; |
int ratio, barlength, i, remaining, overhead = 30; |
int ratio, barlength, i, remaining, overhead = 30; |
char buf[512]; |
char buf[512]; |
|
|
if (flag == -1) { |
if (flag == -1) { |
(void)gettimeofday(&start, NULL); |
clock_gettime(CLOCK_MONOTONIC, &start); |
lastupdate = start; |
lastupdate = start; |
lastsize = restart_point; |
lastsize = restart_point; |
} |
} |
(void)gettimeofday(&now, NULL); |
clock_gettime(CLOCK_MONOTONIC, &now); |
if (!progress || filesize < 0) |
if (!progress || filesize < 0) |
return; |
return; |
cursize = bytes + restart_point; |
cursize = bytes + restart_point; |
|
|
" %5lld %c%c ", (long long)abbrevsize, prefixes[i], |
" %5lld %c%c ", (long long)abbrevsize, prefixes[i], |
prefixes[i] == ' ' ? ' ' : 'B'); |
prefixes[i] == ' ' ? ' ' : 'B'); |
|
|
timersub(&now, &lastupdate, &wait); |
timespecsub(&now, &lastupdate, &wait); |
if (cursize > lastsize) { |
if (cursize > lastsize) { |
lastupdate = now; |
lastupdate = now; |
lastsize = cursize; |
lastsize = cursize; |
if (wait.tv_sec >= STALLTIME) { /* fudge out stalled time */ |
if (wait.tv_sec >= STALLTIME) { /* fudge out stalled time */ |
start.tv_sec += wait.tv_sec; |
start.tv_sec += wait.tv_sec; |
start.tv_usec += wait.tv_usec; |
start.tv_nsec += wait.tv_nsec; |
} |
} |
wait.tv_sec = 0; |
wait.tv_sec = 0; |
} |
} |
|
|
timersub(&now, &start, &td); |
timespecsub(&now, &start, &td); |
elapsed = td.tv_sec + (td.tv_usec / 1000000.0); |
elapsed = td.tv_sec + (td.tv_nsec / 1000000000.0); |
|
|
if (flag == 1) { |
if (flag == 1) { |
i = (int)elapsed / 3600; |
i = (int)elapsed / 3600; |
|
|
void |
void |
ptransfer(int siginfo) |
ptransfer(int siginfo) |
{ |
{ |
struct timeval now, td; |
struct timespec now, td; |
double elapsed; |
double elapsed; |
off_t bs; |
off_t bs; |
int meg, remaining, hh; |
int meg, remaining, hh; |
|
|
if (!verbose && !siginfo) |
if (!verbose && !siginfo) |
return; |
return; |
|
|
(void)gettimeofday(&now, NULL); |
clock_gettime(CLOCK_MONOTONIC, &now); |
timersub(&now, &start, &td); |
timespecsub(&now, &start, &td); |
elapsed = td.tv_sec + (td.tv_usec / 1000000.0); |
elapsed = td.tv_sec + (td.tv_nsec / 1000000000.0); |
bs = bytes / (elapsed == 0.0 ? 1 : elapsed); |
bs = bytes / (elapsed == 0.0 ? 1 : elapsed); |
meg = 0; |
meg = 0; |
if (bs > (1024 * 1024)) |
if (bs > (1024 * 1024)) |