diff options
author | Werner Koch <[email protected]> | 2016-08-09 14:22:24 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-08-09 14:28:39 +0000 |
commit | 16feb1e0ea9b5d3966f22f4ae047335b9d1b60e1 (patch) | |
tree | 4ba0fc04c6090928e044fc56347d8008c99d1a89 /g10/progress.c | |
parent | Cleanup initialization of libgcrypt. (diff) | |
download | gnupg-16feb1e0ea9b5d3966f22f4ae047335b9d1b60e1.tar.gz gnupg-16feb1e0ea9b5d3966f22f4ae047335b9d1b60e1.zip |
gpg: Extend the PROGRESS line to give the used unit.
* g10/progress.c (write_status_progress): Print the units parameter.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/progress.c')
-rw-r--r-- | g10/progress.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/g10/progress.c b/g10/progress.c index a1027b8d3..efc3b3a91 100644 --- a/g10/progress.c +++ b/g10/progress.c @@ -75,7 +75,9 @@ static void write_status_progress (const char *what, unsigned long current, unsigned long total) { - char buffer[50]; + char buffer[60]; + char units[] = "BKMGTPEZY?"; + int unitidx = 0; /* Although we use an unsigned long for the values, 32 bit * applications using GPGME will use an "int" and thus are limited @@ -98,6 +100,7 @@ write_status_progress (const char *what, { total /= 1024; current /= 1024; + unitidx++; } } else @@ -105,11 +108,17 @@ write_status_progress (const char *what, while (current > 1024*1024) { current /= 1024; + unitidx++; } } - snprintf (buffer, sizeof buffer, "%.20s ? %lu %lu", - what? what : "?", current, total); + if (unitidx > 9) + unitidx = 9; + + snprintf (buffer, sizeof buffer, "%.20s ? %lu %lu %c%s", + what? what : "?", current, total, + units[unitidx], + unitidx? "iB" : ""); write_status_text (STATUS_PROGRESS, buffer); } |