aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/common.c b/common.c
index 03c6356..57518d9 100644
--- a/common.c
+++ b/common.c
@@ -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);
+ }
}