summaryrefslogtreecommitdiff
path: root/src/libtipidee/tipidee_conf_get_uint32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libtipidee/tipidee_conf_get_uint32.c')
-rw-r--r--src/libtipidee/tipidee_conf_get_uint32.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libtipidee/tipidee_conf_get_uint32.c b/src/libtipidee/tipidee_conf_get_uint32.c
new file mode 100644
index 0000000..ad8b21b
--- /dev/null
+++ b/src/libtipidee/tipidee_conf_get_uint32.c
@@ -0,0 +1,19 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/uint32.h>
+#include <skalibs/cdb.h>
+
+#include <tipidee/conf.h>
+
+#include <skalibs/posixishard.h>
+
+int tipidee_conf_get_uint32 (tipidee_conf const *conf, char const *key, uint32_t *value)
+{
+ cdb_data data ;
+ if (!tipidee_conf_get(conf, key, &data)) return 0 ;
+ if (data.len != 4) return (errno = EPROTO, 0) ;
+ uint32_unpack_big(data.s, value) ;
+ return 1 ;
+}