mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
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 <wk@gnupg.org>
This commit is contained in:
parent
49829c29e5
commit
16feb1e0ea
@ -929,7 +929,7 @@ pkd:0:1024:B665B1435F4C2 .... FF26ABB:
|
|||||||
- 3 :: Ambigious specification
|
- 3 :: Ambigious specification
|
||||||
- 4 :: Key is stored on a smartcard.
|
- 4 :: Key is stored on a smartcard.
|
||||||
|
|
||||||
*** PROGRESS <what> <char> <cur> <total>
|
*** PROGRESS <what> <char> <cur> <total> [<units>]
|
||||||
Used by the primegen and Public key functions to indicate
|
Used by the primegen and Public key functions to indicate
|
||||||
progress. <char> is the character displayed with no --status-fd
|
progress. <char> is the character displayed with no --status-fd
|
||||||
enabled, with the linefeed replaced by an 'X'. <cur> is the
|
enabled, with the linefeed replaced by an 'X'. <cur> is the
|
||||||
@ -953,6 +953,9 @@ pkd:0:1024:B665B1435F4C2 .... FF26ABB:
|
|||||||
the data of a smartcard.
|
the data of a smartcard.
|
||||||
- card_busy :: A smartcard is still working
|
- card_busy :: A smartcard is still working
|
||||||
|
|
||||||
|
<units> is sometines used to describe the units for <current> and
|
||||||
|
<total>. For example "B", "KiB", or "MiB".
|
||||||
|
|
||||||
*** BACKUP_KEY_CREATED <fingerprint> <fname>
|
*** BACKUP_KEY_CREATED <fingerprint> <fname>
|
||||||
A backup of a key identified by <fingerprint> has been writte to
|
A backup of a key identified by <fingerprint> has been writte to
|
||||||
the file <fname>; <fname> is percent-escaped.
|
the file <fname>; <fname> is percent-escaped.
|
||||||
|
@ -75,7 +75,9 @@ static void
|
|||||||
write_status_progress (const char *what,
|
write_status_progress (const char *what,
|
||||||
unsigned long current, unsigned long total)
|
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
|
/* Although we use an unsigned long for the values, 32 bit
|
||||||
* applications using GPGME will use an "int" and thus are limited
|
* applications using GPGME will use an "int" and thus are limited
|
||||||
@ -98,6 +100,7 @@ write_status_progress (const char *what,
|
|||||||
{
|
{
|
||||||
total /= 1024;
|
total /= 1024;
|
||||||
current /= 1024;
|
current /= 1024;
|
||||||
|
unitidx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -105,11 +108,17 @@ write_status_progress (const char *what,
|
|||||||
while (current > 1024*1024)
|
while (current > 1024*1024)
|
||||||
{
|
{
|
||||||
current /= 1024;
|
current /= 1024;
|
||||||
|
unitidx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (buffer, sizeof buffer, "%.20s ? %lu %lu",
|
if (unitidx > 9)
|
||||||
what? what : "?", current, total);
|
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);
|
write_status_text (STATUS_PROGRESS, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user