blob: fd61cf41aafbd5580f302d282bf14df0989761a8 [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
42void xmlInitGlobals()
43{
44 xmlThrDefMutex = xmlNewMutex();
45}
46
47void xmlCleanupGlobals()
48{
Daniel Veillard2009c4e2003-07-15 20:04:34 +000049 if (xmlThrDefMutex != NULL) {
Daniel Veillarddf101d82003-07-08 14:03:36 +000050 xmlFreeMutex(xmlThrDefMutex);
Daniel Veillard2009c4e2003-07-15 20:04:34 +000051 xmlThrDefMutex = NULL;
52 }
Daniel Veillard781ac8b2003-05-15 22:11:36 +000053}
54
Daniel Veillardb8478642001-10-12 17:29:10 +000055/************************************************************************
56 * *
57 * All the user accessible global variables of the library *
58 * *
59 ************************************************************************/
60
Daniel Veillardb8478642001-10-12 17:29:10 +000061/*
62 * Memory allocation routines
63 */
Daniel Veillard7216cfd2002-11-08 15:10:00 +000064#if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
Daniel Veillard092643b2003-09-25 14:29:29 +000065#ifndef __DEBUG_MEMORY_ALLOC__
Daniel Veillardd0463562001-10-13 09:15:48 +000066extern void xmlMemFree(void *ptr);
67extern void * xmlMemMalloc(size_t size);
68extern void * xmlMemRealloc(void *ptr,size_t size);
69extern char * xmlMemoryStrdup(const char *str);
Daniel Veillard98485322003-08-14 15:44:40 +000070#endif
Daniel Veillardd0463562001-10-13 09:15:48 +000071
Daniel Veillardb8478642001-10-12 17:29:10 +000072xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
73xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +000074xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillardb8478642001-10-12 17:29:10 +000075xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
76xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
77#else
Daniel Veillard9d06d302002-01-22 18:15:52 +000078/**
79 * xmlFree:
80 * @mem: an already allocated block of memory
81 *
82 * The variable holding the libxml free() implementation
83 */
Daniel Veillardb8478642001-10-12 17:29:10 +000084xmlFreeFunc xmlFree = (xmlFreeFunc) free;
Daniel Veillard9d06d302002-01-22 18:15:52 +000085/**
86 * xmlMalloc:
87 * @size: the size requested in bytes
88 *
89 * The variable holding the libxml malloc() implementation
90 *
91 * Returns a pointer to the newly allocated block or NULL in case of error
92 */
Daniel Veillardb8478642001-10-12 17:29:10 +000093xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
Daniel Veillard9d06d302002-01-22 18:15:52 +000094/**
Daniel Veillard3c908dc2003-04-19 00:07:51 +000095 * xmlMallocAtomic:
96 * @size: the size requested in bytes
97 *
98 * The variable holding the libxml malloc() implementation for atomic
99 * data (i.e. blocks not containings pointers), useful when using a
100 * garbage collecting allocator.
101 *
102 * Returns a pointer to the newly allocated block or NULL in case of error
103 */
104xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc;
105/**
Daniel Veillard9d06d302002-01-22 18:15:52 +0000106 * xmlRealloc:
107 * @mem: an already allocated block of memory
108 * @size: the new size requested in bytes
109 *
110 * The variable holding the libxml realloc() implementation
111 *
112 * Returns a pointer to the newly reallocated block or NULL in case of error
113 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000114xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000115/**
116 * xmlMemStrdup:
117 * @str: a zero terminated string
118 *
119 * The variable holding the libxml strdup() implementation
120 *
121 * Returns the copy of the string or NULL in case of error
122 */
Daniel Veillardb82c1662001-12-09 14:00:54 +0000123xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000124#endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
Daniel Veillardb8478642001-10-12 17:29:10 +0000125
Daniel Veillardd0463562001-10-13 09:15:48 +0000126#include <libxml/threads.h>
127#include <libxml/globals.h>
128#include <libxml/SAX.h>
129
130#undef docbDefaultSAXHandler
131#undef htmlDefaultSAXHandler
132#undef oldXMLWDcompatibility
133#undef xmlBufferAllocScheme
134#undef xmlDefaultBufferSize
135#undef xmlDefaultSAXHandler
136#undef xmlDefaultSAXLocator
137#undef xmlDoValidityCheckingDefaultValue
138#undef xmlGenericError
139#undef xmlGenericErrorContext
140#undef xmlGetWarningsDefaultValue
141#undef xmlIndentTreeOutput
Aleksey Sanin23002562002-05-24 07:18:40 +0000142#undef xmlTreeIndentString
Daniel Veillardd0463562001-10-13 09:15:48 +0000143#undef xmlKeepBlanksDefaultValue
144#undef xmlLineNumbersDefaultValue
145#undef xmlLoadExtDtdDefaultValue
146#undef xmlParserDebugEntities
147#undef xmlParserVersion
148#undef xmlPedanticParserDefaultValue
149#undef xmlSaveNoEmptyTags
150#undef xmlSubstituteEntitiesDefaultValue
Daniel Veillard8326e732003-01-07 00:19:07 +0000151#undef xmlRegisterNodeDefaultValue
152#undef xmlDeregisterNodeDefaultValue
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000153#undef xmlLastError
Daniel Veillardd0463562001-10-13 09:15:48 +0000154
155#undef xmlFree
156#undef xmlMalloc
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000157#undef xmlMallocAtomic
Daniel Veillardd0463562001-10-13 09:15:48 +0000158#undef xmlMemStrdup
159#undef xmlRealloc
160
Daniel Veillard9d06d302002-01-22 18:15:52 +0000161/**
162 * xmlParserVersion:
163 *
164 * Constant string describing the internal version of the library
165 */
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000166const char *xmlParserVersion = LIBXML_VERSION_STRING;
167
Daniel Veillard9d06d302002-01-22 18:15:52 +0000168/**
169 * xmlBufferAllocScheme:
170 *
171 * Global setting, default allocation policy for buffers, default is
172 * XML_BUFFER_ALLOC_EXACT
Daniel Veillardb8478642001-10-12 17:29:10 +0000173 */
174xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000175static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000176/**
177 * xmlDefaultBufferSize:
178 *
179 * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
180 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000181int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000182static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
Daniel Veillardb8478642001-10-12 17:29:10 +0000183
184/*
185 * Parser defaults
186 */
Daniel Veillardd0463562001-10-13 09:15:48 +0000187
Daniel Veillard9d06d302002-01-22 18:15:52 +0000188/**
189 * oldXMLWDcompatibility:
190 *
191 * Global setting, DEPRECATED.
192 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000193int oldXMLWDcompatibility = 0; /* DEPRECATED */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000194/**
195 * xmlParserDebugEntities:
196 *
197 * Global setting, asking the parser to print out debugging informations.
198 * while handling entities.
199 * Disabled by default
200 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000201int xmlParserDebugEntities = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000202static int xmlParserDebugEntitiesThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000203/**
204 * xmlDoValidityCheckingDefaultValue:
205 *
206 * Global setting, indicate that the parser should work in validating mode.
207 * Disabled by default.
208 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000209int xmlDoValidityCheckingDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000210static int xmlDoValidityCheckingDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000211/**
212 * xmlGetWarningsDefaultValue:
213 *
214 * Global setting, indicate that the parser should provide warnings.
215 * Activated by default.
216 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000217int xmlGetWarningsDefaultValue = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000218static int xmlGetWarningsDefaultValueThrDef = 1;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000219/**
220 * xmlLoadExtDtdDefaultValue:
221 *
222 * Global setting, indicate that the parser should load DTD while not
223 * validating.
224 * Disabled by default.
225 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000226int xmlLoadExtDtdDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000227static int xmlLoadExtDtdDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000228/**
229 * xmlPedanticParserDefaultValue:
230 *
231 * Global setting, indicate that the parser be pedantic
232 * Disabled by default.
233 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000234int xmlPedanticParserDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000235static int xmlPedanticParserDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000236/**
237 * xmlLineNumbersDefaultValue:
238 *
239 * Global setting, indicate that the parser should store the line number
240 * in the content field of elements in the DOM tree.
241 * Disabled by default since this may not be safe for old classes of
242 * applicaton.
243 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000244int xmlLineNumbersDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000245static int xmlLineNumbersDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000246/**
247 * xmlKeepBlanksDefaultValue:
248 *
249 * Global setting, indicate that the parser should keep all blanks
250 * nodes found in the content
251 * Activated by default, this is actually needed to have the parser
252 * conformant to the XML Recommendation, however the option is kept
253 * for some applications since this was libxml1 default behaviour.
254 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000255int xmlKeepBlanksDefaultValue = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000256static int xmlKeepBlanksDefaultValueThrDef = 1;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000257/**
258 * xmlSubstituteEntitiesDefaultValue:
259 *
260 * Global setting, indicate that the parser should not generate entity
261 * references but replace them with the actual content of the entity
262 * Disabled by default, this should be activated when using XPath since
263 * the XPath data model requires entities replacement and the XPath
264 * engine does not handle entities references transparently.
265 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000266int xmlSubstituteEntitiesDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000267static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
Daniel Veillardb8478642001-10-12 17:29:10 +0000268
Daniel Veillard5335dc52003-01-01 20:59:38 +0000269xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000270static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000271xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000272static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000273
Daniel Veillardb8478642001-10-12 17:29:10 +0000274/*
275 * Error handling
276 */
277
278/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
279/* Must initialize xmlGenericError in xmlInitParser */
Daniel Veillard635ef722001-10-29 11:48:19 +0000280void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
281 const char *msg,
282 ...);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000283/**
284 * xmlGenericError:
285 *
286 * Global setting: function used for generic error callbacks
287 */
Daniel Veillard635ef722001-10-29 11:48:19 +0000288xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000289static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000290/**
291 * xmlGenericErrorContext:
292 *
293 * Global setting passed to generic error callbacks
294 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000295void *xmlGenericErrorContext = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000296static void *xmlGenericErrorContextThrDef = NULL;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000297xmlError xmlLastError;
Daniel Veillardb8478642001-10-12 17:29:10 +0000298
299/*
300 * output defaults
301 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000302/**
303 * xmlIndentTreeOutput:
304 *
305 * Global setting, asking the serializer to indent the output tree by default
Aleksey Sanin23002562002-05-24 07:18:40 +0000306 * Enabled by default
Daniel Veillard9d06d302002-01-22 18:15:52 +0000307 */
Aleksey Sanin23002562002-05-24 07:18:40 +0000308int xmlIndentTreeOutput = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000309static int xmlIndentTreeOutputThrDef = 1;
Aleksey Sanin23002562002-05-24 07:18:40 +0000310
311/**
312 * xmlTreeIndentString:
313 *
314 * The string used to do one-level indent. By default is equal to " " (two spaces)
315 */
316const char *xmlTreeIndentString = " ";
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000317static const char *xmlTreeIndentStringThrDef = " ";
Aleksey Sanin23002562002-05-24 07:18:40 +0000318
Daniel Veillard9d06d302002-01-22 18:15:52 +0000319/**
320 * xmlSaveNoEmptyTags:
321 *
322 * Global setting, asking the serializer to not output empty tags
323 * as <empty/> but <empty></empty>. those two forms are undistinguishable
324 * once parsed.
325 * Disabled by default
326 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000327int xmlSaveNoEmptyTags = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000328int xmlSaveNoEmptyTagsThrDef = 0;
Daniel Veillardb8478642001-10-12 17:29:10 +0000329
Daniel Veillard81273902003-09-30 00:43:48 +0000330#ifdef LIBXML_SAX1_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000331/**
332 * xmlDefaultSAXHandler:
333 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000334 * Default SAX version1 handler for XML, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000335 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000336xmlSAXHandlerV1 xmlDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000337 xmlSAX2InternalSubset,
338 xmlSAX2IsStandalone,
339 xmlSAX2HasInternalSubset,
340 xmlSAX2HasExternalSubset,
341 xmlSAX2ResolveEntity,
342 xmlSAX2GetEntity,
343 xmlSAX2EntityDecl,
344 xmlSAX2NotationDecl,
345 xmlSAX2AttributeDecl,
346 xmlSAX2ElementDecl,
347 xmlSAX2UnparsedEntityDecl,
348 xmlSAX2SetDocumentLocator,
349 xmlSAX2StartDocument,
350 xmlSAX2EndDocument,
351 xmlSAX2StartElement,
352 xmlSAX2EndElement,
353 xmlSAX2Reference,
354 xmlSAX2Characters,
355 xmlSAX2Characters,
356 xmlSAX2ProcessingInstruction,
357 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000358 xmlParserWarning,
359 xmlParserError,
360 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000361 xmlSAX2GetParameterEntity,
362 xmlSAX2CDataBlock,
363 xmlSAX2ExternalSubset,
364 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000365};
Daniel Veillard81273902003-09-30 00:43:48 +0000366#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillardb8478642001-10-12 17:29:10 +0000367
Daniel Veillard9d06d302002-01-22 18:15:52 +0000368/**
369 * xmlDefaultSAXLocator:
370 *
371 * The default SAX Locator
372 * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
Daniel Veillardb8478642001-10-12 17:29:10 +0000373 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000374xmlSAXLocator xmlDefaultSAXLocator = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000375 xmlSAX2GetPublicId,
376 xmlSAX2GetSystemId,
377 xmlSAX2GetLineNumber,
378 xmlSAX2GetColumnNumber
Daniel Veillardb8478642001-10-12 17:29:10 +0000379};
380
381#ifdef LIBXML_HTML_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000382/**
383 * htmlDefaultSAXHandler:
384 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000385 * Default old SAX v1 handler for HTML, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000386 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000387xmlSAXHandlerV1 htmlDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000388 xmlSAX2InternalSubset,
Daniel Veillardb8478642001-10-12 17:29:10 +0000389 NULL,
390 NULL,
391 NULL,
392 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000393 xmlSAX2GetEntity,
Daniel Veillardb8478642001-10-12 17:29:10 +0000394 NULL,
395 NULL,
396 NULL,
397 NULL,
398 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000399 xmlSAX2SetDocumentLocator,
400 xmlSAX2StartDocument,
401 xmlSAX2EndDocument,
402 xmlSAX2StartElement,
403 xmlSAX2EndElement,
Daniel Veillardb8478642001-10-12 17:29:10 +0000404 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000405 xmlSAX2Characters,
406 xmlSAX2IgnorableWhitespace,
Daniel Veillardb8478642001-10-12 17:29:10 +0000407 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000408 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000409 xmlParserWarning,
410 xmlParserError,
411 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000412 xmlSAX2GetParameterEntity,
413 xmlSAX2CDataBlock,
Daniel Veillardb8478642001-10-12 17:29:10 +0000414 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000415 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000416};
417#endif /* LIBXML_HTML_ENABLED */
418
419#ifdef LIBXML_DOCB_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000420/**
421 * docbDefaultSAXHandler:
422 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000423 * Default old SAX v1 handler for SGML DocBook, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000424 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000425xmlSAXHandlerV1 docbDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000426 xmlSAX2InternalSubset,
427 xmlSAX2IsStandalone,
428 xmlSAX2HasInternalSubset,
429 xmlSAX2HasExternalSubset,
430 xmlSAX2ResolveEntity,
431 xmlSAX2GetEntity,
432 xmlSAX2EntityDecl,
Daniel Veillardb8478642001-10-12 17:29:10 +0000433 NULL,
434 NULL,
435 NULL,
436 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000437 xmlSAX2SetDocumentLocator,
438 xmlSAX2StartDocument,
439 xmlSAX2EndDocument,
440 xmlSAX2StartElement,
441 xmlSAX2EndElement,
442 xmlSAX2Reference,
443 xmlSAX2Characters,
444 xmlSAX2IgnorableWhitespace,
Daniel Veillardb8478642001-10-12 17:29:10 +0000445 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000446 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000447 xmlParserWarning,
448 xmlParserError,
449 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000450 xmlSAX2GetParameterEntity,
Daniel Veillardb8478642001-10-12 17:29:10 +0000451 NULL,
452 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000453 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000454};
455#endif /* LIBXML_DOCB_ENABLED */
456
457/**
458 * xmlInitializeGlobalState:
459 * @gs: a pointer to a newly allocated global state
460 *
461 * xmlInitializeGlobalState() initialize a global state with all the
462 * default values of the library.
463 */
464void
465xmlInitializeGlobalState(xmlGlobalStatePtr gs)
466{
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000467#ifdef DEBUG_GLOBALS
468 fprintf(stderr, "Initializing globals at %lu for thread %d\n",
469 (unsigned long) gs, xmlGetThreadId());
470#endif
471
Daniel Veillardb8478642001-10-12 17:29:10 +0000472 /*
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000473 * Perform initialization as required by libxml
Daniel Veillardb8478642001-10-12 17:29:10 +0000474 */
Daniel Veillard5805be22003-08-28 08:03:23 +0000475 if (xmlThrDefMutex == NULL)
476 xmlInitGlobals();
477
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000478 xmlMutexLock(xmlThrDefMutex);
William M. Brack8b2c7f12002-11-22 05:07:29 +0000479
Daniel Veillarda4617b82001-11-04 20:19:12 +0000480#ifdef LIBXML_DOCB_ENABLED
Daniel Veillard092643b2003-09-25 14:29:29 +0000481 initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
Daniel Veillarda4617b82001-11-04 20:19:12 +0000482#endif
483#ifdef LIBXML_HTML_ENABLED
Daniel Veillard092643b2003-09-25 14:29:29 +0000484 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
Daniel Veillarda4617b82001-11-04 20:19:12 +0000485#endif
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000486
Daniel Veillardb8478642001-10-12 17:29:10 +0000487 gs->oldXMLWDcompatibility = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000488 gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
489 gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
Daniel Veillard81273902003-09-30 00:43:48 +0000490#ifdef LIBXML_SAX1_ENABLED
Daniel Veillard092643b2003-09-25 14:29:29 +0000491 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
Daniel Veillard81273902003-09-30 00:43:48 +0000492#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillard4432df22003-09-28 18:58:27 +0000493 gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
494 gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
495 gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
496 gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000497 gs->xmlDoValidityCheckingDefaultValue =
498 xmlDoValidityCheckingDefaultValueThrDef;
Daniel Veillardb8478642001-10-12 17:29:10 +0000499#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
500 gs->xmlFree = (xmlFreeFunc) xmlMemFree;
501 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000502 gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillardb8478642001-10-12 17:29:10 +0000503 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
504 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
505#else
506 gs->xmlFree = (xmlFreeFunc) free;
507 gs->xmlMalloc = (xmlMallocFunc) malloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000508 gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
Daniel Veillardb8478642001-10-12 17:29:10 +0000509 gs->xmlRealloc = (xmlReallocFunc) realloc;
Daniel Veillard572577e2002-01-18 16:23:55 +0000510 gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
Daniel Veillardb8478642001-10-12 17:29:10 +0000511#endif
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000512 gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
513 gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
514 gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
515 gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
516 gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
517 gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
518 gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
Daniel Veillardb8478642001-10-12 17:29:10 +0000519 gs->xmlParserVersion = LIBXML_VERSION_STRING;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000520 gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
521 gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
522 gs->xmlSubstituteEntitiesDefaultValue =
523 xmlSubstituteEntitiesDefaultValueThrDef;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000524
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000525 gs->xmlGenericError = xmlGenericErrorThrDef;
526 gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
527 gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
528 gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000529 memset(&gs->xmlLastError, 0, sizeof(xmlError));
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000530
531 xmlMutexUnlock(xmlThrDefMutex);
532}
533
534void
535xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
536 xmlMutexLock(xmlThrDefMutex);
537 xmlGenericErrorContextThrDef = ctx;
538 if (handler != NULL)
539 xmlGenericErrorThrDef = handler;
540 else
541 xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
542 xmlMutexUnlock(xmlThrDefMutex);
Daniel Veillardb8478642001-10-12 17:29:10 +0000543}
544
Daniel Veillard5335dc52003-01-01 20:59:38 +0000545/**
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000546 * xmlRegisterNodeDefault:
Daniel Veillard5335dc52003-01-01 20:59:38 +0000547 * @func: function pointer to the new RegisterNodeFunc
548 *
Daniel Veillard1703c5f2003-02-10 14:28:44 +0000549 * Registers a callback for node creation
550 *
551 * Returns the old value of the registration function
Daniel Veillard5335dc52003-01-01 20:59:38 +0000552 */
553xmlRegisterNodeFunc
554xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
555{
556 xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
557
Daniel Veillarda880b122003-04-21 21:36:41 +0000558 __xmlRegisterCallbacks = 1;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000559 xmlRegisterNodeDefaultValue = func;
560 return(old);
561}
562
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000563xmlRegisterNodeFunc
564xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
565{
566 xmlRegisterNodeFunc old;
567
568 xmlMutexLock(xmlThrDefMutex);
569 old = xmlRegisterNodeDefaultValueThrDef;
570
571 __xmlRegisterCallbacks = 1;
572 xmlRegisterNodeDefaultValueThrDef = func;
573 xmlMutexUnlock(xmlThrDefMutex);
574
575 return(old);
576}
577
Daniel Veillard5335dc52003-01-01 20:59:38 +0000578/**
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000579 * xmlDeregisterNodeDefault:
Daniel Veillard5335dc52003-01-01 20:59:38 +0000580 * @func: function pointer to the new DeregisterNodeFunc
581 *
Daniel Veillard1703c5f2003-02-10 14:28:44 +0000582 * Registers a callback for node destruction
583 *
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000584 * Returns the previous value of the deregistration function
Daniel Veillard5335dc52003-01-01 20:59:38 +0000585 */
586xmlDeregisterNodeFunc
587xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
588{
589 xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
590
Daniel Veillarda880b122003-04-21 21:36:41 +0000591 __xmlRegisterCallbacks = 1;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000592 xmlDeregisterNodeDefaultValue = func;
593 return(old);
594}
595
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000596xmlDeregisterNodeFunc
597xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
598{
599 xmlDeregisterNodeFunc old;
600
601 xmlMutexLock(xmlThrDefMutex);
602 old = xmlDeregisterNodeDefaultValueThrDef;
603
604 __xmlRegisterCallbacks = 1;
605 xmlDeregisterNodeDefaultValueThrDef = func;
606 xmlMutexUnlock(xmlThrDefMutex);
607
608 return(old);
609}
610
Daniel Veillard5335dc52003-01-01 20:59:38 +0000611
Daniel Veillarda4617b82001-11-04 20:19:12 +0000612#ifdef LIBXML_DOCB_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000613#undef docbDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000614xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000615__docbDefaultSAXHandler(void) {
616 if (IS_MAIN_THREAD)
617 return (&docbDefaultSAXHandler);
618 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000619 return (&xmlGetGlobalState()->docbDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000620}
Daniel Veillarda4617b82001-11-04 20:19:12 +0000621#endif
Daniel Veillardb8478642001-10-12 17:29:10 +0000622
Daniel Veillarda4617b82001-11-04 20:19:12 +0000623#ifdef LIBXML_HTML_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000624#undef htmlDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000625xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000626__htmlDefaultSAXHandler(void) {
627 if (IS_MAIN_THREAD)
628 return (&htmlDefaultSAXHandler);
629 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000630 return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000631}
Daniel Veillarda4617b82001-11-04 20:19:12 +0000632#endif
633
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000634#undef xmlLastError
635xmlError *
636__xmlLastError(void) {
637 if (IS_MAIN_THREAD)
638 return (&xmlLastError);
639 else
640 return (&xmlGetGlobalState()->xmlLastError);
641}
642
Daniel Veillarda4617b82001-11-04 20:19:12 +0000643/*
644 * Everything starting from the line below is
645 * Automatically generated by build_glob.py.
646 * Do not modify the previous line.
647 */
648
Daniel Veillardb8478642001-10-12 17:29:10 +0000649
Daniel Veillardb8478642001-10-12 17:29:10 +0000650#undef oldXMLWDcompatibility
651int *
652__oldXMLWDcompatibility(void) {
653 if (IS_MAIN_THREAD)
654 return (&oldXMLWDcompatibility);
655 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000656 return (&xmlGetGlobalState()->oldXMLWDcompatibility);
Daniel Veillardb8478642001-10-12 17:29:10 +0000657}
658
Daniel Veillardb8478642001-10-12 17:29:10 +0000659#undef xmlBufferAllocScheme
660xmlBufferAllocationScheme *
661__xmlBufferAllocScheme(void) {
662 if (IS_MAIN_THREAD)
663 return (&xmlBufferAllocScheme);
664 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000665 return (&xmlGetGlobalState()->xmlBufferAllocScheme);
Daniel Veillardb8478642001-10-12 17:29:10 +0000666}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000667xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
668 xmlBufferAllocationScheme ret;
669 xmlMutexLock(xmlThrDefMutex);
670 ret = xmlBufferAllocSchemeThrDef;
671 xmlBufferAllocSchemeThrDef = v;
672 xmlMutexUnlock(xmlThrDefMutex);
673 return ret;
674}
Daniel Veillardb8478642001-10-12 17:29:10 +0000675
Daniel Veillardb8478642001-10-12 17:29:10 +0000676#undef xmlDefaultBufferSize
677int *
678__xmlDefaultBufferSize(void) {
679 if (IS_MAIN_THREAD)
680 return (&xmlDefaultBufferSize);
681 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000682 return (&xmlGetGlobalState()->xmlDefaultBufferSize);
Daniel Veillardb8478642001-10-12 17:29:10 +0000683}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000684int xmlThrDefDefaultBufferSize(int v) {
685 int ret;
686 xmlMutexLock(xmlThrDefMutex);
687 ret = xmlDefaultBufferSizeThrDef;
688 xmlDefaultBufferSizeThrDef = v;
689 xmlMutexUnlock(xmlThrDefMutex);
690 return ret;
691}
Daniel Veillardb8478642001-10-12 17:29:10 +0000692
Daniel Veillard81273902003-09-30 00:43:48 +0000693#ifdef LIBXML_SAX1_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000694#undef xmlDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000695xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000696__xmlDefaultSAXHandler(void) {
697 if (IS_MAIN_THREAD)
698 return (&xmlDefaultSAXHandler);
699 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000700 return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000701}
Daniel Veillard81273902003-09-30 00:43:48 +0000702#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillardb8478642001-10-12 17:29:10 +0000703
Daniel Veillardb8478642001-10-12 17:29:10 +0000704#undef xmlDefaultSAXLocator
705xmlSAXLocator *
706__xmlDefaultSAXLocator(void) {
707 if (IS_MAIN_THREAD)
708 return (&xmlDefaultSAXLocator);
709 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000710 return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
Daniel Veillardb8478642001-10-12 17:29:10 +0000711}
712
Daniel Veillardb8478642001-10-12 17:29:10 +0000713#undef xmlDoValidityCheckingDefaultValue
714int *
715__xmlDoValidityCheckingDefaultValue(void) {
716 if (IS_MAIN_THREAD)
717 return (&xmlDoValidityCheckingDefaultValue);
718 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000719 return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000720}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000721int xmlThrDefDoValidityCheckingDefaultValue(int v) {
722 int ret;
723 xmlMutexLock(xmlThrDefMutex);
724 ret = xmlDoValidityCheckingDefaultValueThrDef;
725 xmlDoValidityCheckingDefaultValueThrDef = v;
726 xmlMutexUnlock(xmlThrDefMutex);
727 return ret;
728}
Daniel Veillardb8478642001-10-12 17:29:10 +0000729
Daniel Veillardb8478642001-10-12 17:29:10 +0000730#undef xmlGenericError
731xmlGenericErrorFunc *
732__xmlGenericError(void) {
733 if (IS_MAIN_THREAD)
734 return (&xmlGenericError);
735 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000736 return (&xmlGetGlobalState()->xmlGenericError);
Daniel Veillardb8478642001-10-12 17:29:10 +0000737}
738
Daniel Veillardb8478642001-10-12 17:29:10 +0000739#undef xmlGenericErrorContext
740void * *
741__xmlGenericErrorContext(void) {
742 if (IS_MAIN_THREAD)
743 return (&xmlGenericErrorContext);
744 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000745 return (&xmlGetGlobalState()->xmlGenericErrorContext);
Daniel Veillardb8478642001-10-12 17:29:10 +0000746}
747
Daniel Veillardb8478642001-10-12 17:29:10 +0000748#undef xmlGetWarningsDefaultValue
749int *
750__xmlGetWarningsDefaultValue(void) {
751 if (IS_MAIN_THREAD)
752 return (&xmlGetWarningsDefaultValue);
753 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000754 return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000755}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000756int xmlThrDefGetWarningsDefaultValue(int v) {
757 int ret;
758 xmlMutexLock(xmlThrDefMutex);
759 ret = xmlGetWarningsDefaultValueThrDef;
760 xmlGetWarningsDefaultValueThrDef = v;
761 xmlMutexUnlock(xmlThrDefMutex);
762 return ret;
763}
Daniel Veillardb8478642001-10-12 17:29:10 +0000764
Daniel Veillardb8478642001-10-12 17:29:10 +0000765#undef xmlIndentTreeOutput
766int *
767__xmlIndentTreeOutput(void) {
768 if (IS_MAIN_THREAD)
769 return (&xmlIndentTreeOutput);
770 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000771 return (&xmlGetGlobalState()->xmlIndentTreeOutput);
Daniel Veillardb8478642001-10-12 17:29:10 +0000772}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000773int xmlThrDefIndentTreeOutput(int v) {
774 int ret;
775 xmlMutexLock(xmlThrDefMutex);
776 ret = xmlIndentTreeOutputThrDef;
777 xmlIndentTreeOutputThrDef = v;
778 xmlMutexUnlock(xmlThrDefMutex);
779 return ret;
780}
Daniel Veillardb8478642001-10-12 17:29:10 +0000781
Aleksey Sanin23002562002-05-24 07:18:40 +0000782#undef xmlTreeIndentString
783const char * *
784__xmlTreeIndentString(void) {
785 if (IS_MAIN_THREAD)
786 return (&xmlTreeIndentString);
787 else
788 return (&xmlGetGlobalState()->xmlTreeIndentString);
789}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000790const char * xmlThrDefTreeIndentString(const char * v) {
791 const char * ret;
792 xmlMutexLock(xmlThrDefMutex);
793 ret = xmlTreeIndentStringThrDef;
794 xmlTreeIndentStringThrDef = v;
795 xmlMutexUnlock(xmlThrDefMutex);
796 return ret;
797}
Aleksey Sanin23002562002-05-24 07:18:40 +0000798
Daniel Veillardb8478642001-10-12 17:29:10 +0000799#undef xmlKeepBlanksDefaultValue
800int *
801__xmlKeepBlanksDefaultValue(void) {
802 if (IS_MAIN_THREAD)
803 return (&xmlKeepBlanksDefaultValue);
804 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000805 return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000806}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000807int xmlThrDefKeepBlanksDefaultValue(int v) {
808 int ret;
809 xmlMutexLock(xmlThrDefMutex);
810 ret = xmlKeepBlanksDefaultValueThrDef;
811 xmlKeepBlanksDefaultValueThrDef = v;
812 xmlMutexUnlock(xmlThrDefMutex);
813 return ret;
814}
Daniel Veillardb8478642001-10-12 17:29:10 +0000815
Daniel Veillardb8478642001-10-12 17:29:10 +0000816#undef xmlLineNumbersDefaultValue
817int *
818__xmlLineNumbersDefaultValue(void) {
819 if (IS_MAIN_THREAD)
820 return (&xmlLineNumbersDefaultValue);
821 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000822 return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000823}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000824int xmlThrDefLineNumbersDefaultValue(int v) {
825 int ret;
826 xmlMutexLock(xmlThrDefMutex);
827 ret = xmlLineNumbersDefaultValueThrDef;
828 xmlLineNumbersDefaultValueThrDef = v;
829 xmlMutexUnlock(xmlThrDefMutex);
830 return ret;
831}
Daniel Veillardb8478642001-10-12 17:29:10 +0000832
Daniel Veillardb8478642001-10-12 17:29:10 +0000833#undef xmlLoadExtDtdDefaultValue
834int *
835__xmlLoadExtDtdDefaultValue(void) {
836 if (IS_MAIN_THREAD)
837 return (&xmlLoadExtDtdDefaultValue);
838 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000839 return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000840}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000841int xmlThrDefLoadExtDtdDefaultValue(int v) {
842 int ret;
843 xmlMutexLock(xmlThrDefMutex);
844 ret = xmlLoadExtDtdDefaultValueThrDef;
845 xmlLoadExtDtdDefaultValueThrDef = v;
846 xmlMutexUnlock(xmlThrDefMutex);
847 return ret;
848}
Daniel Veillardb8478642001-10-12 17:29:10 +0000849
Daniel Veillardb8478642001-10-12 17:29:10 +0000850#undef xmlParserDebugEntities
851int *
852__xmlParserDebugEntities(void) {
853 if (IS_MAIN_THREAD)
854 return (&xmlParserDebugEntities);
855 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000856 return (&xmlGetGlobalState()->xmlParserDebugEntities);
Daniel Veillardb8478642001-10-12 17:29:10 +0000857}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000858int xmlThrDefParserDebugEntities(int v) {
859 int ret;
860 xmlMutexLock(xmlThrDefMutex);
861 ret = xmlParserDebugEntitiesThrDef;
862 xmlParserDebugEntitiesThrDef = v;
863 xmlMutexUnlock(xmlThrDefMutex);
864 return ret;
865}
Daniel Veillardb8478642001-10-12 17:29:10 +0000866
Daniel Veillardb8478642001-10-12 17:29:10 +0000867#undef xmlParserVersion
868const char * *
869__xmlParserVersion(void) {
870 if (IS_MAIN_THREAD)
871 return (&xmlParserVersion);
872 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000873 return (&xmlGetGlobalState()->xmlParserVersion);
Daniel Veillardb8478642001-10-12 17:29:10 +0000874}
875
Daniel Veillardb8478642001-10-12 17:29:10 +0000876#undef xmlPedanticParserDefaultValue
877int *
878__xmlPedanticParserDefaultValue(void) {
879 if (IS_MAIN_THREAD)
880 return (&xmlPedanticParserDefaultValue);
881 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000882 return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000883}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000884int xmlThrDefPedanticParserDefaultValue(int v) {
885 int ret;
886 xmlMutexLock(xmlThrDefMutex);
887 ret = xmlPedanticParserDefaultValueThrDef;
888 xmlPedanticParserDefaultValueThrDef = v;
889 xmlMutexUnlock(xmlThrDefMutex);
890 return ret;
891}
Daniel Veillardb8478642001-10-12 17:29:10 +0000892
Daniel Veillardb8478642001-10-12 17:29:10 +0000893#undef xmlSaveNoEmptyTags
894int *
895__xmlSaveNoEmptyTags(void) {
896 if (IS_MAIN_THREAD)
897 return (&xmlSaveNoEmptyTags);
898 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000899 return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
Daniel Veillardb8478642001-10-12 17:29:10 +0000900}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000901int xmlThrDefSaveNoEmptyTags(int v) {
902 int ret;
903 xmlMutexLock(xmlThrDefMutex);
904 ret = xmlSaveNoEmptyTagsThrDef;
905 xmlSaveNoEmptyTagsThrDef = v;
906 xmlMutexUnlock(xmlThrDefMutex);
907 return ret;
908}
Daniel Veillardb8478642001-10-12 17:29:10 +0000909
Daniel Veillardb8478642001-10-12 17:29:10 +0000910#undef xmlSubstituteEntitiesDefaultValue
911int *
912__xmlSubstituteEntitiesDefaultValue(void) {
913 if (IS_MAIN_THREAD)
914 return (&xmlSubstituteEntitiesDefaultValue);
915 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000916 return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000917}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000918int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
919 int ret;
920 xmlMutexLock(xmlThrDefMutex);
921 ret = xmlSubstituteEntitiesDefaultValueThrDef;
922 xmlSubstituteEntitiesDefaultValueThrDef = v;
923 xmlMutexUnlock(xmlThrDefMutex);
924 return ret;
925}
Daniel Veillard5335dc52003-01-01 20:59:38 +0000926
927#undef xmlRegisterNodeDefaultValue
928xmlRegisterNodeFunc *
929__xmlRegisterNodeDefaultValue(void) {
930 if (IS_MAIN_THREAD)
931 return (&xmlRegisterNodeDefaultValue);
932 else
933 return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
934}
935
936#undef xmlDeregisterNodeDefaultValue
937xmlDeregisterNodeFunc *
938__xmlDeregisterNodeDefaultValue(void) {
939 if (IS_MAIN_THREAD)
940 return (&xmlDeregisterNodeDefaultValue);
941 else
942 return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
943}