-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml.h
47 lines (34 loc) · 1.1 KB
/
xml.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef _XML_H
#define _XML_H
#include <stdio.h>
#include "ebuf.h"
enum xml_elem_type {
XML_ELEM_TYPE_UNDEF = 0, /* Undefined type */
XML_ELEM_TYPE_ELEM = 1,
XML_ELEM_TYPE_EMPTY = 2, /* Empty-element tag */
XML_ELEM_TYPE_TEXT = 3,
};
struct xml_attr {
char *name;
char *val;
struct xml_attr *pnext;
};
struct xml_elem {
enum xml_elem_type type;
char *name; /* Text for text element */
struct xml_elem *parent; /* Null for root element */
struct xml_elem *child; /* List of childs. Can be null */
struct xml_attr *attr; /* List of attributes */
struct xml_elem *pnext; /* In parent's childs list */
};
struct xml_elem *xml_parse(FILE *fp, struct ebuf *ebuf);
int xml_print(struct xml_elem *root, FILE *fp);
void xml_free(struct xml_elem *root);
struct xml_elem *xml_get_child(struct xml_elem *elem, const char *name);
struct xml_elem *xml_get_elem(struct xml_elem *root, const char *path);
char *xml_get_attr(struct xml_elem *elem, const char *name);
struct xml_elem *xml_get_child_with_attr(struct xml_elem *elem,
const char *name,
const char *attr,
const char *val);
#endif