blob: 182a7baba726e06206b08fea7cdeb3b5d6453b85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/* ISC license. */
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <skalibs/uint32.h>
#include <skalibs/cdb.h>
#include <tipidee/resattr.h>
#include <tipidee/conf.h>
#include <skalibs/posixishard.h>
int tipidee_conf_get_resattr1 (tipidee_conf const *conf, char const *key, tipidee_resattr *ra)
{
tipidee_resattr atom = TIPIDEE_RESATTR_ZERO ;
cdb_data data ;
if (!tipidee_conf_get(conf, key, &data)) return errno == ENOENT ? 0 : -1 ;
if (data.len < 9 || data.s[data.len - 1]) return (errno = EPROTO, -1) ;
uint32_unpack_big(data.s, &atom.flags) ;
uint32_unpack_big(data.s + 4, &atom.mask) ;
data.s += 8 ; data.len -= 8 ;
if (*data.s)
{
size_t len = strlen(data.s) + 1 ;
if (len > data.len) return (errno = EPROTO, -1) ;
atom.content_type = data.s ;
data.s += len ;
data.len -= len ;
}
else data.len-- ;
if (data.len) return (errno = EPROTO, -1) ;
*ra = atom ;
return 1 ;
}
|