diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/xmltree.c | 20 | ||||
| -rw-r--r-- | lib/xmltree.h | 1 | 
2 files changed, 21 insertions, 0 deletions
| diff --git a/lib/xmltree.c b/lib/xmltree.c index b0a945ce..00b37ae6 100644 --- a/lib/xmltree.c +++ b/lib/xmltree.c @@ -549,6 +549,26 @@ void xt_add_child( struct xt_node *parent, struct xt_node *child )  	}  } +/* Same, but at the beginning. */ +void xt_insert_child( struct xt_node *parent, struct xt_node *child ) +{ +	struct xt_node *node, *last; +	 +	for( node = child; node; node = node->next ) +	{ +		if( node->parent != NULL ) +		{ +			/* ERROR CONDITION: They seem to have a parent already??? */ +		} +		 +		node->parent = parent; +		last = node; +	} +	 +	last->next = parent->children; +	parent->children = child; +} +  void xt_add_attr( struct xt_node *node, const char *key, const char *value )  {  	int i; diff --git a/lib/xmltree.h b/lib/xmltree.h index 34e3be68..ddb3f02f 100644 --- a/lib/xmltree.h +++ b/lib/xmltree.h @@ -91,6 +91,7 @@ char *xt_find_attr( struct xt_node *node, const char *key );  struct xt_node *xt_new_node( char *name, const char *text, struct xt_node *children );  void xt_add_child( struct xt_node *parent, struct xt_node *child ); +void xt_insert_child( struct xt_node *parent, struct xt_node *child );  void xt_add_attr( struct xt_node *node, const char *key, const char *value );  int xt_remove_attr( struct xt_node *node, const char *key ); | 
