blob: 20b430880ab7270f62712bc185607f53bd23dae7 [file] [log] [blame]
Daniel Veillardb8478642001-10-12 17:29:10 +00001/*
2 * globals.c: definition and handling of the set of global variables
3 * of the library
4 *
5 * The bottom of this file is automatically generated by build_glob.py
6 * based on the description file global.data
7 *
8 * See Copyright for the status of this software.
9 *
10 * Gary Pennington <Gary.Pennington@uk.sun.com>
11 * daniel@veillard.com
12 */
13
Daniel Veillard34ce8be2002-03-18 19:37:11 +000014#define IN_LIBXML
Daniel Veillardb8478642001-10-12 17:29:10 +000015#include "libxml.h"
16
Daniel Veillarde7090612001-10-13 12:18:28 +000017#ifdef HAVE_STDLIB_H
Jaka Mocnik77d19ae2001-10-13 12:06:09 +000018#include <stdlib.h>
Daniel Veillarde7090612001-10-13 12:18:28 +000019#endif
Jaka Mocnik77d19ae2001-10-13 12:06:09 +000020#include <string.h>
21
Daniel Veillard3c01b1d2001-10-17 15:58:35 +000022#include <libxml/globals.h>
Daniel Veillarde7090612001-10-13 12:18:28 +000023#include <libxml/xmlmemory.h>
Daniel Veillard781ac8b2003-05-15 22:11:36 +000024#include <libxml/threads.h>
Daniel Veillarde7090612001-10-13 12:18:28 +000025
Daniel Veillard3c01b1d2001-10-17 15:58:35 +000026/* #define DEBUG_GLOBALS */
27
Daniel Veillardb8478642001-10-12 17:29:10 +000028/*
29 * Helpful Macro
30 */
Daniel Veillard3c01b1d2001-10-17 15:58:35 +000031#ifdef LIBXML_THREAD_ENABLED
32#define IS_MAIN_THREAD (xmlIsMainThread())
Daniel Veillardb8478642001-10-12 17:29:10 +000033#else
34#define IS_MAIN_THREAD 1
35#endif
36
Daniel Veillard781ac8b2003-05-15 22:11:36 +000037/*
38 * Mutex to protect "ForNewThreads" variables
39 */
40static xmlMutexPtr xmlThrDefMutex = NULL;
41
William M. Brack966668a2003-12-20 02:10:28 +000042/**
43 * xmlInitGlobals:
44 *
45 * Additional initialisation for multi-threading
46 */
Daniel Veillard75e389d2005-07-29 22:02:24 +000047void xmlInitGlobals(void)
Daniel Veillard781ac8b2003-05-15 22:11:36 +000048{
Kai Henning2c212832009-10-12 22:30:32 +020049 if (xmlThrDefMutex == NULL)
MOD44d1eff2009-09-09 19:03:13 +020050 xmlThrDefMutex = xmlNewMutex();
Daniel Veillard781ac8b2003-05-15 22:11:36 +000051}
52
William M. Brack966668a2003-12-20 02:10:28 +000053/**
54 * xmlCleanupGlobals:
55 *
56 * Additional cleanup for multi-threading
57 */
Daniel Veillard75e389d2005-07-29 22:02:24 +000058void xmlCleanupGlobals(void)
Daniel Veillard781ac8b2003-05-15 22:11:36 +000059{
Daniel Veillard2009c4e2003-07-15 20:04:34 +000060 if (xmlThrDefMutex != NULL) {
Daniel Veillarddf101d82003-07-08 14:03:36 +000061 xmlFreeMutex(xmlThrDefMutex);
Daniel Veillard2009c4e2003-07-15 20:04:34 +000062 xmlThrDefMutex = NULL;
63 }
Daniel Veillardccc476f2008-03-04 13:19:49 +000064 __xmlGlobalInitMutexDestroy();
Daniel Veillard781ac8b2003-05-15 22:11:36 +000065}
66
Daniel Veillardb8478642001-10-12 17:29:10 +000067/************************************************************************
Daniel Veillardf8e3db02012-09-11 13:26:36 +080068 * *
Daniel Veillardb8478642001-10-12 17:29:10 +000069 * All the user accessible global variables of the library *
Daniel Veillardf8e3db02012-09-11 13:26:36 +080070 * *
Daniel Veillardb8478642001-10-12 17:29:10 +000071 ************************************************************************/
72
Daniel Veillardb8478642001-10-12 17:29:10 +000073/*
74 * Memory allocation routines
75 */
William M. Brack5ab479b2004-06-10 13:00:15 +000076#undef xmlFree
77#undef xmlMalloc
78#undef xmlMallocAtomic
79#undef xmlMemStrdup
80#undef xmlRealloc
81
Daniel Veillard7216cfd2002-11-08 15:10:00 +000082#if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
Daniel Veillardb8478642001-10-12 17:29:10 +000083xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
84xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +000085xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillardb8478642001-10-12 17:29:10 +000086xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
87xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
88#else
Daniel Veillard9d06d302002-01-22 18:15:52 +000089/**
90 * xmlFree:
91 * @mem: an already allocated block of memory
92 *
93 * The variable holding the libxml free() implementation
94 */
Nick Wellnhofer71462a62017-11-09 13:42:33 +010095xmlFreeFunc xmlFree = free;
Daniel Veillard9d06d302002-01-22 18:15:52 +000096/**
97 * xmlMalloc:
98 * @size: the size requested in bytes
99 *
100 * The variable holding the libxml malloc() implementation
101 *
102 * Returns a pointer to the newly allocated block or NULL in case of error
103 */
Nick Wellnhofer71462a62017-11-09 13:42:33 +0100104xmlMallocFunc xmlMalloc = malloc;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000105/**
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000106 * xmlMallocAtomic:
107 * @size: the size requested in bytes
108 *
109 * The variable holding the libxml malloc() implementation for atomic
110 * data (i.e. blocks not containings pointers), useful when using a
111 * garbage collecting allocator.
112 *
113 * Returns a pointer to the newly allocated block or NULL in case of error
114 */
Nick Wellnhofer71462a62017-11-09 13:42:33 +0100115xmlMallocFunc xmlMallocAtomic = malloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000116/**
Daniel Veillard9d06d302002-01-22 18:15:52 +0000117 * xmlRealloc:
118 * @mem: an already allocated block of memory
119 * @size: the new size requested in bytes
120 *
121 * The variable holding the libxml realloc() implementation
122 *
123 * Returns a pointer to the newly reallocated block or NULL in case of error
124 */
Nick Wellnhofer71462a62017-11-09 13:42:33 +0100125xmlReallocFunc xmlRealloc = realloc;
126/**
127 * xmlPosixStrdup
128 * @cur: the input char *
129 *
130 * a strdup implementation with a type signature matching POSIX
131 *
132 * Returns a new xmlChar * or NULL
133 */
134static char *
135xmlPosixStrdup(const char *cur) {
136 return((char*) xmlCharStrdup(cur));
137}
Daniel Veillard9d06d302002-01-22 18:15:52 +0000138/**
139 * xmlMemStrdup:
140 * @str: a zero terminated string
141 *
142 * The variable holding the libxml strdup() implementation
143 *
144 * Returns the copy of the string or NULL in case of error
145 */
Nick Wellnhofer71462a62017-11-09 13:42:33 +0100146xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000147#endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
Daniel Veillardb8478642001-10-12 17:29:10 +0000148
Daniel Veillardd0463562001-10-13 09:15:48 +0000149#include <libxml/threads.h>
150#include <libxml/globals.h>
151#include <libxml/SAX.h>
152
153#undef docbDefaultSAXHandler
154#undef htmlDefaultSAXHandler
155#undef oldXMLWDcompatibility
156#undef xmlBufferAllocScheme
157#undef xmlDefaultBufferSize
158#undef xmlDefaultSAXHandler
159#undef xmlDefaultSAXLocator
160#undef xmlDoValidityCheckingDefaultValue
161#undef xmlGenericError
Daniel Veillard659e71e2003-10-10 14:10:40 +0000162#undef xmlStructuredError
Daniel Veillardd0463562001-10-13 09:15:48 +0000163#undef xmlGenericErrorContext
Wang Lam1de382e2009-08-24 17:34:25 +0200164#undef xmlStructuredErrorContext
Daniel Veillardd0463562001-10-13 09:15:48 +0000165#undef xmlGetWarningsDefaultValue
166#undef xmlIndentTreeOutput
Aleksey Sanin23002562002-05-24 07:18:40 +0000167#undef xmlTreeIndentString
Daniel Veillardd0463562001-10-13 09:15:48 +0000168#undef xmlKeepBlanksDefaultValue
169#undef xmlLineNumbersDefaultValue
170#undef xmlLoadExtDtdDefaultValue
171#undef xmlParserDebugEntities
172#undef xmlParserVersion
173#undef xmlPedanticParserDefaultValue
174#undef xmlSaveNoEmptyTags
175#undef xmlSubstituteEntitiesDefaultValue
Daniel Veillard8326e732003-01-07 00:19:07 +0000176#undef xmlRegisterNodeDefaultValue
177#undef xmlDeregisterNodeDefaultValue
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000178#undef xmlLastError
Daniel Veillardd0463562001-10-13 09:15:48 +0000179
Daniel Veillard0335a842004-06-02 16:18:40 +0000180#undef xmlParserInputBufferCreateFilenameValue
181#undef xmlOutputBufferCreateFilenameValue
Daniel Veillard9d06d302002-01-22 18:15:52 +0000182/**
183 * xmlParserVersion:
184 *
185 * Constant string describing the internal version of the library
186 */
William M. Brackf4025492004-08-18 21:08:46 +0000187const char *xmlParserVersion = LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA;
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000188
Daniel Veillard9d06d302002-01-22 18:15:52 +0000189/**
190 * xmlBufferAllocScheme:
191 *
192 * Global setting, default allocation policy for buffers, default is
193 * XML_BUFFER_ALLOC_EXACT
Daniel Veillardb8478642001-10-12 17:29:10 +0000194 */
195xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000196static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000197/**
198 * xmlDefaultBufferSize:
199 *
200 * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
201 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000202int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000203static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
Daniel Veillardb8478642001-10-12 17:29:10 +0000204
205/*
206 * Parser defaults
207 */
Daniel Veillardd0463562001-10-13 09:15:48 +0000208
Daniel Veillard9d06d302002-01-22 18:15:52 +0000209/**
210 * oldXMLWDcompatibility:
211 *
212 * Global setting, DEPRECATED.
213 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000214int oldXMLWDcompatibility = 0; /* DEPRECATED */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000215/**
216 * xmlParserDebugEntities:
217 *
218 * Global setting, asking the parser to print out debugging informations.
219 * while handling entities.
220 * Disabled by default
221 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000222int xmlParserDebugEntities = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000223static int xmlParserDebugEntitiesThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000224/**
225 * xmlDoValidityCheckingDefaultValue:
226 *
227 * Global setting, indicate that the parser should work in validating mode.
228 * Disabled by default.
229 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000230int xmlDoValidityCheckingDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000231static int xmlDoValidityCheckingDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000232/**
233 * xmlGetWarningsDefaultValue:
234 *
235 * Global setting, indicate that the parser should provide warnings.
236 * Activated by default.
237 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000238int xmlGetWarningsDefaultValue = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000239static int xmlGetWarningsDefaultValueThrDef = 1;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000240/**
241 * xmlLoadExtDtdDefaultValue:
242 *
243 * Global setting, indicate that the parser should load DTD while not
244 * validating.
245 * Disabled by default.
246 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000247int xmlLoadExtDtdDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000248static int xmlLoadExtDtdDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000249/**
250 * xmlPedanticParserDefaultValue:
251 *
252 * Global setting, indicate that the parser be pedantic
253 * Disabled by default.
254 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000255int xmlPedanticParserDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000256static int xmlPedanticParserDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000257/**
258 * xmlLineNumbersDefaultValue:
259 *
260 * Global setting, indicate that the parser should store the line number
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800261 * in the content field of elements in the DOM tree.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000262 * Disabled by default since this may not be safe for old classes of
263 * applicaton.
264 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000265int xmlLineNumbersDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000266static int xmlLineNumbersDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000267/**
268 * xmlKeepBlanksDefaultValue:
269 *
270 * Global setting, indicate that the parser should keep all blanks
271 * nodes found in the content
272 * Activated by default, this is actually needed to have the parser
273 * conformant to the XML Recommendation, however the option is kept
274 * for some applications since this was libxml1 default behaviour.
275 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000276int xmlKeepBlanksDefaultValue = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000277static int xmlKeepBlanksDefaultValueThrDef = 1;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000278/**
279 * xmlSubstituteEntitiesDefaultValue:
280 *
281 * Global setting, indicate that the parser should not generate entity
282 * references but replace them with the actual content of the entity
283 * Disabled by default, this should be activated when using XPath since
284 * the XPath data model requires entities replacement and the XPath
285 * engine does not handle entities references transparently.
286 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000287int xmlSubstituteEntitiesDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000288static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
Daniel Veillardb8478642001-10-12 17:29:10 +0000289
Daniel Veillard5335dc52003-01-01 20:59:38 +0000290xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000291static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000292xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000293static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000294
Daniel Veillard0335a842004-06-02 16:18:40 +0000295xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL;
296static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL;
297
298xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
299static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL;
300
Daniel Veillardb8478642001-10-12 17:29:10 +0000301/*
302 * Error handling
303 */
304
305/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
306/* Must initialize xmlGenericError in xmlInitParser */
Daniel Veillardffa3c742005-07-21 13:24:09 +0000307void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
Daniel Veillard635ef722001-10-29 11:48:19 +0000308 const char *msg,
309 ...);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000310/**
311 * xmlGenericError:
312 *
313 * Global setting: function used for generic error callbacks
314 */
Daniel Veillard635ef722001-10-29 11:48:19 +0000315xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000316static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000317/**
Daniel Veillard659e71e2003-10-10 14:10:40 +0000318 * xmlStructuredError:
319 *
320 * Global setting: function used for structured error callbacks
321 */
322xmlStructuredErrorFunc xmlStructuredError = NULL;
323static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
324/**
Daniel Veillard9d06d302002-01-22 18:15:52 +0000325 * xmlGenericErrorContext:
326 *
327 * Global setting passed to generic error callbacks
328 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000329void *xmlGenericErrorContext = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000330static void *xmlGenericErrorContextThrDef = NULL;
Wang Lam1de382e2009-08-24 17:34:25 +0200331/**
332 * xmlStructuredErrorContext:
333 *
334 * Global setting passed to structured error callbacks
335 */
336void *xmlStructuredErrorContext = NULL;
337static void *xmlStructuredErrorContextThrDef = NULL;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000338xmlError xmlLastError;
Daniel Veillardb8478642001-10-12 17:29:10 +0000339
340/*
341 * output defaults
342 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000343/**
344 * xmlIndentTreeOutput:
345 *
346 * Global setting, asking the serializer to indent the output tree by default
Aleksey Sanin23002562002-05-24 07:18:40 +0000347 * Enabled by default
Daniel Veillard9d06d302002-01-22 18:15:52 +0000348 */
Aleksey Sanin23002562002-05-24 07:18:40 +0000349int xmlIndentTreeOutput = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000350static int xmlIndentTreeOutputThrDef = 1;
Aleksey Sanin23002562002-05-24 07:18:40 +0000351
352/**
353 * xmlTreeIndentString:
354 *
355 * The string used to do one-level indent. By default is equal to " " (two spaces)
356 */
357const char *xmlTreeIndentString = " ";
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000358static const char *xmlTreeIndentStringThrDef = " ";
Aleksey Sanin23002562002-05-24 07:18:40 +0000359
Daniel Veillard9d06d302002-01-22 18:15:52 +0000360/**
361 * xmlSaveNoEmptyTags:
362 *
363 * Global setting, asking the serializer to not output empty tags
364 * as <empty/> but <empty></empty>. those two forms are undistinguishable
365 * once parsed.
366 * Disabled by default
367 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000368int xmlSaveNoEmptyTags = 0;
Daniel Veillard24505b02005-07-28 23:49:35 +0000369static int xmlSaveNoEmptyTagsThrDef = 0;
Daniel Veillardb8478642001-10-12 17:29:10 +0000370
Daniel Veillard81273902003-09-30 00:43:48 +0000371#ifdef LIBXML_SAX1_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000372/**
373 * xmlDefaultSAXHandler:
374 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000375 * Default SAX version1 handler for XML, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000376 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000377xmlSAXHandlerV1 xmlDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000378 xmlSAX2InternalSubset,
379 xmlSAX2IsStandalone,
380 xmlSAX2HasInternalSubset,
381 xmlSAX2HasExternalSubset,
382 xmlSAX2ResolveEntity,
383 xmlSAX2GetEntity,
384 xmlSAX2EntityDecl,
385 xmlSAX2NotationDecl,
386 xmlSAX2AttributeDecl,
387 xmlSAX2ElementDecl,
388 xmlSAX2UnparsedEntityDecl,
389 xmlSAX2SetDocumentLocator,
390 xmlSAX2StartDocument,
391 xmlSAX2EndDocument,
392 xmlSAX2StartElement,
393 xmlSAX2EndElement,
394 xmlSAX2Reference,
395 xmlSAX2Characters,
396 xmlSAX2Characters,
397 xmlSAX2ProcessingInstruction,
398 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000399 xmlParserWarning,
400 xmlParserError,
401 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000402 xmlSAX2GetParameterEntity,
403 xmlSAX2CDataBlock,
404 xmlSAX2ExternalSubset,
405 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000406};
Daniel Veillard81273902003-09-30 00:43:48 +0000407#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillardb8478642001-10-12 17:29:10 +0000408
Daniel Veillard9d06d302002-01-22 18:15:52 +0000409/**
410 * xmlDefaultSAXLocator:
411 *
412 * The default SAX Locator
413 * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
Daniel Veillardb8478642001-10-12 17:29:10 +0000414 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000415xmlSAXLocator xmlDefaultSAXLocator = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000416 xmlSAX2GetPublicId,
417 xmlSAX2GetSystemId,
418 xmlSAX2GetLineNumber,
419 xmlSAX2GetColumnNumber
Daniel Veillardb8478642001-10-12 17:29:10 +0000420};
421
422#ifdef LIBXML_HTML_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000423/**
424 * htmlDefaultSAXHandler:
425 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000426 * Default old SAX v1 handler for HTML, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000427 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000428xmlSAXHandlerV1 htmlDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000429 xmlSAX2InternalSubset,
Daniel Veillardb8478642001-10-12 17:29:10 +0000430 NULL,
431 NULL,
432 NULL,
433 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000434 xmlSAX2GetEntity,
Daniel Veillardb8478642001-10-12 17:29:10 +0000435 NULL,
436 NULL,
437 NULL,
438 NULL,
439 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000440 xmlSAX2SetDocumentLocator,
441 xmlSAX2StartDocument,
442 xmlSAX2EndDocument,
443 xmlSAX2StartElement,
444 xmlSAX2EndElement,
Daniel Veillardb8478642001-10-12 17:29:10 +0000445 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000446 xmlSAX2Characters,
447 xmlSAX2IgnorableWhitespace,
Daniel Veillardfc484dd2004-10-22 14:34:23 +0000448 xmlSAX2ProcessingInstruction,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000449 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000450 xmlParserWarning,
451 xmlParserError,
452 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000453 xmlSAX2GetParameterEntity,
454 xmlSAX2CDataBlock,
Daniel Veillardb8478642001-10-12 17:29:10 +0000455 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000456 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000457};
458#endif /* LIBXML_HTML_ENABLED */
459
460#ifdef LIBXML_DOCB_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000461/**
462 * docbDefaultSAXHandler:
463 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000464 * Default old SAX v1 handler for SGML DocBook, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000465 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000466xmlSAXHandlerV1 docbDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000467 xmlSAX2InternalSubset,
468 xmlSAX2IsStandalone,
469 xmlSAX2HasInternalSubset,
470 xmlSAX2HasExternalSubset,
471 xmlSAX2ResolveEntity,
472 xmlSAX2GetEntity,
473 xmlSAX2EntityDecl,
Daniel Veillardb8478642001-10-12 17:29:10 +0000474 NULL,
475 NULL,
476 NULL,
477 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000478 xmlSAX2SetDocumentLocator,
479 xmlSAX2StartDocument,
480 xmlSAX2EndDocument,
481 xmlSAX2StartElement,
482 xmlSAX2EndElement,
483 xmlSAX2Reference,
484 xmlSAX2Characters,
485 xmlSAX2IgnorableWhitespace,
Daniel Veillardb8478642001-10-12 17:29:10 +0000486 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000487 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000488 xmlParserWarning,
489 xmlParserError,
490 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000491 xmlSAX2GetParameterEntity,
Daniel Veillardb8478642001-10-12 17:29:10 +0000492 NULL,
493 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000494 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000495};
496#endif /* LIBXML_DOCB_ENABLED */
497
498/**
499 * xmlInitializeGlobalState:
500 * @gs: a pointer to a newly allocated global state
501 *
502 * xmlInitializeGlobalState() initialize a global state with all the
503 * default values of the library.
504 */
505void
506xmlInitializeGlobalState(xmlGlobalStatePtr gs)
507{
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000508#ifdef DEBUG_GLOBALS
509 fprintf(stderr, "Initializing globals at %lu for thread %d\n",
510 (unsigned long) gs, xmlGetThreadId());
511#endif
512
Daniel Veillardb8478642001-10-12 17:29:10 +0000513 /*
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000514 * Perform initialization as required by libxml
Daniel Veillardb8478642001-10-12 17:29:10 +0000515 */
Daniel Veillard5805be22003-08-28 08:03:23 +0000516 if (xmlThrDefMutex == NULL)
517 xmlInitGlobals();
518
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000519 xmlMutexLock(xmlThrDefMutex);
William M. Brack8b2c7f12002-11-22 05:07:29 +0000520
Daniel Veillardbca3ad22005-08-23 22:14:02 +0000521#if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
Daniel Veillard092643b2003-09-25 14:29:29 +0000522 initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
Daniel Veillarda4617b82001-11-04 20:19:12 +0000523#endif
Akira TAGOH961b5352012-07-03 14:13:59 +0900524#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
Daniel Veillard092643b2003-09-25 14:29:29 +0000525 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
Daniel Veillarda4617b82001-11-04 20:19:12 +0000526#endif
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000527
Daniel Veillardb8478642001-10-12 17:29:10 +0000528 gs->oldXMLWDcompatibility = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000529 gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
530 gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
William M. Brack21e4ef22005-01-02 09:53:13 +0000531#if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
Daniel Veillard092643b2003-09-25 14:29:29 +0000532 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
Daniel Veillard81273902003-09-30 00:43:48 +0000533#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillard4432df22003-09-28 18:58:27 +0000534 gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
535 gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
536 gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
537 gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800538 gs->xmlDoValidityCheckingDefaultValue =
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000539 xmlDoValidityCheckingDefaultValueThrDef;
Daniel Veillardb8478642001-10-12 17:29:10 +0000540#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
541 gs->xmlFree = (xmlFreeFunc) xmlMemFree;
542 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000543 gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillardb8478642001-10-12 17:29:10 +0000544 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
545 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
546#else
547 gs->xmlFree = (xmlFreeFunc) free;
548 gs->xmlMalloc = (xmlMallocFunc) malloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000549 gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
Daniel Veillardb8478642001-10-12 17:29:10 +0000550 gs->xmlRealloc = (xmlReallocFunc) realloc;
Daniel Veillard572577e2002-01-18 16:23:55 +0000551 gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
Daniel Veillardb8478642001-10-12 17:29:10 +0000552#endif
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000553 gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
554 gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
555 gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
556 gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
557 gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
558 gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
559 gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
Daniel Veillardb8478642001-10-12 17:29:10 +0000560 gs->xmlParserVersion = LIBXML_VERSION_STRING;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000561 gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
562 gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800563 gs->xmlSubstituteEntitiesDefaultValue =
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000564 xmlSubstituteEntitiesDefaultValueThrDef;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000565
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000566 gs->xmlGenericError = xmlGenericErrorThrDef;
Daniel Veillard659e71e2003-10-10 14:10:40 +0000567 gs->xmlStructuredError = xmlStructuredErrorThrDef;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000568 gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
Wang Lam1de382e2009-08-24 17:34:25 +0200569 gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000570 gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
571 gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
Daniel Veillard0335a842004-06-02 16:18:40 +0000572
573 gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
574 gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000575 memset(&gs->xmlLastError, 0, sizeof(xmlError));
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000576
577 xmlMutexUnlock(xmlThrDefMutex);
578}
579
Daniel Veillard1e906612003-12-05 14:57:46 +0000580/**
581 * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions,
582 * those are really internal work
583 */
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000584void
585xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
586 xmlMutexLock(xmlThrDefMutex);
587 xmlGenericErrorContextThrDef = ctx;
588 if (handler != NULL)
589 xmlGenericErrorThrDef = handler;
590 else
591 xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
592 xmlMutexUnlock(xmlThrDefMutex);
Daniel Veillardb8478642001-10-12 17:29:10 +0000593}
594
Daniel Veillard659e71e2003-10-10 14:10:40 +0000595void
596xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
597 xmlMutexLock(xmlThrDefMutex);
Wang Lam1de382e2009-08-24 17:34:25 +0200598 xmlStructuredErrorContextThrDef = ctx;
Daniel Veillard659e71e2003-10-10 14:10:40 +0000599 xmlStructuredErrorThrDef = handler;
600 xmlMutexUnlock(xmlThrDefMutex);
601}
602
Daniel Veillard5335dc52003-01-01 20:59:38 +0000603/**
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000604 * xmlRegisterNodeDefault:
Daniel Veillard5335dc52003-01-01 20:59:38 +0000605 * @func: function pointer to the new RegisterNodeFunc
606 *
Daniel Veillard1703c5f2003-02-10 14:28:44 +0000607 * Registers a callback for node creation
608 *
609 * Returns the old value of the registration function
Daniel Veillard5335dc52003-01-01 20:59:38 +0000610 */
611xmlRegisterNodeFunc
612xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
613{
614 xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800615
Daniel Veillarda880b122003-04-21 21:36:41 +0000616 __xmlRegisterCallbacks = 1;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000617 xmlRegisterNodeDefaultValue = func;
618 return(old);
619}
620
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000621xmlRegisterNodeFunc
622xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
623{
624 xmlRegisterNodeFunc old;
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800625
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000626 xmlMutexLock(xmlThrDefMutex);
627 old = xmlRegisterNodeDefaultValueThrDef;
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800628
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000629 __xmlRegisterCallbacks = 1;
630 xmlRegisterNodeDefaultValueThrDef = func;
631 xmlMutexUnlock(xmlThrDefMutex);
632
633 return(old);
634}
635
Daniel Veillard5335dc52003-01-01 20:59:38 +0000636/**
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000637 * xmlDeregisterNodeDefault:
Daniel Veillard5335dc52003-01-01 20:59:38 +0000638 * @func: function pointer to the new DeregisterNodeFunc
639 *
Daniel Veillard1703c5f2003-02-10 14:28:44 +0000640 * Registers a callback for node destruction
641 *
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000642 * Returns the previous value of the deregistration function
Daniel Veillard5335dc52003-01-01 20:59:38 +0000643 */
644xmlDeregisterNodeFunc
645xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
646{
647 xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800648
Daniel Veillarda880b122003-04-21 21:36:41 +0000649 __xmlRegisterCallbacks = 1;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000650 xmlDeregisterNodeDefaultValue = func;
651 return(old);
652}
653
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000654xmlDeregisterNodeFunc
655xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
656{
657 xmlDeregisterNodeFunc old;
658
659 xmlMutexLock(xmlThrDefMutex);
660 old = xmlDeregisterNodeDefaultValueThrDef;
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800661
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000662 __xmlRegisterCallbacks = 1;
663 xmlDeregisterNodeDefaultValueThrDef = func;
664 xmlMutexUnlock(xmlThrDefMutex);
665
666 return(old);
667}
668
Daniel Veillard0335a842004-06-02 16:18:40 +0000669xmlParserInputBufferCreateFilenameFunc
670xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
671{
672 xmlParserInputBufferCreateFilenameFunc old;
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800673
Daniel Veillard0335a842004-06-02 16:18:40 +0000674 xmlMutexLock(xmlThrDefMutex);
675 old = xmlParserInputBufferCreateFilenameValueThrDef;
Daniel Veillard1b243b42004-06-08 10:16:42 +0000676 if (old == NULL) {
677 old = __xmlParserInputBufferCreateFilename;
678 }
679
Daniel Veillard0335a842004-06-02 16:18:40 +0000680 xmlParserInputBufferCreateFilenameValueThrDef = func;
681 xmlMutexUnlock(xmlThrDefMutex);
682
683 return(old);
684}
685
Daniel Veillard0335a842004-06-02 16:18:40 +0000686xmlOutputBufferCreateFilenameFunc
687xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
688{
689 xmlOutputBufferCreateFilenameFunc old;
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800690
Daniel Veillard0335a842004-06-02 16:18:40 +0000691 xmlMutexLock(xmlThrDefMutex);
692 old = xmlOutputBufferCreateFilenameValueThrDef;
Daniel Veillard1b243b42004-06-08 10:16:42 +0000693#ifdef LIBXML_OUTPUT_ENABLED
694 if (old == NULL) {
695 old = __xmlOutputBufferCreateFilename;
696 }
697#endif
Daniel Veillard0335a842004-06-02 16:18:40 +0000698 xmlOutputBufferCreateFilenameValueThrDef = func;
699 xmlMutexUnlock(xmlThrDefMutex);
700
701 return(old);
702}
Daniel Veillard5335dc52003-01-01 20:59:38 +0000703
Daniel Veillarda4617b82001-11-04 20:19:12 +0000704#ifdef LIBXML_DOCB_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000705#undef docbDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000706xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000707__docbDefaultSAXHandler(void) {
708 if (IS_MAIN_THREAD)
709 return (&docbDefaultSAXHandler);
710 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000711 return (&xmlGetGlobalState()->docbDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000712}
Daniel Veillarda4617b82001-11-04 20:19:12 +0000713#endif
Daniel Veillardb8478642001-10-12 17:29:10 +0000714
Daniel Veillarda4617b82001-11-04 20:19:12 +0000715#ifdef LIBXML_HTML_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000716#undef htmlDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000717xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000718__htmlDefaultSAXHandler(void) {
719 if (IS_MAIN_THREAD)
720 return (&htmlDefaultSAXHandler);
721 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000722 return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000723}
Daniel Veillarda4617b82001-11-04 20:19:12 +0000724#endif
725
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000726#undef xmlLastError
727xmlError *
728__xmlLastError(void) {
729 if (IS_MAIN_THREAD)
730 return (&xmlLastError);
731 else
732 return (&xmlGetGlobalState()->xmlLastError);
733}
734
Daniel Veillarda4617b82001-11-04 20:19:12 +0000735/*
William M. Brack5ab479b2004-06-10 13:00:15 +0000736 * The following memory routines were apparently lost at some point,
737 * and were re-inserted at this point on June 10, 2004. Hope it's
738 * the right place for them :-)
739 */
740#if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED)
741#undef xmlMalloc
742xmlMallocFunc *
743__xmlMalloc(void){
744 if (IS_MAIN_THREAD)
745 return (&xmlMalloc);
746 else
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800747 return (&xmlGetGlobalState()->xmlMalloc);
William M. Brack5ab479b2004-06-10 13:00:15 +0000748}
749
750#undef xmlMallocAtomic
751xmlMallocFunc *
752__xmlMallocAtomic(void){
753 if (IS_MAIN_THREAD)
754 return (&xmlMallocAtomic);
755 else
756 return (&xmlGetGlobalState()->xmlMallocAtomic);
757}
758
759#undef xmlRealloc
760xmlReallocFunc *
761__xmlRealloc(void){
762 if (IS_MAIN_THREAD)
763 return (&xmlRealloc);
764 else
765 return (&xmlGetGlobalState()->xmlRealloc);
766}
767
768#undef xmlFree
769xmlFreeFunc *
770__xmlFree(void){
771 if (IS_MAIN_THREAD)
772 return (&xmlFree);
773 else
774 return (&xmlGetGlobalState()->xmlFree);
775}
776
777xmlStrdupFunc *
778__xmlMemStrdup(void){
779 if (IS_MAIN_THREAD)
780 return (&xmlMemStrdup);
781 else
782 return (&xmlGetGlobalState()->xmlMemStrdup);
783}
784
785#endif
786
787/*
Daniel Veillarda4617b82001-11-04 20:19:12 +0000788 * Everything starting from the line below is
789 * Automatically generated by build_glob.py.
790 * Do not modify the previous line.
791 */
792
Daniel Veillardb8478642001-10-12 17:29:10 +0000793
Daniel Veillardb8478642001-10-12 17:29:10 +0000794#undef oldXMLWDcompatibility
795int *
796__oldXMLWDcompatibility(void) {
797 if (IS_MAIN_THREAD)
798 return (&oldXMLWDcompatibility);
799 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000800 return (&xmlGetGlobalState()->oldXMLWDcompatibility);
Daniel Veillardb8478642001-10-12 17:29:10 +0000801}
802
Daniel Veillardb8478642001-10-12 17:29:10 +0000803#undef xmlBufferAllocScheme
804xmlBufferAllocationScheme *
805__xmlBufferAllocScheme(void) {
806 if (IS_MAIN_THREAD)
807 return (&xmlBufferAllocScheme);
808 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000809 return (&xmlGetGlobalState()->xmlBufferAllocScheme);
Daniel Veillardb8478642001-10-12 17:29:10 +0000810}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000811xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
812 xmlBufferAllocationScheme ret;
813 xmlMutexLock(xmlThrDefMutex);
814 ret = xmlBufferAllocSchemeThrDef;
815 xmlBufferAllocSchemeThrDef = v;
816 xmlMutexUnlock(xmlThrDefMutex);
817 return ret;
818}
Daniel Veillardb8478642001-10-12 17:29:10 +0000819
Daniel Veillardb8478642001-10-12 17:29:10 +0000820#undef xmlDefaultBufferSize
821int *
822__xmlDefaultBufferSize(void) {
823 if (IS_MAIN_THREAD)
824 return (&xmlDefaultBufferSize);
825 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000826 return (&xmlGetGlobalState()->xmlDefaultBufferSize);
Daniel Veillardb8478642001-10-12 17:29:10 +0000827}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000828int xmlThrDefDefaultBufferSize(int v) {
829 int ret;
830 xmlMutexLock(xmlThrDefMutex);
831 ret = xmlDefaultBufferSizeThrDef;
832 xmlDefaultBufferSizeThrDef = v;
833 xmlMutexUnlock(xmlThrDefMutex);
834 return ret;
835}
Daniel Veillardb8478642001-10-12 17:29:10 +0000836
Daniel Veillard81273902003-09-30 00:43:48 +0000837#ifdef LIBXML_SAX1_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000838#undef xmlDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000839xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000840__xmlDefaultSAXHandler(void) {
841 if (IS_MAIN_THREAD)
842 return (&xmlDefaultSAXHandler);
843 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000844 return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000845}
Daniel Veillard81273902003-09-30 00:43:48 +0000846#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillardb8478642001-10-12 17:29:10 +0000847
Daniel Veillardb8478642001-10-12 17:29:10 +0000848#undef xmlDefaultSAXLocator
849xmlSAXLocator *
850__xmlDefaultSAXLocator(void) {
851 if (IS_MAIN_THREAD)
852 return (&xmlDefaultSAXLocator);
853 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000854 return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
Daniel Veillardb8478642001-10-12 17:29:10 +0000855}
856
Daniel Veillardb8478642001-10-12 17:29:10 +0000857#undef xmlDoValidityCheckingDefaultValue
858int *
859__xmlDoValidityCheckingDefaultValue(void) {
860 if (IS_MAIN_THREAD)
861 return (&xmlDoValidityCheckingDefaultValue);
862 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000863 return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000864}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000865int xmlThrDefDoValidityCheckingDefaultValue(int v) {
866 int ret;
867 xmlMutexLock(xmlThrDefMutex);
868 ret = xmlDoValidityCheckingDefaultValueThrDef;
869 xmlDoValidityCheckingDefaultValueThrDef = v;
870 xmlMutexUnlock(xmlThrDefMutex);
871 return ret;
872}
Daniel Veillardb8478642001-10-12 17:29:10 +0000873
Daniel Veillardb8478642001-10-12 17:29:10 +0000874#undef xmlGenericError
875xmlGenericErrorFunc *
876__xmlGenericError(void) {
877 if (IS_MAIN_THREAD)
878 return (&xmlGenericError);
879 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000880 return (&xmlGetGlobalState()->xmlGenericError);
Daniel Veillardb8478642001-10-12 17:29:10 +0000881}
882
Daniel Veillard659e71e2003-10-10 14:10:40 +0000883#undef xmlStructuredError
884xmlStructuredErrorFunc *
885__xmlStructuredError(void) {
886 if (IS_MAIN_THREAD)
887 return (&xmlStructuredError);
888 else
889 return (&xmlGetGlobalState()->xmlStructuredError);
890}
891
Daniel Veillardb8478642001-10-12 17:29:10 +0000892#undef xmlGenericErrorContext
893void * *
894__xmlGenericErrorContext(void) {
895 if (IS_MAIN_THREAD)
896 return (&xmlGenericErrorContext);
897 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000898 return (&xmlGetGlobalState()->xmlGenericErrorContext);
Daniel Veillardb8478642001-10-12 17:29:10 +0000899}
900
Wang Lam1de382e2009-08-24 17:34:25 +0200901#undef xmlStructuredErrorContext
902void * *
903__xmlStructuredErrorContext(void) {
904 if (IS_MAIN_THREAD)
905 return (&xmlStructuredErrorContext);
906 else
907 return (&xmlGetGlobalState()->xmlStructuredErrorContext);
908}
909
Daniel Veillardb8478642001-10-12 17:29:10 +0000910#undef xmlGetWarningsDefaultValue
911int *
912__xmlGetWarningsDefaultValue(void) {
913 if (IS_MAIN_THREAD)
914 return (&xmlGetWarningsDefaultValue);
915 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000916 return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000917}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000918int xmlThrDefGetWarningsDefaultValue(int v) {
919 int ret;
920 xmlMutexLock(xmlThrDefMutex);
921 ret = xmlGetWarningsDefaultValueThrDef;
922 xmlGetWarningsDefaultValueThrDef = v;
923 xmlMutexUnlock(xmlThrDefMutex);
924 return ret;
925}
Daniel Veillardb8478642001-10-12 17:29:10 +0000926
Daniel Veillardb8478642001-10-12 17:29:10 +0000927#undef xmlIndentTreeOutput
928int *
929__xmlIndentTreeOutput(void) {
930 if (IS_MAIN_THREAD)
931 return (&xmlIndentTreeOutput);
932 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000933 return (&xmlGetGlobalState()->xmlIndentTreeOutput);
Daniel Veillardb8478642001-10-12 17:29:10 +0000934}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000935int xmlThrDefIndentTreeOutput(int v) {
936 int ret;
937 xmlMutexLock(xmlThrDefMutex);
938 ret = xmlIndentTreeOutputThrDef;
939 xmlIndentTreeOutputThrDef = v;
940 xmlMutexUnlock(xmlThrDefMutex);
941 return ret;
942}
Daniel Veillardb8478642001-10-12 17:29:10 +0000943
Wang Lam1de382e2009-08-24 17:34:25 +0200944#undef xmlTreeIndentString
Aleksey Sanin23002562002-05-24 07:18:40 +0000945const char * *
946__xmlTreeIndentString(void) {
947 if (IS_MAIN_THREAD)
948 return (&xmlTreeIndentString);
949 else
950 return (&xmlGetGlobalState()->xmlTreeIndentString);
951}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000952const char * xmlThrDefTreeIndentString(const char * v) {
953 const char * ret;
954 xmlMutexLock(xmlThrDefMutex);
955 ret = xmlTreeIndentStringThrDef;
956 xmlTreeIndentStringThrDef = v;
957 xmlMutexUnlock(xmlThrDefMutex);
958 return ret;
959}
Aleksey Sanin23002562002-05-24 07:18:40 +0000960
Daniel Veillardb8478642001-10-12 17:29:10 +0000961#undef xmlKeepBlanksDefaultValue
962int *
963__xmlKeepBlanksDefaultValue(void) {
964 if (IS_MAIN_THREAD)
965 return (&xmlKeepBlanksDefaultValue);
966 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000967 return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000968}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000969int xmlThrDefKeepBlanksDefaultValue(int v) {
970 int ret;
971 xmlMutexLock(xmlThrDefMutex);
972 ret = xmlKeepBlanksDefaultValueThrDef;
973 xmlKeepBlanksDefaultValueThrDef = v;
974 xmlMutexUnlock(xmlThrDefMutex);
975 return ret;
976}
Daniel Veillardb8478642001-10-12 17:29:10 +0000977
Daniel Veillardb8478642001-10-12 17:29:10 +0000978#undef xmlLineNumbersDefaultValue
979int *
980__xmlLineNumbersDefaultValue(void) {
981 if (IS_MAIN_THREAD)
982 return (&xmlLineNumbersDefaultValue);
983 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000984 return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000985}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000986int xmlThrDefLineNumbersDefaultValue(int v) {
987 int ret;
988 xmlMutexLock(xmlThrDefMutex);
989 ret = xmlLineNumbersDefaultValueThrDef;
990 xmlLineNumbersDefaultValueThrDef = v;
991 xmlMutexUnlock(xmlThrDefMutex);
992 return ret;
993}
Daniel Veillardb8478642001-10-12 17:29:10 +0000994
Daniel Veillardb8478642001-10-12 17:29:10 +0000995#undef xmlLoadExtDtdDefaultValue
996int *
997__xmlLoadExtDtdDefaultValue(void) {
998 if (IS_MAIN_THREAD)
999 return (&xmlLoadExtDtdDefaultValue);
1000 else
Daniel Veillardd0463562001-10-13 09:15:48 +00001001 return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +00001002}
Daniel Veillard781ac8b2003-05-15 22:11:36 +00001003int xmlThrDefLoadExtDtdDefaultValue(int v) {
1004 int ret;
1005 xmlMutexLock(xmlThrDefMutex);
1006 ret = xmlLoadExtDtdDefaultValueThrDef;
1007 xmlLoadExtDtdDefaultValueThrDef = v;
1008 xmlMutexUnlock(xmlThrDefMutex);
1009 return ret;
1010}
Daniel Veillardb8478642001-10-12 17:29:10 +00001011
Daniel Veillardb8478642001-10-12 17:29:10 +00001012#undef xmlParserDebugEntities
1013int *
1014__xmlParserDebugEntities(void) {
1015 if (IS_MAIN_THREAD)
1016 return (&xmlParserDebugEntities);
1017 else
Daniel Veillardd0463562001-10-13 09:15:48 +00001018 return (&xmlGetGlobalState()->xmlParserDebugEntities);
Daniel Veillardb8478642001-10-12 17:29:10 +00001019}
Daniel Veillard781ac8b2003-05-15 22:11:36 +00001020int xmlThrDefParserDebugEntities(int v) {
1021 int ret;
1022 xmlMutexLock(xmlThrDefMutex);
1023 ret = xmlParserDebugEntitiesThrDef;
1024 xmlParserDebugEntitiesThrDef = v;
1025 xmlMutexUnlock(xmlThrDefMutex);
1026 return ret;
1027}
Daniel Veillardb8478642001-10-12 17:29:10 +00001028
Daniel Veillardb8478642001-10-12 17:29:10 +00001029#undef xmlParserVersion
1030const char * *
1031__xmlParserVersion(void) {
1032 if (IS_MAIN_THREAD)
1033 return (&xmlParserVersion);
1034 else
Daniel Veillardd0463562001-10-13 09:15:48 +00001035 return (&xmlGetGlobalState()->xmlParserVersion);
Daniel Veillardb8478642001-10-12 17:29:10 +00001036}
1037
Daniel Veillardb8478642001-10-12 17:29:10 +00001038#undef xmlPedanticParserDefaultValue
1039int *
1040__xmlPedanticParserDefaultValue(void) {
1041 if (IS_MAIN_THREAD)
1042 return (&xmlPedanticParserDefaultValue);
1043 else
Daniel Veillardd0463562001-10-13 09:15:48 +00001044 return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +00001045}
Daniel Veillard781ac8b2003-05-15 22:11:36 +00001046int xmlThrDefPedanticParserDefaultValue(int v) {
1047 int ret;
1048 xmlMutexLock(xmlThrDefMutex);
1049 ret = xmlPedanticParserDefaultValueThrDef;
1050 xmlPedanticParserDefaultValueThrDef = v;
1051 xmlMutexUnlock(xmlThrDefMutex);
1052 return ret;
1053}
Daniel Veillardb8478642001-10-12 17:29:10 +00001054
Daniel Veillardb8478642001-10-12 17:29:10 +00001055#undef xmlSaveNoEmptyTags
1056int *
1057__xmlSaveNoEmptyTags(void) {
1058 if (IS_MAIN_THREAD)
1059 return (&xmlSaveNoEmptyTags);
1060 else
Daniel Veillardd0463562001-10-13 09:15:48 +00001061 return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
Daniel Veillardb8478642001-10-12 17:29:10 +00001062}
Daniel Veillard781ac8b2003-05-15 22:11:36 +00001063int xmlThrDefSaveNoEmptyTags(int v) {
1064 int ret;
1065 xmlMutexLock(xmlThrDefMutex);
1066 ret = xmlSaveNoEmptyTagsThrDef;
1067 xmlSaveNoEmptyTagsThrDef = v;
1068 xmlMutexUnlock(xmlThrDefMutex);
1069 return ret;
1070}
Daniel Veillardb8478642001-10-12 17:29:10 +00001071
Daniel Veillardb8478642001-10-12 17:29:10 +00001072#undef xmlSubstituteEntitiesDefaultValue
1073int *
1074__xmlSubstituteEntitiesDefaultValue(void) {
1075 if (IS_MAIN_THREAD)
1076 return (&xmlSubstituteEntitiesDefaultValue);
1077 else
Daniel Veillardd0463562001-10-13 09:15:48 +00001078 return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +00001079}
Daniel Veillard781ac8b2003-05-15 22:11:36 +00001080int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
1081 int ret;
1082 xmlMutexLock(xmlThrDefMutex);
1083 ret = xmlSubstituteEntitiesDefaultValueThrDef;
1084 xmlSubstituteEntitiesDefaultValueThrDef = v;
1085 xmlMutexUnlock(xmlThrDefMutex);
1086 return ret;
1087}
Daniel Veillard5335dc52003-01-01 20:59:38 +00001088
1089#undef xmlRegisterNodeDefaultValue
1090xmlRegisterNodeFunc *
1091__xmlRegisterNodeDefaultValue(void) {
1092 if (IS_MAIN_THREAD)
1093 return (&xmlRegisterNodeDefaultValue);
1094 else
1095 return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
1096}
1097
1098#undef xmlDeregisterNodeDefaultValue
1099xmlDeregisterNodeFunc *
1100__xmlDeregisterNodeDefaultValue(void) {
1101 if (IS_MAIN_THREAD)
1102 return (&xmlDeregisterNodeDefaultValue);
1103 else
1104 return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
1105}
Daniel Veillard0335a842004-06-02 16:18:40 +00001106
1107#undef xmlParserInputBufferCreateFilenameValue
1108xmlParserInputBufferCreateFilenameFunc *
1109__xmlParserInputBufferCreateFilenameValue(void) {
1110 if (IS_MAIN_THREAD)
1111 return (&xmlParserInputBufferCreateFilenameValue);
1112 else
1113 return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
1114}
1115
1116#undef xmlOutputBufferCreateFilenameValue
1117xmlOutputBufferCreateFilenameFunc *
1118__xmlOutputBufferCreateFilenameValue(void) {
1119 if (IS_MAIN_THREAD)
1120 return (&xmlOutputBufferCreateFilenameValue);
1121 else
1122 return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
William M. Brack803812b2004-06-03 02:11:24 +00001123}
Daniel Veillard5d4644e2005-04-01 13:11:58 +00001124
1125#define bottom_globals
1126#include "elfgcchack.h"