]>
| Commit | Line | Data |
|---|---|---|
| 1 | #ifndef _HUMANSIZE_H_ | |
| 2 | #define _HUMANSIZE_H_ | |
| 3 | ||
| 4 | #include <stdint.h> | |
| 5 | ||
| 6 | /** | |
| 7 | * humansize(size): | |
| 8 | * Given a size in bytes, allocate and return a string of the form "<N> B" | |
| 9 | * for 0 <= N <= 999 or "<X> <prefix>B" where either 10 <= X <= 999 or | |
| 10 | * 1.0 <= X <= 9.9 and <prefix> is "k", "M", "G", "T", "P", or "E"; and where | |
| 11 | * the value returned is the largest valid value <= the provided size. | |
| 12 | */ | |
| 13 | char * humansize(uint64_t); | |
| 14 | ||
| 15 | /** | |
| 16 | * humansize_parse(s, size): | |
| 17 | * Parse a string matching /[0-9]+ ?[kMGTPE]?B?/ as a size in bytes. | |
| 18 | */ | |
| 19 | int humansize_parse(const char *, uint64_t *); | |
| 20 | ||
| 21 | #endif /* !_HUMANSIZE_H_ */ |