• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
14 #define IN_LIBXML
15 #include "libxml.h"
16 
17 #include <stdlib.h>
18 #include <string.h>
19 
20 #include <libxml/globals.h>
21 #include <libxml/xmlmemory.h>
22 #include <libxml/threads.h>
23 
24 #include "private/error.h"
25 #include "private/globals.h"
26 #include "private/threads.h"
27 #include "private/tree.h"
28 
29 /* #define DEBUG_GLOBALS */
30 
31 /*
32  * Helpful Macro
33  */
34 #ifdef LIBXML_THREAD_ENABLED
35 #define IS_MAIN_THREAD (xmlIsMainThread())
36 #else
37 #define IS_MAIN_THREAD 1
38 #endif
39 
40 /*
41  * Mutex to protect "ForNewThreads" variables
42  */
43 static xmlMutex xmlThrDefMutex;
44 
45 /**
46  * xmlInitGlobals:
47  *
48  * DEPRECATED: Alias for xmlInitParser.
49  */
xmlInitGlobals(void)50 void xmlInitGlobals(void) {
51     xmlInitParser();
52 }
53 
54 /**
55  * xmlInitGlobalsInternal:
56  *
57  * Additional initialisation for multi-threading
58  */
xmlInitGlobalsInternal(void)59 void xmlInitGlobalsInternal(void) {
60     xmlInitMutex(&xmlThrDefMutex);
61 }
62 
63 /************************************************************************
64  *									*
65  *	All the user accessible global variables of the library		*
66  *									*
67  ************************************************************************/
68 
69 /*
70  * Memory allocation routines
71  */
72 #undef	xmlFree
73 #undef	xmlMalloc
74 #undef	xmlMallocAtomic
75 #undef	xmlMemStrdup
76 #undef	xmlRealloc
77 
78 #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
79 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
80 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
81 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
82 xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
83 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
84 #else
85 /**
86  * xmlFree:
87  * @mem: an already allocated block of memory
88  *
89  * The variable holding the libxml free() implementation
90  */
91 xmlFreeFunc xmlFree = free;
92 /**
93  * xmlMalloc:
94  * @size:  the size requested in bytes
95  *
96  * The variable holding the libxml malloc() implementation
97  *
98  * Returns a pointer to the newly allocated block or NULL in case of error
99  */
100 xmlMallocFunc xmlMalloc = malloc;
101 /**
102  * xmlMallocAtomic:
103  * @size:  the size requested in bytes
104  *
105  * The variable holding the libxml malloc() implementation for atomic
106  * data (i.e. blocks not containing pointers), useful when using a
107  * garbage collecting allocator.
108  *
109  * Returns a pointer to the newly allocated block or NULL in case of error
110  */
111 xmlMallocFunc xmlMallocAtomic = malloc;
112 /**
113  * xmlRealloc:
114  * @mem: an already allocated block of memory
115  * @size:  the new size requested in bytes
116  *
117  * The variable holding the libxml realloc() implementation
118  *
119  * Returns a pointer to the newly reallocated block or NULL in case of error
120  */
121 xmlReallocFunc xmlRealloc = realloc;
122 /**
123  * xmlPosixStrdup
124  * @cur:  the input char *
125  *
126  * a strdup implementation with a type signature matching POSIX
127  *
128  * Returns a new xmlChar * or NULL
129  */
130 static char *
xmlPosixStrdup(const char * cur)131 xmlPosixStrdup(const char *cur) {
132     return((char*) xmlCharStrdup(cur));
133 }
134 /**
135  * xmlMemStrdup:
136  * @str: a zero terminated string
137  *
138  * The variable holding the libxml strdup() implementation
139  *
140  * Returns the copy of the string or NULL in case of error
141  */
142 xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup;
143 #endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
144 
145 #include <libxml/threads.h>
146 #include <libxml/globals.h>
147 #include <libxml/SAX.h>
148 
149 #undef	htmlDefaultSAXHandler
150 #undef	oldXMLWDcompatibility
151 #undef	xmlBufferAllocScheme
152 #undef	xmlDefaultBufferSize
153 #undef	xmlDefaultSAXHandler
154 #undef	xmlDefaultSAXLocator
155 #undef	xmlDoValidityCheckingDefaultValue
156 #undef	xmlGenericError
157 #undef	xmlStructuredError
158 #undef	xmlGenericErrorContext
159 #undef	xmlStructuredErrorContext
160 #undef	xmlGetWarningsDefaultValue
161 #undef	xmlIndentTreeOutput
162 #undef  xmlTreeIndentString
163 #undef	xmlKeepBlanksDefaultValue
164 #undef	xmlLineNumbersDefaultValue
165 #undef	xmlLoadExtDtdDefaultValue
166 #undef	xmlParserDebugEntities
167 #undef	xmlParserVersion
168 #undef	xmlPedanticParserDefaultValue
169 #undef	xmlSaveNoEmptyTags
170 #undef	xmlSubstituteEntitiesDefaultValue
171 #undef	xmlRegisterNodeDefaultValue
172 #undef	xmlDeregisterNodeDefaultValue
173 #undef	xmlLastError
174 
175 #undef  xmlParserInputBufferCreateFilenameValue
176 #undef  xmlOutputBufferCreateFilenameValue
177 /**
178  * xmlParserVersion:
179  *
180  * Constant string describing the internal version of the library
181  */
182 const char *xmlParserVersion = LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA;
183 
184 /**
185  * xmlBufferAllocScheme:
186  *
187  * DEPRECATED: Don't use.
188  *
189  * Global setting, default allocation policy for buffers, default is
190  * XML_BUFFER_ALLOC_EXACT
191  */
192 xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
193 static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT;
194 /**
195  * xmlDefaultBufferSize:
196  *
197  * DEPRECATED: Don't use.
198  *
199  * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
200  */
201 int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
202 static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
203 
204 /*
205  * Parser defaults
206  */
207 
208 /**
209  * oldXMLWDcompatibility:
210  *
211  * Global setting, DEPRECATED.
212  */
213 int oldXMLWDcompatibility = 0; /* DEPRECATED */
214 /**
215  * xmlParserDebugEntities:
216  *
217  * DEPRECATED: Don't use
218  *
219  * Global setting, asking the parser to print out debugging information.
220  * while handling entities.
221  * Disabled by default
222  */
223 int xmlParserDebugEntities = 0;
224 static int xmlParserDebugEntitiesThrDef = 0;
225 /**
226  * xmlDoValidityCheckingDefaultValue:
227  *
228  * DEPRECATED: Use the modern options API with XML_PARSE_DTDVALID.
229  *
230  * Global setting, indicate that the parser should work in validating mode.
231  * Disabled by default.
232  */
233 int xmlDoValidityCheckingDefaultValue = 0;
234 static int xmlDoValidityCheckingDefaultValueThrDef = 0;
235 /**
236  * xmlGetWarningsDefaultValue:
237  *
238  * DEPRECATED: Don't use
239  *
240  * Global setting, indicate that the DTD validation should provide warnings.
241  * Activated by default.
242  */
243 int xmlGetWarningsDefaultValue = 1;
244 static int xmlGetWarningsDefaultValueThrDef = 1;
245 /**
246  * xmlLoadExtDtdDefaultValue:
247  *
248  * DEPRECATED: Use the modern options API with XML_PARSE_DTDLOAD.
249  *
250  * Global setting, indicate that the parser should load DTD while not
251  * validating.
252  * Disabled by default.
253  */
254 int xmlLoadExtDtdDefaultValue = 0;
255 static int xmlLoadExtDtdDefaultValueThrDef = 0;
256 /**
257  * xmlPedanticParserDefaultValue:
258  *
259  * DEPRECATED: Use the modern options API with XML_PARSE_PEDANTIC.
260  *
261  * Global setting, indicate that the parser be pedantic
262  * Disabled by default.
263  */
264 int xmlPedanticParserDefaultValue = 0;
265 static int xmlPedanticParserDefaultValueThrDef = 0;
266 /**
267  * xmlLineNumbersDefaultValue:
268  *
269  * DEPRECATED: The modern options API always enables line numbers.
270  *
271  * Global setting, indicate that the parser should store the line number
272  * in the content field of elements in the DOM tree.
273  * Disabled by default since this may not be safe for old classes of
274  * application.
275  */
276 int xmlLineNumbersDefaultValue = 0;
277 static int xmlLineNumbersDefaultValueThrDef = 0;
278 /**
279  * xmlKeepBlanksDefaultValue:
280  *
281  * DEPRECATED: Use the modern options API with XML_PARSE_NOBLANKS.
282  *
283  * Global setting, indicate that the parser should keep all blanks
284  * nodes found in the content
285  * Activated by default, this is actually needed to have the parser
286  * conformant to the XML Recommendation, however the option is kept
287  * for some applications since this was libxml1 default behaviour.
288  */
289 int xmlKeepBlanksDefaultValue = 1;
290 static int xmlKeepBlanksDefaultValueThrDef = 1;
291 /**
292  * xmlSubstituteEntitiesDefaultValue:
293  *
294  * DEPRECATED: Use the modern options API with XML_PARSE_NOENT.
295  *
296  * Global setting, indicate that the parser should not generate entity
297  * references but replace them with the actual content of the entity
298  * Disabled by default, this should be activated when using XPath since
299  * the XPath data model requires entities replacement and the XPath
300  * engine does not handle entities references transparently.
301  */
302 int xmlSubstituteEntitiesDefaultValue = 0;
303 static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
304 
305 /**
306  * xmlRegisterNodeDefaultValue:
307  *
308  * DEPRECATED: Don't use
309  */
310 xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
311 static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
312 
313 /**
314  * xmlDeregisterNodeDefaultValue:
315  *
316  * DEPRECATED: Don't use
317  */
318 xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
319 static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
320 
321 /**
322  * xmlParserInputBufferCreateFilenameValue:
323  *
324  * DEPRECATED: Don't use
325  */
326 xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL;
327 static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL;
328 
329 /**
330  * xmlOutputBufferCreateFilenameValue:
331  *
332  * DEPRECATED: Don't use
333  */
334 xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
335 static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL;
336 
337 /**
338  * xmlGenericError:
339  *
340  * Global setting: function used for generic error callbacks
341  */
342 xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
343 static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
344 /**
345  * xmlStructuredError:
346  *
347  * Global setting: function used for structured error callbacks
348  */
349 xmlStructuredErrorFunc xmlStructuredError = NULL;
350 static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
351 /**
352  * xmlGenericErrorContext:
353  *
354  * Global setting passed to generic error callbacks
355  */
356 void *xmlGenericErrorContext = NULL;
357 static void *xmlGenericErrorContextThrDef = NULL;
358 /**
359  * xmlStructuredErrorContext:
360  *
361  * Global setting passed to structured error callbacks
362  */
363 void *xmlStructuredErrorContext = NULL;
364 static void *xmlStructuredErrorContextThrDef = NULL;
365 xmlError xmlLastError;
366 
367 /*
368  * output defaults
369  */
370 /**
371  * xmlIndentTreeOutput:
372  *
373  * Global setting, asking the serializer to indent the output tree by default
374  * Enabled by default
375  */
376 int xmlIndentTreeOutput = 1;
377 static int xmlIndentTreeOutputThrDef = 1;
378 
379 /**
380  * xmlTreeIndentString:
381  *
382  * The string used to do one-level indent. By default is equal to "  " (two spaces)
383  */
384 const char *xmlTreeIndentString = "  ";
385 static const char *xmlTreeIndentStringThrDef = "  ";
386 
387 /**
388  * xmlSaveNoEmptyTags:
389  *
390  * Global setting, asking the serializer to not output empty tags
391  * as <empty/> but <empty></empty>. those two forms are indistinguishable
392  * once parsed.
393  * Disabled by default
394  */
395 int xmlSaveNoEmptyTags = 0;
396 static int xmlSaveNoEmptyTagsThrDef = 0;
397 
398 #ifdef LIBXML_SAX1_ENABLED
399 /**
400  * xmlDefaultSAXHandler:
401  *
402  * DEPRECATED: This handler is unused and will be removed from future
403  * versions.
404  *
405  * Default SAX version1 handler for XML, builds the DOM tree
406  */
407 xmlSAXHandlerV1 xmlDefaultSAXHandler = {
408     xmlSAX2InternalSubset,
409     xmlSAX2IsStandalone,
410     xmlSAX2HasInternalSubset,
411     xmlSAX2HasExternalSubset,
412     xmlSAX2ResolveEntity,
413     xmlSAX2GetEntity,
414     xmlSAX2EntityDecl,
415     xmlSAX2NotationDecl,
416     xmlSAX2AttributeDecl,
417     xmlSAX2ElementDecl,
418     xmlSAX2UnparsedEntityDecl,
419     xmlSAX2SetDocumentLocator,
420     xmlSAX2StartDocument,
421     xmlSAX2EndDocument,
422     xmlSAX2StartElement,
423     xmlSAX2EndElement,
424     xmlSAX2Reference,
425     xmlSAX2Characters,
426     xmlSAX2Characters,
427     xmlSAX2ProcessingInstruction,
428     xmlSAX2Comment,
429     xmlParserWarning,
430     xmlParserError,
431     xmlParserError,
432     xmlSAX2GetParameterEntity,
433     xmlSAX2CDataBlock,
434     xmlSAX2ExternalSubset,
435     1,
436 };
437 #endif /* LIBXML_SAX1_ENABLED */
438 
439 /**
440  * xmlDefaultSAXLocator:
441  *
442  * DEPRECATED: Don't use
443  *
444  * The default SAX Locator
445  * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
446  */
447 xmlSAXLocator xmlDefaultSAXLocator = {
448     xmlSAX2GetPublicId,
449     xmlSAX2GetSystemId,
450     xmlSAX2GetLineNumber,
451     xmlSAX2GetColumnNumber
452 };
453 
454 #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_SAX1_ENABLED)
455 /**
456  * htmlDefaultSAXHandler:
457  *
458  * DEPRECATED: This handler is unused and will be removed from future
459  * versions.
460  *
461  * Default old SAX v1 handler for HTML, builds the DOM tree
462  */
463 xmlSAXHandlerV1 htmlDefaultSAXHandler = {
464     xmlSAX2InternalSubset,
465     NULL,
466     NULL,
467     NULL,
468     NULL,
469     xmlSAX2GetEntity,
470     NULL,
471     NULL,
472     NULL,
473     NULL,
474     NULL,
475     xmlSAX2SetDocumentLocator,
476     xmlSAX2StartDocument,
477     xmlSAX2EndDocument,
478     xmlSAX2StartElement,
479     xmlSAX2EndElement,
480     NULL,
481     xmlSAX2Characters,
482     xmlSAX2IgnorableWhitespace,
483     xmlSAX2ProcessingInstruction,
484     xmlSAX2Comment,
485     xmlParserWarning,
486     xmlParserError,
487     xmlParserError,
488     NULL,
489     xmlSAX2CDataBlock,
490     NULL,
491     1,
492 };
493 #endif /* LIBXML_HTML_ENABLED */
494 
495 /**
496  * xmlInitializeGlobalState:
497  * @gs: a pointer to a newly allocated global state
498  *
499  * xmlInitializeGlobalState() initialize a global state with all the
500  * default values of the library.
501  */
502 void
xmlInitializeGlobalState(xmlGlobalStatePtr gs)503 xmlInitializeGlobalState(xmlGlobalStatePtr gs)
504 {
505 #ifdef DEBUG_GLOBALS
506     fprintf(stderr, "Initializing globals at %p for thread %d\n",
507 	    (void *) gs, xmlGetThreadId());
508 #endif
509 
510     xmlMutexLock(&xmlThrDefMutex);
511 
512 #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
513     inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
514 #endif
515 
516     gs->oldXMLWDcompatibility = 0;
517     gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
518     gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
519 #if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
520     initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
521 #endif /* LIBXML_SAX1_ENABLED */
522     gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
523     gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
524     gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
525     gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
526     gs->xmlDoValidityCheckingDefaultValue =
527          xmlDoValidityCheckingDefaultValueThrDef;
528 #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
529     gs->xmlFree = (xmlFreeFunc) xmlMemFree;
530     gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
531     gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
532     gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
533     gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
534 #else
535     gs->xmlFree = (xmlFreeFunc) free;
536     gs->xmlMalloc = (xmlMallocFunc) malloc;
537     gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
538     gs->xmlRealloc = (xmlReallocFunc) realloc;
539     gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
540 #endif
541     gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
542     gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
543     gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
544     gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
545     gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
546     gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
547     gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
548     gs->xmlParserVersion = LIBXML_VERSION_STRING;
549     gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
550     gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
551     gs->xmlSubstituteEntitiesDefaultValue =
552         xmlSubstituteEntitiesDefaultValueThrDef;
553 
554     gs->xmlGenericError = xmlGenericErrorThrDef;
555     gs->xmlStructuredError = xmlStructuredErrorThrDef;
556     gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
557     gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
558     gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
559     gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
560 
561 	gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
562 	gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
563     memset(&gs->xmlLastError, 0, sizeof(xmlError));
564 
565     xmlMutexUnlock(&xmlThrDefMutex);
566 }
567 
568 /**
569  * xmlCleanupGlobals:
570  *
571  * DEPRECATED: This function is a no-op. Call xmlCleanupParser
572  * to free global state but see the warnings there. xmlCleanupParser
573  * should be only called once at program exit. In most cases, you don't
574  * have call cleanup functions at all.
575  */
xmlCleanupGlobals(void)576 void xmlCleanupGlobals(void) {
577 }
578 
579 /**
580  * xmlCleanupGlobalsInternal:
581  *
582  * Additional cleanup for multi-threading
583  */
xmlCleanupGlobalsInternal(void)584 void xmlCleanupGlobalsInternal(void) {
585     xmlResetError(&xmlLastError);
586 
587     xmlCleanupMutex(&xmlThrDefMutex);
588     __xmlGlobalInitMutexDestroy();
589 }
590 
591 void
xmlThrDefSetGenericErrorFunc(void * ctx,xmlGenericErrorFunc handler)592 xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
593     xmlMutexLock(&xmlThrDefMutex);
594     xmlGenericErrorContextThrDef = ctx;
595     if (handler != NULL)
596 	xmlGenericErrorThrDef = handler;
597     else
598 	xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
599     xmlMutexUnlock(&xmlThrDefMutex);
600 }
601 
602 void
xmlThrDefSetStructuredErrorFunc(void * ctx,xmlStructuredErrorFunc handler)603 xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
604     xmlMutexLock(&xmlThrDefMutex);
605     xmlStructuredErrorContextThrDef = ctx;
606     xmlStructuredErrorThrDef = handler;
607     xmlMutexUnlock(&xmlThrDefMutex);
608 }
609 
610 /**
611  * xmlRegisterNodeDefault:
612  * @func: function pointer to the new RegisterNodeFunc
613  *
614  * Registers a callback for node creation
615  *
616  * Returns the old value of the registration function
617  */
618 xmlRegisterNodeFunc
xmlRegisterNodeDefault(xmlRegisterNodeFunc func)619 xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
620 {
621     xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
622 
623     __xmlRegisterCallbacks = 1;
624     xmlRegisterNodeDefaultValue = func;
625     return(old);
626 }
627 
628 xmlRegisterNodeFunc
xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)629 xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
630 {
631     xmlRegisterNodeFunc old;
632 
633     xmlMutexLock(&xmlThrDefMutex);
634     old = xmlRegisterNodeDefaultValueThrDef;
635 
636     __xmlRegisterCallbacks = 1;
637     xmlRegisterNodeDefaultValueThrDef = func;
638     xmlMutexUnlock(&xmlThrDefMutex);
639 
640     return(old);
641 }
642 
643 /**
644  * xmlDeregisterNodeDefault:
645  * @func: function pointer to the new DeregisterNodeFunc
646  *
647  * Registers a callback for node destruction
648  *
649  * Returns the previous value of the deregistration function
650  */
651 xmlDeregisterNodeFunc
xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)652 xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
653 {
654     xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
655 
656     __xmlRegisterCallbacks = 1;
657     xmlDeregisterNodeDefaultValue = func;
658     return(old);
659 }
660 
661 xmlDeregisterNodeFunc
xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)662 xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
663 {
664     xmlDeregisterNodeFunc old;
665 
666     xmlMutexLock(&xmlThrDefMutex);
667     old = xmlDeregisterNodeDefaultValueThrDef;
668 
669     __xmlRegisterCallbacks = 1;
670     xmlDeregisterNodeDefaultValueThrDef = func;
671     xmlMutexUnlock(&xmlThrDefMutex);
672 
673     return(old);
674 }
675 
676 xmlParserInputBufferCreateFilenameFunc
xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)677 xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
678 {
679     xmlParserInputBufferCreateFilenameFunc old;
680 
681     xmlMutexLock(&xmlThrDefMutex);
682     old = xmlParserInputBufferCreateFilenameValueThrDef;
683     if (old == NULL) {
684 		old = __xmlParserInputBufferCreateFilename;
685 	}
686 
687     xmlParserInputBufferCreateFilenameValueThrDef = func;
688     xmlMutexUnlock(&xmlThrDefMutex);
689 
690     return(old);
691 }
692 
693 xmlOutputBufferCreateFilenameFunc
xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)694 xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
695 {
696     xmlOutputBufferCreateFilenameFunc old;
697 
698     xmlMutexLock(&xmlThrDefMutex);
699     old = xmlOutputBufferCreateFilenameValueThrDef;
700 #ifdef LIBXML_OUTPUT_ENABLED
701     if (old == NULL) {
702 		old = __xmlOutputBufferCreateFilename;
703 	}
704 #endif
705     xmlOutputBufferCreateFilenameValueThrDef = func;
706     xmlMutexUnlock(&xmlThrDefMutex);
707 
708     return(old);
709 }
710 
711 #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_SAX1_ENABLED)
712 #undef	htmlDefaultSAXHandler
713 xmlSAXHandlerV1 *
__htmlDefaultSAXHandler(void)714 __htmlDefaultSAXHandler(void) {
715     if (IS_MAIN_THREAD)
716 	return (&htmlDefaultSAXHandler);
717     else
718 	return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
719 }
720 #endif
721 
722 #undef xmlLastError
723 xmlError *
__xmlLastError(void)724 __xmlLastError(void) {
725     if (IS_MAIN_THREAD)
726 	return (&xmlLastError);
727     else
728 	return (&xmlGetGlobalState()->xmlLastError);
729 }
730 
731 /*
732  * The following memory routines were apparently lost at some point,
733  * and were re-inserted at this point on June 10, 2004.  Hope it's
734  * the right place for them :-)
735  */
736 #if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED)
737 #undef xmlMalloc
738 xmlMallocFunc *
__xmlMalloc(void)739 __xmlMalloc(void){
740     if (IS_MAIN_THREAD)
741         return (&xmlMalloc);
742     else
743 	return (&xmlGetGlobalState()->xmlMalloc);
744 }
745 
746 #undef xmlMallocAtomic
747 xmlMallocFunc *
__xmlMallocAtomic(void)748 __xmlMallocAtomic(void){
749     if (IS_MAIN_THREAD)
750         return (&xmlMallocAtomic);
751     else
752         return (&xmlGetGlobalState()->xmlMallocAtomic);
753 }
754 
755 #undef xmlRealloc
756 xmlReallocFunc *
__xmlRealloc(void)757 __xmlRealloc(void){
758     if (IS_MAIN_THREAD)
759         return (&xmlRealloc);
760     else
761         return (&xmlGetGlobalState()->xmlRealloc);
762 }
763 
764 #undef xmlFree
765 xmlFreeFunc *
__xmlFree(void)766 __xmlFree(void){
767     if (IS_MAIN_THREAD)
768         return (&xmlFree);
769     else
770         return (&xmlGetGlobalState()->xmlFree);
771 }
772 
773 xmlStrdupFunc *
__xmlMemStrdup(void)774 __xmlMemStrdup(void){
775     if (IS_MAIN_THREAD)
776         return (&xmlMemStrdup);
777     else
778         return (&xmlGetGlobalState()->xmlMemStrdup);
779 }
780 
781 #endif
782 
783 /*
784  * Everything starting from the line below is
785  * Automatically generated by build_glob.py.
786  * Do not modify the previous line.
787  */
788 
789 
790 #undef	oldXMLWDcompatibility
791 int *
__oldXMLWDcompatibility(void)792 __oldXMLWDcompatibility(void) {
793     if (IS_MAIN_THREAD)
794 	return (&oldXMLWDcompatibility);
795     else
796 	return (&xmlGetGlobalState()->oldXMLWDcompatibility);
797 }
798 
799 #undef	xmlBufferAllocScheme
800 xmlBufferAllocationScheme *
__xmlBufferAllocScheme(void)801 __xmlBufferAllocScheme(void) {
802     if (IS_MAIN_THREAD)
803 	return (&xmlBufferAllocScheme);
804     else
805 	return (&xmlGetGlobalState()->xmlBufferAllocScheme);
806 }
xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v)807 xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
808     xmlBufferAllocationScheme ret;
809     xmlMutexLock(&xmlThrDefMutex);
810     ret = xmlBufferAllocSchemeThrDef;
811     xmlBufferAllocSchemeThrDef = v;
812     xmlMutexUnlock(&xmlThrDefMutex);
813     return ret;
814 }
815 
816 #undef	xmlDefaultBufferSize
817 int *
__xmlDefaultBufferSize(void)818 __xmlDefaultBufferSize(void) {
819     if (IS_MAIN_THREAD)
820 	return (&xmlDefaultBufferSize);
821     else
822 	return (&xmlGetGlobalState()->xmlDefaultBufferSize);
823 }
xmlThrDefDefaultBufferSize(int v)824 int xmlThrDefDefaultBufferSize(int v) {
825     int ret;
826     xmlMutexLock(&xmlThrDefMutex);
827     ret = xmlDefaultBufferSizeThrDef;
828     xmlDefaultBufferSizeThrDef = v;
829     xmlMutexUnlock(&xmlThrDefMutex);
830     return ret;
831 }
832 
833 #ifdef LIBXML_SAX1_ENABLED
834 #undef	xmlDefaultSAXHandler
835 xmlSAXHandlerV1 *
__xmlDefaultSAXHandler(void)836 __xmlDefaultSAXHandler(void) {
837     if (IS_MAIN_THREAD)
838 	return (&xmlDefaultSAXHandler);
839     else
840 	return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
841 }
842 #endif /* LIBXML_SAX1_ENABLED */
843 
844 #undef	xmlDefaultSAXLocator
845 xmlSAXLocator *
__xmlDefaultSAXLocator(void)846 __xmlDefaultSAXLocator(void) {
847     if (IS_MAIN_THREAD)
848 	return (&xmlDefaultSAXLocator);
849     else
850 	return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
851 }
852 
853 #undef	xmlDoValidityCheckingDefaultValue
854 int *
__xmlDoValidityCheckingDefaultValue(void)855 __xmlDoValidityCheckingDefaultValue(void) {
856     if (IS_MAIN_THREAD)
857 	return (&xmlDoValidityCheckingDefaultValue);
858     else
859 	return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
860 }
xmlThrDefDoValidityCheckingDefaultValue(int v)861 int xmlThrDefDoValidityCheckingDefaultValue(int v) {
862     int ret;
863     xmlMutexLock(&xmlThrDefMutex);
864     ret = xmlDoValidityCheckingDefaultValueThrDef;
865     xmlDoValidityCheckingDefaultValueThrDef = v;
866     xmlMutexUnlock(&xmlThrDefMutex);
867     return ret;
868 }
869 
870 #undef	xmlGenericError
871 xmlGenericErrorFunc *
__xmlGenericError(void)872 __xmlGenericError(void) {
873     if (IS_MAIN_THREAD)
874 	return (&xmlGenericError);
875     else
876 	return (&xmlGetGlobalState()->xmlGenericError);
877 }
878 
879 #undef	xmlStructuredError
880 xmlStructuredErrorFunc *
__xmlStructuredError(void)881 __xmlStructuredError(void) {
882     if (IS_MAIN_THREAD)
883 	return (&xmlStructuredError);
884     else
885 	return (&xmlGetGlobalState()->xmlStructuredError);
886 }
887 
888 #undef	xmlGenericErrorContext
889 void * *
__xmlGenericErrorContext(void)890 __xmlGenericErrorContext(void) {
891     if (IS_MAIN_THREAD)
892 	return (&xmlGenericErrorContext);
893     else
894 	return (&xmlGetGlobalState()->xmlGenericErrorContext);
895 }
896 
897 #undef	xmlStructuredErrorContext
898 void * *
__xmlStructuredErrorContext(void)899 __xmlStructuredErrorContext(void) {
900     if (IS_MAIN_THREAD)
901 	return (&xmlStructuredErrorContext);
902     else
903 	return (&xmlGetGlobalState()->xmlStructuredErrorContext);
904 }
905 
906 #undef	xmlGetWarningsDefaultValue
907 int *
__xmlGetWarningsDefaultValue(void)908 __xmlGetWarningsDefaultValue(void) {
909     if (IS_MAIN_THREAD)
910 	return (&xmlGetWarningsDefaultValue);
911     else
912 	return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
913 }
xmlThrDefGetWarningsDefaultValue(int v)914 int xmlThrDefGetWarningsDefaultValue(int v) {
915     int ret;
916     xmlMutexLock(&xmlThrDefMutex);
917     ret = xmlGetWarningsDefaultValueThrDef;
918     xmlGetWarningsDefaultValueThrDef = v;
919     xmlMutexUnlock(&xmlThrDefMutex);
920     return ret;
921 }
922 
923 #undef	xmlIndentTreeOutput
924 int *
__xmlIndentTreeOutput(void)925 __xmlIndentTreeOutput(void) {
926     if (IS_MAIN_THREAD)
927 	return (&xmlIndentTreeOutput);
928     else
929 	return (&xmlGetGlobalState()->xmlIndentTreeOutput);
930 }
xmlThrDefIndentTreeOutput(int v)931 int xmlThrDefIndentTreeOutput(int v) {
932     int ret;
933     xmlMutexLock(&xmlThrDefMutex);
934     ret = xmlIndentTreeOutputThrDef;
935     xmlIndentTreeOutputThrDef = v;
936     xmlMutexUnlock(&xmlThrDefMutex);
937     return ret;
938 }
939 
940 #undef	xmlTreeIndentString
941 const char * *
__xmlTreeIndentString(void)942 __xmlTreeIndentString(void) {
943     if (IS_MAIN_THREAD)
944 	return (&xmlTreeIndentString);
945     else
946 	return (&xmlGetGlobalState()->xmlTreeIndentString);
947 }
xmlThrDefTreeIndentString(const char * v)948 const char * xmlThrDefTreeIndentString(const char * v) {
949     const char * ret;
950     xmlMutexLock(&xmlThrDefMutex);
951     ret = xmlTreeIndentStringThrDef;
952     xmlTreeIndentStringThrDef = v;
953     xmlMutexUnlock(&xmlThrDefMutex);
954     return ret;
955 }
956 
957 #undef	xmlKeepBlanksDefaultValue
958 int *
__xmlKeepBlanksDefaultValue(void)959 __xmlKeepBlanksDefaultValue(void) {
960     if (IS_MAIN_THREAD)
961 	return (&xmlKeepBlanksDefaultValue);
962     else
963 	return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
964 }
xmlThrDefKeepBlanksDefaultValue(int v)965 int xmlThrDefKeepBlanksDefaultValue(int v) {
966     int ret;
967     xmlMutexLock(&xmlThrDefMutex);
968     ret = xmlKeepBlanksDefaultValueThrDef;
969     xmlKeepBlanksDefaultValueThrDef = v;
970     xmlMutexUnlock(&xmlThrDefMutex);
971     return ret;
972 }
973 
974 #undef	xmlLineNumbersDefaultValue
975 int *
__xmlLineNumbersDefaultValue(void)976 __xmlLineNumbersDefaultValue(void) {
977     if (IS_MAIN_THREAD)
978 	return (&xmlLineNumbersDefaultValue);
979     else
980 	return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
981 }
xmlThrDefLineNumbersDefaultValue(int v)982 int xmlThrDefLineNumbersDefaultValue(int v) {
983     int ret;
984     xmlMutexLock(&xmlThrDefMutex);
985     ret = xmlLineNumbersDefaultValueThrDef;
986     xmlLineNumbersDefaultValueThrDef = v;
987     xmlMutexUnlock(&xmlThrDefMutex);
988     return ret;
989 }
990 
991 #undef	xmlLoadExtDtdDefaultValue
992 int *
__xmlLoadExtDtdDefaultValue(void)993 __xmlLoadExtDtdDefaultValue(void) {
994     if (IS_MAIN_THREAD)
995 	return (&xmlLoadExtDtdDefaultValue);
996     else
997 	return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
998 }
xmlThrDefLoadExtDtdDefaultValue(int v)999 int xmlThrDefLoadExtDtdDefaultValue(int v) {
1000     int ret;
1001     xmlMutexLock(&xmlThrDefMutex);
1002     ret = xmlLoadExtDtdDefaultValueThrDef;
1003     xmlLoadExtDtdDefaultValueThrDef = v;
1004     xmlMutexUnlock(&xmlThrDefMutex);
1005     return ret;
1006 }
1007 
1008 #undef	xmlParserDebugEntities
1009 int *
__xmlParserDebugEntities(void)1010 __xmlParserDebugEntities(void) {
1011     if (IS_MAIN_THREAD)
1012 	return (&xmlParserDebugEntities);
1013     else
1014 	return (&xmlGetGlobalState()->xmlParserDebugEntities);
1015 }
xmlThrDefParserDebugEntities(int v)1016 int xmlThrDefParserDebugEntities(int v) {
1017     int ret;
1018     xmlMutexLock(&xmlThrDefMutex);
1019     ret = xmlParserDebugEntitiesThrDef;
1020     xmlParserDebugEntitiesThrDef = v;
1021     xmlMutexUnlock(&xmlThrDefMutex);
1022     return ret;
1023 }
1024 
1025 #undef	xmlParserVersion
1026 const char * *
__xmlParserVersion(void)1027 __xmlParserVersion(void) {
1028     if (IS_MAIN_THREAD)
1029 	return (&xmlParserVersion);
1030     else
1031 	return (&xmlGetGlobalState()->xmlParserVersion);
1032 }
1033 
1034 #undef	xmlPedanticParserDefaultValue
1035 int *
__xmlPedanticParserDefaultValue(void)1036 __xmlPedanticParserDefaultValue(void) {
1037     if (IS_MAIN_THREAD)
1038 	return (&xmlPedanticParserDefaultValue);
1039     else
1040 	return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
1041 }
xmlThrDefPedanticParserDefaultValue(int v)1042 int xmlThrDefPedanticParserDefaultValue(int v) {
1043     int ret;
1044     xmlMutexLock(&xmlThrDefMutex);
1045     ret = xmlPedanticParserDefaultValueThrDef;
1046     xmlPedanticParserDefaultValueThrDef = v;
1047     xmlMutexUnlock(&xmlThrDefMutex);
1048     return ret;
1049 }
1050 
1051 #undef	xmlSaveNoEmptyTags
1052 int *
__xmlSaveNoEmptyTags(void)1053 __xmlSaveNoEmptyTags(void) {
1054     if (IS_MAIN_THREAD)
1055 	return (&xmlSaveNoEmptyTags);
1056     else
1057 	return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
1058 }
xmlThrDefSaveNoEmptyTags(int v)1059 int xmlThrDefSaveNoEmptyTags(int v) {
1060     int ret;
1061     xmlMutexLock(&xmlThrDefMutex);
1062     ret = xmlSaveNoEmptyTagsThrDef;
1063     xmlSaveNoEmptyTagsThrDef = v;
1064     xmlMutexUnlock(&xmlThrDefMutex);
1065     return ret;
1066 }
1067 
1068 #undef	xmlSubstituteEntitiesDefaultValue
1069 int *
__xmlSubstituteEntitiesDefaultValue(void)1070 __xmlSubstituteEntitiesDefaultValue(void) {
1071     if (IS_MAIN_THREAD)
1072 	return (&xmlSubstituteEntitiesDefaultValue);
1073     else
1074 	return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
1075 }
xmlThrDefSubstituteEntitiesDefaultValue(int v)1076 int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
1077     int ret;
1078     xmlMutexLock(&xmlThrDefMutex);
1079     ret = xmlSubstituteEntitiesDefaultValueThrDef;
1080     xmlSubstituteEntitiesDefaultValueThrDef = v;
1081     xmlMutexUnlock(&xmlThrDefMutex);
1082     return ret;
1083 }
1084 
1085 #undef	xmlRegisterNodeDefaultValue
1086 xmlRegisterNodeFunc *
__xmlRegisterNodeDefaultValue(void)1087 __xmlRegisterNodeDefaultValue(void) {
1088     if (IS_MAIN_THREAD)
1089 	return (&xmlRegisterNodeDefaultValue);
1090     else
1091 	return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
1092 }
1093 
1094 #undef	xmlDeregisterNodeDefaultValue
1095 xmlDeregisterNodeFunc *
__xmlDeregisterNodeDefaultValue(void)1096 __xmlDeregisterNodeDefaultValue(void) {
1097     if (IS_MAIN_THREAD)
1098 	return (&xmlDeregisterNodeDefaultValue);
1099     else
1100 	return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
1101 }
1102 
1103 #undef	xmlParserInputBufferCreateFilenameValue
1104 xmlParserInputBufferCreateFilenameFunc *
__xmlParserInputBufferCreateFilenameValue(void)1105 __xmlParserInputBufferCreateFilenameValue(void) {
1106     if (IS_MAIN_THREAD)
1107 	return (&xmlParserInputBufferCreateFilenameValue);
1108     else
1109 	return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
1110 }
1111 
1112 #undef	xmlOutputBufferCreateFilenameValue
1113 xmlOutputBufferCreateFilenameFunc *
__xmlOutputBufferCreateFilenameValue(void)1114 __xmlOutputBufferCreateFilenameValue(void) {
1115     if (IS_MAIN_THREAD)
1116 	return (&xmlOutputBufferCreateFilenameValue);
1117     else
1118 	return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
1119 }
1120 
1121