diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-05-20 14:41:28 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-05-20 14:41:28 +0000 |
commit | 7b3c726991f0f060ca18c576fc7816b930435240 (patch) | |
tree | 1b6e5c7396fd89cd81baa018af6080c5349e1c6b /hardinfo2/util.c | |
parent | cbd8b0d401add58a06d82c7a5d7fb22b53d80714 (diff) |
- Add binreloc support.
- Add users information.
- Add ppc64 and mips64 support.
- Fix loadgraph autoscaling (should be usable now! :)
- Misc cosmetic changes.
- Misc wording changes.
Diffstat (limited to 'hardinfo2/util.c')
-rw-r--r-- | hardinfo2/util.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/hardinfo2/util.c b/hardinfo2/util.c index 79084c2c..ee6040b2 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -19,18 +19,21 @@ #include <hardinfo.h> #include <gtk/gtk.h> -inline void -remove_quotes(gchar *str) -{ - if (!str) - return; +#define KiB 1024 +#define MiB 1048576 +#define GiB 1073741824 - while (*str == '"') - *(str++) = ' '; +inline gchar * +size_human_readable(gfloat size) +{ + if (size < KiB) + return g_strdup_printf("%.1f B", size); + if (size < MiB) + return g_strdup_printf("%.1f KiB", size / KiB); + if (size < GiB) + return g_strdup_printf("%.1f MiB", size / MiB); - gchar *p; - if ((p = strchr(str, '"'))) - *p = 0; + return g_strdup_printf("%.1f GiB", size / GiB); } inline void @@ -45,6 +48,18 @@ strend(gchar *str, gchar chr) } inline void +remove_quotes(gchar *str) +{ + if (!str) + return; + + while (*str == '"') + *(str++) = ' '; + + strend(str, '"'); +} + +inline void remove_linefeed(gchar * str) { strend(str, '\n'); |