1
2#include "tcl.h"
3#include <expat.h>
4
5
6struct TclGenExpatInfo;
7
8typedef void (*CHandlerSet_userDataReset)(Tcl_Interp *interp, void *userData);
9typedef void (*CHandlerSet_userDataFree)(Tcl_Interp *interp, void *userData);
10typedef void (*CHandlerSet_parserReset)(XML_Parser parser, void *userData);
11typedef void (*CHandlerSet_initParse)(const struct TclGenExpatInfo *expat,
12                                      void *userData);
13
14typedef struct CHandlerSet {
15    struct CHandlerSet *nextHandlerSet;
16    char *name;                     /* refname of the handler set */
17    int ignoreWhiteCDATAs;          /* ignore 'white' CDATA sections */
18
19    void *userData;                 /* Handler set specific Data Structure;
20                                       the C handler set extention has to
21                                       malloc the needed structure in his
22                                       init func and has to provide a
23                                       cleanup func (to free it). */
24
25    CHandlerSet_userDataReset        resetProc;
26    CHandlerSet_userDataFree         freeProc;
27    CHandlerSet_parserReset          parserResetProc;
28    CHandlerSet_initParse            initParseProc;
29
30    /* C func for element start */
31    XML_StartElementHandler          elementstartcommand;
32    /* C func for element end */
33    XML_EndElementHandler            elementendcommand;
34    /* C func for character data */
35    XML_CharacterDataHandler         datacommand;
36    /* C func for namespace decl start */
37    XML_StartNamespaceDeclHandler    startnsdeclcommand;
38    /* C func for namespace decl end */
39    XML_EndNamespaceDeclHandler      endnsdeclcommand;
40    /* C func for processing instruction */
41    XML_ProcessingInstructionHandler picommand;
42    /* C func for default data */
43    XML_DefaultHandler               defaultcommand;
44    /* C func for unparsed entity declaration */
45    XML_NotationDeclHandler          notationcommand;
46    /* C func for external entity */
47    XML_ExternalEntityRefHandler     externalentitycommand;
48    /* C func for unknown encoding */
49    XML_UnknownEncodingHandler       unknownencodingcommand;
50    /* C func for comments */
51    XML_CommentHandler               commentCommand;
52    /* C func for "not standalone" docs */
53    XML_NotStandaloneHandler         notStandaloneCommand;
54    /* C func for CDATA section start */
55    XML_StartCdataSectionHandler     startCdataSectionCommand;
56    /* C func for CDATA section end */
57    XML_EndCdataSectionHandler       endCdataSectionCommand;
58    /* C func for <!ELEMENT decl's */
59    XML_ElementDeclHandler           elementDeclCommand;
60    /* C func for <!ATTLIST decl's */
61    XML_AttlistDeclHandler           attlistDeclCommand;
62    /* C func for <!DOCTYPE decl's */
63    XML_StartDoctypeDeclHandler      startDoctypeDeclCommand;
64    /* C func for <!DOCTYPE decl ends */
65    XML_EndDoctypeDeclHandler        endDoctypeDeclCommand;
66    /* C func for <?XML decl's */
67    XML_XmlDeclHandler               xmlDeclCommand;
68    /* C func for <!ENTITY decls's */
69    XML_EntityDeclHandler            entityDeclCommand;
70} CHandlerSet;
71
72/*----------------------------------------------------------------------------
73|   The structure below is used to refer to an event handler set
74|   of tcl scripts.
75\---------------------------------------------------------------------------*/
76
77typedef struct TclHandlerSet {
78    struct TclHandlerSet *nextHandlerSet;
79    char *name;                     /* refname of the handler set */
80    int status;                     /* handler set status */
81    int continueCount;		    /* reference count for continue */
82    int ignoreWhiteCDATAs;          /* ignore 'white' CDATA sections */
83
84    Tcl_Obj *elementstartcommand;      /* Script for element start */
85    Tcl_ObjCmdProc *elementstartObjProc;
86    ClientData      elementstartclientData;
87    Tcl_Obj *elementendcommand;        /* Script for element end */
88    Tcl_ObjCmdProc *elementendObjProc;
89    ClientData      elementendclientData;
90    Tcl_Obj *datacommand;	       /* Script for character data */
91    Tcl_ObjCmdProc *datacommandObjProc;
92    ClientData      datacommandclientData;
93    Tcl_Obj *startnsdeclcommand;       /* Script for namespace decl start */
94    Tcl_Obj *endnsdeclcommand;         /* Script for namespace decl end */
95    Tcl_Obj *picommand;		       /* Script for processing instruction */
96    Tcl_Obj *defaultcommand;	       /* Script for default data */
97    Tcl_Obj *notationcommand;	       /* Script for notation declaration */
98    Tcl_Obj *externalentitycommand;    /* Script for external entity */
99    Tcl_Obj *unknownencodingcommand;   /* Script for unknown encoding */
100    Tcl_Obj *commentCommand;           /* Script for comments */
101    Tcl_Obj *notStandaloneCommand;     /* Script for "not standalone" docs */
102    Tcl_Obj *startCdataSectionCommand; /* Script for CDATA section start */
103    Tcl_Obj *endCdataSectionCommand;   /* Script for CDATA section end */
104    Tcl_Obj *elementDeclCommand;       /* Script for <!ELEMENT decl's */
105    Tcl_Obj *attlistDeclCommand;       /* Script for <!ATTLIST decl's */
106    Tcl_Obj *startDoctypeDeclCommand;  /* Script for <!DOCTYPE decl's */
107    Tcl_Obj *endDoctypeDeclCommand;    /* Script for <!DOCTYPE decl ends */
108    Tcl_Obj *xmlDeclCommand;           /* Script for <?XML decl's */
109    Tcl_Obj *entityDeclCommand;        /* Script for <!ENTITY decl's */
110} TclHandlerSet;
111
112typedef struct TclGenExpatInfo {
113    XML_Parser  parser;		/* The expat parser structure */
114    Tcl_Interp *interp;		/* Interpreter for this instance */
115    Tcl_Obj    *name;		/* name of this instance */
116    int final;			/* input data complete? */
117    int needWSCheck;            /* Any handler set has ignoreWhiteCDATAs==1? */
118    int status;			/* application status */
119    Tcl_Obj *result;		/* application return result */
120    const char *context;        /* reference to the context pointer */
121    Tcl_Obj *cdata;             /* Accumulates character data */
122    int      ns_mode;           /* namespace mode */
123    XML_Char nsSeparator;
124
125    TclHandlerSet *firstTclHandlerSet;
126    CHandlerSet *firstCHandlerSet;
127} TclGenExpatInfo;
128
129#ifdef BUILD_tdom
130# undef TCL_STORAGE_CLASS
131# define TCL_STORAGE_CLASS DLLEXPORT
132#endif
133
134#include "dom.h"
135#include "tdomDecls.h"
136
137
138
139