diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-08-05 11:51:25 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-08-05 11:51:25 +0000 |
commit | 17c382d1c9d7236c101418060758d2296cc5e17e (patch) | |
tree | fd00e58df0d9d3c70ddd1accfec9e819249c672a /src/libtipidee/tipidee_conf_get.c | |
download | tipidee-17c382d1c9d7236c101418060758d2296cc5e17e.tar.xz |
Initial commit
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libtipidee/tipidee_conf_get.c')
-rw-r--r-- | src/libtipidee/tipidee_conf_get.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libtipidee/tipidee_conf_get.c b/src/libtipidee/tipidee_conf_get.c new file mode 100644 index 0000000..866ec99 --- /dev/null +++ b/src/libtipidee/tipidee_conf_get.c @@ -0,0 +1,22 @@ +/* ISC license. */ + +#include <errno.h> +#include <string.h> + +#include <skalibs/cdb.h> +#include <skalibs/lolstdio.h> + +#include <tipidee/conf.h> + +int tipidee_conf_get (tipidee_conf const *conf, char const *key, cdb_data *data) +{ + size_t keylen = strlen(key) ; + if (keylen > TIPIDEE_CONF_KEY_MAXLEN) return (errno = EINVAL, 0) ; + LOLDEBUG("tipidee_conf_get: looking up %s", key) ; + switch (cdb_find(&conf->c, data, key, keylen)) + { + case -1 : return (errno = EILSEQ, 0) ; + case 0 : return (errno = ENOENT, 0) ; + default : return 1 ; + } +} |