libxbps::xbps_humanize_number(): use common values and hide implementation details from API.

So now its prototype is the following:

int xbps_humanize_number(char *buf, int64_t bytes)

It is a wrapper around NetBSD's humanize_number(3) which uses 6 digits for max
length, HN_AUTOSCALE and HN_NOSPACE|HN_DECIMAL. All users have been updated.
This commit is contained in:
Juan RP
2011-01-18 23:10:07 +01:00
parent e2b55c90be
commit 992e8c6a14
5 changed files with 42 additions and 42 deletions

View File

@@ -195,7 +195,7 @@ show_transaction_sizes(struct transaction *trans)
prop_object_t obj;
uint64_t dlsize = 0, instsize = 0;
const char *tract;
char size[64];
char size[8];
bool trans_inst, trans_up, trans_conf;
trans_inst = trans_up = trans_conf = false;
@@ -240,15 +240,13 @@ show_transaction_sizes(struct transaction *trans)
prop_dictionary_get_uint64(trans->dict, "total-download-size", &dlsize);
prop_dictionary_get_uint64(trans->dict, "total-installed-size",
&instsize);
if (xbps_humanize_number(size, 5, (int64_t)dlsize,
"", HN_AUTOSCALE, HN_B|HN_DECIMAL|HN_NOSPACE) == -1) {
if (xbps_humanize_number(size, (int64_t)dlsize) == -1) {
fprintf(stderr, "xbps-bin: error: humanize_number returns "
"%s\n", strerror(errno));
return -1;
}
printf("Total download size: %sB\n", size);
if (xbps_humanize_number(size, 5, (int64_t)instsize,
"", HN_AUTOSCALE, HN_B|HN_DECIMAL|HN_NOSPACE) == -1) {
if (xbps_humanize_number(size, (int64_t)instsize) == -1) {
fprintf(stderr, "xbps-bin: error: humanize_number2 returns "
"%s\n", strerror(errno));
return -1;