2 * globals.c: definition and handling of the set of global variables
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>
22 #include <libxml/globals.h>
23 #include <libxml/xmlmemory.h>
25 /* #define DEBUG_GLOBALS */
30 #ifdef LIBXML_THREAD_ENABLED
31 #define IS_MAIN_THREAD (xmlIsMainThread())
33 #define IS_MAIN_THREAD 1
36 /************************************************************************
38 * All the user accessible global variables of the library *
40 ************************************************************************/
43 * Memory allocation routines
45 #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
46 extern void xmlMemFree(void *ptr);
47 extern void * xmlMemMalloc(size_t size);
48 extern void * xmlMemRealloc(void *ptr,size_t size);
49 extern char * xmlMemoryStrdup(const char *str);
51 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
52 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
53 xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
54 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
58 * @mem: an already allocated block of memory
60 * The variable holding the libxml free() implementation
62 xmlFreeFunc xmlFree = (xmlFreeFunc) free;
65 * @size: the size requested in bytes
67 * The variable holding the libxml malloc() implementation
69 * Returns a pointer to the newly allocated block or NULL in case of error
71 xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
74 * @mem: an already allocated block of memory
75 * @size: the new size requested in bytes
77 * The variable holding the libxml realloc() implementation
79 * Returns a pointer to the newly reallocated block or NULL in case of error
81 xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
84 * @str: a zero terminated string
86 * The variable holding the libxml strdup() implementation
88 * Returns the copy of the string or NULL in case of error
90 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
93 #include <libxml/threads.h>
94 #include <libxml/globals.h>
95 #include <libxml/SAX.h>
97 #undef docbDefaultSAXHandler
98 #undef htmlDefaultSAXHandler
99 #undef oldXMLWDcompatibility
100 #undef xmlBufferAllocScheme
101 #undef xmlDefaultBufferSize
102 #undef xmlDefaultSAXHandler
103 #undef xmlDefaultSAXLocator
104 #undef xmlDoValidityCheckingDefaultValue
105 #undef xmlGenericError
106 #undef xmlGenericErrorContext
107 #undef xmlGetWarningsDefaultValue
108 #undef xmlIndentTreeOutput
109 #undef xmlTreeIndentString
110 #undef xmlKeepBlanksDefaultValue
111 #undef xmlLineNumbersDefaultValue
112 #undef xmlLoadExtDtdDefaultValue
113 #undef xmlParserDebugEntities
114 #undef xmlParserVersion
115 #undef xmlPedanticParserDefaultValue
116 #undef xmlSaveNoEmptyTags
117 #undef xmlSubstituteEntitiesDefaultValue
118 #undef xmlRegisterNodeDefaultValue
119 #undef xmlDeregisterNodeDefaultValue
129 * Constant string describing the internal version of the library
131 const char *xmlParserVersion = LIBXML_VERSION_STRING;
134 * xmlBufferAllocScheme:
136 * Global setting, default allocation policy for buffers, default is
137 * XML_BUFFER_ALLOC_EXACT
139 xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
141 * xmlDefaultBufferSize:
143 * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
145 int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
152 * oldXMLWDcompatibility:
154 * Global setting, DEPRECATED.
156 int oldXMLWDcompatibility = 0; /* DEPRECATED */
158 * xmlParserDebugEntities:
160 * Global setting, asking the parser to print out debugging informations.
161 * while handling entities.
162 * Disabled by default
164 int xmlParserDebugEntities = 0;
166 * xmlDoValidityCheckingDefaultValue:
168 * Global setting, indicate that the parser should work in validating mode.
169 * Disabled by default.
171 int xmlDoValidityCheckingDefaultValue = 0;
173 * xmlGetWarningsDefaultValue:
175 * Global setting, indicate that the parser should provide warnings.
176 * Activated by default.
178 int xmlGetWarningsDefaultValue = 1;
180 * xmlLoadExtDtdDefaultValue:
182 * Global setting, indicate that the parser should load DTD while not
184 * Disabled by default.
186 int xmlLoadExtDtdDefaultValue = 0;
188 * xmlPedanticParserDefaultValue:
190 * Global setting, indicate that the parser be pedantic
191 * Disabled by default.
193 int xmlPedanticParserDefaultValue = 0;
195 * xmlLineNumbersDefaultValue:
197 * Global setting, indicate that the parser should store the line number
198 * in the content field of elements in the DOM tree.
199 * Disabled by default since this may not be safe for old classes of
202 int xmlLineNumbersDefaultValue = 0;
204 * xmlKeepBlanksDefaultValue:
206 * Global setting, indicate that the parser should keep all blanks
207 * nodes found in the content
208 * Activated by default, this is actually needed to have the parser
209 * conformant to the XML Recommendation, however the option is kept
210 * for some applications since this was libxml1 default behaviour.
212 int xmlKeepBlanksDefaultValue = 1;
214 * xmlSubstituteEntitiesDefaultValue:
216 * Global setting, indicate that the parser should not generate entity
217 * references but replace them with the actual content of the entity
218 * Disabled by default, this should be activated when using XPath since
219 * the XPath data model requires entities replacement and the XPath
220 * engine does not handle entities references transparently.
222 int xmlSubstituteEntitiesDefaultValue = 0;
224 xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
225 xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
231 /* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
232 /* Must initialize xmlGenericError in xmlInitParser */
233 void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
239 * Global setting: function used for generic error callbacks
241 xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
243 * xmlGenericErrorContext:
245 * Global setting passed to generic error callbacks
247 void *xmlGenericErrorContext = NULL;
253 * xmlIndentTreeOutput:
255 * Global setting, asking the serializer to indent the output tree by default
258 int xmlIndentTreeOutput = 1;
261 * xmlTreeIndentString:
263 * The string used to do one-level indent. By default is equal to " " (two spaces)
265 const char *xmlTreeIndentString = " ";
268 * xmlSaveNoEmptyTags:
270 * Global setting, asking the serializer to not output empty tags
271 * as <empty/> but <empty></empty>. those two forms are undistinguishable
273 * Disabled by default
275 int xmlSaveNoEmptyTags = 0;
278 * xmlDefaultSAXHandler:
280 * Default handler for XML, builds the DOM tree
282 xmlSAXHandler xmlDefaultSAXHandler = {
302 processingInstruction,
314 * xmlDefaultSAXLocator:
316 * The default SAX Locator
317 * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
319 xmlSAXLocator xmlDefaultSAXLocator = {
320 getPublicId, getSystemId, getLineNumber, getColumnNumber
323 #ifdef LIBXML_HTML_ENABLED
325 * htmlDefaultSAXHandler:
327 * Default handler for HTML, builds the DOM tree
329 xmlSAXHandler htmlDefaultSAXHandler = {
359 #endif /* LIBXML_HTML_ENABLED */
361 #ifdef LIBXML_DOCB_ENABLED
363 * docbDefaultSAXHandler:
365 * Default handler for SGML DocBook, builds the DOM tree
367 xmlSAXHandler docbDefaultSAXHandler = {
397 #endif /* LIBXML_DOCB_ENABLED */
400 * xmlInitializeGlobalState:
401 * @gs: a pointer to a newly allocated global state
403 * xmlInitializeGlobalState() initialize a global state with all the
404 * default values of the library.
407 xmlInitializeGlobalState(xmlGlobalStatePtr gs)
410 fprintf(stderr, "Initializing globals at %lu for thread %d\n",
411 (unsigned long) gs, xmlGetThreadId());
415 * Perform initialization as required by libxml
418 #ifdef LIBXML_DOCB_ENABLED
419 initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
421 #ifdef LIBXML_HTML_ENABLED
422 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
424 initGenericErrorDefaultFunc(&gs->xmlGenericError);
426 gs->oldXMLWDcompatibility = 0;
427 gs->xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
428 gs->xmlDefaultBufferSize = BASE_BUFFER_SIZE;
429 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
430 gs->xmlDefaultSAXLocator.getPublicId = getPublicId;
431 gs->xmlDefaultSAXLocator.getSystemId = getSystemId;
432 gs->xmlDefaultSAXLocator.getLineNumber = getLineNumber;
433 gs->xmlDefaultSAXLocator.getColumnNumber = getColumnNumber;
434 gs->xmlDoValidityCheckingDefaultValue = 0;
435 #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
436 gs->xmlFree = (xmlFreeFunc) xmlMemFree;
437 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
438 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
439 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
441 gs->xmlFree = (xmlFreeFunc) free;
442 gs->xmlMalloc = (xmlMallocFunc) malloc;
443 gs->xmlRealloc = (xmlReallocFunc) realloc;
444 gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
446 gs->xmlGenericErrorContext = NULL;
447 gs->xmlGetWarningsDefaultValue = 1;
448 gs->xmlIndentTreeOutput = 1;
449 gs->xmlTreeIndentString = " ";
450 gs->xmlKeepBlanksDefaultValue = 1;
451 gs->xmlLineNumbersDefaultValue = 0;
452 gs->xmlLoadExtDtdDefaultValue = 0;
453 gs->xmlParserDebugEntities = 0;
454 gs->xmlParserVersion = LIBXML_VERSION_STRING;
455 gs->xmlPedanticParserDefaultValue = 0;
456 gs->xmlSaveNoEmptyTags = 0;
457 gs->xmlSubstituteEntitiesDefaultValue = 0;
459 gs->xmlRegisterNodeDefaultValue = NULL;
460 gs->xmlDeregisterNodeDefaultValue = NULL;
464 * xmlRegisterNodeDefault:
465 * @func: function pointer to the new RegisterNodeFunc
467 * Registers a callback for node creation
469 * Returns the old value of the registration function
472 xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
474 xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
476 xmlRegisterNodeDefaultValue = func;
481 * xmlDeregisterNodeDefault:
482 * @func: function pointer to the new DeregisterNodeFunc
484 * Registers a callback for node destruction
486 * Returns the previous value of the deregistration function
488 xmlDeregisterNodeFunc
489 xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
491 xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
493 xmlDeregisterNodeDefaultValue = func;
498 #ifdef LIBXML_DOCB_ENABLED
499 #undef docbDefaultSAXHandler
501 __docbDefaultSAXHandler(void) {
503 return (&docbDefaultSAXHandler);
505 return (&xmlGetGlobalState()->docbDefaultSAXHandler);
509 #ifdef LIBXML_HTML_ENABLED
510 #undef htmlDefaultSAXHandler
512 __htmlDefaultSAXHandler(void) {
514 return (&htmlDefaultSAXHandler);
516 return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
521 * Everything starting from the line below is
522 * Automatically generated by build_glob.py.
523 * Do not modify the previous line.
527 #undef oldXMLWDcompatibility
529 __oldXMLWDcompatibility(void) {
531 return (&oldXMLWDcompatibility);
533 return (&xmlGetGlobalState()->oldXMLWDcompatibility);
536 #undef xmlBufferAllocScheme
537 xmlBufferAllocationScheme *
538 __xmlBufferAllocScheme(void) {
540 return (&xmlBufferAllocScheme);
542 return (&xmlGetGlobalState()->xmlBufferAllocScheme);
545 #undef xmlDefaultBufferSize
547 __xmlDefaultBufferSize(void) {
549 return (&xmlDefaultBufferSize);
551 return (&xmlGetGlobalState()->xmlDefaultBufferSize);
554 #undef xmlDefaultSAXHandler
556 __xmlDefaultSAXHandler(void) {
558 return (&xmlDefaultSAXHandler);
560 return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
563 #undef xmlDefaultSAXLocator
565 __xmlDefaultSAXLocator(void) {
567 return (&xmlDefaultSAXLocator);
569 return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
572 #undef xmlDoValidityCheckingDefaultValue
574 __xmlDoValidityCheckingDefaultValue(void) {
576 return (&xmlDoValidityCheckingDefaultValue);
578 return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
581 #undef xmlGenericError
582 xmlGenericErrorFunc *
583 __xmlGenericError(void) {
585 return (&xmlGenericError);
587 return (&xmlGetGlobalState()->xmlGenericError);
590 #undef xmlGenericErrorContext
592 __xmlGenericErrorContext(void) {
594 return (&xmlGenericErrorContext);
596 return (&xmlGetGlobalState()->xmlGenericErrorContext);
599 #undef xmlGetWarningsDefaultValue
601 __xmlGetWarningsDefaultValue(void) {
603 return (&xmlGetWarningsDefaultValue);
605 return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
608 #undef xmlIndentTreeOutput
610 __xmlIndentTreeOutput(void) {
612 return (&xmlIndentTreeOutput);
614 return (&xmlGetGlobalState()->xmlIndentTreeOutput);
617 #undef xmlTreeIndentString
619 __xmlTreeIndentString(void) {
621 return (&xmlTreeIndentString);
623 return (&xmlGetGlobalState()->xmlTreeIndentString);
626 #undef xmlKeepBlanksDefaultValue
628 __xmlKeepBlanksDefaultValue(void) {
630 return (&xmlKeepBlanksDefaultValue);
632 return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
635 #undef xmlLineNumbersDefaultValue
637 __xmlLineNumbersDefaultValue(void) {
639 return (&xmlLineNumbersDefaultValue);
641 return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
644 #undef xmlLoadExtDtdDefaultValue
646 __xmlLoadExtDtdDefaultValue(void) {
648 return (&xmlLoadExtDtdDefaultValue);
650 return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
653 #undef xmlParserDebugEntities
655 __xmlParserDebugEntities(void) {
657 return (&xmlParserDebugEntities);
659 return (&xmlGetGlobalState()->xmlParserDebugEntities);
662 #undef xmlParserVersion
664 __xmlParserVersion(void) {
666 return (&xmlParserVersion);
668 return (&xmlGetGlobalState()->xmlParserVersion);
671 #undef xmlPedanticParserDefaultValue
673 __xmlPedanticParserDefaultValue(void) {
675 return (&xmlPedanticParserDefaultValue);
677 return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
680 #undef xmlSaveNoEmptyTags
682 __xmlSaveNoEmptyTags(void) {
684 return (&xmlSaveNoEmptyTags);
686 return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
689 #undef xmlSubstituteEntitiesDefaultValue
691 __xmlSubstituteEntitiesDefaultValue(void) {
693 return (&xmlSubstituteEntitiesDefaultValue);
695 return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
698 #undef xmlRegisterNodeDefaultValue
699 xmlRegisterNodeFunc *
700 __xmlRegisterNodeDefaultValue(void) {
702 return (&xmlRegisterNodeDefaultValue);
704 return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
707 #undef xmlDeregisterNodeDefaultValue
708 xmlDeregisterNodeFunc *
709 __xmlDeregisterNodeDefaultValue(void) {
711 return (&xmlDeregisterNodeDefaultValue);
713 return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);