diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-02 15:07:14 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-02 15:07:14 +0200 |
commit | 7cffbc1b2e8361093f0b0311857df0545680611e (patch) | |
tree | 0c8518f8e1a10bc3c477e40e279901427682dcb3 /common.c | |
parent | 409a13ac7f6b0d810affc9a07ac80d55d85d21d7 (diff) | |
download | xK-7cffbc1b2e8361093f0b0311857df0545680611e.tar.gz xK-7cffbc1b2e8361093f0b0311857df0545680611e.tar.xz xK-7cffbc1b2e8361093f0b0311857df0545680611e.zip |
config: implement config_load()
Diffstat (limited to 'common.c')
-rw-r--r-- | common.c | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -1421,7 +1421,7 @@ end: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: this doesn't necessarily have to be well designed at all +// XXX: this doesn't necessarily have to be well designed at all typedef void (*config_module_load_fn) (struct config_item_ *subtree, void *user_data); @@ -1481,8 +1481,25 @@ config_register_module (struct config *self, str_map_set (&self->modules, name, module); } -static bool -config_load (struct config *self, struct config_item_ *root, struct error **e) +static void +config_load (struct config *self, struct config_item_ *root) { - // TODO + hard_assert (root->type == CONFIG_ITEM_OBJECT); + + struct str_map_iter iter; + str_map_iter_init (&iter, &self->modules); + + struct config_module *module; + while ((module = str_map_iter_next (&iter))) + { + struct config_item_ *subtree = str_map_find + (&root->value.object, module->name); + // Silently fix inputs that only a lunatic user could create + if (!subtree || subtree->type != CONFIG_ITEM_OBJECT) + { + subtree = config_item_object (); + str_map_set (&root->value.object, module->name, subtree); + } + module->loader (subtree, module->user_data); + } } |