summaryrefslogtreecommitdiffstats
path: root/libnetdata/inlined.h
diff options
context:
space:
mode:
Diffstat (limited to 'libnetdata/inlined.h')
-rw-r--r--libnetdata/inlined.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/libnetdata/inlined.h b/libnetdata/inlined.h
index 2697b9a0..eb55f0fe 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));
}