diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-07-25 00:58:20 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2024-07-25 00:58:20 +0000 |
commit | 0d53cd3855efb536676a9dcfeadf7bf2c5de6e14 (patch) | |
tree | fa406fba596970111af72846af7bedf467e9b174 /src/cache/conf.c | |
parent | fc85d676b5ca3de92264dfcb41c98d7c9b0d1398 (diff) | |
download | shibari-0d53cd3855efb536676a9dcfeadf7bf2c5de6e14.tar.gz shibari-0d53cd3855efb536676a9dcfeadf7bf2c5de6e14.tar.xz shibari-0d53cd3855efb536676a9dcfeadf7bf2c5de6e14.zip |
shibari-cache skeleton builds!
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/cache/conf.c')
-rw-r--r-- | src/cache/conf.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/cache/conf.c b/src/cache/conf.c index c2f3d6b..68edef5 100644 --- a/src/cache/conf.c +++ b/src/cache/conf.c @@ -1,8 +1,10 @@ /* ISC license. */ +#include <stddef.h> #include <errno.h> #include <string.h> +#include <skalibs/uint16.h> #include <skalibs/uint32.h> #include <skalibs/uint64.h> #include <skalibs/cdb.h> @@ -11,10 +13,10 @@ #include <skalibs/posixishard.h> -int conf_getb (cdb const *c, char const *key, size_t keylen, cdb_data *data) +int conf_getb (char const *key, size_t keylen, cdb_data *data) { if (keylen > 4096) return (errno = EINVAL, 0) ; - switch (cdb_find(c, data, key, keylen)) + switch (cdb_find(&g->confdb, data, key, keylen)) { case -1 : return (errno = EILSEQ, 0) ; case 0 : return (errno = ENOENT, 0) ; @@ -22,42 +24,42 @@ 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) +int conf_get (char const *key, cdb_data *data) { - return conf_getb(c, key, strlen(key), data) ; + return conf_getb(key, strlen(key), data) ; } -int conf_get_uint16 (cdb const *c, char const *key, uint16_t *value) +int conf_get_uint16 (char const *key, uint16_t *value) { cdb_data data ; - if (!conf_get(conf, key, &data)) return 0 ; + if (!conf_get(key, &data)) return 0 ; if (data.len != 2) return (errno = EPROTO, 0) ; uint16_unpack_big(data.s, value) ; return 1 ; } -int conf_get_uint32 (cdb const *c, char const *key, uint32_t *value) +int conf_get_uint32 (char const *key, uint32_t *value) { cdb_data data ; - if (!conf_get(conf, key, &data)) return 0 ; + if (!conf_get(key, &data)) return 0 ; if (data.len != 4) return (errno = EPROTO, 0) ; uint32_unpack_big(data.s, value) ; return 1 ; } -int conf_get_uint64 (cdb const *c, char const *key, uint64_t *value) +int conf_get_uint64 (char const *key, uint64_t *value) { cdb_data data ; - if (!conf_get(conf, key, &data)) return 0 ; + if (!conf_get(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) +char const *conf_get_string (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) ; + if (!conf_get(key, &data)) return 0 ; + if (!data.len || data.s[data.len - 1]) return (errno = EPROTO, NULL) ; return data.s ; } |