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
48
49
50
51
52
53
54
55
56
|
struct solv_xmlparser_element {
int fromstate;
char *element;
int tostate;
int docontent;
};
struct solv_xmlparser {
void *userdata;
char *errstr;
unsigned int line;
unsigned int column;
int state;
int docontent;
Queue elementq;
int unknowncnt;
char *content;
int lcontent; /* current content length */
int acontent; /* allocated content length */
struct solv_xmlparser_element *elements;
int nelements;
void (*startelement)(struct solv_xmlparser *xmlp, int state, const char *name, const char **atts);
void (*endelement)(struct solv_xmlparser *xmlp, int state, char *content);
Id *elementhelper;
void *parser;
};
#define SOLV_XMLPARSER_OK 0
#define SOLV_XMLPARSER_ERROR -1
static inline const char *
solv_xmlparser_find_attr(const char *txt, const char **atts)
{
for (; *atts; atts += 2)
if (!strcmp(*atts, txt))
return atts[1];
return 0;
}
extern void solv_xmlparser_init(struct solv_xmlparser *xmlp, struct solv_xmlparser_element *elements, void *userdata,
void (*startelement)(struct solv_xmlparser *xmlp, int state, const char *name, const char **atts),
void (*endelement)(struct solv_xmlparser *xmlp, int state, char *content));
extern void solv_xmlparser_free(struct solv_xmlparser *xmlp);
extern int solv_xmlparser_parse(struct solv_xmlparser *xmlp, FILE *fp);
unsigned int solv_xmlparser_lineno(struct solv_xmlparser *xmlp);
char *solv_xmlparser_contentspace(struct solv_xmlparser *xmlp, int l);
|