libtreestore

annotate src/xmltree.h @ 5:f3ade599cfbb

ts_free*/ts_destroy* functions shouldn't bork when passed a null pointer
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 13 Nov 2016 20:40:07 +0200
parents
children
rev   line source
nuclear@0 1 #ifndef COMMON_XMLTREE_H_
nuclear@0 2 #define COMMON_XMLTREE_H_
nuclear@0 3
nuclear@0 4 #include <stdio.h>
nuclear@0 5
nuclear@0 6 enum {
nuclear@0 7 ATYPE_STR,
nuclear@0 8 ATYPE_INT,
nuclear@0 9 ATYPE_FLT,
nuclear@0 10 ATYPE_VEC
nuclear@0 11 };
nuclear@0 12
nuclear@0 13 struct xml_attr {
nuclear@0 14 char *name;
nuclear@0 15 char *str;
nuclear@0 16
nuclear@0 17 int type;
nuclear@0 18 int ival;
nuclear@0 19 float fval;
nuclear@0 20 float vval[4];
nuclear@0 21
nuclear@0 22 struct xml_attr *next;
nuclear@0 23 };
nuclear@0 24
nuclear@0 25 struct xml_node {
nuclear@0 26 char *name;
nuclear@0 27 char *cdata;
nuclear@0 28 struct xml_attr *attr; /* attribute list */
nuclear@0 29
nuclear@0 30 int chld_count;
nuclear@0 31
nuclear@0 32 struct xml_node *up; /* parent pointer */
nuclear@0 33 struct xml_node *chld, *chld_tail; /* children list */
nuclear@0 34 struct xml_node *next; /* next sibling */
nuclear@0 35 };
nuclear@0 36
nuclear@0 37 #ifdef __cplusplus
nuclear@0 38 extern "C" {
nuclear@0 39 #endif
nuclear@0 40
nuclear@0 41 struct xml_attr *xml_create_attr(const char *name, const char *val);
nuclear@0 42 void xml_free_attr(struct xml_attr *attr);
nuclear@0 43 void xml_free_attr_list(struct xml_attr *alist);
nuclear@0 44
nuclear@0 45 struct xml_attr *xml_get_attr(struct xml_node *node, const char *attr_name);
nuclear@0 46
nuclear@0 47 struct xml_node *xml_create_tree(void);
nuclear@0 48 void xml_free_tree(struct xml_node *x);
nuclear@0 49
nuclear@0 50 struct xml_node *xml_read_tree(const char *fname);
nuclear@0 51 struct xml_node *xml_read_tree_file(FILE *fp);
nuclear@0 52
nuclear@0 53 int xml_write_tree(struct xml_node *x, const char *fname);
nuclear@0 54 int xml_write_tree_file(struct xml_node *x, FILE *fp);
nuclear@0 55
nuclear@0 56 void xml_add_child(struct xml_node *x, struct xml_node *chld);
nuclear@0 57 void xml_remove_subtree(struct xml_node *sub);
nuclear@0 58
nuclear@0 59 #ifdef __cplusplus
nuclear@0 60 }
nuclear@0 61 #endif
nuclear@0 62
nuclear@0 63 #endif /* COMMON_XMLTREE_H_ */