summaryrefslogtreecommitdiff
path: root/src/libtipidee/tipidee_conf_get_uint32.c
blob: ad8b21b733f6f594c4dffa99ecc740d23c37bc5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 ;
}