blob: 8de87e4b4724da75884c91558ffb5aea840e92f6 [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
Daniel Veillard659e71e2003-10-10 14:10:40 +0000139#undef xmlStructuredError
Daniel Veillardd0463562001-10-13 09:15:48 +0000140#undef xmlGenericErrorContext
141#undef xmlGetWarningsDefaultValue
142#undef xmlIndentTreeOutput
Aleksey Sanin23002562002-05-24 07:18:40 +0000143#undef xmlTreeIndentString
Daniel Veillardd0463562001-10-13 09:15:48 +0000144#undef xmlKeepBlanksDefaultValue
145#undef xmlLineNumbersDefaultValue
146#undef xmlLoadExtDtdDefaultValue
147#undef xmlParserDebugEntities
148#undef xmlParserVersion
149#undef xmlPedanticParserDefaultValue
150#undef xmlSaveNoEmptyTags
151#undef xmlSubstituteEntitiesDefaultValue
Daniel Veillard8326e732003-01-07 00:19:07 +0000152#undef xmlRegisterNodeDefaultValue
153#undef xmlDeregisterNodeDefaultValue
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000154#undef xmlLastError
Daniel Veillardd0463562001-10-13 09:15:48 +0000155
156#undef xmlFree
157#undef xmlMalloc
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000158#undef xmlMallocAtomic
Daniel Veillardd0463562001-10-13 09:15:48 +0000159#undef xmlMemStrdup
160#undef xmlRealloc
161
Daniel Veillard9d06d302002-01-22 18:15:52 +0000162/**
163 * xmlParserVersion:
164 *
165 * Constant string describing the internal version of the library
166 */
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000167const char *xmlParserVersion = LIBXML_VERSION_STRING;
168
Daniel Veillard9d06d302002-01-22 18:15:52 +0000169/**
170 * xmlBufferAllocScheme:
171 *
172 * Global setting, default allocation policy for buffers, default is
173 * XML_BUFFER_ALLOC_EXACT
Daniel Veillardb8478642001-10-12 17:29:10 +0000174 */
175xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000176static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000177/**
178 * xmlDefaultBufferSize:
179 *
180 * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
181 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000182int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000183static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
Daniel Veillardb8478642001-10-12 17:29:10 +0000184
185/*
186 * Parser defaults
187 */
Daniel Veillardd0463562001-10-13 09:15:48 +0000188
Daniel Veillard9d06d302002-01-22 18:15:52 +0000189/**
190 * oldXMLWDcompatibility:
191 *
192 * Global setting, DEPRECATED.
193 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000194int oldXMLWDcompatibility = 0; /* DEPRECATED */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000195/**
196 * xmlParserDebugEntities:
197 *
198 * Global setting, asking the parser to print out debugging informations.
199 * while handling entities.
200 * Disabled by default
201 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000202int xmlParserDebugEntities = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000203static int xmlParserDebugEntitiesThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000204/**
205 * xmlDoValidityCheckingDefaultValue:
206 *
207 * Global setting, indicate that the parser should work in validating mode.
208 * Disabled by default.
209 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000210int xmlDoValidityCheckingDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000211static int xmlDoValidityCheckingDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000212/**
213 * xmlGetWarningsDefaultValue:
214 *
215 * Global setting, indicate that the parser should provide warnings.
216 * Activated by default.
217 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000218int xmlGetWarningsDefaultValue = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000219static int xmlGetWarningsDefaultValueThrDef = 1;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000220/**
221 * xmlLoadExtDtdDefaultValue:
222 *
223 * Global setting, indicate that the parser should load DTD while not
224 * validating.
225 * Disabled by default.
226 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000227int xmlLoadExtDtdDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000228static int xmlLoadExtDtdDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000229/**
230 * xmlPedanticParserDefaultValue:
231 *
232 * Global setting, indicate that the parser be pedantic
233 * Disabled by default.
234 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000235int xmlPedanticParserDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000236static int xmlPedanticParserDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000237/**
238 * xmlLineNumbersDefaultValue:
239 *
240 * Global setting, indicate that the parser should store the line number
241 * in the content field of elements in the DOM tree.
242 * Disabled by default since this may not be safe for old classes of
243 * applicaton.
244 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000245int xmlLineNumbersDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000246static int xmlLineNumbersDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000247/**
248 * xmlKeepBlanksDefaultValue:
249 *
250 * Global setting, indicate that the parser should keep all blanks
251 * nodes found in the content
252 * Activated by default, this is actually needed to have the parser
253 * conformant to the XML Recommendation, however the option is kept
254 * for some applications since this was libxml1 default behaviour.
255 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000256int xmlKeepBlanksDefaultValue = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000257static int xmlKeepBlanksDefaultValueThrDef = 1;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000258/**
259 * xmlSubstituteEntitiesDefaultValue:
260 *
261 * Global setting, indicate that the parser should not generate entity
262 * references but replace them with the actual content of the entity
263 * Disabled by default, this should be activated when using XPath since
264 * the XPath data model requires entities replacement and the XPath
265 * engine does not handle entities references transparently.
266 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000267int xmlSubstituteEntitiesDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000268static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
Daniel Veillardb8478642001-10-12 17:29:10 +0000269
Daniel Veillard5335dc52003-01-01 20:59:38 +0000270xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000271static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000272xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000273static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000274
Daniel Veillardb8478642001-10-12 17:29:10 +0000275/*
276 * Error handling
277 */
278
279/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
280/* Must initialize xmlGenericError in xmlInitParser */
Daniel Veillard635ef722001-10-29 11:48:19 +0000281void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
282 const char *msg,
283 ...);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000284/**
285 * xmlGenericError:
286 *
287 * Global setting: function used for generic error callbacks
288 */
Daniel Veillard635ef722001-10-29 11:48:19 +0000289xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000290static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000291/**
Daniel Veillard659e71e2003-10-10 14:10:40 +0000292 * xmlStructuredError:
293 *
294 * Global setting: function used for structured error callbacks
295 */
296xmlStructuredErrorFunc xmlStructuredError = NULL;
297static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
298/**
Daniel Veillard9d06d302002-01-22 18:15:52 +0000299 * xmlGenericErrorContext:
300 *
301 * Global setting passed to generic error callbacks
302 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000303void *xmlGenericErrorContext = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000304static void *xmlGenericErrorContextThrDef = NULL;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000305xmlError xmlLastError;
Daniel Veillardb8478642001-10-12 17:29:10 +0000306
307/*
308 * output defaults
309 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000310/**
311 * xmlIndentTreeOutput:
312 *
313 * Global setting, asking the serializer to indent the output tree by default
Aleksey Sanin23002562002-05-24 07:18:40 +0000314 * Enabled by default
Daniel Veillard9d06d302002-01-22 18:15:52 +0000315 */
Aleksey Sanin23002562002-05-24 07:18:40 +0000316int xmlIndentTreeOutput = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000317static int xmlIndentTreeOutputThrDef = 1;
Aleksey Sanin23002562002-05-24 07:18:40 +0000318
319/**
320 * xmlTreeIndentString:
321 *
322 * The string used to do one-level indent. By default is equal to " " (two spaces)
323 */
324const char *xmlTreeIndentString = " ";
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000325static const char *xmlTreeIndentStringThrDef = " ";
Aleksey Sanin23002562002-05-24 07:18:40 +0000326
Daniel Veillard9d06d302002-01-22 18:15:52 +0000327/**
328 * xmlSaveNoEmptyTags:
329 *
330 * Global setting, asking the serializer to not output empty tags
331 * as <empty/> but <empty></empty>. those two forms are undistinguishable
332 * once parsed.
333 * Disabled by default
334 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000335int xmlSaveNoEmptyTags = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000336int xmlSaveNoEmptyTagsThrDef = 0;
Daniel Veillardb8478642001-10-12 17:29:10 +0000337
Daniel Veillard81273902003-09-30 00:43:48 +0000338#ifdef LIBXML_SAX1_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000339/**
340 * xmlDefaultSAXHandler:
341 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000342 * Default SAX version1 handler for XML, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000343 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000344xmlSAXHandlerV1 xmlDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000345 xmlSAX2InternalSubset,
346 xmlSAX2IsStandalone,
347 xmlSAX2HasInternalSubset,
348 xmlSAX2HasExternalSubset,
349 xmlSAX2ResolveEntity,
350 xmlSAX2GetEntity,
351 xmlSAX2EntityDecl,
352 xmlSAX2NotationDecl,
353 xmlSAX2AttributeDecl,
354 xmlSAX2ElementDecl,
355 xmlSAX2UnparsedEntityDecl,
356 xmlSAX2SetDocumentLocator,
357 xmlSAX2StartDocument,
358 xmlSAX2EndDocument,
359 xmlSAX2StartElement,
360 xmlSAX2EndElement,
361 xmlSAX2Reference,
362 xmlSAX2Characters,
363 xmlSAX2Characters,
364 xmlSAX2ProcessingInstruction,
365 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000366 xmlParserWarning,
367 xmlParserError,
368 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000369 xmlSAX2GetParameterEntity,
370 xmlSAX2CDataBlock,
371 xmlSAX2ExternalSubset,
372 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000373};
Daniel Veillard81273902003-09-30 00:43:48 +0000374#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillardb8478642001-10-12 17:29:10 +0000375
Daniel Veillard9d06d302002-01-22 18:15:52 +0000376/**
377 * xmlDefaultSAXLocator:
378 *
379 * The default SAX Locator
380 * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
Daniel Veillardb8478642001-10-12 17:29:10 +0000381 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000382xmlSAXLocator xmlDefaultSAXLocator = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000383 xmlSAX2GetPublicId,
384 xmlSAX2GetSystemId,
385 xmlSAX2GetLineNumber,
386 xmlSAX2GetColumnNumber
Daniel Veillardb8478642001-10-12 17:29:10 +0000387};
388
389#ifdef LIBXML_HTML_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000390/**
391 * htmlDefaultSAXHandler:
392 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000393 * Default old SAX v1 handler for HTML, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000394 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000395xmlSAXHandlerV1 htmlDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000396 xmlSAX2InternalSubset,
Daniel Veillardb8478642001-10-12 17:29:10 +0000397 NULL,
398 NULL,
399 NULL,
400 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000401 xmlSAX2GetEntity,
Daniel Veillardb8478642001-10-12 17:29:10 +0000402 NULL,
403 NULL,
404 NULL,
405 NULL,
406 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000407 xmlSAX2SetDocumentLocator,
408 xmlSAX2StartDocument,
409 xmlSAX2EndDocument,
410 xmlSAX2StartElement,
411 xmlSAX2EndElement,
Daniel Veillardb8478642001-10-12 17:29:10 +0000412 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000413 xmlSAX2Characters,
414 xmlSAX2IgnorableWhitespace,
Daniel Veillardb8478642001-10-12 17:29:10 +0000415 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000416 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000417 xmlParserWarning,
418 xmlParserError,
419 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000420 xmlSAX2GetParameterEntity,
421 xmlSAX2CDataBlock,
Daniel Veillardb8478642001-10-12 17:29:10 +0000422 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000423 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000424};
425#endif /* LIBXML_HTML_ENABLED */
426
427#ifdef LIBXML_DOCB_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000428/**
429 * docbDefaultSAXHandler:
430 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000431 * Default old SAX v1 handler for SGML DocBook, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000432 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000433xmlSAXHandlerV1 docbDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000434 xmlSAX2InternalSubset,
435 xmlSAX2IsStandalone,
436 xmlSAX2HasInternalSubset,
437 xmlSAX2HasExternalSubset,
438 xmlSAX2ResolveEntity,
439 xmlSAX2GetEntity,
440 xmlSAX2EntityDecl,
Daniel Veillardb8478642001-10-12 17:29:10 +0000441 NULL,
442 NULL,
443 NULL,
444 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000445 xmlSAX2SetDocumentLocator,
446 xmlSAX2StartDocument,
447 xmlSAX2EndDocument,
448 xmlSAX2StartElement,
449 xmlSAX2EndElement,
450 xmlSAX2Reference,
451 xmlSAX2Characters,
452 xmlSAX2IgnorableWhitespace,
Daniel Veillardb8478642001-10-12 17:29:10 +0000453 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000454 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000455 xmlParserWarning,
456 xmlParserError,
457 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000458 xmlSAX2GetParameterEntity,
Daniel Veillardb8478642001-10-12 17:29:10 +0000459 NULL,
460 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000461 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000462};
463#endif /* LIBXML_DOCB_ENABLED */
464
465/**
466 * xmlInitializeGlobalState:
467 * @gs: a pointer to a newly allocated global state
468 *
469 * xmlInitializeGlobalState() initialize a global state with all the
470 * default values of the library.
471 */
472void
473xmlInitializeGlobalState(xmlGlobalStatePtr gs)
474{
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000475#ifdef DEBUG_GLOBALS
476 fprintf(stderr, "Initializing globals at %lu for thread %d\n",
477 (unsigned long) gs, xmlGetThreadId());
478#endif
479
Daniel Veillardb8478642001-10-12 17:29:10 +0000480 /*
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000481 * Perform initialization as required by libxml
Daniel Veillardb8478642001-10-12 17:29:10 +0000482 */
Daniel Veillard5805be22003-08-28 08:03:23 +0000483 if (xmlThrDefMutex == NULL)
484 xmlInitGlobals();
485
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000486 xmlMutexLock(xmlThrDefMutex);
William M. Brack8b2c7f12002-11-22 05:07:29 +0000487
Daniel Veillarda4617b82001-11-04 20:19:12 +0000488#ifdef LIBXML_DOCB_ENABLED
Daniel Veillard092643b2003-09-25 14:29:29 +0000489 initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
Daniel Veillarda4617b82001-11-04 20:19:12 +0000490#endif
491#ifdef LIBXML_HTML_ENABLED
Daniel Veillard092643b2003-09-25 14:29:29 +0000492 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
Daniel Veillarda4617b82001-11-04 20:19:12 +0000493#endif
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000494
Daniel Veillardb8478642001-10-12 17:29:10 +0000495 gs->oldXMLWDcompatibility = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000496 gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
497 gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
Daniel Veillard81273902003-09-30 00:43:48 +0000498#ifdef LIBXML_SAX1_ENABLED
Daniel Veillard092643b2003-09-25 14:29:29 +0000499 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
Daniel Veillard81273902003-09-30 00:43:48 +0000500#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillard4432df22003-09-28 18:58:27 +0000501 gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
502 gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
503 gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
504 gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000505 gs->xmlDoValidityCheckingDefaultValue =
506 xmlDoValidityCheckingDefaultValueThrDef;
Daniel Veillardb8478642001-10-12 17:29:10 +0000507#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
508 gs->xmlFree = (xmlFreeFunc) xmlMemFree;
509 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000510 gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillardb8478642001-10-12 17:29:10 +0000511 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
512 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
513#else
514 gs->xmlFree = (xmlFreeFunc) free;
515 gs->xmlMalloc = (xmlMallocFunc) malloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000516 gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
Daniel Veillardb8478642001-10-12 17:29:10 +0000517 gs->xmlRealloc = (xmlReallocFunc) realloc;
Daniel Veillard572577e2002-01-18 16:23:55 +0000518 gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
Daniel Veillardb8478642001-10-12 17:29:10 +0000519#endif
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000520 gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
521 gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
522 gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
523 gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
524 gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
525 gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
526 gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
Daniel Veillardb8478642001-10-12 17:29:10 +0000527 gs->xmlParserVersion = LIBXML_VERSION_STRING;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000528 gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
529 gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
530 gs->xmlSubstituteEntitiesDefaultValue =
531 xmlSubstituteEntitiesDefaultValueThrDef;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000532
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000533 gs->xmlGenericError = xmlGenericErrorThrDef;
Daniel Veillard659e71e2003-10-10 14:10:40 +0000534 gs->xmlStructuredError = xmlStructuredErrorThrDef;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000535 gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
536 gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
537 gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000538 memset(&gs->xmlLastError, 0, sizeof(xmlError));
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000539
540 xmlMutexUnlock(xmlThrDefMutex);
541}
542
543void
544xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
545 xmlMutexLock(xmlThrDefMutex);
546 xmlGenericErrorContextThrDef = ctx;
547 if (handler != NULL)
548 xmlGenericErrorThrDef = handler;
549 else
550 xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
551 xmlMutexUnlock(xmlThrDefMutex);
Daniel Veillardb8478642001-10-12 17:29:10 +0000552}
553
Daniel Veillard659e71e2003-10-10 14:10:40 +0000554void
555xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
556 xmlMutexLock(xmlThrDefMutex);
557 xmlGenericErrorContextThrDef = ctx;
558 xmlStructuredErrorThrDef = handler;
559 xmlMutexUnlock(xmlThrDefMutex);
560}
561
Daniel Veillard5335dc52003-01-01 20:59:38 +0000562/**
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000563 * xmlRegisterNodeDefault:
Daniel Veillard5335dc52003-01-01 20:59:38 +0000564 * @func: function pointer to the new RegisterNodeFunc
565 *
Daniel Veillard1703c5f2003-02-10 14:28:44 +0000566 * Registers a callback for node creation
567 *
568 * Returns the old value of the registration function
Daniel Veillard5335dc52003-01-01 20:59:38 +0000569 */
570xmlRegisterNodeFunc
571xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
572{
573 xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
574
Daniel Veillarda880b122003-04-21 21:36:41 +0000575 __xmlRegisterCallbacks = 1;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000576 xmlRegisterNodeDefaultValue = func;
577 return(old);
578}
579
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000580xmlRegisterNodeFunc
581xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
582{
583 xmlRegisterNodeFunc old;
584
585 xmlMutexLock(xmlThrDefMutex);
586 old = xmlRegisterNodeDefaultValueThrDef;
587
588 __xmlRegisterCallbacks = 1;
589 xmlRegisterNodeDefaultValueThrDef = func;
590 xmlMutexUnlock(xmlThrDefMutex);
591
592 return(old);
593}
594
Daniel Veillard5335dc52003-01-01 20:59:38 +0000595/**
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000596 * xmlDeregisterNodeDefault:
Daniel Veillard5335dc52003-01-01 20:59:38 +0000597 * @func: function pointer to the new DeregisterNodeFunc
598 *
Daniel Veillard1703c5f2003-02-10 14:28:44 +0000599 * Registers a callback for node destruction
600 *
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000601 * Returns the previous value of the deregistration function
Daniel Veillard5335dc52003-01-01 20:59:38 +0000602 */
603xmlDeregisterNodeFunc
604xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
605{
606 xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
607
Daniel Veillarda880b122003-04-21 21:36:41 +0000608 __xmlRegisterCallbacks = 1;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000609 xmlDeregisterNodeDefaultValue = func;
610 return(old);
611}
612
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000613xmlDeregisterNodeFunc
614xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
615{
616 xmlDeregisterNodeFunc old;
617
618 xmlMutexLock(xmlThrDefMutex);
619 old = xmlDeregisterNodeDefaultValueThrDef;
620
621 __xmlRegisterCallbacks = 1;
622 xmlDeregisterNodeDefaultValueThrDef = func;
623 xmlMutexUnlock(xmlThrDefMutex);
624
625 return(old);
626}
627
Daniel Veillard5335dc52003-01-01 20:59:38 +0000628
Daniel Veillarda4617b82001-11-04 20:19:12 +0000629#ifdef LIBXML_DOCB_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000630#undef docbDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000631xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000632__docbDefaultSAXHandler(void) {
633 if (IS_MAIN_THREAD)
634 return (&docbDefaultSAXHandler);
635 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000636 return (&xmlGetGlobalState()->docbDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000637}
Daniel Veillarda4617b82001-11-04 20:19:12 +0000638#endif
Daniel Veillardb8478642001-10-12 17:29:10 +0000639
Daniel Veillarda4617b82001-11-04 20:19:12 +0000640#ifdef LIBXML_HTML_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000641#undef htmlDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000642xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000643__htmlDefaultSAXHandler(void) {
644 if (IS_MAIN_THREAD)
645 return (&htmlDefaultSAXHandler);
646 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000647 return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000648}
Daniel Veillarda4617b82001-11-04 20:19:12 +0000649#endif
650
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000651#undef xmlLastError
652xmlError *
653__xmlLastError(void) {
654 if (IS_MAIN_THREAD)
655 return (&xmlLastError);
656 else
657 return (&xmlGetGlobalState()->xmlLastError);
658}
659
Daniel Veillarda4617b82001-11-04 20:19:12 +0000660/*
661 * Everything starting from the line below is
662 * Automatically generated by build_glob.py.
663 * Do not modify the previous line.
664 */
665
Daniel Veillardb8478642001-10-12 17:29:10 +0000666
Daniel Veillardb8478642001-10-12 17:29:10 +0000667#undef oldXMLWDcompatibility
668int *
669__oldXMLWDcompatibility(void) {
670 if (IS_MAIN_THREAD)
671 return (&oldXMLWDcompatibility);
672 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000673 return (&xmlGetGlobalState()->oldXMLWDcompatibility);
Daniel Veillardb8478642001-10-12 17:29:10 +0000674}
675
Daniel Veillardb8478642001-10-12 17:29:10 +0000676#undef xmlBufferAllocScheme
677xmlBufferAllocationScheme *
678__xmlBufferAllocScheme(void) {
679 if (IS_MAIN_THREAD)
680 return (&xmlBufferAllocScheme);
681 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000682 return (&xmlGetGlobalState()->xmlBufferAllocScheme);
Daniel Veillardb8478642001-10-12 17:29:10 +0000683}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000684xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
685 xmlBufferAllocationScheme ret;
686 xmlMutexLock(xmlThrDefMutex);
687 ret = xmlBufferAllocSchemeThrDef;
688 xmlBufferAllocSchemeThrDef = v;
689 xmlMutexUnlock(xmlThrDefMutex);
690 return ret;
691}
Daniel Veillardb8478642001-10-12 17:29:10 +0000692
Daniel Veillardb8478642001-10-12 17:29:10 +0000693#undef xmlDefaultBufferSize
694int *
695__xmlDefaultBufferSize(void) {
696 if (IS_MAIN_THREAD)
697 return (&xmlDefaultBufferSize);
698 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000699 return (&xmlGetGlobalState()->xmlDefaultBufferSize);
Daniel Veillardb8478642001-10-12 17:29:10 +0000700}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000701int xmlThrDefDefaultBufferSize(int v) {
702 int ret;
703 xmlMutexLock(xmlThrDefMutex);
704 ret = xmlDefaultBufferSizeThrDef;
705 xmlDefaultBufferSizeThrDef = v;
706 xmlMutexUnlock(xmlThrDefMutex);
707 return ret;
708}
Daniel Veillardb8478642001-10-12 17:29:10 +0000709
Daniel Veillard81273902003-09-30 00:43:48 +0000710#ifdef LIBXML_SAX1_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000711#undef xmlDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000712xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000713__xmlDefaultSAXHandler(void) {
714 if (IS_MAIN_THREAD)
715 return (&xmlDefaultSAXHandler);
716 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000717 return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000718}
Daniel Veillard81273902003-09-30 00:43:48 +0000719#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillardb8478642001-10-12 17:29:10 +0000720
Daniel Veillardb8478642001-10-12 17:29:10 +0000721#undef xmlDefaultSAXLocator
722xmlSAXLocator *
723__xmlDefaultSAXLocator(void) {
724 if (IS_MAIN_THREAD)
725 return (&xmlDefaultSAXLocator);
726 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000727 return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
Daniel Veillardb8478642001-10-12 17:29:10 +0000728}
729
Daniel Veillardb8478642001-10-12 17:29:10 +0000730#undef xmlDoValidityCheckingDefaultValue
731int *
732__xmlDoValidityCheckingDefaultValue(void) {
733 if (IS_MAIN_THREAD)
734 return (&xmlDoValidityCheckingDefaultValue);
735 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000736 return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000737}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000738int xmlThrDefDoValidityCheckingDefaultValue(int v) {
739 int ret;
740 xmlMutexLock(xmlThrDefMutex);
741 ret = xmlDoValidityCheckingDefaultValueThrDef;
742 xmlDoValidityCheckingDefaultValueThrDef = v;
743 xmlMutexUnlock(xmlThrDefMutex);
744 return ret;
745}
Daniel Veillardb8478642001-10-12 17:29:10 +0000746
Daniel Veillardb8478642001-10-12 17:29:10 +0000747#undef xmlGenericError
748xmlGenericErrorFunc *
749__xmlGenericError(void) {
750 if (IS_MAIN_THREAD)
751 return (&xmlGenericError);
752 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000753 return (&xmlGetGlobalState()->xmlGenericError);
Daniel Veillardb8478642001-10-12 17:29:10 +0000754}
755
Daniel Veillard659e71e2003-10-10 14:10:40 +0000756#undef xmlStructuredError
757xmlStructuredErrorFunc *
758__xmlStructuredError(void) {
759 if (IS_MAIN_THREAD)
760 return (&xmlStructuredError);
761 else
762 return (&xmlGetGlobalState()->xmlStructuredError);
763}
764
Daniel Veillardb8478642001-10-12 17:29:10 +0000765#undef xmlGenericErrorContext
766void * *
767__xmlGenericErrorContext(void) {
768 if (IS_MAIN_THREAD)
769 return (&xmlGenericErrorContext);
770 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000771 return (&xmlGetGlobalState()->xmlGenericErrorContext);
Daniel Veillardb8478642001-10-12 17:29:10 +0000772}
773
Daniel Veillardb8478642001-10-12 17:29:10 +0000774#undef xmlGetWarningsDefaultValue
775int *
776__xmlGetWarningsDefaultValue(void) {
777 if (IS_MAIN_THREAD)
778 return (&xmlGetWarningsDefaultValue);
779 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000780 return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000781}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000782int xmlThrDefGetWarningsDefaultValue(int v) {
783 int ret;
784 xmlMutexLock(xmlThrDefMutex);
785 ret = xmlGetWarningsDefaultValueThrDef;
786 xmlGetWarningsDefaultValueThrDef = v;
787 xmlMutexUnlock(xmlThrDefMutex);
788 return ret;
789}
Daniel Veillardb8478642001-10-12 17:29:10 +0000790
Daniel Veillardb8478642001-10-12 17:29:10 +0000791#undef xmlIndentTreeOutput
792int *
793__xmlIndentTreeOutput(void) {
794 if (IS_MAIN_THREAD)
795 return (&xmlIndentTreeOutput);
796 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000797 return (&xmlGetGlobalState()->xmlIndentTreeOutput);
Daniel Veillardb8478642001-10-12 17:29:10 +0000798}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000799int xmlThrDefIndentTreeOutput(int v) {
800 int ret;
801 xmlMutexLock(xmlThrDefMutex);
802 ret = xmlIndentTreeOutputThrDef;
803 xmlIndentTreeOutputThrDef = v;
804 xmlMutexUnlock(xmlThrDefMutex);
805 return ret;
806}
Daniel Veillardb8478642001-10-12 17:29:10 +0000807
Aleksey Sanin23002562002-05-24 07:18:40 +0000808#undef xmlTreeIndentString
809const char * *
810__xmlTreeIndentString(void) {
811 if (IS_MAIN_THREAD)
812 return (&xmlTreeIndentString);
813 else
814 return (&xmlGetGlobalState()->xmlTreeIndentString);
815}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000816const char * xmlThrDefTreeIndentString(const char * v) {
817 const char * ret;
818 xmlMutexLock(xmlThrDefMutex);
819 ret = xmlTreeIndentStringThrDef;
820 xmlTreeIndentStringThrDef = v;
821 xmlMutexUnlock(xmlThrDefMutex);
822 return ret;
823}
Aleksey Sanin23002562002-05-24 07:18:40 +0000824
Daniel Veillardb8478642001-10-12 17:29:10 +0000825#undef xmlKeepBlanksDefaultValue
826int *
827__xmlKeepBlanksDefaultValue(void) {
828 if (IS_MAIN_THREAD)
829 return (&xmlKeepBlanksDefaultValue);
830 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000831 return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000832}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000833int xmlThrDefKeepBlanksDefaultValue(int v) {
834 int ret;
835 xmlMutexLock(xmlThrDefMutex);
836 ret = xmlKeepBlanksDefaultValueThrDef;
837 xmlKeepBlanksDefaultValueThrDef = v;
838 xmlMutexUnlock(xmlThrDefMutex);
839 return ret;
840}
Daniel Veillardb8478642001-10-12 17:29:10 +0000841
Daniel Veillardb8478642001-10-12 17:29:10 +0000842#undef xmlLineNumbersDefaultValue
843int *
844__xmlLineNumbersDefaultValue(void) {
845 if (IS_MAIN_THREAD)
846 return (&xmlLineNumbersDefaultValue);
847 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000848 return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000849}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000850int xmlThrDefLineNumbersDefaultValue(int v) {
851 int ret;
852 xmlMutexLock(xmlThrDefMutex);
853 ret = xmlLineNumbersDefaultValueThrDef;
854 xmlLineNumbersDefaultValueThrDef = v;
855 xmlMutexUnlock(xmlThrDefMutex);
856 return ret;
857}
Daniel Veillardb8478642001-10-12 17:29:10 +0000858
Daniel Veillardb8478642001-10-12 17:29:10 +0000859#undef xmlLoadExtDtdDefaultValue
860int *
861__xmlLoadExtDtdDefaultValue(void) {
862 if (IS_MAIN_THREAD)
863 return (&xmlLoadExtDtdDefaultValue);
864 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000865 return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000866}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000867int xmlThrDefLoadExtDtdDefaultValue(int v) {
868 int ret;
869 xmlMutexLock(xmlThrDefMutex);
870 ret = xmlLoadExtDtdDefaultValueThrDef;
871 xmlLoadExtDtdDefaultValueThrDef = v;
872 xmlMutexUnlock(xmlThrDefMutex);
873 return ret;
874}
Daniel Veillardb8478642001-10-12 17:29:10 +0000875
Daniel Veillardb8478642001-10-12 17:29:10 +0000876#undef xmlParserDebugEntities
877int *
878__xmlParserDebugEntities(void) {
879 if (IS_MAIN_THREAD)
880 return (&xmlParserDebugEntities);
881 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000882 return (&xmlGetGlobalState()->xmlParserDebugEntities);
Daniel Veillardb8478642001-10-12 17:29:10 +0000883}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000884int xmlThrDefParserDebugEntities(int v) {
885 int ret;
886 xmlMutexLock(xmlThrDefMutex);
887 ret = xmlParserDebugEntitiesThrDef;
888 xmlParserDebugEntitiesThrDef = 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 xmlParserVersion
894const char * *
895__xmlParserVersion(void) {
896 if (IS_MAIN_THREAD)
897 return (&xmlParserVersion);
898 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000899 return (&xmlGetGlobalState()->xmlParserVersion);
Daniel Veillardb8478642001-10-12 17:29:10 +0000900}
901
Daniel Veillardb8478642001-10-12 17:29:10 +0000902#undef xmlPedanticParserDefaultValue
903int *
904__xmlPedanticParserDefaultValue(void) {
905 if (IS_MAIN_THREAD)
906 return (&xmlPedanticParserDefaultValue);
907 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000908 return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000909}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000910int xmlThrDefPedanticParserDefaultValue(int v) {
911 int ret;
912 xmlMutexLock(xmlThrDefMutex);
913 ret = xmlPedanticParserDefaultValueThrDef;
914 xmlPedanticParserDefaultValueThrDef = v;
915 xmlMutexUnlock(xmlThrDefMutex);
916 return ret;
917}
Daniel Veillardb8478642001-10-12 17:29:10 +0000918
Daniel Veillardb8478642001-10-12 17:29:10 +0000919#undef xmlSaveNoEmptyTags
920int *
921__xmlSaveNoEmptyTags(void) {
922 if (IS_MAIN_THREAD)
923 return (&xmlSaveNoEmptyTags);
924 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000925 return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
Daniel Veillardb8478642001-10-12 17:29:10 +0000926}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000927int xmlThrDefSaveNoEmptyTags(int v) {
928 int ret;
929 xmlMutexLock(xmlThrDefMutex);
930 ret = xmlSaveNoEmptyTagsThrDef;
931 xmlSaveNoEmptyTagsThrDef = v;
932 xmlMutexUnlock(xmlThrDefMutex);
933 return ret;
934}
Daniel Veillardb8478642001-10-12 17:29:10 +0000935
Daniel Veillardb8478642001-10-12 17:29:10 +0000936#undef xmlSubstituteEntitiesDefaultValue
937int *
938__xmlSubstituteEntitiesDefaultValue(void) {
939 if (IS_MAIN_THREAD)
940 return (&xmlSubstituteEntitiesDefaultValue);
941 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000942 return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000943}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000944int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
945 int ret;
946 xmlMutexLock(xmlThrDefMutex);
947 ret = xmlSubstituteEntitiesDefaultValueThrDef;
948 xmlSubstituteEntitiesDefaultValueThrDef = v;
949 xmlMutexUnlock(xmlThrDefMutex);
950 return ret;
951}
Daniel Veillard5335dc52003-01-01 20:59:38 +0000952
953#undef xmlRegisterNodeDefaultValue
954xmlRegisterNodeFunc *
955__xmlRegisterNodeDefaultValue(void) {
956 if (IS_MAIN_THREAD)
957 return (&xmlRegisterNodeDefaultValue);
958 else
959 return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
960}
961
962#undef xmlDeregisterNodeDefaultValue
963xmlDeregisterNodeFunc *
964__xmlDeregisterNodeDefaultValue(void) {
965 if (IS_MAIN_THREAD)
966 return (&xmlDeregisterNodeDefaultValue);
967 else
968 return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
969}