fix config dump
[protos/libecoli.git] / lib / ecoli_node.h
index 9bf459d..45f3e74 100644 (file)
@@ -83,8 +83,8 @@ typedef const char * (*ec_node_desc_t)(const struct ec_node *);
 typedef int (*ec_node_init_priv_t)(struct ec_node *);
 typedef void (*ec_node_free_priv_t)(struct ec_node *);
 typedef size_t (*ec_node_get_children_count_t)(const struct ec_node *);
-typedef struct ec_node * (*ec_node_get_child_t)(const struct ec_node *,
-                                               size_t i);
+typedef int (*ec_node_get_child_t)(const struct ec_node *,
+       size_t i, struct ec_node **child, unsigned int *refs);
 
 /**
  * A structure describing a node type.
@@ -92,9 +92,9 @@ typedef struct ec_node * (*ec_node_get_child_t)(const struct ec_node *,
 struct ec_node_type {
        TAILQ_ENTRY(ec_node_type) next;  /**< Next in list. */
        const char *name;                /**< Node type name. */
-       /** Generic configuration schema. */
+       /** Configuration schema array, must be terminated by a sentinel
+        *  (.type = EC_CONFIG_TYPE_NONE). */
        const struct ec_config_schema *schema;
-       size_t schema_len;               /**< Number of elts in schema array. */
        ec_node_set_config_t set_config; /* validate/ack a config change */
        ec_node_parse_t parse;
        ec_node_complete_t complete;
@@ -132,6 +132,18 @@ const struct ec_node_type *ec_node_type_lookup(const char *name);
  */
 void ec_node_type_dump(FILE *out);
 
+/**
+ * Get the config schema of a node type.
+ */
+const struct ec_config_schema *
+ec_node_type_schema(const struct ec_node_type *type);
+
+/**
+ * Get the name of a node type.
+ */
+const char *
+ec_node_type_name(const struct ec_node_type *type);
+
 enum ec_node_free_state {
        EC_NODE_FREE_STATE_NONE,
        EC_NODE_FREE_STATE_TRAVERSED,
@@ -156,7 +168,7 @@ struct ec_node {
 
 /* create a new node when the type is known, typically called from the node
  * code */
-struct ec_node *__ec_node(const struct ec_node_type *type, const char *id);
+struct ec_node *ec_node_from_type(const struct ec_node_type *type, const char *id);
 
 /* create a new node */
 struct ec_node *ec_node(const char *typename, const char *id);
@@ -174,10 +186,9 @@ int ec_node_set_config(struct ec_node *node, struct ec_config *config);
 const struct ec_config *ec_node_get_config(struct ec_node *node);
 
 size_t ec_node_get_children_count(const struct ec_node *node);
-struct ec_node *
-ec_node_get_child(const struct ec_node *node, size_t i);
-int ec_node_add_child(struct ec_node *node, struct ec_node *child);
-int ec_node_del_child(struct ec_node *node, struct ec_node *child);
+int
+ec_node_get_child(const struct ec_node *node, size_t i,
+       struct ec_node **child, unsigned int *refs);
 
 /* XXX add more accessors */
 const struct ec_node_type *ec_node_type(const struct ec_node *node);