chiark / gitweb /
conffile: Provide dict_read_dict
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 23 Apr 2017 12:09:36 +0000 (13:09 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 23 Apr 2017 13:29:39 +0000 (14:29 +0100)
No callers yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
conffile.c
secnet.h

index bf4891e..7f0202c 100644 (file)
@@ -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)
 {
index 83ee97f..63307ac 100644 (file)
--- 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);