blob: 79b4a14e02db4b21427762f28f64a68918633e97 [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 Veillard781ac8b2003-05-15 22:11:36 +000047void xmlInitGlobals()
48{
49 xmlThrDefMutex = xmlNewMutex();
50}
51
William M. Brack966668a2003-12-20 02:10:28 +000052/**
53 * xmlCleanupGlobals:
54 *
55 * Additional cleanup for multi-threading
56 */
Daniel Veillard781ac8b2003-05-15 22:11:36 +000057void xmlCleanupGlobals()
58{
Daniel Veillard2009c4e2003-07-15 20:04:34 +000059 if (xmlThrDefMutex != NULL) {
Daniel Veillarddf101d82003-07-08 14:03:36 +000060 xmlFreeMutex(xmlThrDefMutex);
Daniel Veillard2009c4e2003-07-15 20:04:34 +000061 xmlThrDefMutex = NULL;
62 }
Daniel Veillard781ac8b2003-05-15 22:11:36 +000063}
64
Daniel Veillardb8478642001-10-12 17:29:10 +000065/************************************************************************
66 * *
67 * All the user accessible global variables of the library *
68 * *
69 ************************************************************************/
70
Daniel Veillardb8478642001-10-12 17:29:10 +000071/*
72 * Memory allocation routines
73 */
Daniel Veillard7216cfd2002-11-08 15:10:00 +000074#if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
Daniel Veillard092643b2003-09-25 14:29:29 +000075#ifndef __DEBUG_MEMORY_ALLOC__
Daniel Veillardd0463562001-10-13 09:15:48 +000076extern void xmlMemFree(void *ptr);
77extern void * xmlMemMalloc(size_t size);
78extern void * xmlMemRealloc(void *ptr,size_t size);
79extern char * xmlMemoryStrdup(const char *str);
Daniel Veillard98485322003-08-14 15:44:40 +000080#endif
Daniel Veillardd0463562001-10-13 09:15:48 +000081
Daniel Veillardb8478642001-10-12 17:29:10 +000082xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
83xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +000084xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillardb8478642001-10-12 17:29:10 +000085xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
86xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
87#else
Daniel Veillard9d06d302002-01-22 18:15:52 +000088/**
89 * xmlFree:
90 * @mem: an already allocated block of memory
91 *
92 * The variable holding the libxml free() implementation
93 */
Daniel Veillardb8478642001-10-12 17:29:10 +000094xmlFreeFunc xmlFree = (xmlFreeFunc) free;
Daniel Veillard9d06d302002-01-22 18:15:52 +000095/**
96 * xmlMalloc:
97 * @size: the size requested in bytes
98 *
99 * The variable holding the libxml malloc() implementation
100 *
101 * Returns a pointer to the newly allocated block or NULL in case of error
102 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000103xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000104/**
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000105 * xmlMallocAtomic:
106 * @size: the size requested in bytes
107 *
108 * The variable holding the libxml malloc() implementation for atomic
109 * data (i.e. blocks not containings pointers), useful when using a
110 * garbage collecting allocator.
111 *
112 * Returns a pointer to the newly allocated block or NULL in case of error
113 */
114xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc;
115/**
Daniel Veillard9d06d302002-01-22 18:15:52 +0000116 * xmlRealloc:
117 * @mem: an already allocated block of memory
118 * @size: the new size requested in bytes
119 *
120 * The variable holding the libxml realloc() implementation
121 *
122 * Returns a pointer to the newly reallocated block or NULL in case of error
123 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000124xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000125/**
126 * xmlMemStrdup:
127 * @str: a zero terminated string
128 *
129 * The variable holding the libxml strdup() implementation
130 *
131 * Returns the copy of the string or NULL in case of error
132 */
Daniel Veillardb82c1662001-12-09 14:00:54 +0000133xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000134#endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
Daniel Veillardb8478642001-10-12 17:29:10 +0000135
Daniel Veillardd0463562001-10-13 09:15:48 +0000136#include <libxml/threads.h>
137#include <libxml/globals.h>
138#include <libxml/SAX.h>
139
140#undef docbDefaultSAXHandler
141#undef htmlDefaultSAXHandler
142#undef oldXMLWDcompatibility
143#undef xmlBufferAllocScheme
144#undef xmlDefaultBufferSize
145#undef xmlDefaultSAXHandler
146#undef xmlDefaultSAXLocator
147#undef xmlDoValidityCheckingDefaultValue
148#undef xmlGenericError
Daniel Veillard659e71e2003-10-10 14:10:40 +0000149#undef xmlStructuredError
Daniel Veillardd0463562001-10-13 09:15:48 +0000150#undef xmlGenericErrorContext
151#undef xmlGetWarningsDefaultValue
152#undef xmlIndentTreeOutput
Aleksey Sanin23002562002-05-24 07:18:40 +0000153#undef xmlTreeIndentString
Daniel Veillardd0463562001-10-13 09:15:48 +0000154#undef xmlKeepBlanksDefaultValue
155#undef xmlLineNumbersDefaultValue
156#undef xmlLoadExtDtdDefaultValue
157#undef xmlParserDebugEntities
158#undef xmlParserVersion
159#undef xmlPedanticParserDefaultValue
160#undef xmlSaveNoEmptyTags
161#undef xmlSubstituteEntitiesDefaultValue
Daniel Veillard8326e732003-01-07 00:19:07 +0000162#undef xmlRegisterNodeDefaultValue
163#undef xmlDeregisterNodeDefaultValue
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000164#undef xmlLastError
Daniel Veillardd0463562001-10-13 09:15:48 +0000165
166#undef xmlFree
167#undef xmlMalloc
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000168#undef xmlMallocAtomic
Daniel Veillardd0463562001-10-13 09:15:48 +0000169#undef xmlMemStrdup
170#undef xmlRealloc
171
Daniel Veillard0335a842004-06-02 16:18:40 +0000172#undef xmlParserInputBufferCreateFilenameValue
173#undef xmlOutputBufferCreateFilenameValue
Daniel Veillard9d06d302002-01-22 18:15:52 +0000174/**
175 * xmlParserVersion:
176 *
177 * Constant string describing the internal version of the library
178 */
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000179const char *xmlParserVersion = LIBXML_VERSION_STRING;
180
Daniel Veillard9d06d302002-01-22 18:15:52 +0000181/**
182 * xmlBufferAllocScheme:
183 *
184 * Global setting, default allocation policy for buffers, default is
185 * XML_BUFFER_ALLOC_EXACT
Daniel Veillardb8478642001-10-12 17:29:10 +0000186 */
187xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000188static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000189/**
190 * xmlDefaultBufferSize:
191 *
192 * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
193 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000194int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000195static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
Daniel Veillardb8478642001-10-12 17:29:10 +0000196
197/*
198 * Parser defaults
199 */
Daniel Veillardd0463562001-10-13 09:15:48 +0000200
Daniel Veillard9d06d302002-01-22 18:15:52 +0000201/**
202 * oldXMLWDcompatibility:
203 *
204 * Global setting, DEPRECATED.
205 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000206int oldXMLWDcompatibility = 0; /* DEPRECATED */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000207/**
208 * xmlParserDebugEntities:
209 *
210 * Global setting, asking the parser to print out debugging informations.
211 * while handling entities.
212 * Disabled by default
213 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000214int xmlParserDebugEntities = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000215static int xmlParserDebugEntitiesThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000216/**
217 * xmlDoValidityCheckingDefaultValue:
218 *
219 * Global setting, indicate that the parser should work in validating mode.
220 * Disabled by default.
221 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000222int xmlDoValidityCheckingDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000223static int xmlDoValidityCheckingDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000224/**
225 * xmlGetWarningsDefaultValue:
226 *
227 * Global setting, indicate that the parser should provide warnings.
228 * Activated by default.
229 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000230int xmlGetWarningsDefaultValue = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000231static int xmlGetWarningsDefaultValueThrDef = 1;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000232/**
233 * xmlLoadExtDtdDefaultValue:
234 *
235 * Global setting, indicate that the parser should load DTD while not
236 * validating.
237 * Disabled by default.
238 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000239int xmlLoadExtDtdDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000240static int xmlLoadExtDtdDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000241/**
242 * xmlPedanticParserDefaultValue:
243 *
244 * Global setting, indicate that the parser be pedantic
245 * Disabled by default.
246 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000247int xmlPedanticParserDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000248static int xmlPedanticParserDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000249/**
250 * xmlLineNumbersDefaultValue:
251 *
252 * Global setting, indicate that the parser should store the line number
253 * in the content field of elements in the DOM tree.
254 * Disabled by default since this may not be safe for old classes of
255 * applicaton.
256 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000257int xmlLineNumbersDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000258static int xmlLineNumbersDefaultValueThrDef = 0;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000259/**
260 * xmlKeepBlanksDefaultValue:
261 *
262 * Global setting, indicate that the parser should keep all blanks
263 * nodes found in the content
264 * Activated by default, this is actually needed to have the parser
265 * conformant to the XML Recommendation, however the option is kept
266 * for some applications since this was libxml1 default behaviour.
267 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000268int xmlKeepBlanksDefaultValue = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000269static int xmlKeepBlanksDefaultValueThrDef = 1;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000270/**
271 * xmlSubstituteEntitiesDefaultValue:
272 *
273 * Global setting, indicate that the parser should not generate entity
274 * references but replace them with the actual content of the entity
275 * Disabled by default, this should be activated when using XPath since
276 * the XPath data model requires entities replacement and the XPath
277 * engine does not handle entities references transparently.
278 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000279int xmlSubstituteEntitiesDefaultValue = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000280static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
Daniel Veillardb8478642001-10-12 17:29:10 +0000281
Daniel Veillard5335dc52003-01-01 20:59:38 +0000282xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000283static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000284xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000285static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000286
Daniel Veillard0335a842004-06-02 16:18:40 +0000287xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL;
288static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL;
289
290xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
291static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL;
292
Daniel Veillardb8478642001-10-12 17:29:10 +0000293/*
294 * Error handling
295 */
296
297/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
298/* Must initialize xmlGenericError in xmlInitParser */
Daniel Veillard635ef722001-10-29 11:48:19 +0000299void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
300 const char *msg,
301 ...);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000302/**
303 * xmlGenericError:
304 *
305 * Global setting: function used for generic error callbacks
306 */
Daniel Veillard635ef722001-10-29 11:48:19 +0000307xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000308static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
Daniel Veillard9d06d302002-01-22 18:15:52 +0000309/**
Daniel Veillard659e71e2003-10-10 14:10:40 +0000310 * xmlStructuredError:
311 *
312 * Global setting: function used for structured error callbacks
313 */
314xmlStructuredErrorFunc xmlStructuredError = NULL;
315static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
316/**
Daniel Veillard9d06d302002-01-22 18:15:52 +0000317 * xmlGenericErrorContext:
318 *
319 * Global setting passed to generic error callbacks
320 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000321void *xmlGenericErrorContext = NULL;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000322static void *xmlGenericErrorContextThrDef = NULL;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000323xmlError xmlLastError;
Daniel Veillardb8478642001-10-12 17:29:10 +0000324
325/*
326 * output defaults
327 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000328/**
329 * xmlIndentTreeOutput:
330 *
331 * Global setting, asking the serializer to indent the output tree by default
Aleksey Sanin23002562002-05-24 07:18:40 +0000332 * Enabled by default
Daniel Veillard9d06d302002-01-22 18:15:52 +0000333 */
Aleksey Sanin23002562002-05-24 07:18:40 +0000334int xmlIndentTreeOutput = 1;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000335static int xmlIndentTreeOutputThrDef = 1;
Aleksey Sanin23002562002-05-24 07:18:40 +0000336
337/**
338 * xmlTreeIndentString:
339 *
340 * The string used to do one-level indent. By default is equal to " " (two spaces)
341 */
342const char *xmlTreeIndentString = " ";
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000343static const char *xmlTreeIndentStringThrDef = " ";
Aleksey Sanin23002562002-05-24 07:18:40 +0000344
Daniel Veillard9d06d302002-01-22 18:15:52 +0000345/**
346 * xmlSaveNoEmptyTags:
347 *
348 * Global setting, asking the serializer to not output empty tags
349 * as <empty/> but <empty></empty>. those two forms are undistinguishable
350 * once parsed.
351 * Disabled by default
352 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000353int xmlSaveNoEmptyTags = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000354int xmlSaveNoEmptyTagsThrDef = 0;
Daniel Veillardb8478642001-10-12 17:29:10 +0000355
Daniel Veillard81273902003-09-30 00:43:48 +0000356#ifdef LIBXML_SAX1_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000357/**
358 * xmlDefaultSAXHandler:
359 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000360 * Default SAX version1 handler for XML, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000361 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000362xmlSAXHandlerV1 xmlDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000363 xmlSAX2InternalSubset,
364 xmlSAX2IsStandalone,
365 xmlSAX2HasInternalSubset,
366 xmlSAX2HasExternalSubset,
367 xmlSAX2ResolveEntity,
368 xmlSAX2GetEntity,
369 xmlSAX2EntityDecl,
370 xmlSAX2NotationDecl,
371 xmlSAX2AttributeDecl,
372 xmlSAX2ElementDecl,
373 xmlSAX2UnparsedEntityDecl,
374 xmlSAX2SetDocumentLocator,
375 xmlSAX2StartDocument,
376 xmlSAX2EndDocument,
377 xmlSAX2StartElement,
378 xmlSAX2EndElement,
379 xmlSAX2Reference,
380 xmlSAX2Characters,
381 xmlSAX2Characters,
382 xmlSAX2ProcessingInstruction,
383 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000384 xmlParserWarning,
385 xmlParserError,
386 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000387 xmlSAX2GetParameterEntity,
388 xmlSAX2CDataBlock,
389 xmlSAX2ExternalSubset,
390 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000391};
Daniel Veillard81273902003-09-30 00:43:48 +0000392#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillardb8478642001-10-12 17:29:10 +0000393
Daniel Veillard9d06d302002-01-22 18:15:52 +0000394/**
395 * xmlDefaultSAXLocator:
396 *
397 * The default SAX Locator
398 * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
Daniel Veillardb8478642001-10-12 17:29:10 +0000399 */
Daniel Veillardb8478642001-10-12 17:29:10 +0000400xmlSAXLocator xmlDefaultSAXLocator = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000401 xmlSAX2GetPublicId,
402 xmlSAX2GetSystemId,
403 xmlSAX2GetLineNumber,
404 xmlSAX2GetColumnNumber
Daniel Veillardb8478642001-10-12 17:29:10 +0000405};
406
407#ifdef LIBXML_HTML_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000408/**
409 * htmlDefaultSAXHandler:
410 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000411 * Default old SAX v1 handler for HTML, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000412 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000413xmlSAXHandlerV1 htmlDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000414 xmlSAX2InternalSubset,
Daniel Veillardb8478642001-10-12 17:29:10 +0000415 NULL,
416 NULL,
417 NULL,
418 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000419 xmlSAX2GetEntity,
Daniel Veillardb8478642001-10-12 17:29:10 +0000420 NULL,
421 NULL,
422 NULL,
423 NULL,
424 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000425 xmlSAX2SetDocumentLocator,
426 xmlSAX2StartDocument,
427 xmlSAX2EndDocument,
428 xmlSAX2StartElement,
429 xmlSAX2EndElement,
Daniel Veillardb8478642001-10-12 17:29:10 +0000430 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000431 xmlSAX2Characters,
432 xmlSAX2IgnorableWhitespace,
Daniel Veillardb8478642001-10-12 17:29:10 +0000433 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000434 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000435 xmlParserWarning,
436 xmlParserError,
437 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000438 xmlSAX2GetParameterEntity,
439 xmlSAX2CDataBlock,
Daniel Veillardb8478642001-10-12 17:29:10 +0000440 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000441 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000442};
443#endif /* LIBXML_HTML_ENABLED */
444
445#ifdef LIBXML_DOCB_ENABLED
Daniel Veillard9d06d302002-01-22 18:15:52 +0000446/**
447 * docbDefaultSAXHandler:
448 *
Daniel Veillard092643b2003-09-25 14:29:29 +0000449 * Default old SAX v1 handler for SGML DocBook, builds the DOM tree
Daniel Veillardb8478642001-10-12 17:29:10 +0000450 */
Daniel Veillard092643b2003-09-25 14:29:29 +0000451xmlSAXHandlerV1 docbDefaultSAXHandler = {
Daniel Veillard1af9a412003-08-20 22:54:39 +0000452 xmlSAX2InternalSubset,
453 xmlSAX2IsStandalone,
454 xmlSAX2HasInternalSubset,
455 xmlSAX2HasExternalSubset,
456 xmlSAX2ResolveEntity,
457 xmlSAX2GetEntity,
458 xmlSAX2EntityDecl,
Daniel Veillardb8478642001-10-12 17:29:10 +0000459 NULL,
460 NULL,
461 NULL,
462 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000463 xmlSAX2SetDocumentLocator,
464 xmlSAX2StartDocument,
465 xmlSAX2EndDocument,
466 xmlSAX2StartElement,
467 xmlSAX2EndElement,
468 xmlSAX2Reference,
469 xmlSAX2Characters,
470 xmlSAX2IgnorableWhitespace,
Daniel Veillardb8478642001-10-12 17:29:10 +0000471 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000472 xmlSAX2Comment,
Daniel Veillardb8478642001-10-12 17:29:10 +0000473 xmlParserWarning,
474 xmlParserError,
475 xmlParserError,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000476 xmlSAX2GetParameterEntity,
Daniel Veillardb8478642001-10-12 17:29:10 +0000477 NULL,
478 NULL,
Daniel Veillard1af9a412003-08-20 22:54:39 +0000479 0,
Daniel Veillardb8478642001-10-12 17:29:10 +0000480};
481#endif /* LIBXML_DOCB_ENABLED */
482
483/**
484 * xmlInitializeGlobalState:
485 * @gs: a pointer to a newly allocated global state
486 *
487 * xmlInitializeGlobalState() initialize a global state with all the
488 * default values of the library.
489 */
490void
491xmlInitializeGlobalState(xmlGlobalStatePtr gs)
492{
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000493#ifdef DEBUG_GLOBALS
494 fprintf(stderr, "Initializing globals at %lu for thread %d\n",
495 (unsigned long) gs, xmlGetThreadId());
496#endif
497
Daniel Veillardb8478642001-10-12 17:29:10 +0000498 /*
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000499 * Perform initialization as required by libxml
Daniel Veillardb8478642001-10-12 17:29:10 +0000500 */
Daniel Veillard5805be22003-08-28 08:03:23 +0000501 if (xmlThrDefMutex == NULL)
502 xmlInitGlobals();
503
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000504 xmlMutexLock(xmlThrDefMutex);
William M. Brack8b2c7f12002-11-22 05:07:29 +0000505
Daniel Veillarda4617b82001-11-04 20:19:12 +0000506#ifdef LIBXML_DOCB_ENABLED
Daniel Veillard092643b2003-09-25 14:29:29 +0000507 initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
Daniel Veillarda4617b82001-11-04 20:19:12 +0000508#endif
509#ifdef LIBXML_HTML_ENABLED
Daniel Veillard092643b2003-09-25 14:29:29 +0000510 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
Daniel Veillarda4617b82001-11-04 20:19:12 +0000511#endif
Daniel Veillard3c01b1d2001-10-17 15:58:35 +0000512
Daniel Veillardb8478642001-10-12 17:29:10 +0000513 gs->oldXMLWDcompatibility = 0;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000514 gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
515 gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
Daniel Veillard81273902003-09-30 00:43:48 +0000516#ifdef LIBXML_SAX1_ENABLED
Daniel Veillard092643b2003-09-25 14:29:29 +0000517 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
Daniel Veillard81273902003-09-30 00:43:48 +0000518#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillard4432df22003-09-28 18:58:27 +0000519 gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
520 gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
521 gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
522 gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000523 gs->xmlDoValidityCheckingDefaultValue =
524 xmlDoValidityCheckingDefaultValueThrDef;
Daniel Veillardb8478642001-10-12 17:29:10 +0000525#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
526 gs->xmlFree = (xmlFreeFunc) xmlMemFree;
527 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000528 gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
Daniel Veillardb8478642001-10-12 17:29:10 +0000529 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
530 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
531#else
532 gs->xmlFree = (xmlFreeFunc) free;
533 gs->xmlMalloc = (xmlMallocFunc) malloc;
Daniel Veillard3c908dc2003-04-19 00:07:51 +0000534 gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
Daniel Veillardb8478642001-10-12 17:29:10 +0000535 gs->xmlRealloc = (xmlReallocFunc) realloc;
Daniel Veillard572577e2002-01-18 16:23:55 +0000536 gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
Daniel Veillardb8478642001-10-12 17:29:10 +0000537#endif
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000538 gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
539 gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
540 gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
541 gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
542 gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
543 gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
544 gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
Daniel Veillardb8478642001-10-12 17:29:10 +0000545 gs->xmlParserVersion = LIBXML_VERSION_STRING;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000546 gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
547 gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
548 gs->xmlSubstituteEntitiesDefaultValue =
549 xmlSubstituteEntitiesDefaultValueThrDef;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000550
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000551 gs->xmlGenericError = xmlGenericErrorThrDef;
Daniel Veillard659e71e2003-10-10 14:10:40 +0000552 gs->xmlStructuredError = xmlStructuredErrorThrDef;
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000553 gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
554 gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
555 gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
Daniel Veillard0335a842004-06-02 16:18:40 +0000556
557 gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
558 gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000559 memset(&gs->xmlLastError, 0, sizeof(xmlError));
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000560
561 xmlMutexUnlock(xmlThrDefMutex);
562}
563
Daniel Veillard1e906612003-12-05 14:57:46 +0000564/**
565 * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions,
566 * those are really internal work
567 */
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000568void
569xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
570 xmlMutexLock(xmlThrDefMutex);
571 xmlGenericErrorContextThrDef = ctx;
572 if (handler != NULL)
573 xmlGenericErrorThrDef = handler;
574 else
575 xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
576 xmlMutexUnlock(xmlThrDefMutex);
Daniel Veillardb8478642001-10-12 17:29:10 +0000577}
578
Daniel Veillard659e71e2003-10-10 14:10:40 +0000579void
580xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
581 xmlMutexLock(xmlThrDefMutex);
582 xmlGenericErrorContextThrDef = ctx;
583 xmlStructuredErrorThrDef = handler;
584 xmlMutexUnlock(xmlThrDefMutex);
585}
586
Daniel Veillard5335dc52003-01-01 20:59:38 +0000587/**
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000588 * xmlRegisterNodeDefault:
Daniel Veillard5335dc52003-01-01 20:59:38 +0000589 * @func: function pointer to the new RegisterNodeFunc
590 *
Daniel Veillard1703c5f2003-02-10 14:28:44 +0000591 * Registers a callback for node creation
592 *
593 * Returns the old value of the registration function
Daniel Veillard5335dc52003-01-01 20:59:38 +0000594 */
595xmlRegisterNodeFunc
596xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
597{
598 xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
599
Daniel Veillarda880b122003-04-21 21:36:41 +0000600 __xmlRegisterCallbacks = 1;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000601 xmlRegisterNodeDefaultValue = func;
602 return(old);
603}
604
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000605xmlRegisterNodeFunc
606xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
607{
608 xmlRegisterNodeFunc old;
609
610 xmlMutexLock(xmlThrDefMutex);
611 old = xmlRegisterNodeDefaultValueThrDef;
612
613 __xmlRegisterCallbacks = 1;
614 xmlRegisterNodeDefaultValueThrDef = func;
615 xmlMutexUnlock(xmlThrDefMutex);
616
617 return(old);
618}
619
Daniel Veillard5335dc52003-01-01 20:59:38 +0000620/**
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000621 * xmlDeregisterNodeDefault:
Daniel Veillard5335dc52003-01-01 20:59:38 +0000622 * @func: function pointer to the new DeregisterNodeFunc
623 *
Daniel Veillard1703c5f2003-02-10 14:28:44 +0000624 * Registers a callback for node destruction
625 *
Daniel Veillard7b4b2f92003-01-06 13:11:20 +0000626 * Returns the previous value of the deregistration function
Daniel Veillard5335dc52003-01-01 20:59:38 +0000627 */
628xmlDeregisterNodeFunc
629xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
630{
631 xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
632
Daniel Veillarda880b122003-04-21 21:36:41 +0000633 __xmlRegisterCallbacks = 1;
Daniel Veillard5335dc52003-01-01 20:59:38 +0000634 xmlDeregisterNodeDefaultValue = func;
635 return(old);
636}
637
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000638xmlDeregisterNodeFunc
639xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
640{
641 xmlDeregisterNodeFunc old;
642
643 xmlMutexLock(xmlThrDefMutex);
644 old = xmlDeregisterNodeDefaultValueThrDef;
645
646 __xmlRegisterCallbacks = 1;
647 xmlDeregisterNodeDefaultValueThrDef = func;
648 xmlMutexUnlock(xmlThrDefMutex);
649
650 return(old);
651}
652
Daniel Veillard0335a842004-06-02 16:18:40 +0000653xmlParserInputBufferCreateFilenameFunc
654xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
655{
656 xmlParserInputBufferCreateFilenameFunc old;
657
658 xmlMutexLock(xmlThrDefMutex);
659 old = xmlParserInputBufferCreateFilenameValueThrDef;
Daniel Veillard1b243b42004-06-08 10:16:42 +0000660 if (old == NULL) {
661 old = __xmlParserInputBufferCreateFilename;
662 }
663
Daniel Veillard0335a842004-06-02 16:18:40 +0000664 xmlParserInputBufferCreateFilenameValueThrDef = func;
665 xmlMutexUnlock(xmlThrDefMutex);
666
667 return(old);
668}
669
Daniel Veillard0335a842004-06-02 16:18:40 +0000670xmlOutputBufferCreateFilenameFunc
671xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
672{
673 xmlOutputBufferCreateFilenameFunc old;
674
675 xmlMutexLock(xmlThrDefMutex);
676 old = xmlOutputBufferCreateFilenameValueThrDef;
Daniel Veillard1b243b42004-06-08 10:16:42 +0000677#ifdef LIBXML_OUTPUT_ENABLED
678 if (old == NULL) {
679 old = __xmlOutputBufferCreateFilename;
680 }
681#endif
Daniel Veillard0335a842004-06-02 16:18:40 +0000682 xmlOutputBufferCreateFilenameValueThrDef = func;
683 xmlMutexUnlock(xmlThrDefMutex);
684
685 return(old);
686}
Daniel Veillard5335dc52003-01-01 20:59:38 +0000687
Daniel Veillarda4617b82001-11-04 20:19:12 +0000688#ifdef LIBXML_DOCB_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000689#undef docbDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000690xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000691__docbDefaultSAXHandler(void) {
692 if (IS_MAIN_THREAD)
693 return (&docbDefaultSAXHandler);
694 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000695 return (&xmlGetGlobalState()->docbDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000696}
Daniel Veillarda4617b82001-11-04 20:19:12 +0000697#endif
Daniel Veillardb8478642001-10-12 17:29:10 +0000698
Daniel Veillarda4617b82001-11-04 20:19:12 +0000699#ifdef LIBXML_HTML_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000700#undef htmlDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000701xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000702__htmlDefaultSAXHandler(void) {
703 if (IS_MAIN_THREAD)
704 return (&htmlDefaultSAXHandler);
705 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000706 return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000707}
Daniel Veillarda4617b82001-11-04 20:19:12 +0000708#endif
709
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000710#undef xmlLastError
711xmlError *
712__xmlLastError(void) {
713 if (IS_MAIN_THREAD)
714 return (&xmlLastError);
715 else
716 return (&xmlGetGlobalState()->xmlLastError);
717}
718
Daniel Veillarda4617b82001-11-04 20:19:12 +0000719/*
720 * Everything starting from the line below is
721 * Automatically generated by build_glob.py.
722 * Do not modify the previous line.
723 */
724
Daniel Veillardb8478642001-10-12 17:29:10 +0000725
Daniel Veillardb8478642001-10-12 17:29:10 +0000726#undef oldXMLWDcompatibility
727int *
728__oldXMLWDcompatibility(void) {
729 if (IS_MAIN_THREAD)
730 return (&oldXMLWDcompatibility);
731 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000732 return (&xmlGetGlobalState()->oldXMLWDcompatibility);
Daniel Veillardb8478642001-10-12 17:29:10 +0000733}
734
Daniel Veillardb8478642001-10-12 17:29:10 +0000735#undef xmlBufferAllocScheme
736xmlBufferAllocationScheme *
737__xmlBufferAllocScheme(void) {
738 if (IS_MAIN_THREAD)
739 return (&xmlBufferAllocScheme);
740 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000741 return (&xmlGetGlobalState()->xmlBufferAllocScheme);
Daniel Veillardb8478642001-10-12 17:29:10 +0000742}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000743xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
744 xmlBufferAllocationScheme ret;
745 xmlMutexLock(xmlThrDefMutex);
746 ret = xmlBufferAllocSchemeThrDef;
747 xmlBufferAllocSchemeThrDef = v;
748 xmlMutexUnlock(xmlThrDefMutex);
749 return ret;
750}
Daniel Veillardb8478642001-10-12 17:29:10 +0000751
Daniel Veillardb8478642001-10-12 17:29:10 +0000752#undef xmlDefaultBufferSize
753int *
754__xmlDefaultBufferSize(void) {
755 if (IS_MAIN_THREAD)
756 return (&xmlDefaultBufferSize);
757 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000758 return (&xmlGetGlobalState()->xmlDefaultBufferSize);
Daniel Veillardb8478642001-10-12 17:29:10 +0000759}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000760int xmlThrDefDefaultBufferSize(int v) {
761 int ret;
762 xmlMutexLock(xmlThrDefMutex);
763 ret = xmlDefaultBufferSizeThrDef;
764 xmlDefaultBufferSizeThrDef = v;
765 xmlMutexUnlock(xmlThrDefMutex);
766 return ret;
767}
Daniel Veillardb8478642001-10-12 17:29:10 +0000768
Daniel Veillard81273902003-09-30 00:43:48 +0000769#ifdef LIBXML_SAX1_ENABLED
Daniel Veillardb8478642001-10-12 17:29:10 +0000770#undef xmlDefaultSAXHandler
Daniel Veillard092643b2003-09-25 14:29:29 +0000771xmlSAXHandlerV1 *
Daniel Veillardb8478642001-10-12 17:29:10 +0000772__xmlDefaultSAXHandler(void) {
773 if (IS_MAIN_THREAD)
774 return (&xmlDefaultSAXHandler);
775 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000776 return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000777}
Daniel Veillard81273902003-09-30 00:43:48 +0000778#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillardb8478642001-10-12 17:29:10 +0000779
Daniel Veillardb8478642001-10-12 17:29:10 +0000780#undef xmlDefaultSAXLocator
781xmlSAXLocator *
782__xmlDefaultSAXLocator(void) {
783 if (IS_MAIN_THREAD)
784 return (&xmlDefaultSAXLocator);
785 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000786 return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
Daniel Veillardb8478642001-10-12 17:29:10 +0000787}
788
Daniel Veillardb8478642001-10-12 17:29:10 +0000789#undef xmlDoValidityCheckingDefaultValue
790int *
791__xmlDoValidityCheckingDefaultValue(void) {
792 if (IS_MAIN_THREAD)
793 return (&xmlDoValidityCheckingDefaultValue);
794 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000795 return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000796}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000797int xmlThrDefDoValidityCheckingDefaultValue(int v) {
798 int ret;
799 xmlMutexLock(xmlThrDefMutex);
800 ret = xmlDoValidityCheckingDefaultValueThrDef;
801 xmlDoValidityCheckingDefaultValueThrDef = v;
802 xmlMutexUnlock(xmlThrDefMutex);
803 return ret;
804}
Daniel Veillardb8478642001-10-12 17:29:10 +0000805
Daniel Veillardb8478642001-10-12 17:29:10 +0000806#undef xmlGenericError
807xmlGenericErrorFunc *
808__xmlGenericError(void) {
809 if (IS_MAIN_THREAD)
810 return (&xmlGenericError);
811 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000812 return (&xmlGetGlobalState()->xmlGenericError);
Daniel Veillardb8478642001-10-12 17:29:10 +0000813}
814
Daniel Veillard659e71e2003-10-10 14:10:40 +0000815#undef xmlStructuredError
816xmlStructuredErrorFunc *
817__xmlStructuredError(void) {
818 if (IS_MAIN_THREAD)
819 return (&xmlStructuredError);
820 else
821 return (&xmlGetGlobalState()->xmlStructuredError);
822}
823
Daniel Veillardb8478642001-10-12 17:29:10 +0000824#undef xmlGenericErrorContext
825void * *
826__xmlGenericErrorContext(void) {
827 if (IS_MAIN_THREAD)
828 return (&xmlGenericErrorContext);
829 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000830 return (&xmlGetGlobalState()->xmlGenericErrorContext);
Daniel Veillardb8478642001-10-12 17:29:10 +0000831}
832
Daniel Veillardb8478642001-10-12 17:29:10 +0000833#undef xmlGetWarningsDefaultValue
834int *
835__xmlGetWarningsDefaultValue(void) {
836 if (IS_MAIN_THREAD)
837 return (&xmlGetWarningsDefaultValue);
838 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000839 return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000840}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000841int xmlThrDefGetWarningsDefaultValue(int v) {
842 int ret;
843 xmlMutexLock(xmlThrDefMutex);
844 ret = xmlGetWarningsDefaultValueThrDef;
845 xmlGetWarningsDefaultValueThrDef = 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 xmlIndentTreeOutput
851int *
852__xmlIndentTreeOutput(void) {
853 if (IS_MAIN_THREAD)
854 return (&xmlIndentTreeOutput);
855 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000856 return (&xmlGetGlobalState()->xmlIndentTreeOutput);
Daniel Veillardb8478642001-10-12 17:29:10 +0000857}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000858int xmlThrDefIndentTreeOutput(int v) {
859 int ret;
860 xmlMutexLock(xmlThrDefMutex);
861 ret = xmlIndentTreeOutputThrDef;
862 xmlIndentTreeOutputThrDef = v;
863 xmlMutexUnlock(xmlThrDefMutex);
864 return ret;
865}
Daniel Veillardb8478642001-10-12 17:29:10 +0000866
Aleksey Sanin23002562002-05-24 07:18:40 +0000867#undef xmlTreeIndentString
868const char * *
869__xmlTreeIndentString(void) {
870 if (IS_MAIN_THREAD)
871 return (&xmlTreeIndentString);
872 else
873 return (&xmlGetGlobalState()->xmlTreeIndentString);
874}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000875const char * xmlThrDefTreeIndentString(const char * v) {
876 const char * ret;
877 xmlMutexLock(xmlThrDefMutex);
878 ret = xmlTreeIndentStringThrDef;
879 xmlTreeIndentStringThrDef = v;
880 xmlMutexUnlock(xmlThrDefMutex);
881 return ret;
882}
Aleksey Sanin23002562002-05-24 07:18:40 +0000883
Daniel Veillardb8478642001-10-12 17:29:10 +0000884#undef xmlKeepBlanksDefaultValue
885int *
886__xmlKeepBlanksDefaultValue(void) {
887 if (IS_MAIN_THREAD)
888 return (&xmlKeepBlanksDefaultValue);
889 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000890 return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000891}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000892int xmlThrDefKeepBlanksDefaultValue(int v) {
893 int ret;
894 xmlMutexLock(xmlThrDefMutex);
895 ret = xmlKeepBlanksDefaultValueThrDef;
896 xmlKeepBlanksDefaultValueThrDef = v;
897 xmlMutexUnlock(xmlThrDefMutex);
898 return ret;
899}
Daniel Veillardb8478642001-10-12 17:29:10 +0000900
Daniel Veillardb8478642001-10-12 17:29:10 +0000901#undef xmlLineNumbersDefaultValue
902int *
903__xmlLineNumbersDefaultValue(void) {
904 if (IS_MAIN_THREAD)
905 return (&xmlLineNumbersDefaultValue);
906 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000907 return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000908}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000909int xmlThrDefLineNumbersDefaultValue(int v) {
910 int ret;
911 xmlMutexLock(xmlThrDefMutex);
912 ret = xmlLineNumbersDefaultValueThrDef;
913 xmlLineNumbersDefaultValueThrDef = v;
914 xmlMutexUnlock(xmlThrDefMutex);
915 return ret;
916}
Daniel Veillardb8478642001-10-12 17:29:10 +0000917
Daniel Veillardb8478642001-10-12 17:29:10 +0000918#undef xmlLoadExtDtdDefaultValue
919int *
920__xmlLoadExtDtdDefaultValue(void) {
921 if (IS_MAIN_THREAD)
922 return (&xmlLoadExtDtdDefaultValue);
923 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000924 return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000925}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000926int xmlThrDefLoadExtDtdDefaultValue(int v) {
927 int ret;
928 xmlMutexLock(xmlThrDefMutex);
929 ret = xmlLoadExtDtdDefaultValueThrDef;
930 xmlLoadExtDtdDefaultValueThrDef = v;
931 xmlMutexUnlock(xmlThrDefMutex);
932 return ret;
933}
Daniel Veillardb8478642001-10-12 17:29:10 +0000934
Daniel Veillardb8478642001-10-12 17:29:10 +0000935#undef xmlParserDebugEntities
936int *
937__xmlParserDebugEntities(void) {
938 if (IS_MAIN_THREAD)
939 return (&xmlParserDebugEntities);
940 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000941 return (&xmlGetGlobalState()->xmlParserDebugEntities);
Daniel Veillardb8478642001-10-12 17:29:10 +0000942}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000943int xmlThrDefParserDebugEntities(int v) {
944 int ret;
945 xmlMutexLock(xmlThrDefMutex);
946 ret = xmlParserDebugEntitiesThrDef;
947 xmlParserDebugEntitiesThrDef = v;
948 xmlMutexUnlock(xmlThrDefMutex);
949 return ret;
950}
Daniel Veillardb8478642001-10-12 17:29:10 +0000951
Daniel Veillardb8478642001-10-12 17:29:10 +0000952#undef xmlParserVersion
953const char * *
954__xmlParserVersion(void) {
955 if (IS_MAIN_THREAD)
956 return (&xmlParserVersion);
957 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000958 return (&xmlGetGlobalState()->xmlParserVersion);
Daniel Veillardb8478642001-10-12 17:29:10 +0000959}
960
Daniel Veillardb8478642001-10-12 17:29:10 +0000961#undef xmlPedanticParserDefaultValue
962int *
963__xmlPedanticParserDefaultValue(void) {
964 if (IS_MAIN_THREAD)
965 return (&xmlPedanticParserDefaultValue);
966 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000967 return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000968}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000969int xmlThrDefPedanticParserDefaultValue(int v) {
970 int ret;
971 xmlMutexLock(xmlThrDefMutex);
972 ret = xmlPedanticParserDefaultValueThrDef;
973 xmlPedanticParserDefaultValueThrDef = 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 xmlSaveNoEmptyTags
979int *
980__xmlSaveNoEmptyTags(void) {
981 if (IS_MAIN_THREAD)
982 return (&xmlSaveNoEmptyTags);
983 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000984 return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
Daniel Veillardb8478642001-10-12 17:29:10 +0000985}
Daniel Veillard781ac8b2003-05-15 22:11:36 +0000986int xmlThrDefSaveNoEmptyTags(int v) {
987 int ret;
988 xmlMutexLock(xmlThrDefMutex);
989 ret = xmlSaveNoEmptyTagsThrDef;
990 xmlSaveNoEmptyTagsThrDef = 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 xmlSubstituteEntitiesDefaultValue
996int *
997__xmlSubstituteEntitiesDefaultValue(void) {
998 if (IS_MAIN_THREAD)
999 return (&xmlSubstituteEntitiesDefaultValue);
1000 else
Daniel Veillardd0463562001-10-13 09:15:48 +00001001 return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +00001002}
Daniel Veillard781ac8b2003-05-15 22:11:36 +00001003int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
1004 int ret;
1005 xmlMutexLock(xmlThrDefMutex);
1006 ret = xmlSubstituteEntitiesDefaultValueThrDef;
1007 xmlSubstituteEntitiesDefaultValueThrDef = v;
1008 xmlMutexUnlock(xmlThrDefMutex);
1009 return ret;
1010}
Daniel Veillard5335dc52003-01-01 20:59:38 +00001011
1012#undef xmlRegisterNodeDefaultValue
1013xmlRegisterNodeFunc *
1014__xmlRegisterNodeDefaultValue(void) {
1015 if (IS_MAIN_THREAD)
1016 return (&xmlRegisterNodeDefaultValue);
1017 else
1018 return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
1019}
1020
1021#undef xmlDeregisterNodeDefaultValue
1022xmlDeregisterNodeFunc *
1023__xmlDeregisterNodeDefaultValue(void) {
1024 if (IS_MAIN_THREAD)
1025 return (&xmlDeregisterNodeDefaultValue);
1026 else
1027 return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
1028}
Daniel Veillard0335a842004-06-02 16:18:40 +00001029
1030#undef xmlParserInputBufferCreateFilenameValue
1031xmlParserInputBufferCreateFilenameFunc *
1032__xmlParserInputBufferCreateFilenameValue(void) {
1033 if (IS_MAIN_THREAD)
1034 return (&xmlParserInputBufferCreateFilenameValue);
1035 else
1036 return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
1037}
1038
1039#undef xmlOutputBufferCreateFilenameValue
1040xmlOutputBufferCreateFilenameFunc *
1041__xmlOutputBufferCreateFilenameValue(void) {
1042 if (IS_MAIN_THREAD)
1043 return (&xmlOutputBufferCreateFilenameValue);
1044 else
1045 return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
William M. Brack803812b2004-06-03 02:11:24 +00001046}