diff options
author | Werner Koch <wk@gnupg.org> | 2016-08-11 21:31:12 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-08-11 21:32:55 +0200 |
commit | 70b5d7c43a57a44dad60c2c700a263610748d8f4 (patch) | |
tree | d06377f79320f6fade30f50d252a0b29c491916c /g10/progress.c | |
parent | common: New function string_to_u64. (diff) | |
download | gnupg2-70b5d7c43a57a44dad60c2c700a263610748d8f4.tar.xz gnupg2-70b5d7c43a57a44dad60c2c700a263610748d8f4.zip |
gpg: New option --input-size-hint.
* g10/options.h: Include stdint.h.
(struct opt): Add field 'input_size_hint'.
* g10/gpg.c (oInputSizeHint): New.
(opts): Add --input-size-hint.
(main): Set opt.input_size_hint.
* g10/progress.c (write_status_progress): Use the hint.
--
This is a prerequisite to fix
GnuPG-bug-id: 2368
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/progress.c')
-rw-r--r-- | g10/progress.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/g10/progress.c b/g10/progress.c index efc3b3a91..f151657da 100644 --- a/g10/progress.c +++ b/g10/progress.c @@ -73,11 +73,12 @@ release_progress_context (progress_filter_context_t *pfx) static void write_status_progress (const char *what, - unsigned long current, unsigned long total) + unsigned long current, unsigned long total_arg) { char buffer[60]; char units[] = "BKMGTPEZY?"; int unitidx = 0; + uint64_t total = total_arg; /* Although we use an unsigned long for the values, 32 bit * applications using GPGME will use an "int" and thus are limited @@ -91,6 +92,10 @@ write_status_progress (const char *what, * thus scaling CURRENT and TOTAL down before they get to large, * should not have a noticeable effect except for rounding * imprecision. */ + + if (!total && opt.input_size_hint) + total = opt.input_size_hint; + if (total) { if (current > total) @@ -116,7 +121,7 @@ write_status_progress (const char *what, unitidx = 9; snprintf (buffer, sizeof buffer, "%.20s ? %lu %lu %c%s", - what? what : "?", current, total, + what? what : "?", current, (unsigned long)total, units[unitidx], unitidx? "iB" : ""); write_status_text (STATUS_PROGRESS, buffer); |