diff options
Diffstat (limited to 'src/util.h')
| -rw-r--r-- | src/util.h | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -5,6 +5,7 @@ #include <stddef.h> #include <stdbool.h> #include <stdio.h> +#include <stdint.h> #define unreachable() log_panic("The impossible happened"); @@ -67,10 +68,20 @@ bool strfind(const char *string, const char *cases[]); size_t strprefix(const char *string, const char *prefix); -char *strformat(const char *string, char delim, const char *keys[], const char *values[]); - void strfree(char **list); bool iszero(const void *ptr, size_t size); +typedef enum { + UNIT_B = 1 << 0, + UNIT_KB = 1 << 1, + UNIT_MB = 1 << 2, + UNIT_GB = 1 << 3, + UNIT_TB = 1 << 4, + UNIT_SI = 1 << 5, + UNIT_MASK = UNIT_B | UNIT_KB | UNIT_MB | UNIT_GB | UNIT_TB | UNIT_SI, +} unit_t; + +int snprintf_units(char *buffer, size_t max, uint64_t bytes, unit_t unit); + #endif |
