| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef LIBNETDATA_PARSERS_SIZE_H |
| 4 | #define LIBNETDATA_PARSERS_SIZE_H |
| 5 | |
| 6 | #include "parsers.h" |
| 7 | |
| 8 | bool size_parse(const char *size_str, uint64_t *result, const char *default_unit); |
| 9 | #define size_parse_bytes(size_str, bytes) size_parse(size_str, bytes, "B") |
| 10 | #define size_parse_kb(size_str, kb) size_parse(size_str, kb, "KiB") |
| 11 | #define size_parse_mb(size_str, mb) size_parse(size_str, mb, "MiB") |
| 12 | #define size_parse_gb(size_str, gb) size_parse(size_str, gb, "GiB") |
| 13 | |
| 14 | ssize_t size_snprintf(char *dst, size_t dst_size, uint64_t value, const char *unit, bool accurate); |
| 15 | #define size_snprintf_bytes(dst, dst_size, value) size_snprintf(dst, dst_size, value, "B", true) |
| 16 | #define size_snprintf_kb(dst, dst_size, value) size_snprintf(dst, dst_size, value, "KiB", true) |
| 17 | #define size_snprintf_mb(dst, dst_size, value) size_snprintf(dst, dst_size, value, "MiB", true) |
| 18 | #define size_snprintf_gb(dst, dst_size, value) size_snprintf(dst, dst_size, value, "GiB", true) |
| 19 | |
| 20 | #endif //LIBNETDATA_PARSERS_SIZE_H |