00001
00002
00003
00004
00005
00006
00007 #ifndef XP_H
00008 #define XP_H
00009
00010 #ifndef DYSTRING_H
00011 #include "dystring.h"
00012 #endif
00013
00014 struct xpStack
00015
00016 {
00017 struct dyString *tag;
00018 struct dyString *text;
00019 };
00020
00021 struct xp
00022
00023 {
00024 struct xp *next;
00025 struct xpStack *stack;
00026 struct xpStack stackBuf[64];
00027 struct xpStack *stackBufEnd;
00028 struct dyString *attDyBuf[128];
00029 char *attBuf[128];
00030 struct dyString *endTag;
00031 void *userData;
00032 void (*atStartTag)(void *userData, char *name, char **atts);
00033 void (*atEndTag)(void *userData, char *name, char *text);
00034 int (*read)(void *userData, char *buf, int bufSize);
00035 char *fileName;
00036 int lineIx;
00037 char inBuf[16*1024];
00038 char *inBufEnd;
00039 char *in;
00040 struct hash *symHash;
00041 };
00042
00043 struct xp *xpNew(void *userData,
00044 void (*atStartTag)(void *userData, char *name, char **atts),
00045 void (*atEndTag)(void *userData, char *name, char *text),
00046 int (*read)(void *userData, char *buf, int bufSize),
00047 char *fileName);
00048
00049
00050
00051 void xpFree(struct xp **pXp);
00052
00053
00054 int xpLineIx(struct xp *xp);
00055
00056
00057 char *xpFileName(struct xp *xp);
00058
00059
00060 int xpReadFromFile(void *userData, char *buf, int bufSize);
00061
00062
00063
00064 void xpError(struct xp *xp, char *format, ...);
00065
00066
00067 boolean xpParseNext(struct xp *xp, char *tag);
00068
00069
00070
00071
00072
00073 void xpParse(struct xp *xp);
00074
00075
00076
00077 #endif
00078