struct ec_strvec;
struct ec_keyval;
-/* return 0 on success, else -errno. */
-typedef int (*ec_node_build_t)(struct ec_node *node);
-
-typedef struct ec_parsed *(*ec_node_parse_t)(const struct ec_node *node,
- const struct ec_strvec *strvec);
-typedef struct ec_completed *(*ec_node_complete_t)(const struct ec_node *node,
- const struct ec_strvec *strvec);
-typedef const char * (*ec_node_desc_t)(const struct ec_node *);
-typedef void (*ec_node_init_priv_t)(struct ec_node *);
-typedef void (*ec_node_free_priv_t)(struct ec_node *);
-
#define EC_NODE_TYPE_REGISTER(t) \
static void ec_node_init_##t(void); \
static void __attribute__((constructor, used)) \
TAILQ_HEAD(ec_node_type_list, ec_node_type);
+/* return 0 on success, else -errno. */
+typedef int (*ec_node_build_t)(struct ec_node *node);
+
+typedef int (*ec_node_parse_t)(const struct ec_node *node,
+ struct ec_parsed *state,
+ const struct ec_strvec *strvec);
+typedef int (*ec_node_complete_t)(const struct ec_node *node,
+ struct ec_completed *completed_state,
+ struct ec_parsed *parsed_state,
+ const struct ec_strvec *strvec);
+typedef size_t (*ec_node_get_max_parse_len_t)(const struct ec_node *node);
+typedef const char * (*ec_node_desc_t)(const struct ec_node *);
+typedef void (*ec_node_init_priv_t)(struct ec_node *);
+typedef void (*ec_node_free_priv_t)(struct ec_node *);
+
/**
* A structure describing a node type.
*/
ec_node_build_t build; /* (re)build the node, called by generic parse */
ec_node_parse_t parse;
ec_node_complete_t complete;
+ ec_node_get_max_parse_len_t get_max_parse_len;
ec_node_desc_t desc;
size_t size;
ec_node_init_priv_t init_priv;
struct ec_node *ec_node_clone(struct ec_node *node);
void ec_node_free(struct ec_node *node);
+/**
+ * Get the max len of strvec that can be parsed by this node
+ *
+ * If there is no maximum, return SIZE_MAX.
+ */
+size_t ec_node_get_max_parse_len(const struct ec_node *node);
+
/* XXX add more accessors */
struct ec_keyval *ec_node_attrs(const struct ec_node *node);
struct ec_node *ec_node_parent(const struct ec_node *node);