X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=src%2Fecoli_node_any.c;h=88ac54213aa0df3156e1cc9abb8c9f433ac143f1;hb=41bf1ba66e15c00f38375d05e49b31aa70f92349;hp=9166dbbd5fa0799794c25f31d74ea72799b2bfec;hpb=18d03456d96f7a086a2ccc82ce97fcf056848d90;p=protos%2Flibecoli.git diff --git a/src/ecoli_node_any.c b/src/ecoli_node_any.c index 9166dbb..88ac542 100644 --- a/src/ecoli_node_any.c +++ b/src/ecoli_node_any.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -30,7 +30,7 @@ static int ec_node_any_parse(const struct ec_node *gen_node, const struct ec_strvec *strvec) { struct ec_node_any *node = (struct ec_node_any *)gen_node; - const struct ec_keyval *attrs; + const struct ec_dict *attrs; (void)state; @@ -38,7 +38,7 @@ static int ec_node_any_parse(const struct ec_node *gen_node, return EC_PARSE_NOMATCH; if (node->attr_name != NULL) { attrs = ec_strvec_get_attrs(strvec, 0); - if (attrs == NULL || !ec_keyval_has_key(attrs, node->attr_name)) + if (attrs == NULL || !ec_dict_has_key(attrs, node->attr_name)) return EC_PARSE_NOMATCH; } @@ -99,6 +99,38 @@ static struct ec_node_type ec_node_any_type = { EC_NODE_TYPE_REGISTER(ec_node_any_type); +struct ec_node * +ec_node_any(const char *id, const char *attr) +{ + struct ec_config *config = NULL; + struct ec_node *gen_node = NULL; + int ret; + + gen_node = ec_node_from_type(&ec_node_any_type, id); + if (gen_node == NULL) + return NULL; + + config = ec_config_dict(); + if (config == NULL) + goto fail; + + ret = ec_config_dict_set(config, "attr", ec_config_string(attr)); + if (ret < 0) + goto fail; + + ret = ec_node_set_config(gen_node, config); + config = NULL; + if (ret < 0) + goto fail; + + return gen_node; + +fail: + ec_config_free(config); + ec_node_free(gen_node); + return NULL; +} + /* LCOV_EXCL_START */ static int ec_node_any_testcase(void) {