diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-10 09:18:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-10 09:18:49 +0000 |
commit | dd814a7c1a8de056a79f7238578b09236edd5506 (patch) | |
tree | 429e7eed5a634a4efe9a6877ce66da8e64aa1782 /libnetdata/inlined.h | |
parent | Adding upstream version 1.41.0. (diff) | |
download | netdata-dd814a7c1a8de056a79f7238578b09236edd5506.tar.xz netdata-dd814a7c1a8de056a79f7238578b09236edd5506.zip |
Adding upstream version 1.42.0.upstream/1.42.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/inlined.h')
-rw-r--r-- | libnetdata/inlined.h | 23 |
1 files changed, 22 insertions, 1 deletions
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)); } |