fix config dump
[protos/libecoli.git] / lib / ecoli_node_str.c
index 28c69b9..d53ea39 100644 (file)
@@ -99,6 +99,9 @@ static const struct ec_config_schema ec_node_str_schema[] = {
                .desc = "The string to match.",
                .type = EC_CONFIG_TYPE_STRING,
        },
+       {
+               .type = EC_CONFIG_TYPE_NONE,
+       },
 };
 
 static int ec_node_str_set_config(struct ec_node *gen_node,
@@ -108,7 +111,7 @@ static int ec_node_str_set_config(struct ec_node *gen_node,
        const struct ec_config *value = NULL;
        char *s = NULL;
 
-       value = ec_config_get(config, "string");
+       value = ec_config_dict_get(config, "string");
        if (value == NULL) {
                errno = EINVAL;
                goto fail;
@@ -132,7 +135,6 @@ fail:
 static struct ec_node_type ec_node_str_type = {
        .name = "str",
        .schema = ec_node_str_schema,
-       .schema_len = EC_COUNT_OF(ec_node_str_schema),
        .set_config = ec_node_str_set_config,
        .parse = ec_node_str_parse,
        .complete = ec_node_str_complete,
@@ -146,6 +148,7 @@ EC_NODE_TYPE_REGISTER(ec_node_str_type);
 int ec_node_str_set_str(struct ec_node *gen_node, const char *str)
 {
        struct ec_config *config = NULL;
+       int ret;
 
        if (ec_node_check_type(gen_node, &ec_node_str_type) < 0)
                goto fail;
@@ -159,10 +162,13 @@ int ec_node_str_set_str(struct ec_node *gen_node, const char *str)
        if (config == NULL)
                goto fail;
 
-       if (ec_config_dict_set(config, "string", ec_config_string(str)) < 0)
+       ret = ec_config_dict_set(config, "string", ec_config_string(str));
+       if (ret < 0)
                goto fail;
 
-       if (ec_node_set_config(gen_node, config) < 0)
+       ret = ec_node_set_config(gen_node, config);
+       config = NULL;
+       if (ret < 0)
                goto fail;
 
        return 0;
@@ -176,7 +182,7 @@ struct ec_node *ec_node_str(const char *id, const char *str)
 {
        struct ec_node *gen_node = NULL;
 
-       gen_node = __ec_node(&ec_node_str_type, id);
+       gen_node = ec_node_from_type(&ec_node_str_type, id);
        if (gen_node == NULL)
                goto fail;