From 5d2a98490e87872214e6acdeac1031c0eb8cfc92 Mon Sep 17 00:00:00 2001 From: Francesco Cosoleto Date: Thu, 26 May 2011 15:17:25 +0200 Subject: 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 Signed-off-by: Karel Zak --- include/strutils.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'include/strutils.h') 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 -- cgit v1.2.3-55-g7522