2 * exml.h -- Embedded Xml Parser header
4 * Copyright (c) Mbedthis Software, LLC, 2003-2003. All Rights Reserved. -- MOB
10 /******************************** Description *********************************/
14 /********************************** Defines ***********************************/
16 #if BLD_FEATURE_SQUEEZE
17 #define EXML_BUFSIZE 512 /* Read buffer size */
19 #define EXML_BUFSIZE 1024 /* Read buffer size */
23 * XML parser states. The states that are passed to the user handler have
24 * "U" appended to the comment. The error states (ERR and EOF) must be
27 #define EXML_ERR -1 /* Error */
28 #define EXML_EOF -2 /* End of input */
29 #define EXML_BEGIN 1 /* Before next tag */
30 #define EXML_AFTER_LS 2 /* Seen "<" */
31 #define EXML_COMMENT 3 /* Seen "<!--" (usr) U */
32 #define EXML_NEW_ELT 4 /* Seen "<tag" (usr) U */
33 #define EXML_ATT_NAME 5 /* Seen "<tag att" */
34 #define EXML_ATT_EQ 6 /* Seen "<tag att" = */
35 #define EXML_NEW_ATT 7 /* Seen "<tag att = "val" U */
36 #define EXML_SOLO_ELT_DEFINED 8 /* Seen "<tag../>" U */
37 #define EXML_ELT_DEFINED 9 /* Seen "<tag...>" U */
38 #define EXML_ELT_DATA 10 /* Seen "<tag>....<" U */
39 #define EXML_END_ELT 11 /* Seen "<tag>....</tag>" U */
40 #define EXML_PI 12 /* Seen "<?processingInst" U */
41 #define EXML_CDATA 13 /* Seen "<![CDATA[" U */
46 typedef enum ExmlToken {
48 TOKEN_TOO_BIG, /* Token is too big */
52 TOKEN_LS, /* "<" -- Opening a tag */
53 TOKEN_LS_SLASH, /* "</" -- Closing a tag */
54 TOKEN_GR, /* ">" -- End of an open tag */
55 TOKEN_SLASH_GR, /* "/>" -- End of a solo tag */
63 typedef int (*ExmlHandler)(struct Exml *xp, int state,
64 const char *tagName, const char* attName, const char* value);
65 typedef int (*ExmlInputStream)(struct Exml *xp, void *arg, char *buf, int size);
68 * Per XML session structure
71 ExmlHandler handler; /* Callback function */
72 ExmlInputStream readFn; /* Read data function */
73 MprBuf *inBuf; /* Input data queue */
74 MprBuf *tokBuf; /* Parsed token buffer */
75 int quoteChar; /* XdbAtt quote char */
76 int lineNumber; /* Current line no for debug */
77 void *parseArg; /* Arg passed to exmlParse() */
78 void *inputArg; /* Arg passed to exmlSetInputStream() */
79 char *errMsg; /* Error message text */
82 extern Exml *exmlOpen(MprCtx ctx, int initialSize, int maxSize);
83 extern void exmlClose(Exml *xp);
84 extern void exmlSetParserHandler(Exml *xp, ExmlHandler h);
85 extern void exmlSetInputStream(Exml *xp, ExmlInputStream s, void *arg);
86 extern int exmlParse(Exml *xp);
87 extern void exmlSetParseArg(Exml *xp, void *parseArg);
88 extern void *exmlGetParseArg(Exml *xp);
89 extern const char *exmlGetErrorMsg(Exml *xp);
90 extern int exmlGetLineNumber(Exml *xp);
92 /******************************************************************************/