From cb6dee014612526d8127fee843b71d932968c059 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 23 Apr 2017 13:09:36 +0100 Subject: [PATCH] conffile: Provide dict_read_dict No callers yet. Signed-off-by: Ian Jackson --- conffile.c | 15 +++++++++++++++ secnet.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/conffile.c b/conffile.c index bf4891e..7f0202c 100644 --- a/conffile.c +++ b/conffile.c @@ -767,6 +767,21 @@ bool_t dict_read_bool(dict_t *dict, cstring_t key, bool_t required, return r; } +dict_t *dict_read_dict(dict_t *dict, cstring_t key, bool_t required, + cstring_t desc, struct cloc loc) +{ + item_t *i; + dict_t *r; + + i=dict_find_item(dict,key,required,desc,loc); + if (!i) return NULL; + if (i->type!=t_dict) { + cfgfatal(loc,desc,"\"%s\" must be a dictionary\n",key); + } + r=i->data.dict; + return r; +} + uint32_t string_to_word(cstring_t s, struct cloc loc, struct flagstr *f, cstring_t desc) { diff --git a/secnet.h b/secnet.h index 83ee97f..63307ac 100644 --- a/secnet.h +++ b/secnet.h @@ -171,6 +171,8 @@ extern uint32_t dict_read_number(dict_t *dict, cstring_t key, bool_t required, /* return value can safely be assigned to int32_t */ extern bool_t dict_read_bool(dict_t *dict, cstring_t key, bool_t required, cstring_t desc, struct cloc loc, bool_t def); +extern dict_t *dict_read_dict(dict_t *dict, cstring_t key, bool_t required, + cstring_t desc, struct cloc loc); const char **dict_read_string_array(dict_t *dict, cstring_t key, bool_t required, cstring_t desc, struct cloc loc, const char *const *def); -- 2.11.0