summaryrefslogtreecommitdiffstats
path: root/include/tclxml/tclxml.h.in
blob: c809fdcfa3f771a8ca4d646d360c5d73a8ef2bc3 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*
 * tclxml.h --
 *
 *	Generic interface to XML parsers.
 *
 * Copyright (c) 2005-2007 by Explain.
 * Copyright (c) 1999-2004 Steve Ball, Zveno Pty Ltd
 *
 * See the file "LICENSE" for information on usage and
 * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * $Id: tclxml.h.in,v 1.1.1.1 2009/01/16 22:11:49 joye Exp $
 *
 */

#ifndef __TCLXML_H__
#define __TCLXML_H__

#ifdef TCLXML_BUILD_AS_FRAMEWORK
#include <Tcl/tcl.h>
#else
#include <tcl.h>
#endif /* TCLXML_BUILD_AS_FRAMEWORK */

#define TCLXML_VERSION		"@PACKAGE_VERSION@"

/*
 * Used to block the rest of this header file from resource compilers so
 * we can just get the version info.
 */
#ifndef RC_INVOKED

/* TIP 27 update. If CONST84 is not defined we are compiling against a
 * core before 8.4 and have to disable some CONST'ness.
 */

#ifndef CONST84
#   define CONST84
#endif

/*
 * Fix the Borland bug that's in the EXTERN macro from tcl.h.
 */
#ifndef TCL_EXTERN
#   undef DLLIMPORT
#   undef DLLEXPORT
#   if defined(STATIC_BUILD)
#	define DLLIMPORT
#	define DLLEXPORT
#   elif (defined(__WIN32__) && (defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || (defined(__GNUC__) && defined(__declspec)))) || (defined(MAC_TCL) && FUNCTION_DECLSPEC)
#	define DLLIMPORT __declspec(dllimport)
#	define DLLEXPORT __declspec(dllexport)
#   elif defined(__BORLANDC__)
#	define OLDBORLAND 1
#	define DLLIMPORT __import
#	define DLLEXPORT __export
#   else
#	define DLLIMPORT
#	define DLLEXPORT
#   endif
    /* Avoid name mangling from C++ compilers. */
#   ifdef __cplusplus
#	define TCL_EXTRNC extern "C"
#   else
#	define TCL_EXTRNC extern
#   endif
    /* Pre-5.5 Borland requires the attributes be placed after the */
    /* return type. */
#   ifdef OLDBORLAND
#	define TCL_EXTERN(RTYPE) TCL_EXTRNC RTYPE TCL_STORAGE_CLASS
#   else
#	define TCL_EXTERN(RTYPE) TCL_EXTRNC TCL_STORAGE_CLASS RTYPE
#   endif
#endif



/*
 * These macros are used to control whether functions are being declared for
 * import or export in Windows, 
 * They map to no-op declarations on non-Windows systems.
 * Assumes that tcl.h defines DLLEXPORT & DLLIMPORT correctly.
 * The default build on windows is for a DLL, which causes the DLLIMPORT
 * and DLLEXPORT macros to be nonempty. To build a static library, the
 * macro STATIC_BUILD should be defined before the inclusion of tcl.h
 *
 * If a function is being declared while it is being built
 * to be included in a shared library, then it should have the DLLEXPORT
 * storage class.  If is being declared for use by a module that is going to
 * link against the shared library, then it should have the DLLIMPORT storage
 * class.  If the symbol is beind declared for a static build or for use from a
 * stub library, then the storage class should be empty.
 *
 * The convention is that a macro called BUILD_xxxx, where xxxx is the
 * name of a library we are building, is set on the compile line for sources
 * that are to be placed in the library.  When this macro is set, the
 * storage class will be set to DLLEXPORT.  At the end of the header file, the
 * storage class will be reset to DLLIMPORt.
 */

#undef TCL_STORAGE_CLASS
#ifdef BUILD_Tclxml
# define TCL_STORAGE_CLASS DLLEXPORT
#else
# ifdef USE_TCLXML_STUBS
#  define TCL_STORAGE_CLASS
# else
#  define TCL_STORAGE_CLASS DLLIMPORT
# endif
#endif


/*
 * C API for TclXML generic layer
 *
 * C callback functions to application code and their registration functions.
 * These all mimic the Tcl callbacks.
 */

typedef int (TclXML_ElementStartProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr, Tcl_Obj *nsuri, Tcl_Obj *attListPtr, Tcl_Obj *nsDeclsPtr));
typedef int (TclXML_ElementEndProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr));
typedef int (TclXML_CharacterDataProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *dataPtr));
typedef int (TclXML_PIProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *targetPtr, Tcl_Obj *dataPtr));
typedef int (TclXML_DefaultProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *dataPtr));
typedef int (TclXML_UnparsedProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *entityPtr, Tcl_Obj *basePtr, Tcl_Obj *systemIdPtr, Tcl_Obj *publicIdPtr, Tcl_Obj *notationNamePtr));
typedef int (TclXML_NotationDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr, Tcl_Obj *basePtr, Tcl_Obj *systemIdPtr, Tcl_Obj *publicIdPtr));
typedef int (TclXML_EntityProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr, Tcl_Obj *basePtr, Tcl_Obj *systemIdPtr, Tcl_Obj *publicIdPtr));
typedef int (TclXML_UnknownEncodingProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *dataPtr, void *info));
typedef int (TclXML_CommentProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *dataPtr));
typedef int (TclXML_NotStandaloneProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData));
typedef int (TclXML_ElementDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr, Tcl_Obj *contentspecPtr));
typedef int (TclXML_AttlistDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *elementnamePtr, Tcl_Obj *attrdefnsPtr));
typedef int (TclXML_StartDoctypeDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr));
typedef int (TclXML_EndDoctypeDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData));

/*
 * The structure below is used to refer to a parser object.
 */

typedef struct TclXML_Info {
    Tcl_Interp *interp;		/* Interpreter for this instance */
    Tcl_Obj *name;		/* name of this instance */

    Tcl_Obj *base;		/* base URI for document entity */

	Tcl_Obj *encoding;   /* character encoding */

    void *parserClass;		/* Parser-specific functions
				 * Actually of type TclXML_ParserClassInfo
				 */
    ClientData clientData;	/* Parser-specific data structure */
    
    int final;			/* input data complete? */
    int validate;		/* Validate document? */
    
    int status;			/* application status */
    Tcl_Obj *result;		/* application return result */
    
    int continueCount;		/* reference count for continue */
    Tcl_Obj *context;           /* reference to the context pointer */

    Tcl_Obj *cdata;		/* Accumulates character data */
    int nowhitespace;		/* Whether to ignore white space */
    int reportempty;		/* Whether to report empty elements */
    int expandinternalentities;	/* Whether to expand internal entities */
    int paramentities;		/* Whether to include parameter entities */

    Tcl_Obj *elementstartcommand;	/* Script for element start */
    TclXML_ElementStartProc *elementstart;	/* Callback for element start */
    ClientData elementstartdata;
    Tcl_Obj *elementendcommand;	        /* Script for element end */
    TclXML_ElementEndProc *elementend;	/* Callback for element end */
    ClientData elementenddata;
    Tcl_Obj *datacommand;	        /* Script for character data */
    TclXML_CharacterDataProc *cdatacb;	/* Callback for character data */
    ClientData cdatacbdata;
    Tcl_Obj *picommand;		        /* Script for processing instruction */
    TclXML_PIProc *pi;			/* Callback for processing instruction */
    ClientData pidata;
    Tcl_Obj *defaultcommand;	        /* Script for default data */
    TclXML_DefaultProc *defaultcb;		/* Callback for default data */
    ClientData defaultdata;
    Tcl_Obj *unparsedcommand;		/* Script for unparsed entity declaration */
    TclXML_UnparsedProc *unparsed;	/* Callback for unparsed entity declaraion */
    ClientData unparseddata;
    Tcl_Obj *notationcommand;		/* Script for notation declaration */
    TclXML_NotationDeclProc *notation;	/* Callback for notation declaraion */
    ClientData notationdata;
    Tcl_Obj *entitycommand;		/* Script for external entity */
    TclXML_EntityProc *entity;		/* Callback for external entity */
    ClientData entitydata;
    Tcl_Obj *unknownencodingcommand;	/* Script for unknown encoding */
    TclXML_UnknownEncodingProc *unknownencoding;	/* Callback for unknown encoding */
    ClientData unknownencodingdata;
    /* Following added by ericm@scriptics */
    Tcl_Obj *commentCommand;		/* Script for comments */
    TclXML_CommentProc *comment;		/* Callback for comments */
    ClientData commentdata;
    Tcl_Obj *notStandaloneCommand;	/* Script for "not standalone" docs */
    TclXML_NotStandaloneProc *notStandalone;	/* Callback for "not standalone" docs */
    ClientData notstandalonedata;

    Tcl_Obj *elementDeclCommand;	/* Script for <!ELEMENT decl's */
    TclXML_ElementDeclProc *elementDecl;	/* Callback for element declaration */
    ClientData elementdecldata;
    Tcl_Obj *attlistDeclCommand;	/* Script for <!ATTLIST decl's */
    TclXML_AttlistDeclProc *attlistDecl;	/* Callback for attribute list declaration */
    ClientData attlistdecldata;

  /* Do we really need these? */
    Tcl_Obj *startDoctypeDeclCommand;	/* Script for <!DOCTYPE decl's */
    TclXML_StartDoctypeDeclProc *startDoctypeDecl;	/* Callback for document type declaration start */
    ClientData startdoctypedecldata;
    Tcl_Obj *endDoctypeDeclCommand;    /* Script for <!DOCTYPE decl ends */
    TclXML_EndDoctypeDeclProc *endDoctypeDecl;	/* Callback for document type declaration start */
    ClientData enddoctypedecldata;

} TclXML_Info;

/*
 * These function definitions are provided by a parser
 * implementation and registered with this module.
 */

typedef ClientData (TclXML_CreateProc) _ANSI_ARGS_((Tcl_Interp *interp, TclXML_Info *xmlinfo));
typedef ClientData (TclXML_CreateEntityParserProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData));
typedef int (TclXML_ParseProc) _ANSI_ARGS_((ClientData clientData, char *buffer, int len, int final));
typedef int (TclXML_ConfigureProc) _ANSI_ARGS_((ClientData clientData, Tcl_Obj *CONST optionPtr, Tcl_Obj *CONST valuePtr));
typedef int (TclXML_GetProc) _ANSI_ARGS_((ClientData clientData, int objc, Tcl_Obj *CONST objv[]));
typedef int (TclXML_ResetProc) _ANSI_ARGS_((ClientData clientData));
typedef int (TclXML_DeleteProc) _ANSI_ARGS_((ClientData clientData));

/*
 * The structure below is used store function pointers 
 * for a parser implementation.
 */

typedef struct TclXML_ParserClassInfo {
  Tcl_Obj *name;

  TclXML_CreateProc *create;	/* Direct-call creation proc */
  Tcl_Obj *createCmd;	/* Tcl command creation script */

  TclXML_CreateEntityParserProc *createEntity;
  Tcl_Obj *createEntityCmd;

  TclXML_ParseProc *parse;
  Tcl_Obj *parseCmd;

  TclXML_ConfigureProc *configure;
  Tcl_Obj *configureCmd;

  TclXML_GetProc *get;
  Tcl_Obj *getCmd;
  
  TclXML_ResetProc *reset;
  Tcl_Obj *resetCmd;

  TclXML_DeleteProc *destroy;
  Tcl_Obj *destroyCmd;

} TclXML_ParserClassInfo;

/*
 *----------------------------------------------------------------------------
 *
 * Support for error handling
 *
 *----------------------------------------------------------------------------
 */

typedef Tcl_Obj * (TclXML_ErrorNodeHandlerProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData));

typedef struct TclXML_ErrorInfo {
  Tcl_Interp *interp;
  Tcl_Obj *listPtr;
  TclXML_ErrorNodeHandlerProc *nodeHandlerProc;
} TclXML_ErrorInfo;

/*
 *----------------------------------------------------------------------------
 *
 * Function prototypes for publically accessible routines
 *
 *----------------------------------------------------------------------------
 */

#include <tclxml/tclxmlDecls.h>

#ifdef USE_TCLXML_STUBS
TCL_EXTRNC CONST char *
    TclXML_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, CONST char *version, int exact));
#endif

#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT

#endif /* RC_INVOKED */
#endif /* __TCLXML_H__ */