xml.h (2842B)
1 #ifndef _XML_H 2 #define _XML_H 3 4 #define XML_BUFSIZ (2<<20) 5 6 #include <stdlib.h> 7 8 struct xmlparser { 9 /* handlers */ 10 void (*xmlattr)(struct xmlparser *, const char *, size_t, 11 const char *, size_t, const char *, size_t); 12 void (*xmlattrend)(struct xmlparser *, const char *, size_t, 13 const char *, size_t); 14 void (*xmlattrstart)(struct xmlparser *, const char *, size_t, 15 const char *, size_t); 16 void (*xmlattrentity)(struct xmlparser *, const char *, size_t, 17 const char *, size_t, const char *, size_t); 18 void (*xmlcdatastart)(struct xmlparser *); 19 void (*xmlcdata)(struct xmlparser *, const char *, size_t); 20 void (*xmlcdataend)(struct xmlparser *); 21 void (*xmlcommentstart)(struct xmlparser *); 22 void (*xmlcomment)(struct xmlparser *, const char *, size_t); 23 void (*xmlcommentend)(struct xmlparser *); 24 void (*xmldata)(struct xmlparser *, const char *, size_t); 25 void (*xmldataend)(struct xmlparser *); 26 void (*xmldataentity)(struct xmlparser *, const char *, size_t); 27 void (*xmldatastart)(struct xmlparser *); 28 void (*xmltagend)(struct xmlparser *, const char *, size_t, int); 29 void (*xmltagstart)(struct xmlparser *, const char *, size_t); 30 void (*xmltagstartparsed)(struct xmlparser *, const char *, 31 size_t, int); 32 33 #ifndef GETNEXT 34 #define GETNEXT (x)->getnext(x) 35 int (*getnext)(struct xmlparser *); 36 #endif 37 38 /* current tag */ 39 char tag[1024]; 40 size_t taglen; 41 void *user_data; 42 /* current tag is in short form ? <tag /> */ 43 int isshorttag; 44 /* current attribute name */ 45 char name[1024]; 46 /* data buffer used for tag data, cdata and attribute data */ 47 char data[XML_BUFSIZ]; 48 }; 49 50 int xml_entitytostr(const char *, char *, size_t); 51 void xml_parse(struct xmlparser *); 52 #endif 53 54 /* 55 void xmlattr(struct xmlparser *x, const char *t, size_t tl, const char *a, size_t al, const char *v, size_t vl) 56 void xmlattrentity(struct xmlparser *x, const char *t, size_t tl, const char *a, size_t al, const char *v, size_t vl) 57 void xmlattrend(struct xmlparser *x, const char *t, size_t tl, const char *a, size_t al) 58 void xmlattrstart(struct xmlparser *x, const char *t, size_t tl, const char *a, size_t al) 59 void xmlcdatastart(struct xmlparser *x) 60 void xmlcdata(struct xmlparser *x, const char *d, size_t dl) 61 void xmlcdataend(struct xmlparser *x) 62 void xmlcommentstart(struct xmlparser *x) 63 void xmlcomment(struct xmlparser *x, const char *c, size_t cl) 64 void xmlcommentend(struct xmlparser *x) 65 void xmldata(struct xmlparser *x, const char *d, size_t dl) 66 void xmldataend(struct xmlparser *x) 67 void xmldataentity(struct xmlparser *x, const char *d, size_t dl) 68 void xmldatastart(struct xmlparser *x) 69 void xmltagend(struct xmlparser *x, const char *t, size_t tl, int isshort) 70 void xmltagstart(struct xmlparser *x, const char *t, size_t tl) 71 void xmltagstartparsed(struct xmlparser *x, const char *t, size_t tl, int isshort) 72 73 */