From 8c9b0194063411882d3bbcec80d5e5c861d37544 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 24 Jul 2024 18:54:07 +0000 Subject: Add stuff to shibari-cache Signed-off-by: Laurent Bercot --- src/cache/conf.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/cache/conf.c') diff --git a/src/cache/conf.c b/src/cache/conf.c index ea35646..209fdc3 100644 --- a/src/cache/conf.c +++ b/src/cache/conf.c @@ -4,6 +4,7 @@ #include #include +#include #include #include "shibari-cache-internal.h" @@ -23,7 +24,7 @@ int conf_getb (cdb const *c, char const *key, size_t keylen, cdb_data *data) int conf_get (cdb const *c, char const *key, cdb_data *data) { - return conf_get(c, key, strlen(key), data) ; + return conf_getb(c, key, strlen(key), data) ; } int conf_get_uint32 (cdb const *c, char const *key, uint32_t *value) @@ -34,3 +35,20 @@ int conf_get_uint32 (cdb const *c, char const *key, uint32_t *value) uint32_unpack_big(data.s, value) ; return 1 ; } + +int conf_get_uint64 (cdb const *c, char const *key, uint64_t *value) +{ + cdb_data data ; + if (!conf_get(conf, key, &data)) return 0 ; + if (data.len != 8) return (errno = EPROTO, 0) ; + uint64_unpack_big(data.s, value) ; + return 1 ; +} + +char const *conf_get_string (cdb const *c, char const *key) +{ + cdb_data data ; + if (!conf_get(conf, key, &data)) return 0 ; + if (!data.len || data.s[data.len - 1]) return (errno = EPROTO, 0) ; + return data.s ; +} -- cgit v1.2.3