updated libxml2 to 2.5.10
[TestXSLT.git] / libxml2 / globals.c
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 #ifdef HAVE_STDLIB_H
18 #include <stdlib.h>
19 #endif
20 #include <string.h>
21
22 #include <libxml/globals.h>
23 #include <libxml/xmlmemory.h>
24 #include <libxml/threads.h>
25
26 /* #define DEBUG_GLOBALS */
27
28 /*
29  * Helpful Macro
30  */
31 #ifdef LIBXML_THREAD_ENABLED
32 #define IS_MAIN_THREAD (xmlIsMainThread())
33 #else
34 #define IS_MAIN_THREAD 1
35 #endif
36
37 /*
38  * Mutex to protect "ForNewThreads" variables
39  */
40 static xmlMutexPtr xmlThrDefMutex = NULL;
41
42 void xmlInitGlobals()
43 {
44     xmlThrDefMutex = xmlNewMutex();
45 }
46
47 void xmlCleanupGlobals()
48 {
49     if (xmlThrDefMutex != NULL) {
50         xmlFreeMutex(xmlThrDefMutex);
51         xmlThrDefMutex = NULL;
52     }
53 }
54
55 /************************************************************************
56  *                                                                      *
57  *      All the user accessible global variables of the library         *
58  *                                                                      *
59  ************************************************************************/
60
61 /*
62  * Memory allocation routines
63  */
64 #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
65 #ifndef _DEBUG_MEMORY_ALLOC_
66 extern void xmlMemFree(void *ptr);
67 extern void * xmlMemMalloc(size_t size);
68 extern void * xmlMemRealloc(void *ptr,size_t size);
69 extern char * xmlMemoryStrdup(const char *str);
70 #endif
71
72 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
73 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
74 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
75 xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
76 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
77 #else
78 /**
79  * xmlFree:
80  * @mem: an already allocated block of memory
81  *
82  * The variable holding the libxml free() implementation
83  */
84 xmlFreeFunc xmlFree = (xmlFreeFunc) free;
85 /**
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  */
93 xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
94 /**
95  * 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  */
104 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc;
105 /**
106  * 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  */
114 xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
115 /**
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  */
123 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
124 #endif
125
126 #include <libxml/threads.h>
127 #include <libxml/globals.h>
128 #include <libxml/SAX.h>
129
130 #undef  docbDefaultSAXHandler
131 #undef  htmlDefaultSAXHandler
132 #undef  oldXMLWDcompatibility
133 #undef  xmlBufferAllocScheme
134 #undef  xmlDefaultBufferSize
135 #undef  xmlDefaultSAXHandler
136 #undef  xmlDefaultSAXLocator
137 #undef  xmlDoValidityCheckingDefaultValue
138 #undef  xmlGenericError
139 #undef  xmlGenericErrorContext
140 #undef  xmlGetWarningsDefaultValue
141 #undef  xmlIndentTreeOutput
142 #undef  xmlTreeIndentString
143 #undef  xmlKeepBlanksDefaultValue
144 #undef  xmlLineNumbersDefaultValue
145 #undef  xmlLoadExtDtdDefaultValue
146 #undef  xmlParserDebugEntities
147 #undef  xmlParserVersion
148 #undef  xmlPedanticParserDefaultValue
149 #undef  xmlSaveNoEmptyTags
150 #undef  xmlSubstituteEntitiesDefaultValue
151 #undef  xmlRegisterNodeDefaultValue
152 #undef  xmlDeregisterNodeDefaultValue
153
154 #undef  xmlFree
155 #undef  xmlMalloc
156 #undef  xmlMallocAtomic
157 #undef  xmlMemStrdup
158 #undef  xmlRealloc
159
160 /**
161  * xmlParserVersion:
162  *
163  * Constant string describing the internal version of the library
164  */
165 const char *xmlParserVersion = LIBXML_VERSION_STRING;
166
167 /**
168  * xmlBufferAllocScheme:
169  *
170  * Global setting, default allocation policy for buffers, default is
171  * XML_BUFFER_ALLOC_EXACT
172  */
173 xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
174 static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT;
175 /**
176  * xmlDefaultBufferSize:
177  *
178  * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
179  */
180 int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
181 static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
182
183 /*
184  * Parser defaults
185  */
186
187 /**
188  * oldXMLWDcompatibility:
189  *
190  * Global setting, DEPRECATED.
191  */
192 int oldXMLWDcompatibility = 0; /* DEPRECATED */
193 /**
194  * xmlParserDebugEntities:
195  *
196  * Global setting, asking the parser to print out debugging informations.
197  * while handling entities.
198  * Disabled by default
199  */
200 int xmlParserDebugEntities = 0;
201 static int xmlParserDebugEntitiesThrDef = 0;
202 /**
203  * xmlDoValidityCheckingDefaultValue:
204  *
205  * Global setting, indicate that the parser should work in validating mode.
206  * Disabled by default.
207  */
208 int xmlDoValidityCheckingDefaultValue = 0;
209 static int xmlDoValidityCheckingDefaultValueThrDef = 0;
210 /**
211  * xmlGetWarningsDefaultValue:
212  *
213  * Global setting, indicate that the parser should provide warnings.
214  * Activated by default.
215  */
216 int xmlGetWarningsDefaultValue = 1;
217 static int xmlGetWarningsDefaultValueThrDef = 1;
218 /**
219  * xmlLoadExtDtdDefaultValue:
220  *
221  * Global setting, indicate that the parser should load DTD while not
222  * validating.
223  * Disabled by default.
224  */
225 int xmlLoadExtDtdDefaultValue = 0;
226 static int xmlLoadExtDtdDefaultValueThrDef = 0;
227 /**
228  * xmlPedanticParserDefaultValue:
229  *
230  * Global setting, indicate that the parser be pedantic
231  * Disabled by default.
232  */
233 int xmlPedanticParserDefaultValue = 0;
234 static int xmlPedanticParserDefaultValueThrDef = 0;
235 /**
236  * xmlLineNumbersDefaultValue:
237  *
238  * Global setting, indicate that the parser should store the line number
239  * in the content field of elements in the DOM tree. 
240  * Disabled by default since this may not be safe for old classes of
241  * applicaton.
242  */
243 int xmlLineNumbersDefaultValue = 0;
244 static int xmlLineNumbersDefaultValueThrDef = 0;
245 /**
246  * xmlKeepBlanksDefaultValue:
247  *
248  * Global setting, indicate that the parser should keep all blanks
249  * nodes found in the content
250  * Activated by default, this is actually needed to have the parser
251  * conformant to the XML Recommendation, however the option is kept
252  * for some applications since this was libxml1 default behaviour.
253  */
254 int xmlKeepBlanksDefaultValue = 1;
255 static int xmlKeepBlanksDefaultValueThrDef = 1;
256 /**
257  * xmlSubstituteEntitiesDefaultValue:
258  *
259  * Global setting, indicate that the parser should not generate entity
260  * references but replace them with the actual content of the entity
261  * Disabled by default, this should be activated when using XPath since
262  * the XPath data model requires entities replacement and the XPath
263  * engine does not handle entities references transparently.
264  */
265 int xmlSubstituteEntitiesDefaultValue = 0;
266 static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
267
268 xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
269 static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
270 xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
271 static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
272
273 /*
274  * Error handling
275  */
276
277 /* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
278 /* Must initialize xmlGenericError in xmlInitParser */
279 void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
280                                  const char *msg,
281                                  ...);
282 /**
283  * xmlGenericError:
284  *
285  * Global setting: function used for generic error callbacks
286  */
287 xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
288 static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
289 /**
290  * xmlGenericErrorContext:
291  *
292  * Global setting passed to generic error callbacks
293  */
294 void *xmlGenericErrorContext = NULL;
295 static void *xmlGenericErrorContextThrDef = NULL;
296
297 /*
298  * output defaults
299  */
300 /**
301  * xmlIndentTreeOutput:
302  *
303  * Global setting, asking the serializer to indent the output tree by default
304  * Enabled by default
305  */
306 int xmlIndentTreeOutput = 1;
307 static int xmlIndentTreeOutputThrDef = 1;
308
309 /**
310  * xmlTreeIndentString:
311  *
312  * The string used to do one-level indent. By default is equal to "  " (two spaces)
313  */
314 const char *xmlTreeIndentString = "  ";
315 static const char *xmlTreeIndentStringThrDef = "  ";
316
317 /**
318  * xmlSaveNoEmptyTags:
319  *
320  * Global setting, asking the serializer to not output empty tags
321  * as <empty/> but <empty></empty>. those two forms are undistinguishable
322  * once parsed.
323  * Disabled by default
324  */
325 int xmlSaveNoEmptyTags = 0;
326 int xmlSaveNoEmptyTagsThrDef = 0;
327
328 /**
329  * xmlDefaultSAXHandler:
330  *
331  * Default handler for XML, builds the DOM tree
332  */
333 xmlSAXHandler xmlDefaultSAXHandler = {
334     internalSubset,
335     isStandalone,
336     hasInternalSubset,
337     hasExternalSubset,
338     resolveEntity,
339     getEntity,
340     entityDecl,
341     notationDecl,
342     attributeDecl,
343     elementDecl,
344     unparsedEntityDecl,
345     setDocumentLocator,
346     startDocument,
347     endDocument,
348     startElement,
349     endElement,
350     reference,
351     characters,
352     characters,
353     processingInstruction,
354     comment,
355     xmlParserWarning,
356     xmlParserError,
357     xmlParserError,
358     getParameterEntity,
359     cdataBlock,
360     externalSubset,
361     0
362 };
363
364 /**
365  * xmlDefaultSAXLocator:
366  *
367  * The default SAX Locator
368  * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
369  */
370 xmlSAXLocator xmlDefaultSAXLocator = {
371     getPublicId, getSystemId, getLineNumber, getColumnNumber
372 };
373
374 #ifdef LIBXML_HTML_ENABLED
375 /**
376  * htmlDefaultSAXHandler:
377  *
378  * Default handler for HTML, builds the DOM tree
379  */
380 xmlSAXHandler htmlDefaultSAXHandler = {
381     internalSubset,
382     NULL,
383     NULL,
384     NULL,
385     NULL,
386     getEntity,
387     NULL,
388     NULL,
389     NULL,
390     NULL,
391     NULL,
392     setDocumentLocator,
393     startDocument,
394     endDocument,
395     startElement,
396     endElement,
397     NULL,
398     characters,
399     ignorableWhitespace,
400     NULL,
401     comment,
402     xmlParserWarning,
403     xmlParserError,
404     xmlParserError,
405     getParameterEntity,
406     cdataBlock,
407     NULL,
408     0
409 };
410 #endif /* LIBXML_HTML_ENABLED */
411
412 #ifdef LIBXML_DOCB_ENABLED
413 /**
414  * docbDefaultSAXHandler:
415  *
416  * Default handler for SGML DocBook, builds the DOM tree
417  */
418 xmlSAXHandler docbDefaultSAXHandler = {
419     internalSubset,
420     isStandalone,
421     hasInternalSubset,
422     hasExternalSubset,
423     resolveEntity,
424     getEntity,
425     entityDecl,
426     NULL,
427     NULL,
428     NULL,
429     NULL,
430     setDocumentLocator,
431     startDocument,
432     endDocument,
433     startElement,
434     endElement,
435     reference,
436     characters,
437     ignorableWhitespace,
438     NULL,
439     comment,
440     xmlParserWarning,
441     xmlParserError,
442     xmlParserError,
443     getParameterEntity,
444     NULL,
445     NULL,
446     0
447 };
448 #endif /* LIBXML_DOCB_ENABLED */
449
450 /**
451  * xmlInitializeGlobalState:
452  * @gs: a pointer to a newly allocated global state
453  *
454  * xmlInitializeGlobalState() initialize a global state with all the
455  * default values of the library.
456  */
457 void
458 xmlInitializeGlobalState(xmlGlobalStatePtr gs)
459 {
460 #ifdef DEBUG_GLOBALS
461     fprintf(stderr, "Initializing globals at %lu for thread %d\n",
462             (unsigned long) gs, xmlGetThreadId());
463 #endif
464
465     /*
466      * Perform initialization as required by libxml
467      */
468     xmlMutexLock(xmlThrDefMutex);
469
470 #ifdef LIBXML_DOCB_ENABLED
471     initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
472 #endif
473 #ifdef LIBXML_HTML_ENABLED
474     inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
475 #endif
476
477     gs->oldXMLWDcompatibility = 0;
478     gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
479     gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
480     initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
481     gs->xmlDefaultSAXLocator.getPublicId = getPublicId;
482     gs->xmlDefaultSAXLocator.getSystemId = getSystemId;
483     gs->xmlDefaultSAXLocator.getLineNumber = getLineNumber;
484     gs->xmlDefaultSAXLocator.getColumnNumber = getColumnNumber;
485     gs->xmlDoValidityCheckingDefaultValue = 
486          xmlDoValidityCheckingDefaultValueThrDef;
487 #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
488     gs->xmlFree = (xmlFreeFunc) xmlMemFree;
489     gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
490     gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
491     gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
492     gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
493 #else
494     gs->xmlFree = (xmlFreeFunc) free;
495     gs->xmlMalloc = (xmlMallocFunc) malloc;
496     gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
497     gs->xmlRealloc = (xmlReallocFunc) realloc;
498     gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
499 #endif
500     gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
501     gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
502     gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
503     gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
504     gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
505     gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
506     gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
507     gs->xmlParserVersion = LIBXML_VERSION_STRING;
508     gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
509     gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
510     gs->xmlSubstituteEntitiesDefaultValue = 
511         xmlSubstituteEntitiesDefaultValueThrDef;
512
513     gs->xmlGenericError = xmlGenericErrorThrDef;
514     gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
515     gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
516     gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
517
518     xmlMutexUnlock(xmlThrDefMutex);
519 }
520
521 void
522 xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
523     xmlMutexLock(xmlThrDefMutex);
524     xmlGenericErrorContextThrDef = ctx;
525     if (handler != NULL)
526         xmlGenericErrorThrDef = handler;
527     else
528         xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
529     xmlMutexUnlock(xmlThrDefMutex);
530 }
531
532 /**
533  * xmlRegisterNodeDefault:
534  * @func: function pointer to the new RegisterNodeFunc
535  *
536  * Registers a callback for node creation
537  *
538  * Returns the old value of the registration function
539  */
540 xmlRegisterNodeFunc
541 xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
542 {
543     xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
544     
545     __xmlRegisterCallbacks = 1;
546     xmlRegisterNodeDefaultValue = func;
547     return(old);
548 }
549
550 xmlRegisterNodeFunc
551 xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
552 {
553     xmlRegisterNodeFunc old;
554     
555     xmlMutexLock(xmlThrDefMutex);
556     old = xmlRegisterNodeDefaultValueThrDef;
557     
558     __xmlRegisterCallbacks = 1;
559     xmlRegisterNodeDefaultValueThrDef = func;
560     xmlMutexUnlock(xmlThrDefMutex);
561
562     return(old);
563 }
564
565 /**
566  * xmlDeregisterNodeDefault:
567  * @func: function pointer to the new DeregisterNodeFunc
568  *
569  * Registers a callback for node destruction
570  *
571  * Returns the previous value of the deregistration function
572  */
573 xmlDeregisterNodeFunc
574 xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
575 {
576     xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
577     
578     __xmlRegisterCallbacks = 1;
579     xmlDeregisterNodeDefaultValue = func;
580     return(old);
581 }
582
583 xmlDeregisterNodeFunc
584 xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
585 {
586     xmlDeregisterNodeFunc old;
587
588     xmlMutexLock(xmlThrDefMutex);
589     old = xmlDeregisterNodeDefaultValueThrDef;
590     
591     __xmlRegisterCallbacks = 1;
592     xmlDeregisterNodeDefaultValueThrDef = func;
593     xmlMutexUnlock(xmlThrDefMutex);
594
595     return(old);
596 }
597
598
599 #ifdef LIBXML_DOCB_ENABLED
600 #undef  docbDefaultSAXHandler
601 xmlSAXHandler *
602 __docbDefaultSAXHandler(void) {
603     if (IS_MAIN_THREAD)
604         return (&docbDefaultSAXHandler);
605     else
606         return (&xmlGetGlobalState()->docbDefaultSAXHandler);
607 }
608 #endif
609
610 #ifdef LIBXML_HTML_ENABLED
611 #undef  htmlDefaultSAXHandler
612 xmlSAXHandler *
613 __htmlDefaultSAXHandler(void) {
614     if (IS_MAIN_THREAD)
615         return (&htmlDefaultSAXHandler);
616     else
617         return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
618 }
619 #endif
620
621 /*
622  * Everything starting from the line below is
623  * Automatically generated by build_glob.py.
624  * Do not modify the previous line.
625  */
626
627
628 #undef  oldXMLWDcompatibility
629 int *
630 __oldXMLWDcompatibility(void) {
631     if (IS_MAIN_THREAD)
632         return (&oldXMLWDcompatibility);
633     else
634         return (&xmlGetGlobalState()->oldXMLWDcompatibility);
635 }
636
637 #undef  xmlBufferAllocScheme
638 xmlBufferAllocationScheme *
639 __xmlBufferAllocScheme(void) {
640     if (IS_MAIN_THREAD)
641         return (&xmlBufferAllocScheme);
642     else
643         return (&xmlGetGlobalState()->xmlBufferAllocScheme);
644 }
645 xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
646     xmlBufferAllocationScheme ret;
647     xmlMutexLock(xmlThrDefMutex);
648     ret = xmlBufferAllocSchemeThrDef;
649     xmlBufferAllocSchemeThrDef = v;
650     xmlMutexUnlock(xmlThrDefMutex);
651     return ret;
652 }
653
654 #undef  xmlDefaultBufferSize
655 int *
656 __xmlDefaultBufferSize(void) {
657     if (IS_MAIN_THREAD)
658         return (&xmlDefaultBufferSize);
659     else
660         return (&xmlGetGlobalState()->xmlDefaultBufferSize);
661 }
662 int xmlThrDefDefaultBufferSize(int v) {
663     int ret;
664     xmlMutexLock(xmlThrDefMutex);
665     ret = xmlDefaultBufferSizeThrDef;
666     xmlDefaultBufferSizeThrDef = v;
667     xmlMutexUnlock(xmlThrDefMutex);
668     return ret;
669 }
670
671 #undef  xmlDefaultSAXHandler
672 xmlSAXHandler *
673 __xmlDefaultSAXHandler(void) {
674     if (IS_MAIN_THREAD)
675         return (&xmlDefaultSAXHandler);
676     else
677         return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
678 }
679
680 #undef  xmlDefaultSAXLocator
681 xmlSAXLocator *
682 __xmlDefaultSAXLocator(void) {
683     if (IS_MAIN_THREAD)
684         return (&xmlDefaultSAXLocator);
685     else
686         return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
687 }
688
689 #undef  xmlDoValidityCheckingDefaultValue
690 int *
691 __xmlDoValidityCheckingDefaultValue(void) {
692     if (IS_MAIN_THREAD)
693         return (&xmlDoValidityCheckingDefaultValue);
694     else
695         return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
696 }
697 int xmlThrDefDoValidityCheckingDefaultValue(int v) {
698     int ret;
699     xmlMutexLock(xmlThrDefMutex);
700     ret = xmlDoValidityCheckingDefaultValueThrDef;
701     xmlDoValidityCheckingDefaultValueThrDef = v;
702     xmlMutexUnlock(xmlThrDefMutex);
703     return ret;
704 }
705
706 #undef  xmlGenericError
707 xmlGenericErrorFunc *
708 __xmlGenericError(void) {
709     if (IS_MAIN_THREAD)
710         return (&xmlGenericError);
711     else
712         return (&xmlGetGlobalState()->xmlGenericError);
713 }
714
715 #undef  xmlGenericErrorContext
716 void * *
717 __xmlGenericErrorContext(void) {
718     if (IS_MAIN_THREAD)
719         return (&xmlGenericErrorContext);
720     else
721         return (&xmlGetGlobalState()->xmlGenericErrorContext);
722 }
723
724 #undef  xmlGetWarningsDefaultValue
725 int *
726 __xmlGetWarningsDefaultValue(void) {
727     if (IS_MAIN_THREAD)
728         return (&xmlGetWarningsDefaultValue);
729     else
730         return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
731 }
732 int xmlThrDefGetWarningsDefaultValue(int v) {
733     int ret;
734     xmlMutexLock(xmlThrDefMutex);
735     ret = xmlGetWarningsDefaultValueThrDef;
736     xmlGetWarningsDefaultValueThrDef = v;
737     xmlMutexUnlock(xmlThrDefMutex);
738     return ret;
739 }
740
741 #undef  xmlIndentTreeOutput
742 int *
743 __xmlIndentTreeOutput(void) {
744     if (IS_MAIN_THREAD)
745         return (&xmlIndentTreeOutput);
746     else
747         return (&xmlGetGlobalState()->xmlIndentTreeOutput);
748 }
749 int xmlThrDefIndentTreeOutput(int v) {
750     int ret;
751     xmlMutexLock(xmlThrDefMutex);
752     ret = xmlIndentTreeOutputThrDef;
753     xmlIndentTreeOutputThrDef = v;
754     xmlMutexUnlock(xmlThrDefMutex);
755     return ret;
756 }
757
758 #undef xmlTreeIndentString
759 const char * *
760 __xmlTreeIndentString(void) {
761     if (IS_MAIN_THREAD)
762         return (&xmlTreeIndentString);
763     else
764         return (&xmlGetGlobalState()->xmlTreeIndentString);
765 }
766 const char * xmlThrDefTreeIndentString(const char * v) {
767     const char * ret;
768     xmlMutexLock(xmlThrDefMutex);
769     ret = xmlTreeIndentStringThrDef;
770     xmlTreeIndentStringThrDef = v;
771     xmlMutexUnlock(xmlThrDefMutex);
772     return ret;
773 }
774
775 #undef  xmlKeepBlanksDefaultValue
776 int *
777 __xmlKeepBlanksDefaultValue(void) {
778     if (IS_MAIN_THREAD)
779         return (&xmlKeepBlanksDefaultValue);
780     else
781         return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
782 }
783 int xmlThrDefKeepBlanksDefaultValue(int v) {
784     int ret;
785     xmlMutexLock(xmlThrDefMutex);
786     ret = xmlKeepBlanksDefaultValueThrDef;
787     xmlKeepBlanksDefaultValueThrDef = v;
788     xmlMutexUnlock(xmlThrDefMutex);
789     return ret;
790 }
791
792 #undef  xmlLineNumbersDefaultValue
793 int *
794 __xmlLineNumbersDefaultValue(void) {
795     if (IS_MAIN_THREAD)
796         return (&xmlLineNumbersDefaultValue);
797     else
798         return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
799 }
800 int xmlThrDefLineNumbersDefaultValue(int v) {
801     int ret;
802     xmlMutexLock(xmlThrDefMutex);
803     ret = xmlLineNumbersDefaultValueThrDef;
804     xmlLineNumbersDefaultValueThrDef = v;
805     xmlMutexUnlock(xmlThrDefMutex);
806     return ret;
807 }
808
809 #undef  xmlLoadExtDtdDefaultValue
810 int *
811 __xmlLoadExtDtdDefaultValue(void) {
812     if (IS_MAIN_THREAD)
813         return (&xmlLoadExtDtdDefaultValue);
814     else
815         return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
816 }
817 int xmlThrDefLoadExtDtdDefaultValue(int v) {
818     int ret;
819     xmlMutexLock(xmlThrDefMutex);
820     ret = xmlLoadExtDtdDefaultValueThrDef;
821     xmlLoadExtDtdDefaultValueThrDef = v;
822     xmlMutexUnlock(xmlThrDefMutex);
823     return ret;
824 }
825
826 #undef  xmlParserDebugEntities
827 int *
828 __xmlParserDebugEntities(void) {
829     if (IS_MAIN_THREAD)
830         return (&xmlParserDebugEntities);
831     else
832         return (&xmlGetGlobalState()->xmlParserDebugEntities);
833 }
834 int xmlThrDefParserDebugEntities(int v) {
835     int ret;
836     xmlMutexLock(xmlThrDefMutex);
837     ret = xmlParserDebugEntitiesThrDef;
838     xmlParserDebugEntitiesThrDef = v;
839     xmlMutexUnlock(xmlThrDefMutex);
840     return ret;
841 }
842
843 #undef  xmlParserVersion
844 const char * *
845 __xmlParserVersion(void) {
846     if (IS_MAIN_THREAD)
847         return (&xmlParserVersion);
848     else
849         return (&xmlGetGlobalState()->xmlParserVersion);
850 }
851
852 #undef  xmlPedanticParserDefaultValue
853 int *
854 __xmlPedanticParserDefaultValue(void) {
855     if (IS_MAIN_THREAD)
856         return (&xmlPedanticParserDefaultValue);
857     else
858         return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
859 }
860 int xmlThrDefPedanticParserDefaultValue(int v) {
861     int ret;
862     xmlMutexLock(xmlThrDefMutex);
863     ret = xmlPedanticParserDefaultValueThrDef;
864     xmlPedanticParserDefaultValueThrDef = v;
865     xmlMutexUnlock(xmlThrDefMutex);
866     return ret;
867 }
868
869 #undef  xmlSaveNoEmptyTags
870 int *
871 __xmlSaveNoEmptyTags(void) {
872     if (IS_MAIN_THREAD)
873         return (&xmlSaveNoEmptyTags);
874     else
875         return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
876 }
877 int xmlThrDefSaveNoEmptyTags(int v) {
878     int ret;
879     xmlMutexLock(xmlThrDefMutex);
880     ret = xmlSaveNoEmptyTagsThrDef;
881     xmlSaveNoEmptyTagsThrDef = v;
882     xmlMutexUnlock(xmlThrDefMutex);
883     return ret;
884 }
885
886 #undef  xmlSubstituteEntitiesDefaultValue
887 int *
888 __xmlSubstituteEntitiesDefaultValue(void) {
889     if (IS_MAIN_THREAD)
890         return (&xmlSubstituteEntitiesDefaultValue);
891     else
892         return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
893 }
894 int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
895     int ret;
896     xmlMutexLock(xmlThrDefMutex);
897     ret = xmlSubstituteEntitiesDefaultValueThrDef;
898     xmlSubstituteEntitiesDefaultValueThrDef = v;
899     xmlMutexUnlock(xmlThrDefMutex);
900     return ret;
901 }
902
903 #undef  xmlRegisterNodeDefaultValue
904 xmlRegisterNodeFunc *
905 __xmlRegisterNodeDefaultValue(void) {
906     if (IS_MAIN_THREAD)
907         return (&xmlRegisterNodeDefaultValue);
908     else
909         return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
910 }
911
912 #undef  xmlDeregisterNodeDefaultValue
913 xmlDeregisterNodeFunc *
914 __xmlDeregisterNodeDefaultValue(void) {
915     if (IS_MAIN_THREAD)
916         return (&xmlDeregisterNodeDefaultValue);
917     else
918         return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
919 }