+struct ec_node *ec_node_int(const char *id, int64_t min,
+ int64_t max, unsigned int base)
+{
+ struct ec_config *config = NULL;
+ struct ec_node *gen_node = NULL;
+ int ret;
+
+ gen_node = ec_node_from_type(&ec_node_int_type, id);
+ if (gen_node == NULL)
+ return NULL;
+
+ config = ec_config_dict();
+ if (config == NULL)
+ goto fail;
+
+ ret = ec_config_dict_set(config, "min", ec_config_i64(min));
+ if (ret < 0)
+ goto fail;
+ ret = ec_config_dict_set(config, "max", ec_config_i64(max));
+ if (ret < 0)
+ goto fail;
+ ret = ec_config_dict_set(config, "base", ec_config_u64(base));
+ 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;
+}
+
+static const struct ec_config_schema ec_node_uint_schema[] = {
+ {
+ .key = "min",
+ .desc = "The minimum valid value (included).",
+ .type = EC_CONFIG_TYPE_UINT64,
+ },
+ {
+ .key = "max",
+ .desc = "The maximum valid value (included).",
+ .type = EC_CONFIG_TYPE_UINT64,
+ },
+ {
+ .key = "base",
+ .desc = "The base to use. If unset or 0, try to guess.",
+ .type = EC_CONFIG_TYPE_UINT64,
+ },
+ {
+ .type = EC_CONFIG_TYPE_NONE,
+ },
+};
+
+static int ec_node_uint_set_config(struct ec_node *gen_node,
+ const struct ec_config *config)
+{
+ struct ec_node_int_uint *node = (struct ec_node_int_uint *)gen_node;
+ const struct ec_config *min_value = NULL;
+ const struct ec_config *max_value = NULL;
+ const struct ec_config *base_value = NULL;
+ char *s = NULL;
+
+ min_value = ec_config_dict_get(config, "min");
+ max_value = ec_config_dict_get(config, "max");
+ base_value = ec_config_dict_get(config, "base");
+
+ if (min_value && max_value && min_value->u64 > max_value->u64) {
+ errno = EINVAL;
+ goto fail;
+ }
+
+ if (min_value != NULL) {
+ node->check_min = true;
+ node->min = min_value->u64;
+ } else {
+ node->check_min = false;
+ }
+ if (max_value != NULL) {
+ node->check_max = true;
+ node->max = max_value->u64;
+ } else {
+ node->check_min = false;
+ }
+ if (base_value != NULL)
+ node->base = base_value->u64;
+ else
+ node->base = 0;
+
+ return 0;
+
+fail:
+ ec_free(s);
+ return -1;
+}
+
+static struct ec_node_type ec_node_uint_type = {
+ .name = "uint",
+ .schema = ec_node_uint_schema,
+ .set_config = ec_node_uint_set_config,
+ .parse = ec_node_int_uint_parse,
+ .complete = ec_node_complete_unknown,
+ .size = sizeof(struct ec_node_int_uint),
+};
+
+EC_NODE_TYPE_REGISTER(ec_node_uint_type);
+
+struct ec_node *ec_node_uint(const char *id, uint64_t min,
+ uint64_t max, unsigned int base)