Migrate away from the PrefMetricsService-based device ID in PrefHashCalculator.
[chromium-blink-merge.git] / third_party / libxml / src / globals.c
blobb369346994821b79e5510c099bafb65608b54765
1 /*
2 * globals.c: definition and handling of the set of global variables
3 * of the library
5 * The bottom of this file is automatically generated by build_glob.py
6 * based on the description file global.data
8 * See Copyright for the status of this software.
10 * Gary Pennington <Gary.Pennington@uk.sun.com>
11 * daniel@veillard.com
14 #define IN_LIBXML
15 #include "libxml.h"
17 #ifdef HAVE_STDLIB_H
18 #include <stdlib.h>
19 #endif
20 #include <string.h>
22 #include <libxml/globals.h>
23 #include <libxml/xmlmemory.h>
24 #include <libxml/threads.h>
26 /* #define DEBUG_GLOBALS */
29 * Helpful Macro
31 #ifdef LIBXML_THREAD_ENABLED
32 #define IS_MAIN_THREAD (xmlIsMainThread())
33 #else
34 #define IS_MAIN_THREAD 1
35 #endif
38 * Mutex to protect "ForNewThreads" variables
40 static xmlMutexPtr xmlThrDefMutex = NULL;
42 /**
43 * xmlInitGlobals:
45 * Additional initialisation for multi-threading
47 void xmlInitGlobals(void)
49 if (xmlThrDefMutex == NULL)
50 xmlThrDefMutex = xmlNewMutex();
53 /**
54 * xmlCleanupGlobals:
56 * Additional cleanup for multi-threading
58 void xmlCleanupGlobals(void)
60 if (xmlThrDefMutex != NULL) {
61 xmlFreeMutex(xmlThrDefMutex);
62 xmlThrDefMutex = NULL;
64 __xmlGlobalInitMutexDestroy();
67 /************************************************************************
68 * *
69 * All the user accessible global variables of the library *
70 * *
71 ************************************************************************/
74 * Memory allocation routines
76 #undef xmlFree
77 #undef xmlMalloc
78 #undef xmlMallocAtomic
79 #undef xmlMemStrdup
80 #undef xmlRealloc
82 #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
83 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
84 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
85 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
86 xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
87 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
88 #else
90 #define MAX_LIBXML_MALLOC (1024*1024*512)
92 static void* size_checked_malloc(size_t size) {
93 if (size > MAX_LIBXML_MALLOC) {
94 *(volatile char*)0 = '\0';
95 return NULL;
97 return malloc(size);
100 static void* size_checked_realloc(void* ptr, size_t size) {
101 if (size > MAX_LIBXML_MALLOC) {
102 *(volatile char*)0 = '\0';
103 return NULL;
105 return realloc(ptr, size);
109 * xmlFree:
110 * @mem: an already allocated block of memory
112 * The variable holding the libxml free() implementation
114 xmlFreeFunc xmlFree = (xmlFreeFunc) free;
116 * xmlMalloc:
117 * @size: the size requested in bytes
119 * The variable holding the libxml malloc() implementation
121 * Returns a pointer to the newly allocated block or NULL in case of error
123 xmlMallocFunc xmlMalloc = (xmlMallocFunc) size_checked_malloc;
125 * xmlMallocAtomic:
126 * @size: the size requested in bytes
128 * The variable holding the libxml malloc() implementation for atomic
129 * data (i.e. blocks not containings pointers), useful when using a
130 * garbage collecting allocator.
132 * Returns a pointer to the newly allocated block or NULL in case of error
134 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) size_checked_malloc;
136 * xmlRealloc:
137 * @mem: an already allocated block of memory
138 * @size: the new size requested in bytes
140 * The variable holding the libxml realloc() implementation
142 * Returns a pointer to the newly reallocated block or NULL in case of error
144 xmlReallocFunc xmlRealloc = (xmlReallocFunc) size_checked_realloc;
146 * xmlMemStrdup:
147 * @str: a zero terminated string
149 * The variable holding the libxml strdup() implementation
151 * Returns the copy of the string or NULL in case of error
153 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
154 #endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
156 #include <libxml/threads.h>
157 #include <libxml/globals.h>
158 #include <libxml/SAX.h>
160 #undef docbDefaultSAXHandler
161 #undef htmlDefaultSAXHandler
162 #undef oldXMLWDcompatibility
163 #undef xmlBufferAllocScheme
164 #undef xmlDefaultBufferSize
165 #undef xmlDefaultSAXHandler
166 #undef xmlDefaultSAXLocator
167 #undef xmlDoValidityCheckingDefaultValue
168 #undef xmlGenericError
169 #undef xmlStructuredError
170 #undef xmlGenericErrorContext
171 #undef xmlStructuredErrorContext
172 #undef xmlGetWarningsDefaultValue
173 #undef xmlIndentTreeOutput
174 #undef xmlTreeIndentString
175 #undef xmlKeepBlanksDefaultValue
176 #undef xmlLineNumbersDefaultValue
177 #undef xmlLoadExtDtdDefaultValue
178 #undef xmlParserDebugEntities
179 #undef xmlParserVersion
180 #undef xmlPedanticParserDefaultValue
181 #undef xmlSaveNoEmptyTags
182 #undef xmlSubstituteEntitiesDefaultValue
183 #undef xmlRegisterNodeDefaultValue
184 #undef xmlDeregisterNodeDefaultValue
185 #undef xmlLastError
187 #undef xmlParserInputBufferCreateFilenameValue
188 #undef xmlOutputBufferCreateFilenameValue
190 * xmlParserVersion:
192 * Constant string describing the internal version of the library
194 const char *xmlParserVersion = LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA;
197 * xmlBufferAllocScheme:
199 * Global setting, default allocation policy for buffers, default is
200 * XML_BUFFER_ALLOC_EXACT
202 xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
203 static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT;
205 * xmlDefaultBufferSize:
207 * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
209 int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
210 static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
213 * Parser defaults
217 * oldXMLWDcompatibility:
219 * Global setting, DEPRECATED.
221 int oldXMLWDcompatibility = 0; /* DEPRECATED */
223 * xmlParserDebugEntities:
225 * Global setting, asking the parser to print out debugging informations.
226 * while handling entities.
227 * Disabled by default
229 int xmlParserDebugEntities = 0;
230 static int xmlParserDebugEntitiesThrDef = 0;
232 * xmlDoValidityCheckingDefaultValue:
234 * Global setting, indicate that the parser should work in validating mode.
235 * Disabled by default.
237 int xmlDoValidityCheckingDefaultValue = 0;
238 static int xmlDoValidityCheckingDefaultValueThrDef = 0;
240 * xmlGetWarningsDefaultValue:
242 * Global setting, indicate that the parser should provide warnings.
243 * Activated by default.
245 int xmlGetWarningsDefaultValue = 1;
246 static int xmlGetWarningsDefaultValueThrDef = 1;
248 * xmlLoadExtDtdDefaultValue:
250 * Global setting, indicate that the parser should load DTD while not
251 * validating.
252 * Disabled by default.
254 int xmlLoadExtDtdDefaultValue = 0;
255 static int xmlLoadExtDtdDefaultValueThrDef = 0;
257 * xmlPedanticParserDefaultValue:
259 * Global setting, indicate that the parser be pedantic
260 * Disabled by default.
262 int xmlPedanticParserDefaultValue = 0;
263 static int xmlPedanticParserDefaultValueThrDef = 0;
265 * xmlLineNumbersDefaultValue:
267 * Global setting, indicate that the parser should store the line number
268 * in the content field of elements in the DOM tree.
269 * Disabled by default since this may not be safe for old classes of
270 * applicaton.
272 int xmlLineNumbersDefaultValue = 0;
273 static int xmlLineNumbersDefaultValueThrDef = 0;
275 * xmlKeepBlanksDefaultValue:
277 * Global setting, indicate that the parser should keep all blanks
278 * nodes found in the content
279 * Activated by default, this is actually needed to have the parser
280 * conformant to the XML Recommendation, however the option is kept
281 * for some applications since this was libxml1 default behaviour.
283 int xmlKeepBlanksDefaultValue = 1;
284 static int xmlKeepBlanksDefaultValueThrDef = 1;
286 * xmlSubstituteEntitiesDefaultValue:
288 * Global setting, indicate that the parser should not generate entity
289 * references but replace them with the actual content of the entity
290 * Disabled by default, this should be activated when using XPath since
291 * the XPath data model requires entities replacement and the XPath
292 * engine does not handle entities references transparently.
294 int xmlSubstituteEntitiesDefaultValue = 0;
295 static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
297 xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
298 static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
299 xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
300 static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
302 xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL;
303 static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL;
305 xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
306 static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL;
309 * Error handling
312 /* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
313 /* Must initialize xmlGenericError in xmlInitParser */
314 void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
315 const char *msg,
316 ...);
318 * xmlGenericError:
320 * Global setting: function used for generic error callbacks
322 xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
323 static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
325 * xmlStructuredError:
327 * Global setting: function used for structured error callbacks
329 xmlStructuredErrorFunc xmlStructuredError = NULL;
330 static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
332 * xmlGenericErrorContext:
334 * Global setting passed to generic error callbacks
336 void *xmlGenericErrorContext = NULL;
337 static void *xmlGenericErrorContextThrDef = NULL;
339 * xmlStructuredErrorContext:
341 * Global setting passed to structured error callbacks
343 void *xmlStructuredErrorContext = NULL;
344 static void *xmlStructuredErrorContextThrDef = NULL;
345 xmlError xmlLastError;
348 * output defaults
351 * xmlIndentTreeOutput:
353 * Global setting, asking the serializer to indent the output tree by default
354 * Enabled by default
356 int xmlIndentTreeOutput = 1;
357 static int xmlIndentTreeOutputThrDef = 1;
360 * xmlTreeIndentString:
362 * The string used to do one-level indent. By default is equal to " " (two spaces)
364 const char *xmlTreeIndentString = " ";
365 static const char *xmlTreeIndentStringThrDef = " ";
368 * xmlSaveNoEmptyTags:
370 * Global setting, asking the serializer to not output empty tags
371 * as <empty/> but <empty></empty>. those two forms are undistinguishable
372 * once parsed.
373 * Disabled by default
375 int xmlSaveNoEmptyTags = 0;
376 static int xmlSaveNoEmptyTagsThrDef = 0;
378 #ifdef LIBXML_SAX1_ENABLED
380 * xmlDefaultSAXHandler:
382 * Default SAX version1 handler for XML, builds the DOM tree
384 xmlSAXHandlerV1 xmlDefaultSAXHandler = {
385 xmlSAX2InternalSubset,
386 xmlSAX2IsStandalone,
387 xmlSAX2HasInternalSubset,
388 xmlSAX2HasExternalSubset,
389 xmlSAX2ResolveEntity,
390 xmlSAX2GetEntity,
391 xmlSAX2EntityDecl,
392 xmlSAX2NotationDecl,
393 xmlSAX2AttributeDecl,
394 xmlSAX2ElementDecl,
395 xmlSAX2UnparsedEntityDecl,
396 xmlSAX2SetDocumentLocator,
397 xmlSAX2StartDocument,
398 xmlSAX2EndDocument,
399 xmlSAX2StartElement,
400 xmlSAX2EndElement,
401 xmlSAX2Reference,
402 xmlSAX2Characters,
403 xmlSAX2Characters,
404 xmlSAX2ProcessingInstruction,
405 xmlSAX2Comment,
406 xmlParserWarning,
407 xmlParserError,
408 xmlParserError,
409 xmlSAX2GetParameterEntity,
410 xmlSAX2CDataBlock,
411 xmlSAX2ExternalSubset,
414 #endif /* LIBXML_SAX1_ENABLED */
417 * xmlDefaultSAXLocator:
419 * The default SAX Locator
420 * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
422 xmlSAXLocator xmlDefaultSAXLocator = {
423 xmlSAX2GetPublicId,
424 xmlSAX2GetSystemId,
425 xmlSAX2GetLineNumber,
426 xmlSAX2GetColumnNumber
429 #ifdef LIBXML_HTML_ENABLED
431 * htmlDefaultSAXHandler:
433 * Default old SAX v1 handler for HTML, builds the DOM tree
435 xmlSAXHandlerV1 htmlDefaultSAXHandler = {
436 xmlSAX2InternalSubset,
437 NULL,
438 NULL,
439 NULL,
440 NULL,
441 xmlSAX2GetEntity,
442 NULL,
443 NULL,
444 NULL,
445 NULL,
446 NULL,
447 xmlSAX2SetDocumentLocator,
448 xmlSAX2StartDocument,
449 xmlSAX2EndDocument,
450 xmlSAX2StartElement,
451 xmlSAX2EndElement,
452 NULL,
453 xmlSAX2Characters,
454 xmlSAX2IgnorableWhitespace,
455 xmlSAX2ProcessingInstruction,
456 xmlSAX2Comment,
457 xmlParserWarning,
458 xmlParserError,
459 xmlParserError,
460 xmlSAX2GetParameterEntity,
461 xmlSAX2CDataBlock,
462 NULL,
465 #endif /* LIBXML_HTML_ENABLED */
467 #ifdef LIBXML_DOCB_ENABLED
469 * docbDefaultSAXHandler:
471 * Default old SAX v1 handler for SGML DocBook, builds the DOM tree
473 xmlSAXHandlerV1 docbDefaultSAXHandler = {
474 xmlSAX2InternalSubset,
475 xmlSAX2IsStandalone,
476 xmlSAX2HasInternalSubset,
477 xmlSAX2HasExternalSubset,
478 xmlSAX2ResolveEntity,
479 xmlSAX2GetEntity,
480 xmlSAX2EntityDecl,
481 NULL,
482 NULL,
483 NULL,
484 NULL,
485 xmlSAX2SetDocumentLocator,
486 xmlSAX2StartDocument,
487 xmlSAX2EndDocument,
488 xmlSAX2StartElement,
489 xmlSAX2EndElement,
490 xmlSAX2Reference,
491 xmlSAX2Characters,
492 xmlSAX2IgnorableWhitespace,
493 NULL,
494 xmlSAX2Comment,
495 xmlParserWarning,
496 xmlParserError,
497 xmlParserError,
498 xmlSAX2GetParameterEntity,
499 NULL,
500 NULL,
503 #endif /* LIBXML_DOCB_ENABLED */
506 * xmlInitializeGlobalState:
507 * @gs: a pointer to a newly allocated global state
509 * xmlInitializeGlobalState() initialize a global state with all the
510 * default values of the library.
512 void
513 xmlInitializeGlobalState(xmlGlobalStatePtr gs)
515 #ifdef DEBUG_GLOBALS
516 fprintf(stderr, "Initializing globals at %lu for thread %d\n",
517 (unsigned long) gs, xmlGetThreadId());
518 #endif
521 * Perform initialization as required by libxml
523 if (xmlThrDefMutex == NULL)
524 xmlInitGlobals();
526 xmlMutexLock(xmlThrDefMutex);
528 #if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
529 initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
530 #endif
531 #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
532 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
533 #endif
535 gs->oldXMLWDcompatibility = 0;
536 gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
537 gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
538 #if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
539 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
540 #endif /* LIBXML_SAX1_ENABLED */
541 gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
542 gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
543 gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
544 gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
545 gs->xmlDoValidityCheckingDefaultValue =
546 xmlDoValidityCheckingDefaultValueThrDef;
547 #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
548 gs->xmlFree = (xmlFreeFunc) xmlMemFree;
549 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
550 gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
551 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
552 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
553 #else
554 gs->xmlFree = (xmlFreeFunc) free;
555 gs->xmlMalloc = (xmlMallocFunc) malloc;
556 gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
557 gs->xmlRealloc = (xmlReallocFunc) realloc;
558 gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
559 #endif
560 gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
561 gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
562 gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
563 gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
564 gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
565 gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
566 gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
567 gs->xmlParserVersion = LIBXML_VERSION_STRING;
568 gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
569 gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
570 gs->xmlSubstituteEntitiesDefaultValue =
571 xmlSubstituteEntitiesDefaultValueThrDef;
573 gs->xmlGenericError = xmlGenericErrorThrDef;
574 gs->xmlStructuredError = xmlStructuredErrorThrDef;
575 gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
576 gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
577 gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
578 gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
580 gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
581 gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
582 memset(&gs->xmlLastError, 0, sizeof(xmlError));
584 xmlMutexUnlock(xmlThrDefMutex);
588 * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions,
589 * those are really internal work
591 void
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);
602 void
603 xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
604 xmlMutexLock(xmlThrDefMutex);
605 xmlStructuredErrorContextThrDef = ctx;
606 xmlStructuredErrorThrDef = handler;
607 xmlMutexUnlock(xmlThrDefMutex);
611 * xmlRegisterNodeDefault:
612 * @func: function pointer to the new RegisterNodeFunc
614 * Registers a callback for node creation
616 * Returns the old value of the registration function
618 xmlRegisterNodeFunc
619 xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
621 xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
623 __xmlRegisterCallbacks = 1;
624 xmlRegisterNodeDefaultValue = func;
625 return(old);
628 xmlRegisterNodeFunc
629 xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
631 xmlRegisterNodeFunc old;
633 xmlMutexLock(xmlThrDefMutex);
634 old = xmlRegisterNodeDefaultValueThrDef;
636 __xmlRegisterCallbacks = 1;
637 xmlRegisterNodeDefaultValueThrDef = func;
638 xmlMutexUnlock(xmlThrDefMutex);
640 return(old);
644 * xmlDeregisterNodeDefault:
645 * @func: function pointer to the new DeregisterNodeFunc
647 * Registers a callback for node destruction
649 * Returns the previous value of the deregistration function
651 xmlDeregisterNodeFunc
652 xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
654 xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
656 __xmlRegisterCallbacks = 1;
657 xmlDeregisterNodeDefaultValue = func;
658 return(old);
661 xmlDeregisterNodeFunc
662 xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
664 xmlDeregisterNodeFunc old;
666 xmlMutexLock(xmlThrDefMutex);
667 old = xmlDeregisterNodeDefaultValueThrDef;
669 __xmlRegisterCallbacks = 1;
670 xmlDeregisterNodeDefaultValueThrDef = func;
671 xmlMutexUnlock(xmlThrDefMutex);
673 return(old);
676 xmlParserInputBufferCreateFilenameFunc
677 xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
679 xmlParserInputBufferCreateFilenameFunc old;
681 xmlMutexLock(xmlThrDefMutex);
682 old = xmlParserInputBufferCreateFilenameValueThrDef;
683 if (old == NULL) {
684 old = __xmlParserInputBufferCreateFilename;
687 xmlParserInputBufferCreateFilenameValueThrDef = func;
688 xmlMutexUnlock(xmlThrDefMutex);
690 return(old);
693 xmlOutputBufferCreateFilenameFunc
694 xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
696 xmlOutputBufferCreateFilenameFunc old;
698 xmlMutexLock(xmlThrDefMutex);
699 old = xmlOutputBufferCreateFilenameValueThrDef;
700 #ifdef LIBXML_OUTPUT_ENABLED
701 if (old == NULL) {
702 old = __xmlOutputBufferCreateFilename;
704 #endif
705 xmlOutputBufferCreateFilenameValueThrDef = func;
706 xmlMutexUnlock(xmlThrDefMutex);
708 return(old);
711 #ifdef LIBXML_DOCB_ENABLED
712 #undef docbDefaultSAXHandler
713 xmlSAXHandlerV1 *
714 __docbDefaultSAXHandler(void) {
715 if (IS_MAIN_THREAD)
716 return (&docbDefaultSAXHandler);
717 else
718 return (&xmlGetGlobalState()->docbDefaultSAXHandler);
720 #endif
722 #ifdef LIBXML_HTML_ENABLED
723 #undef htmlDefaultSAXHandler
724 xmlSAXHandlerV1 *
725 __htmlDefaultSAXHandler(void) {
726 if (IS_MAIN_THREAD)
727 return (&htmlDefaultSAXHandler);
728 else
729 return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
731 #endif
733 #undef xmlLastError
734 xmlError *
735 __xmlLastError(void) {
736 if (IS_MAIN_THREAD)
737 return (&xmlLastError);
738 else
739 return (&xmlGetGlobalState()->xmlLastError);
743 * The following memory routines were apparently lost at some point,
744 * and were re-inserted at this point on June 10, 2004. Hope it's
745 * the right place for them :-)
747 #if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED)
748 #undef xmlMalloc
749 xmlMallocFunc *
750 __xmlMalloc(void){
751 if (IS_MAIN_THREAD)
752 return (&xmlMalloc);
753 else
754 return (&xmlGetGlobalState()->xmlMalloc);
757 #undef xmlMallocAtomic
758 xmlMallocFunc *
759 __xmlMallocAtomic(void){
760 if (IS_MAIN_THREAD)
761 return (&xmlMallocAtomic);
762 else
763 return (&xmlGetGlobalState()->xmlMallocAtomic);
766 #undef xmlRealloc
767 xmlReallocFunc *
768 __xmlRealloc(void){
769 if (IS_MAIN_THREAD)
770 return (&xmlRealloc);
771 else
772 return (&xmlGetGlobalState()->xmlRealloc);
775 #undef xmlFree
776 xmlFreeFunc *
777 __xmlFree(void){
778 if (IS_MAIN_THREAD)
779 return (&xmlFree);
780 else
781 return (&xmlGetGlobalState()->xmlFree);
784 xmlStrdupFunc *
785 __xmlMemStrdup(void){
786 if (IS_MAIN_THREAD)
787 return (&xmlMemStrdup);
788 else
789 return (&xmlGetGlobalState()->xmlMemStrdup);
792 #endif
795 * Everything starting from the line below is
796 * Automatically generated by build_glob.py.
797 * Do not modify the previous line.
801 #undef oldXMLWDcompatibility
802 int *
803 __oldXMLWDcompatibility(void) {
804 if (IS_MAIN_THREAD)
805 return (&oldXMLWDcompatibility);
806 else
807 return (&xmlGetGlobalState()->oldXMLWDcompatibility);
810 #undef xmlBufferAllocScheme
811 xmlBufferAllocationScheme *
812 __xmlBufferAllocScheme(void) {
813 if (IS_MAIN_THREAD)
814 return (&xmlBufferAllocScheme);
815 else
816 return (&xmlGetGlobalState()->xmlBufferAllocScheme);
818 xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
819 xmlBufferAllocationScheme ret;
820 xmlMutexLock(xmlThrDefMutex);
821 ret = xmlBufferAllocSchemeThrDef;
822 xmlBufferAllocSchemeThrDef = v;
823 xmlMutexUnlock(xmlThrDefMutex);
824 return ret;
827 #undef xmlDefaultBufferSize
828 int *
829 __xmlDefaultBufferSize(void) {
830 if (IS_MAIN_THREAD)
831 return (&xmlDefaultBufferSize);
832 else
833 return (&xmlGetGlobalState()->xmlDefaultBufferSize);
835 int xmlThrDefDefaultBufferSize(int v) {
836 int ret;
837 xmlMutexLock(xmlThrDefMutex);
838 ret = xmlDefaultBufferSizeThrDef;
839 xmlDefaultBufferSizeThrDef = v;
840 xmlMutexUnlock(xmlThrDefMutex);
841 return ret;
844 #ifdef LIBXML_SAX1_ENABLED
845 #undef xmlDefaultSAXHandler
846 xmlSAXHandlerV1 *
847 __xmlDefaultSAXHandler(void) {
848 if (IS_MAIN_THREAD)
849 return (&xmlDefaultSAXHandler);
850 else
851 return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
853 #endif /* LIBXML_SAX1_ENABLED */
855 #undef xmlDefaultSAXLocator
856 xmlSAXLocator *
857 __xmlDefaultSAXLocator(void) {
858 if (IS_MAIN_THREAD)
859 return (&xmlDefaultSAXLocator);
860 else
861 return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
864 #undef xmlDoValidityCheckingDefaultValue
865 int *
866 __xmlDoValidityCheckingDefaultValue(void) {
867 if (IS_MAIN_THREAD)
868 return (&xmlDoValidityCheckingDefaultValue);
869 else
870 return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
872 int xmlThrDefDoValidityCheckingDefaultValue(int v) {
873 int ret;
874 xmlMutexLock(xmlThrDefMutex);
875 ret = xmlDoValidityCheckingDefaultValueThrDef;
876 xmlDoValidityCheckingDefaultValueThrDef = v;
877 xmlMutexUnlock(xmlThrDefMutex);
878 return ret;
881 #undef xmlGenericError
882 xmlGenericErrorFunc *
883 __xmlGenericError(void) {
884 if (IS_MAIN_THREAD)
885 return (&xmlGenericError);
886 else
887 return (&xmlGetGlobalState()->xmlGenericError);
890 #undef xmlStructuredError
891 xmlStructuredErrorFunc *
892 __xmlStructuredError(void) {
893 if (IS_MAIN_THREAD)
894 return (&xmlStructuredError);
895 else
896 return (&xmlGetGlobalState()->xmlStructuredError);
899 #undef xmlGenericErrorContext
900 void * *
901 __xmlGenericErrorContext(void) {
902 if (IS_MAIN_THREAD)
903 return (&xmlGenericErrorContext);
904 else
905 return (&xmlGetGlobalState()->xmlGenericErrorContext);
908 #undef xmlStructuredErrorContext
909 void * *
910 __xmlStructuredErrorContext(void) {
911 if (IS_MAIN_THREAD)
912 return (&xmlStructuredErrorContext);
913 else
914 return (&xmlGetGlobalState()->xmlStructuredErrorContext);
917 #undef xmlGetWarningsDefaultValue
918 int *
919 __xmlGetWarningsDefaultValue(void) {
920 if (IS_MAIN_THREAD)
921 return (&xmlGetWarningsDefaultValue);
922 else
923 return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
925 int xmlThrDefGetWarningsDefaultValue(int v) {
926 int ret;
927 xmlMutexLock(xmlThrDefMutex);
928 ret = xmlGetWarningsDefaultValueThrDef;
929 xmlGetWarningsDefaultValueThrDef = v;
930 xmlMutexUnlock(xmlThrDefMutex);
931 return ret;
934 #undef xmlIndentTreeOutput
935 int *
936 __xmlIndentTreeOutput(void) {
937 if (IS_MAIN_THREAD)
938 return (&xmlIndentTreeOutput);
939 else
940 return (&xmlGetGlobalState()->xmlIndentTreeOutput);
942 int xmlThrDefIndentTreeOutput(int v) {
943 int ret;
944 xmlMutexLock(xmlThrDefMutex);
945 ret = xmlIndentTreeOutputThrDef;
946 xmlIndentTreeOutputThrDef = v;
947 xmlMutexUnlock(xmlThrDefMutex);
948 return ret;
951 #undef xmlTreeIndentString
952 const char * *
953 __xmlTreeIndentString(void) {
954 if (IS_MAIN_THREAD)
955 return (&xmlTreeIndentString);
956 else
957 return (&xmlGetGlobalState()->xmlTreeIndentString);
959 const char * xmlThrDefTreeIndentString(const char * v) {
960 const char * ret;
961 xmlMutexLock(xmlThrDefMutex);
962 ret = xmlTreeIndentStringThrDef;
963 xmlTreeIndentStringThrDef = v;
964 xmlMutexUnlock(xmlThrDefMutex);
965 return ret;
968 #undef xmlKeepBlanksDefaultValue
969 int *
970 __xmlKeepBlanksDefaultValue(void) {
971 if (IS_MAIN_THREAD)
972 return (&xmlKeepBlanksDefaultValue);
973 else
974 return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
976 int xmlThrDefKeepBlanksDefaultValue(int v) {
977 int ret;
978 xmlMutexLock(xmlThrDefMutex);
979 ret = xmlKeepBlanksDefaultValueThrDef;
980 xmlKeepBlanksDefaultValueThrDef = v;
981 xmlMutexUnlock(xmlThrDefMutex);
982 return ret;
985 #undef xmlLineNumbersDefaultValue
986 int *
987 __xmlLineNumbersDefaultValue(void) {
988 if (IS_MAIN_THREAD)
989 return (&xmlLineNumbersDefaultValue);
990 else
991 return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
993 int xmlThrDefLineNumbersDefaultValue(int v) {
994 int ret;
995 xmlMutexLock(xmlThrDefMutex);
996 ret = xmlLineNumbersDefaultValueThrDef;
997 xmlLineNumbersDefaultValueThrDef = v;
998 xmlMutexUnlock(xmlThrDefMutex);
999 return ret;
1002 #undef xmlLoadExtDtdDefaultValue
1003 int *
1004 __xmlLoadExtDtdDefaultValue(void) {
1005 if (IS_MAIN_THREAD)
1006 return (&xmlLoadExtDtdDefaultValue);
1007 else
1008 return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
1010 int xmlThrDefLoadExtDtdDefaultValue(int v) {
1011 int ret;
1012 xmlMutexLock(xmlThrDefMutex);
1013 ret = xmlLoadExtDtdDefaultValueThrDef;
1014 xmlLoadExtDtdDefaultValueThrDef = v;
1015 xmlMutexUnlock(xmlThrDefMutex);
1016 return ret;
1019 #undef xmlParserDebugEntities
1020 int *
1021 __xmlParserDebugEntities(void) {
1022 if (IS_MAIN_THREAD)
1023 return (&xmlParserDebugEntities);
1024 else
1025 return (&xmlGetGlobalState()->xmlParserDebugEntities);
1027 int xmlThrDefParserDebugEntities(int v) {
1028 int ret;
1029 xmlMutexLock(xmlThrDefMutex);
1030 ret = xmlParserDebugEntitiesThrDef;
1031 xmlParserDebugEntitiesThrDef = v;
1032 xmlMutexUnlock(xmlThrDefMutex);
1033 return ret;
1036 #undef xmlParserVersion
1037 const char * *
1038 __xmlParserVersion(void) {
1039 if (IS_MAIN_THREAD)
1040 return (&xmlParserVersion);
1041 else
1042 return (&xmlGetGlobalState()->xmlParserVersion);
1045 #undef xmlPedanticParserDefaultValue
1046 int *
1047 __xmlPedanticParserDefaultValue(void) {
1048 if (IS_MAIN_THREAD)
1049 return (&xmlPedanticParserDefaultValue);
1050 else
1051 return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
1053 int xmlThrDefPedanticParserDefaultValue(int v) {
1054 int ret;
1055 xmlMutexLock(xmlThrDefMutex);
1056 ret = xmlPedanticParserDefaultValueThrDef;
1057 xmlPedanticParserDefaultValueThrDef = v;
1058 xmlMutexUnlock(xmlThrDefMutex);
1059 return ret;
1062 #undef xmlSaveNoEmptyTags
1063 int *
1064 __xmlSaveNoEmptyTags(void) {
1065 if (IS_MAIN_THREAD)
1066 return (&xmlSaveNoEmptyTags);
1067 else
1068 return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
1070 int xmlThrDefSaveNoEmptyTags(int v) {
1071 int ret;
1072 xmlMutexLock(xmlThrDefMutex);
1073 ret = xmlSaveNoEmptyTagsThrDef;
1074 xmlSaveNoEmptyTagsThrDef = v;
1075 xmlMutexUnlock(xmlThrDefMutex);
1076 return ret;
1079 #undef xmlSubstituteEntitiesDefaultValue
1080 int *
1081 __xmlSubstituteEntitiesDefaultValue(void) {
1082 if (IS_MAIN_THREAD)
1083 return (&xmlSubstituteEntitiesDefaultValue);
1084 else
1085 return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
1087 int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
1088 int ret;
1089 xmlMutexLock(xmlThrDefMutex);
1090 ret = xmlSubstituteEntitiesDefaultValueThrDef;
1091 xmlSubstituteEntitiesDefaultValueThrDef = v;
1092 xmlMutexUnlock(xmlThrDefMutex);
1093 return ret;
1096 #undef xmlRegisterNodeDefaultValue
1097 xmlRegisterNodeFunc *
1098 __xmlRegisterNodeDefaultValue(void) {
1099 if (IS_MAIN_THREAD)
1100 return (&xmlRegisterNodeDefaultValue);
1101 else
1102 return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
1105 #undef xmlDeregisterNodeDefaultValue
1106 xmlDeregisterNodeFunc *
1107 __xmlDeregisterNodeDefaultValue(void) {
1108 if (IS_MAIN_THREAD)
1109 return (&xmlDeregisterNodeDefaultValue);
1110 else
1111 return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
1114 #undef xmlParserInputBufferCreateFilenameValue
1115 xmlParserInputBufferCreateFilenameFunc *
1116 __xmlParserInputBufferCreateFilenameValue(void) {
1117 if (IS_MAIN_THREAD)
1118 return (&xmlParserInputBufferCreateFilenameValue);
1119 else
1120 return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
1123 #undef xmlOutputBufferCreateFilenameValue
1124 xmlOutputBufferCreateFilenameFunc *
1125 __xmlOutputBufferCreateFilenameValue(void) {
1126 if (IS_MAIN_THREAD)
1127 return (&xmlOutputBufferCreateFilenameValue);
1128 else
1129 return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
1132 #define bottom_globals
1133 #include "elfgcchack.h"