nuclear@0: #ifndef COMMON_XMLTREE_H_ nuclear@0: #define COMMON_XMLTREE_H_ nuclear@0: nuclear@0: #include nuclear@0: nuclear@0: enum { nuclear@0: ATYPE_STR, nuclear@0: ATYPE_INT, nuclear@0: ATYPE_FLT, nuclear@0: ATYPE_VEC nuclear@0: }; nuclear@0: nuclear@0: struct xml_attr { nuclear@0: char *name; nuclear@0: char *str; nuclear@0: nuclear@0: int type; nuclear@0: int ival; nuclear@0: float fval; nuclear@0: float vval[4]; nuclear@0: nuclear@0: struct xml_attr *next; nuclear@0: }; nuclear@0: nuclear@0: struct xml_node { nuclear@0: char *name; nuclear@0: char *cdata; nuclear@0: struct xml_attr *attr; /* attribute list */ nuclear@0: nuclear@0: int chld_count; nuclear@0: nuclear@0: struct xml_node *up; /* parent pointer */ nuclear@0: struct xml_node *chld, *chld_tail; /* children list */ nuclear@0: struct xml_node *next; /* next sibling */ nuclear@0: }; nuclear@0: nuclear@0: #ifdef __cplusplus nuclear@0: extern "C" { nuclear@0: #endif nuclear@0: nuclear@0: struct xml_attr *xml_create_attr(const char *name, const char *val); nuclear@0: void xml_free_attr(struct xml_attr *attr); nuclear@0: void xml_free_attr_list(struct xml_attr *alist); nuclear@0: nuclear@0: struct xml_attr *xml_get_attr(struct xml_node *node, const char *attr_name); nuclear@0: nuclear@0: struct xml_node *xml_create_tree(void); nuclear@0: void xml_free_tree(struct xml_node *x); nuclear@0: nuclear@0: struct xml_node *xml_read_tree(const char *fname); nuclear@0: struct xml_node *xml_read_tree_file(FILE *fp); nuclear@0: nuclear@0: int xml_write_tree(struct xml_node *x, const char *fname); nuclear@0: int xml_write_tree_file(struct xml_node *x, FILE *fp); nuclear@0: nuclear@0: void xml_add_child(struct xml_node *x, struct xml_node *chld); nuclear@0: void xml_remove_subtree(struct xml_node *sub); nuclear@0: nuclear@0: #ifdef __cplusplus nuclear@0: } nuclear@0: #endif nuclear@0: nuclear@0: #endif /* COMMON_XMLTREE_H_ */