From dd814a7c1a8de056a79f7238578b09236edd5506 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 10 Aug 2023 11:18:49 +0200 Subject: Adding upstream version 1.42.0. Signed-off-by: Daniel Baumann --- libnetdata/inlined.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'libnetdata/inlined.h') diff --git a/libnetdata/inlined.h b/libnetdata/inlined.h index 2697b9a03..eb55f0fe7 100644 --- a/libnetdata/inlined.h +++ b/libnetdata/inlined.h @@ -209,7 +209,7 @@ static inline uint64_t str2uint64_hex(const char *src, char **endptr) { const unsigned char *s = (const unsigned char *)src; unsigned char c; - while ((c = hex_value_from_ascii[*s]) != 255) { + while ((c = hex_value_from_ascii[toupper(*s)]) != 255) { num = (num << 4) | c; s++; } @@ -510,6 +510,27 @@ static inline int read_single_signed_number_file(const char *filename, long long return 0; } +static inline int read_single_base64_or_hex_number_file(const char *filename, unsigned long long *result) { + char buffer[30 + 1]; + + int ret = read_file(filename, buffer, 30); + if(unlikely(ret)) { + *result = 0; + return ret; + } + + buffer[30] = '\0'; + + if(likely(buffer[0])){ + *result = str2ull_encoded(buffer); + return 0; + } + else { + *result = 0; + return -1; + } +} + static inline int uuid_memcmp(const uuid_t *uu1, const uuid_t *uu2) { return memcmp(uu1, uu2, sizeof(uuid_t)); } -- cgit v1.2.3