diff options
author | Francesco Cosoleto | 2011-05-26 15:17:25 +0200 |
---|---|---|
committer | Karel Zak | 2011-05-26 15:32:33 +0200 |
commit | 5d2a98490e87872214e6acdeac1031c0eb8cfc92 (patch) | |
tree | d2eaea544a6d8b662612e71395196c92bb6b5833 /include/strutils.h | |
parent | build-sys: use AUTOMAKE_OPTIONS = gnu (diff) | |
download | kernel-qcow2-util-linux-5d2a98490e87872214e6acdeac1031c0eb8cfc92.tar.gz kernel-qcow2-util-linux-5d2a98490e87872214e6acdeac1031c0eb8cfc92.tar.xz kernel-qcow2-util-linux-5d2a98490e87872214e6acdeac1031c0eb8cfc92.zip |
This adds a second parameter to size_to_human_string() to return a
string with a different format based on the following flags:
SIZE_SUFFIX_1LETTER = "1K"
SIZE_SUFFIX_3LETTER = "1KiB",
SIZE_SUFFIX_SPACE = "1 KiB" or "1 K"
[kzak@redhat.com: - rename flags to SIZE_SUFFIX_* format,
- fix suffix[] buffer size
- add 3 letter version to the test]
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/strutils.h')
-rw-r--r-- | include/strutils.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/strutils.h b/include/strutils.h index 99d8acd2c..bbe299385 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -27,6 +27,15 @@ static inline void xstrncpy(char *dest, const char *src, size_t n) } extern void strmode(mode_t mode, char *str); -extern char *size_to_human_string(uint64_t bytes); + +/* Options for size_to_human_string() */ +enum +{ + SIZE_SUFFIX_1LETTER = 0, + SIZE_SUFFIX_3LETTER = 1, + SIZE_SUFFIX_SPACE = 2 +}; + +extern char *size_to_human_string(int options, uint64_t bytes); #endif |