+static const struct ec_config_schema ec_node_many_schema[] = {
+ {
+ .key = "child",
+ .desc = "The child node.",
+ .type = EC_CONFIG_TYPE_NODE,
+ },
+ {
+ .key = "min",
+ .desc = "The minimum number of matches (default = 0).",
+ .type = EC_CONFIG_TYPE_UINT64,
+ },
+ {
+ .key = "max",
+ .desc = "The maximum number of matches. If 0, there is "
+ "no maximum (default = 0).",
+ .type = EC_CONFIG_TYPE_UINT64,
+ },
+ {
+ .type = EC_CONFIG_TYPE_NONE,
+ },
+};
+
+static int ec_node_many_set_config(struct ec_node *gen_node,
+ const struct ec_config *config)
+{
+ struct ec_node_many *node = (struct ec_node_many *)gen_node;
+ const struct ec_config *child, *min, *max;
+
+ child = ec_config_dict_get(config, "child");
+ if (child == NULL)
+ goto fail;
+ if (ec_config_get_type(child) != EC_CONFIG_TYPE_NODE) {
+ errno = EINVAL;
+ goto fail;
+ }
+ min = ec_config_dict_get(config, "min");
+ if (min != NULL && (ec_config_get_type(min) != EC_CONFIG_TYPE_UINT64 ||
+ min->u64 >= UINT_MAX)) {
+ errno = EINVAL;
+ goto fail;
+ }
+ max = ec_config_dict_get(config, "max");
+ if (max != NULL && (ec_config_get_type(max) != EC_CONFIG_TYPE_UINT64 ||
+ max->u64 >= UINT_MAX)) {
+ errno = EINVAL;
+ goto fail;
+ }
+
+ if (node->child != NULL)
+ ec_node_free(node->child);
+ node->child = ec_node_clone(child->node);
+ if (min == NULL)
+ node->min = 0;
+ else
+ node->min = min->u64;
+ if (max == NULL)
+ node->max = 0;
+ else
+ node->max = max->u64;
+
+ return 0;
+
+fail:
+ return -1;
+}
+