1/* 2 * tclxml.h -- 3 * 4 * Generic interface to XML parsers. 5 * 6 * Copyright (c) 2005-2007 by Explain. 7 * Copyright (c) 1999-2004 Steve Ball, Zveno Pty Ltd 8 * 9 * See the file "LICENSE" for information on usage and 10 * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. 11 * 12 * $Id: tclxml.h.in,v 1.1.2.1 2005/12/28 06:49:51 balls Exp $ 13 * 14 */ 15 16#ifndef __TCLXML_H__ 17#define __TCLXML_H__ 18 19#ifdef TCLXML_BUILD_AS_FRAMEWORK 20#include <Tcl/tcl.h> 21#else 22#include <tcl.h> 23#endif /* TCLXML_BUILD_AS_FRAMEWORK */ 24 25#define TCLXML_VERSION "@PACKAGE_VERSION@" 26 27/* 28 * Used to block the rest of this header file from resource compilers so 29 * we can just get the version info. 30 */ 31#ifndef RC_INVOKED 32 33/* TIP 27 update. If CONST84 is not defined we are compiling against a 34 * core before 8.4 and have to disable some CONST'ness. 35 */ 36 37#ifndef CONST84 38# define CONST84 39#endif 40 41/* 42 * Fix the Borland bug that's in the EXTERN macro from tcl.h. 43 */ 44#ifndef TCL_EXTERN 45# undef DLLIMPORT 46# undef DLLEXPORT 47# if defined(STATIC_BUILD) 48# define DLLIMPORT 49# define DLLEXPORT 50# elif (defined(__WIN32__) && (defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || (defined(__GNUC__) && defined(__declspec)))) || (defined(MAC_TCL) && FUNCTION_DECLSPEC) 51# define DLLIMPORT __declspec(dllimport) 52# define DLLEXPORT __declspec(dllexport) 53# elif defined(__BORLANDC__) 54# define OLDBORLAND 1 55# define DLLIMPORT __import 56# define DLLEXPORT __export 57# else 58# define DLLIMPORT 59# define DLLEXPORT 60# endif 61 /* Avoid name mangling from C++ compilers. */ 62# ifdef __cplusplus 63# define TCL_EXTRNC extern "C" 64# else 65# define TCL_EXTRNC extern 66# endif 67 /* Pre-5.5 Borland requires the attributes be placed after the */ 68 /* return type. */ 69# ifdef OLDBORLAND 70# define TCL_EXTERN(RTYPE) TCL_EXTRNC RTYPE TCL_STORAGE_CLASS 71# else 72# define TCL_EXTERN(RTYPE) TCL_EXTRNC TCL_STORAGE_CLASS RTYPE 73# endif 74#endif 75 76 77 78/* 79 * These macros are used to control whether functions are being declared for 80 * import or export in Windows, 81 * They map to no-op declarations on non-Windows systems. 82 * Assumes that tcl.h defines DLLEXPORT & DLLIMPORT correctly. 83 * The default build on windows is for a DLL, which causes the DLLIMPORT 84 * and DLLEXPORT macros to be nonempty. To build a static library, the 85 * macro STATIC_BUILD should be defined before the inclusion of tcl.h 86 * 87 * If a function is being declared while it is being built 88 * to be included in a shared library, then it should have the DLLEXPORT 89 * storage class. If is being declared for use by a module that is going to 90 * link against the shared library, then it should have the DLLIMPORT storage 91 * class. If the symbol is beind declared for a static build or for use from a 92 * stub library, then the storage class should be empty. 93 * 94 * The convention is that a macro called BUILD_xxxx, where xxxx is the 95 * name of a library we are building, is set on the compile line for sources 96 * that are to be placed in the library. When this macro is set, the 97 * storage class will be set to DLLEXPORT. At the end of the header file, the 98 * storage class will be reset to DLLIMPORt. 99 */ 100 101#undef TCL_STORAGE_CLASS 102#ifdef BUILD_Tclxml 103# define TCL_STORAGE_CLASS DLLEXPORT 104#else 105# ifdef USE_TCLXML_STUBS 106# define TCL_STORAGE_CLASS 107# else 108# define TCL_STORAGE_CLASS DLLIMPORT 109# endif 110#endif 111 112 113/* 114 * C API for TclXML generic layer 115 * 116 * C callback functions to application code and their registration functions. 117 * These all mimic the Tcl callbacks. 118 */ 119 120typedef int (TclXML_ElementStartProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr, Tcl_Obj *nsuri, Tcl_Obj *attListPtr, Tcl_Obj *nsDeclsPtr)); 121typedef int (TclXML_ElementEndProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr)); 122typedef int (TclXML_CharacterDataProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *dataPtr)); 123typedef int (TclXML_PIProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *targetPtr, Tcl_Obj *dataPtr)); 124typedef int (TclXML_DefaultProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *dataPtr)); 125typedef 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)); 126typedef int (TclXML_NotationDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr, Tcl_Obj *basePtr, Tcl_Obj *systemIdPtr, Tcl_Obj *publicIdPtr)); 127typedef int (TclXML_EntityProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr, Tcl_Obj *basePtr, Tcl_Obj *systemIdPtr, Tcl_Obj *publicIdPtr)); 128typedef int (TclXML_UnknownEncodingProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *dataPtr, void *info)); 129typedef int (TclXML_CommentProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *dataPtr)); 130typedef int (TclXML_NotStandaloneProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData)); 131typedef int (TclXML_ElementDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr, Tcl_Obj *contentspecPtr)); 132typedef int (TclXML_AttlistDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *elementnamePtr, Tcl_Obj *attrdefnsPtr)); 133typedef int (TclXML_StartDoctypeDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData, Tcl_Obj *namePtr)); 134typedef int (TclXML_EndDoctypeDeclProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData)); 135 136/* 137 * The structure below is used to refer to a parser object. 138 */ 139 140typedef struct TclXML_Info { 141 Tcl_Interp *interp; /* Interpreter for this instance */ 142 Tcl_Obj *name; /* name of this instance */ 143 144 Tcl_Obj *base; /* base URI for document entity */ 145 146 Tcl_Obj *encoding; /* character encoding */ 147 148 void *parserClass; /* Parser-specific functions 149 * Actually of type TclXML_ParserClassInfo 150 */ 151 ClientData clientData; /* Parser-specific data structure */ 152 153 int final; /* input data complete? */ 154 int validate; /* Validate document? */ 155 156 int status; /* application status */ 157 Tcl_Obj *result; /* application return result */ 158 159 int continueCount; /* reference count for continue */ 160 Tcl_Obj *context; /* reference to the context pointer */ 161 162 Tcl_Obj *cdata; /* Accumulates character data */ 163 int nowhitespace; /* Whether to ignore white space */ 164 int reportempty; /* Whether to report empty elements */ 165 int expandinternalentities; /* Whether to expand internal entities */ 166 int paramentities; /* Whether to include parameter entities */ 167 168 Tcl_Obj *elementstartcommand; /* Script for element start */ 169 TclXML_ElementStartProc *elementstart; /* Callback for element start */ 170 ClientData elementstartdata; 171 Tcl_Obj *elementendcommand; /* Script for element end */ 172 TclXML_ElementEndProc *elementend; /* Callback for element end */ 173 ClientData elementenddata; 174 Tcl_Obj *datacommand; /* Script for character data */ 175 TclXML_CharacterDataProc *cdatacb; /* Callback for character data */ 176 ClientData cdatacbdata; 177 Tcl_Obj *picommand; /* Script for processing instruction */ 178 TclXML_PIProc *pi; /* Callback for processing instruction */ 179 ClientData pidata; 180 Tcl_Obj *defaultcommand; /* Script for default data */ 181 TclXML_DefaultProc *defaultcb; /* Callback for default data */ 182 ClientData defaultdata; 183 Tcl_Obj *unparsedcommand; /* Script for unparsed entity declaration */ 184 TclXML_UnparsedProc *unparsed; /* Callback for unparsed entity declaraion */ 185 ClientData unparseddata; 186 Tcl_Obj *notationcommand; /* Script for notation declaration */ 187 TclXML_NotationDeclProc *notation; /* Callback for notation declaraion */ 188 ClientData notationdata; 189 Tcl_Obj *entitycommand; /* Script for external entity */ 190 TclXML_EntityProc *entity; /* Callback for external entity */ 191 ClientData entitydata; 192 Tcl_Obj *unknownencodingcommand; /* Script for unknown encoding */ 193 TclXML_UnknownEncodingProc *unknownencoding; /* Callback for unknown encoding */ 194 ClientData unknownencodingdata; 195 /* Following added by ericm@scriptics */ 196 Tcl_Obj *commentCommand; /* Script for comments */ 197 TclXML_CommentProc *comment; /* Callback for comments */ 198 ClientData commentdata; 199 Tcl_Obj *notStandaloneCommand; /* Script for "not standalone" docs */ 200 TclXML_NotStandaloneProc *notStandalone; /* Callback for "not standalone" docs */ 201 ClientData notstandalonedata; 202 203 Tcl_Obj *elementDeclCommand; /* Script for <!ELEMENT decl's */ 204 TclXML_ElementDeclProc *elementDecl; /* Callback for element declaration */ 205 ClientData elementdecldata; 206 Tcl_Obj *attlistDeclCommand; /* Script for <!ATTLIST decl's */ 207 TclXML_AttlistDeclProc *attlistDecl; /* Callback for attribute list declaration */ 208 ClientData attlistdecldata; 209 210 /* Do we really need these? */ 211 Tcl_Obj *startDoctypeDeclCommand; /* Script for <!DOCTYPE decl's */ 212 TclXML_StartDoctypeDeclProc *startDoctypeDecl; /* Callback for document type declaration start */ 213 ClientData startdoctypedecldata; 214 Tcl_Obj *endDoctypeDeclCommand; /* Script for <!DOCTYPE decl ends */ 215 TclXML_EndDoctypeDeclProc *endDoctypeDecl; /* Callback for document type declaration start */ 216 ClientData enddoctypedecldata; 217 218} TclXML_Info; 219 220/* 221 * These function definitions are provided by a parser 222 * implementation and registered with this module. 223 */ 224 225typedef ClientData (TclXML_CreateProc) _ANSI_ARGS_((Tcl_Interp *interp, TclXML_Info *xmlinfo)); 226typedef ClientData (TclXML_CreateEntityParserProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData)); 227typedef int (TclXML_ParseProc) _ANSI_ARGS_((ClientData clientData, char *buffer, int len, int final)); 228typedef int (TclXML_ConfigureProc) _ANSI_ARGS_((ClientData clientData, Tcl_Obj *CONST optionPtr, Tcl_Obj *CONST valuePtr)); 229typedef int (TclXML_GetProc) _ANSI_ARGS_((ClientData clientData, int objc, Tcl_Obj *CONST objv[])); 230typedef int (TclXML_ResetProc) _ANSI_ARGS_((ClientData clientData)); 231typedef int (TclXML_DeleteProc) _ANSI_ARGS_((ClientData clientData)); 232 233/* 234 * The structure below is used store function pointers 235 * for a parser implementation. 236 */ 237 238typedef struct TclXML_ParserClassInfo { 239 Tcl_Obj *name; 240 241 TclXML_CreateProc *create; /* Direct-call creation proc */ 242 Tcl_Obj *createCmd; /* Tcl command creation script */ 243 244 TclXML_CreateEntityParserProc *createEntity; 245 Tcl_Obj *createEntityCmd; 246 247 TclXML_ParseProc *parse; 248 Tcl_Obj *parseCmd; 249 250 TclXML_ConfigureProc *configure; 251 Tcl_Obj *configureCmd; 252 253 TclXML_GetProc *get; 254 Tcl_Obj *getCmd; 255 256 TclXML_ResetProc *reset; 257 Tcl_Obj *resetCmd; 258 259 TclXML_DeleteProc *destroy; 260 Tcl_Obj *destroyCmd; 261 262} TclXML_ParserClassInfo; 263 264/* 265 *---------------------------------------------------------------------------- 266 * 267 * Support for error handling 268 * 269 *---------------------------------------------------------------------------- 270 */ 271 272typedef Tcl_Obj * (TclXML_ErrorNodeHandlerProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData clientData)); 273 274typedef struct TclXML_ErrorInfo { 275 Tcl_Interp *interp; 276 Tcl_Obj *listPtr; 277 TclXML_ErrorNodeHandlerProc *nodeHandlerProc; 278} TclXML_ErrorInfo; 279 280/* 281 *---------------------------------------------------------------------------- 282 * 283 * Function prototypes for publically accessible routines 284 * 285 *---------------------------------------------------------------------------- 286 */ 287 288#include <tclxml/tclxmlDecls.h> 289 290#ifdef USE_TCLXML_STUBS 291TCL_EXTRNC CONST char * 292 TclXML_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, CONST char *version, int exact)); 293#endif 294 295#undef TCL_STORAGE_CLASS 296#define TCL_STORAGE_CLASS DLLIMPORT 297 298#endif /* RC_INVOKED */ 299#endif /* __TCLXML_H__ */ 300