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
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct xmlparser {
/* handlers */
void (*xmltagstart)(struct xmlparser *p, const char *tag, size_t taglen);
void (*xmltagstartparsed)(struct xmlparser *p, const char *tag, size_t taglen, int isshort);
void (*xmltagend)(struct xmlparser *p, const char *tag, size_t taglen, int isshort);
void (*xmldatastart)(struct xmlparser *p);
void (*xmldata)(struct xmlparser *p, const char *data, size_t datalen);
void (*xmldataend)(struct xmlparser *p);
void (*xmldataentity)(struct xmlparser *p, const char *data, size_t datalen);
void (*xmlattrstart)(struct xmlparser *p, const char *tag, size_t taglen, const char *name, size_t namelen);
void (*xmlattr)(struct xmlparser *p, const char *tag, size_t taglen, const char *name, size_t namelen, const char *value, size_t valuelen);
void (*xmlattrend)(struct xmlparser *p, const char *tag, size_t taglen, const char *name, size_t namelen);
void (*xmlattrentity)(struct xmlparser *p, const char *tag, size_t taglen, const char *name, size_t namelen, const char *value, size_t valuelen);
void (*xmlcdatastart)(struct xmlparser *p);
void (*xmlcdata)(struct xmlparser *p, const char *data, size_t datalen);
void (*xmlcdataend)(struct xmlparser *p);
void (*xmlcommentstart)(struct xmlparser *p);
void (*xmlcomment)(struct xmlparser *p, const char *comment, size_t commentlen);
void (*xmlcommentend)(struct xmlparser *p);
FILE *fp; /* stream to read from */
/* private; internal state */
char tag[1024]; /* current tag */
size_t taglen;
char data[BUFSIZ]; /* data buffer used for tag and attribute data */
size_t readoffset;
size_t readlastbytes;
unsigned char readbuf[BUFSIZ]; /* read buffer used by xmlparser_getnext() */
} XMLParser;
void xmlparser_init(XMLParser *x);
void xmlparser_parse(XMLParser *x);
|