Paul Cercueil / libxml2

Dependents:   libiio

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers globals.c Source File

globals.c

00001 /*
00002  * globals.c: definition and handling of the set of global variables
00003  *            of the library
00004  *
00005  * The bottom of this file is automatically generated by build_glob.py
00006  * based on the description file global.data
00007  *
00008  * See Copyright for the status of this software.
00009  *
00010  * Gary Pennington <Gary.Pennington@uk.sun.com>
00011  * daniel@veillard.com
00012  */
00013 
00014 #define IN_LIBXML
00015 #include "libxml.h"
00016 
00017 #ifdef HAVE_STDLIB_H
00018 #include <stdlib.h>
00019 #endif
00020 #include <string.h>
00021 
00022 #include <libxml/globals.h>
00023 #include <libxml/xmlmemory.h>
00024 #include <libxml/threads.h>
00025 
00026 /* #define DEBUG_GLOBALS */
00027 
00028 /*
00029  * Helpful Macro
00030  */
00031 #ifdef LIBXML_THREAD_ENABLED
00032 #define IS_MAIN_THREAD (xmlIsMainThread())
00033 #else
00034 #define IS_MAIN_THREAD 1
00035 #endif
00036 
00037 /*
00038  * Mutex to protect "ForNewThreads" variables
00039  */
00040 static xmlMutexPtr xmlThrDefMutex = NULL;
00041 
00042 /**
00043  * xmlInitGlobals:
00044  *
00045  * Additional initialisation for multi-threading
00046  */
00047 void xmlInitGlobals(void)
00048 {
00049     if (xmlThrDefMutex == NULL)
00050         xmlThrDefMutex = xmlNewMutex();
00051 }
00052 
00053 /**
00054  * xmlCleanupGlobals:
00055  *
00056  * Additional cleanup for multi-threading
00057  */
00058 void xmlCleanupGlobals(void)
00059 {
00060     if (xmlThrDefMutex != NULL) {
00061     xmlFreeMutex(xmlThrDefMutex);
00062     xmlThrDefMutex = NULL;
00063     }
00064     __xmlGlobalInitMutexDestroy();
00065 }
00066 
00067 /************************************************************************
00068  *                                  *
00069  *  All the user accessible global variables of the library     *
00070  *                                  *
00071  ************************************************************************/
00072 
00073 /*
00074  * Memory allocation routines
00075  */
00076 #undef  xmlFree
00077 #undef  xmlMalloc
00078 #undef  xmlMallocAtomic
00079 #undef  xmlMemStrdup
00080 #undef  xmlRealloc
00081 
00082 #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
00083 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
00084 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
00085 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
00086 xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
00087 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
00088 #else
00089 /**
00090  * xmlFree:
00091  * @mem: an already allocated block of memory
00092  *
00093  * The variable holding the libxml free() implementation
00094  */
00095 xmlFreeFunc xmlFree = (xmlFreeFunc) free;
00096 /**
00097  * xmlMalloc:
00098  * @size:  the size requested in bytes
00099  *
00100  * The variable holding the libxml malloc() implementation
00101  *
00102  * Returns a pointer to the newly allocated block or NULL in case of error
00103  */
00104 xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
00105 /**
00106  * xmlMallocAtomic:
00107  * @size:  the size requested in bytes
00108  *
00109  * The variable holding the libxml malloc() implementation for atomic
00110  * data (i.e. blocks not containings pointers), useful when using a
00111  * garbage collecting allocator.
00112  *
00113  * Returns a pointer to the newly allocated block or NULL in case of error
00114  */
00115 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc;
00116 /**
00117  * xmlRealloc:
00118  * @mem: an already allocated block of memory
00119  * @size:  the new size requested in bytes
00120  *
00121  * The variable holding the libxml realloc() implementation
00122  *
00123  * Returns a pointer to the newly reallocated block or NULL in case of error
00124  */
00125 xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
00126 /**
00127  * xmlMemStrdup:
00128  * @str: a zero terminated string
00129  *
00130  * The variable holding the libxml strdup() implementation
00131  *
00132  * Returns the copy of the string or NULL in case of error
00133  */
00134 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
00135 #endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
00136 
00137 #include <libxml/threads.h>
00138 #include <libxml/globals.h>
00139 #include <libxml/SAX.h>
00140 
00141 #undef  docbDefaultSAXHandler
00142 #undef  htmlDefaultSAXHandler
00143 #undef  oldXMLWDcompatibility
00144 #undef  xmlBufferAllocScheme
00145 #undef  xmlDefaultBufferSize
00146 #undef  xmlDefaultSAXHandler
00147 #undef  xmlDefaultSAXLocator
00148 #undef  xmlDoValidityCheckingDefaultValue
00149 #undef  xmlGenericError
00150 #undef  xmlStructuredError
00151 #undef  xmlGenericErrorContext
00152 #undef  xmlStructuredErrorContext
00153 #undef  xmlGetWarningsDefaultValue
00154 #undef  xmlIndentTreeOutput
00155 #undef  xmlTreeIndentString
00156 #undef  xmlKeepBlanksDefaultValue
00157 #undef  xmlLineNumbersDefaultValue
00158 #undef  xmlLoadExtDtdDefaultValue
00159 #undef  xmlParserDebugEntities
00160 #undef  xmlParserVersion
00161 #undef  xmlPedanticParserDefaultValue
00162 #undef  xmlSaveNoEmptyTags
00163 #undef  xmlSubstituteEntitiesDefaultValue
00164 #undef  xmlRegisterNodeDefaultValue
00165 #undef  xmlDeregisterNodeDefaultValue
00166 #undef  xmlLastError
00167 
00168 #undef  xmlParserInputBufferCreateFilenameValue
00169 #undef  xmlOutputBufferCreateFilenameValue
00170 /**
00171  * xmlParserVersion:
00172  *
00173  * Constant string describing the internal version of the library
00174  */
00175 const char *xmlParserVersion = LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA;
00176 
00177 /**
00178  * xmlBufferAllocScheme:
00179  *
00180  * Global setting, default allocation policy for buffers, default is
00181  * XML_BUFFER_ALLOC_EXACT
00182  */
00183 xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
00184 static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT;
00185 /**
00186  * xmlDefaultBufferSize:
00187  *
00188  * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
00189  */
00190 int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
00191 static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
00192 
00193 /*
00194  * Parser defaults
00195  */
00196 
00197 /**
00198  * oldXMLWDcompatibility:
00199  *
00200  * Global setting, DEPRECATED.
00201  */
00202 int oldXMLWDcompatibility = 0; /* DEPRECATED */
00203 /**
00204  * xmlParserDebugEntities:
00205  *
00206  * Global setting, asking the parser to print out debugging informations.
00207  * while handling entities.
00208  * Disabled by default
00209  */
00210 int xmlParserDebugEntities = 0;
00211 static int xmlParserDebugEntitiesThrDef = 0;
00212 /**
00213  * xmlDoValidityCheckingDefaultValue:
00214  *
00215  * Global setting, indicate that the parser should work in validating mode.
00216  * Disabled by default.
00217  */
00218 int xmlDoValidityCheckingDefaultValue = 0;
00219 static int xmlDoValidityCheckingDefaultValueThrDef = 0;
00220 /**
00221  * xmlGetWarningsDefaultValue:
00222  *
00223  * Global setting, indicate that the parser should provide warnings.
00224  * Activated by default.
00225  */
00226 int xmlGetWarningsDefaultValue = 1;
00227 static int xmlGetWarningsDefaultValueThrDef = 1;
00228 /**
00229  * xmlLoadExtDtdDefaultValue:
00230  *
00231  * Global setting, indicate that the parser should load DTD while not
00232  * validating.
00233  * Disabled by default.
00234  */
00235 int xmlLoadExtDtdDefaultValue = 0;
00236 static int xmlLoadExtDtdDefaultValueThrDef = 0;
00237 /**
00238  * xmlPedanticParserDefaultValue:
00239  *
00240  * Global setting, indicate that the parser be pedantic
00241  * Disabled by default.
00242  */
00243 int xmlPedanticParserDefaultValue = 0;
00244 static int xmlPedanticParserDefaultValueThrDef = 0;
00245 /**
00246  * xmlLineNumbersDefaultValue:
00247  *
00248  * Global setting, indicate that the parser should store the line number
00249  * in the content field of elements in the DOM tree.
00250  * Disabled by default since this may not be safe for old classes of
00251  * applicaton.
00252  */
00253 int xmlLineNumbersDefaultValue = 0;
00254 static int xmlLineNumbersDefaultValueThrDef = 0;
00255 /**
00256  * xmlKeepBlanksDefaultValue:
00257  *
00258  * Global setting, indicate that the parser should keep all blanks
00259  * nodes found in the content
00260  * Activated by default, this is actually needed to have the parser
00261  * conformant to the XML Recommendation, however the option is kept
00262  * for some applications since this was libxml1 default behaviour.
00263  */
00264 int xmlKeepBlanksDefaultValue = 1;
00265 static int xmlKeepBlanksDefaultValueThrDef = 1;
00266 /**
00267  * xmlSubstituteEntitiesDefaultValue:
00268  *
00269  * Global setting, indicate that the parser should not generate entity
00270  * references but replace them with the actual content of the entity
00271  * Disabled by default, this should be activated when using XPath since
00272  * the XPath data model requires entities replacement and the XPath
00273  * engine does not handle entities references transparently.
00274  */
00275 int xmlSubstituteEntitiesDefaultValue = 0;
00276 static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
00277 
00278 xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
00279 static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
00280 xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
00281 static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
00282 
00283 xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL;
00284 static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL;
00285 
00286 xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
00287 static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL;
00288 
00289 /*
00290  * Error handling
00291  */
00292 
00293 /* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
00294 /* Must initialize xmlGenericError in xmlInitParser */
00295 void XMLCDECL xmlGenericErrorDefaultFunc    (void *ctx ATTRIBUTE_UNUSED,
00296                  const char *msg,
00297                  ...);
00298 /**
00299  * xmlGenericError:
00300  *
00301  * Global setting: function used for generic error callbacks
00302  */
00303 xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
00304 static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
00305 /**
00306  * xmlStructuredError:
00307  *
00308  * Global setting: function used for structured error callbacks
00309  */
00310 xmlStructuredErrorFunc xmlStructuredError = NULL;
00311 static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
00312 /**
00313  * xmlGenericErrorContext:
00314  *
00315  * Global setting passed to generic error callbacks
00316  */
00317 void *xmlGenericErrorContext = NULL;
00318 static void *xmlGenericErrorContextThrDef = NULL;
00319 /**
00320  * xmlStructuredErrorContext:
00321  *
00322  * Global setting passed to structured error callbacks
00323  */
00324 void *xmlStructuredErrorContext = NULL;
00325 static void *xmlStructuredErrorContextThrDef = NULL;
00326 xmlError xmlLastError;
00327 
00328 /*
00329  * output defaults
00330  */
00331 /**
00332  * xmlIndentTreeOutput:
00333  *
00334  * Global setting, asking the serializer to indent the output tree by default
00335  * Enabled by default
00336  */
00337 int xmlIndentTreeOutput = 1;
00338 static int xmlIndentTreeOutputThrDef = 1;
00339 
00340 /**
00341  * xmlTreeIndentString:
00342  *
00343  * The string used to do one-level indent. By default is equal to "  " (two spaces)
00344  */
00345 const char *xmlTreeIndentString = "  ";
00346 static const char *xmlTreeIndentStringThrDef = "  ";
00347 
00348 /**
00349  * xmlSaveNoEmptyTags:
00350  *
00351  * Global setting, asking the serializer to not output empty tags
00352  * as <empty/> but <empty></empty>. those two forms are undistinguishable
00353  * once parsed.
00354  * Disabled by default
00355  */
00356 int xmlSaveNoEmptyTags = 0;
00357 static int xmlSaveNoEmptyTagsThrDef = 0;
00358 
00359 #ifdef LIBXML_SAX1_ENABLED
00360 /**
00361  * xmlDefaultSAXHandler:
00362  *
00363  * Default SAX version1 handler for XML, builds the DOM tree
00364  */
00365 xmlSAXHandlerV1 xmlDefaultSAXHandler = {
00366     xmlSAX2InternalSubset,
00367     xmlSAX2IsStandalone,
00368     xmlSAX2HasInternalSubset,
00369     xmlSAX2HasExternalSubset,
00370     xmlSAX2ResolveEntity,
00371     xmlSAX2GetEntity,
00372     xmlSAX2EntityDecl,
00373     xmlSAX2NotationDecl,
00374     xmlSAX2AttributeDecl,
00375     xmlSAX2ElementDecl,
00376     xmlSAX2UnparsedEntityDecl,
00377     xmlSAX2SetDocumentLocator,
00378     xmlSAX2StartDocument,
00379     xmlSAX2EndDocument,
00380     xmlSAX2StartElement,
00381     xmlSAX2EndElement,
00382     xmlSAX2Reference,
00383     xmlSAX2Characters,
00384     xmlSAX2Characters,
00385     xmlSAX2ProcessingInstruction,
00386     xmlSAX2Comment,
00387     xmlParserWarning,
00388     xmlParserError,
00389     xmlParserError,
00390     xmlSAX2GetParameterEntity,
00391     xmlSAX2CDataBlock,
00392     xmlSAX2ExternalSubset,
00393     0,
00394 };
00395 #endif /* LIBXML_SAX1_ENABLED */
00396 
00397 /**
00398  * xmlDefaultSAXLocator:
00399  *
00400  * The default SAX Locator
00401  * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
00402  */
00403 xmlSAXLocator xmlDefaultSAXLocator = {
00404     xmlSAX2GetPublicId,
00405     xmlSAX2GetSystemId,
00406     xmlSAX2GetLineNumber,
00407     xmlSAX2GetColumnNumber
00408 };
00409 
00410 #ifdef LIBXML_HTML_ENABLED
00411 /**
00412  * htmlDefaultSAXHandler:
00413  *
00414  * Default old SAX v1 handler for HTML, builds the DOM tree
00415  */
00416 xmlSAXHandlerV1 htmlDefaultSAXHandler = {
00417     xmlSAX2InternalSubset,
00418     NULL,
00419     NULL,
00420     NULL,
00421     NULL,
00422     xmlSAX2GetEntity,
00423     NULL,
00424     NULL,
00425     NULL,
00426     NULL,
00427     NULL,
00428     xmlSAX2SetDocumentLocator,
00429     xmlSAX2StartDocument,
00430     xmlSAX2EndDocument,
00431     xmlSAX2StartElement,
00432     xmlSAX2EndElement,
00433     NULL,
00434     xmlSAX2Characters,
00435     xmlSAX2IgnorableWhitespace,
00436     xmlSAX2ProcessingInstruction,
00437     xmlSAX2Comment,
00438     xmlParserWarning,
00439     xmlParserError,
00440     xmlParserError,
00441     xmlSAX2GetParameterEntity,
00442     xmlSAX2CDataBlock,
00443     NULL,
00444     0,
00445 };
00446 #endif /* LIBXML_HTML_ENABLED */
00447 
00448 #ifdef LIBXML_DOCB_ENABLED
00449 /**
00450  * docbDefaultSAXHandler:
00451  *
00452  * Default old SAX v1 handler for SGML DocBook, builds the DOM tree
00453  */
00454 xmlSAXHandlerV1 docbDefaultSAXHandler = {
00455     xmlSAX2InternalSubset,
00456     xmlSAX2IsStandalone,
00457     xmlSAX2HasInternalSubset,
00458     xmlSAX2HasExternalSubset,
00459     xmlSAX2ResolveEntity,
00460     xmlSAX2GetEntity,
00461     xmlSAX2EntityDecl,
00462     NULL,
00463     NULL,
00464     NULL,
00465     NULL,
00466     xmlSAX2SetDocumentLocator,
00467     xmlSAX2StartDocument,
00468     xmlSAX2EndDocument,
00469     xmlSAX2StartElement,
00470     xmlSAX2EndElement,
00471     xmlSAX2Reference,
00472     xmlSAX2Characters,
00473     xmlSAX2IgnorableWhitespace,
00474     NULL,
00475     xmlSAX2Comment,
00476     xmlParserWarning,
00477     xmlParserError,
00478     xmlParserError,
00479     xmlSAX2GetParameterEntity,
00480     NULL,
00481     NULL,
00482     0,
00483 };
00484 #endif /* LIBXML_DOCB_ENABLED */
00485 
00486 /**
00487  * xmlInitializeGlobalState:
00488  * @gs: a pointer to a newly allocated global state
00489  *
00490  * xmlInitializeGlobalState() initialize a global state with all the
00491  * default values of the library.
00492  */
00493 void
00494 xmlInitializeGlobalState(xmlGlobalStatePtr gs)
00495 {
00496 #ifdef DEBUG_GLOBALS
00497     fprintf(stderr, "Initializing globals at %lu for thread %d\n",
00498         (unsigned long) gs, xmlGetThreadId());
00499 #endif
00500 
00501     /*
00502      * Perform initialization as required by libxml
00503      */
00504     if (xmlThrDefMutex == NULL)
00505         xmlInitGlobals();
00506 
00507     xmlMutexLock(xmlThrDefMutex);
00508 
00509 #if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
00510     initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
00511 #endif
00512 #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
00513     inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
00514 #endif
00515 
00516     gs->oldXMLWDcompatibility = 0;
00517     gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
00518     gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
00519 #if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
00520     initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
00521 #endif /* LIBXML_SAX1_ENABLED */
00522     gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
00523     gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
00524     gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
00525     gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
00526     gs->xmlDoValidityCheckingDefaultValue =
00527          xmlDoValidityCheckingDefaultValueThrDef;
00528 #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
00529     gs->xmlFree = (xmlFreeFunc) xmlMemFree;
00530     gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
00531     gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
00532     gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
00533     gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
00534 #else
00535     gs->xmlFree = (xmlFreeFunc) free;
00536     gs->xmlMalloc = (xmlMallocFunc) malloc;
00537     gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
00538     gs->xmlRealloc = (xmlReallocFunc) realloc;
00539     gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
00540 #endif
00541     gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
00542     gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
00543     gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
00544     gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
00545     gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
00546     gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
00547     gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
00548     gs->xmlParserVersion = LIBXML_VERSION_STRING;
00549     gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
00550     gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
00551     gs->xmlSubstituteEntitiesDefaultValue =
00552         xmlSubstituteEntitiesDefaultValueThrDef;
00553 
00554     gs->xmlGenericError = xmlGenericErrorThrDef;
00555     gs->xmlStructuredError = xmlStructuredErrorThrDef;
00556     gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
00557     gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
00558     gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
00559     gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
00560 
00561     gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
00562     gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
00563     memset(&gs->xmlLastError, 0, sizeof(xmlError));
00564 
00565     xmlMutexUnlock(xmlThrDefMutex);
00566 }
00567 
00568 /**
00569  * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions,
00570  *               those are really internal work
00571  */
00572 void
00573 xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
00574     xmlMutexLock(xmlThrDefMutex);
00575     xmlGenericErrorContextThrDef = ctx;
00576     if (handler != NULL)
00577     xmlGenericErrorThrDef = handler;
00578     else
00579     xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
00580     xmlMutexUnlock(xmlThrDefMutex);
00581 }
00582 
00583 void
00584 xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
00585     xmlMutexLock(xmlThrDefMutex);
00586     xmlStructuredErrorContextThrDef = ctx;
00587     xmlStructuredErrorThrDef = handler;
00588     xmlMutexUnlock(xmlThrDefMutex);
00589 }
00590 
00591 /**
00592  * xmlRegisterNodeDefault:
00593  * @func: function pointer to the new RegisterNodeFunc
00594  *
00595  * Registers a callback for node creation
00596  *
00597  * Returns the old value of the registration function
00598  */
00599 xmlRegisterNodeFunc
00600 xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
00601 {
00602     xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
00603 
00604     __xmlRegisterCallbacks = 1;
00605     xmlRegisterNodeDefaultValue = func;
00606     return(old);
00607 }
00608 
00609 xmlRegisterNodeFunc
00610 xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
00611 {
00612     xmlRegisterNodeFunc old;
00613 
00614     xmlMutexLock(xmlThrDefMutex);
00615     old = xmlRegisterNodeDefaultValueThrDef;
00616 
00617     __xmlRegisterCallbacks = 1;
00618     xmlRegisterNodeDefaultValueThrDef = func;
00619     xmlMutexUnlock(xmlThrDefMutex);
00620 
00621     return(old);
00622 }
00623 
00624 /**
00625  * xmlDeregisterNodeDefault:
00626  * @func: function pointer to the new DeregisterNodeFunc
00627  *
00628  * Registers a callback for node destruction
00629  *
00630  * Returns the previous value of the deregistration function
00631  */
00632 xmlDeregisterNodeFunc
00633 xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
00634 {
00635     xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
00636 
00637     __xmlRegisterCallbacks = 1;
00638     xmlDeregisterNodeDefaultValue = func;
00639     return(old);
00640 }
00641 
00642 xmlDeregisterNodeFunc
00643 xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
00644 {
00645     xmlDeregisterNodeFunc old;
00646 
00647     xmlMutexLock(xmlThrDefMutex);
00648     old = xmlDeregisterNodeDefaultValueThrDef;
00649 
00650     __xmlRegisterCallbacks = 1;
00651     xmlDeregisterNodeDefaultValueThrDef = func;
00652     xmlMutexUnlock(xmlThrDefMutex);
00653 
00654     return(old);
00655 }
00656 
00657 xmlParserInputBufferCreateFilenameFunc
00658 xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
00659 {
00660     xmlParserInputBufferCreateFilenameFunc old;
00661 
00662     xmlMutexLock(xmlThrDefMutex);
00663     old = xmlParserInputBufferCreateFilenameValueThrDef;
00664     if (old == NULL) {
00665         old = __xmlParserInputBufferCreateFilename;
00666     }
00667 
00668     xmlParserInputBufferCreateFilenameValueThrDef = func;
00669     xmlMutexUnlock(xmlThrDefMutex);
00670 
00671     return(old);
00672 }
00673 
00674 xmlOutputBufferCreateFilenameFunc
00675 xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
00676 {
00677     xmlOutputBufferCreateFilenameFunc old;
00678 
00679     xmlMutexLock(xmlThrDefMutex);
00680     old = xmlOutputBufferCreateFilenameValueThrDef;
00681 #ifdef LIBXML_OUTPUT_ENABLED
00682     if (old == NULL) {
00683         old = __xmlOutputBufferCreateFilename;
00684     }
00685 #endif
00686     xmlOutputBufferCreateFilenameValueThrDef = func;
00687     xmlMutexUnlock(xmlThrDefMutex);
00688 
00689     return(old);
00690 }
00691 
00692 #ifdef LIBXML_DOCB_ENABLED
00693 #undef  docbDefaultSAXHandler
00694 xmlSAXHandlerV1 *
00695 __docbDefaultSAXHandler(void) {
00696     if (IS_MAIN_THREAD)
00697     return (&docbDefaultSAXHandler);
00698     else
00699     return (&xmlGetGlobalState()->docbDefaultSAXHandler);
00700 }
00701 #endif
00702 
00703 #ifdef LIBXML_HTML_ENABLED
00704 #undef  htmlDefaultSAXHandler
00705 xmlSAXHandlerV1 *
00706 __htmlDefaultSAXHandler(void) {
00707     if (IS_MAIN_THREAD)
00708     return (&htmlDefaultSAXHandler);
00709     else
00710     return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
00711 }
00712 #endif
00713 
00714 #undef xmlLastError
00715 xmlError *
00716 __xmlLastError(void) {
00717     if (IS_MAIN_THREAD)
00718     return (&xmlLastError);
00719     else
00720     return (&xmlGetGlobalState()->xmlLastError);
00721 }
00722 
00723 /*
00724  * The following memory routines were apparently lost at some point,
00725  * and were re-inserted at this point on June 10, 2004.  Hope it's
00726  * the right place for them :-)
00727  */
00728 #if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED)
00729 #undef xmlMalloc
00730 xmlMallocFunc *
00731 __xmlMalloc(void){
00732     if (IS_MAIN_THREAD)
00733         return (&xmlMalloc);
00734     else
00735     return (&xmlGetGlobalState()->xmlMalloc);
00736 }
00737 
00738 #undef xmlMallocAtomic
00739 xmlMallocFunc *
00740 __xmlMallocAtomic(void){
00741     if (IS_MAIN_THREAD)
00742         return (&xmlMallocAtomic);
00743     else
00744         return (&xmlGetGlobalState()->xmlMallocAtomic);
00745 }
00746 
00747 #undef xmlRealloc
00748 xmlReallocFunc *
00749 __xmlRealloc(void){
00750     if (IS_MAIN_THREAD)
00751         return (&xmlRealloc);
00752     else
00753         return (&xmlGetGlobalState()->xmlRealloc);
00754 }
00755 
00756 #undef xmlFree
00757 xmlFreeFunc *
00758 __xmlFree(void){
00759     if (IS_MAIN_THREAD)
00760         return (&xmlFree);
00761     else
00762         return (&xmlGetGlobalState()->xmlFree);
00763 }
00764 
00765 xmlStrdupFunc *
00766 __xmlMemStrdup(void){
00767     if (IS_MAIN_THREAD)
00768         return (&xmlMemStrdup);
00769     else
00770         return (&xmlGetGlobalState()->xmlMemStrdup);
00771 }
00772 
00773 #endif
00774 
00775 /*
00776  * Everything starting from the line below is
00777  * Automatically generated by build_glob.py.
00778  * Do not modify the previous line.
00779  */
00780 
00781 
00782 #undef  oldXMLWDcompatibility
00783 int *
00784 __oldXMLWDcompatibility(void) {
00785     if (IS_MAIN_THREAD)
00786     return (&oldXMLWDcompatibility);
00787     else
00788     return (&xmlGetGlobalState()->oldXMLWDcompatibility);
00789 }
00790 
00791 #undef  xmlBufferAllocScheme
00792 xmlBufferAllocationScheme *
00793 __xmlBufferAllocScheme(void) {
00794     if (IS_MAIN_THREAD)
00795     return (&xmlBufferAllocScheme);
00796     else
00797     return (&xmlGetGlobalState()->xmlBufferAllocScheme);
00798 }
00799 xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
00800     xmlBufferAllocationScheme ret;
00801     xmlMutexLock(xmlThrDefMutex);
00802     ret = xmlBufferAllocSchemeThrDef;
00803     xmlBufferAllocSchemeThrDef = v;
00804     xmlMutexUnlock(xmlThrDefMutex);
00805     return ret;
00806 }
00807 
00808 #undef  xmlDefaultBufferSize
00809 int *
00810 __xmlDefaultBufferSize(void) {
00811     if (IS_MAIN_THREAD)
00812     return (&xmlDefaultBufferSize);
00813     else
00814     return (&xmlGetGlobalState()->xmlDefaultBufferSize);
00815 }
00816 int xmlThrDefDefaultBufferSize(int v) {
00817     int ret;
00818     xmlMutexLock(xmlThrDefMutex);
00819     ret = xmlDefaultBufferSizeThrDef;
00820     xmlDefaultBufferSizeThrDef = v;
00821     xmlMutexUnlock(xmlThrDefMutex);
00822     return ret;
00823 }
00824 
00825 #ifdef LIBXML_SAX1_ENABLED
00826 #undef  xmlDefaultSAXHandler
00827 xmlSAXHandlerV1 *
00828 __xmlDefaultSAXHandler(void) {
00829     if (IS_MAIN_THREAD)
00830     return (&xmlDefaultSAXHandler);
00831     else
00832     return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
00833 }
00834 #endif /* LIBXML_SAX1_ENABLED */
00835 
00836 #undef  xmlDefaultSAXLocator
00837 xmlSAXLocator *
00838 __xmlDefaultSAXLocator(void) {
00839     if (IS_MAIN_THREAD)
00840     return (&xmlDefaultSAXLocator);
00841     else
00842     return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
00843 }
00844 
00845 #undef  xmlDoValidityCheckingDefaultValue
00846 int *
00847 __xmlDoValidityCheckingDefaultValue(void) {
00848     if (IS_MAIN_THREAD)
00849     return (&xmlDoValidityCheckingDefaultValue);
00850     else
00851     return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
00852 }
00853 int xmlThrDefDoValidityCheckingDefaultValue(int v) {
00854     int ret;
00855     xmlMutexLock(xmlThrDefMutex);
00856     ret = xmlDoValidityCheckingDefaultValueThrDef;
00857     xmlDoValidityCheckingDefaultValueThrDef = v;
00858     xmlMutexUnlock(xmlThrDefMutex);
00859     return ret;
00860 }
00861 
00862 #undef  xmlGenericError
00863 xmlGenericErrorFunc *
00864 __xmlGenericError(void) {
00865     if (IS_MAIN_THREAD)
00866     return (&xmlGenericError);
00867     else
00868     return (&xmlGetGlobalState()->xmlGenericError);
00869 }
00870 
00871 #undef  xmlStructuredError
00872 xmlStructuredErrorFunc *
00873 __xmlStructuredError(void) {
00874     if (IS_MAIN_THREAD)
00875     return (&xmlStructuredError);
00876     else
00877     return (&xmlGetGlobalState()->xmlStructuredError);
00878 }
00879 
00880 #undef  xmlGenericErrorContext
00881 void * *
00882 __xmlGenericErrorContext(void) {
00883     if (IS_MAIN_THREAD)
00884     return (&xmlGenericErrorContext);
00885     else
00886     return (&xmlGetGlobalState()->xmlGenericErrorContext);
00887 }
00888 
00889 #undef  xmlStructuredErrorContext
00890 void * *
00891 __xmlStructuredErrorContext(void) {
00892     if (IS_MAIN_THREAD)
00893     return (&xmlStructuredErrorContext);
00894     else
00895     return (&xmlGetGlobalState()->xmlStructuredErrorContext);
00896 }
00897 
00898 #undef  xmlGetWarningsDefaultValue
00899 int *
00900 __xmlGetWarningsDefaultValue(void) {
00901     if (IS_MAIN_THREAD)
00902     return (&xmlGetWarningsDefaultValue);
00903     else
00904     return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
00905 }
00906 int xmlThrDefGetWarningsDefaultValue(int v) {
00907     int ret;
00908     xmlMutexLock(xmlThrDefMutex);
00909     ret = xmlGetWarningsDefaultValueThrDef;
00910     xmlGetWarningsDefaultValueThrDef = v;
00911     xmlMutexUnlock(xmlThrDefMutex);
00912     return ret;
00913 }
00914 
00915 #undef  xmlIndentTreeOutput
00916 int *
00917 __xmlIndentTreeOutput(void) {
00918     if (IS_MAIN_THREAD)
00919     return (&xmlIndentTreeOutput);
00920     else
00921     return (&xmlGetGlobalState()->xmlIndentTreeOutput);
00922 }
00923 int xmlThrDefIndentTreeOutput(int v) {
00924     int ret;
00925     xmlMutexLock(xmlThrDefMutex);
00926     ret = xmlIndentTreeOutputThrDef;
00927     xmlIndentTreeOutputThrDef = v;
00928     xmlMutexUnlock(xmlThrDefMutex);
00929     return ret;
00930 }
00931 
00932 #undef  xmlTreeIndentString
00933 const char * *
00934 __xmlTreeIndentString(void) {
00935     if (IS_MAIN_THREAD)
00936     return (&xmlTreeIndentString);
00937     else
00938     return (&xmlGetGlobalState()->xmlTreeIndentString);
00939 }
00940 const char * xmlThrDefTreeIndentString(const char * v) {
00941     const char * ret;
00942     xmlMutexLock(xmlThrDefMutex);
00943     ret = xmlTreeIndentStringThrDef;
00944     xmlTreeIndentStringThrDef = v;
00945     xmlMutexUnlock(xmlThrDefMutex);
00946     return ret;
00947 }
00948 
00949 #undef  xmlKeepBlanksDefaultValue
00950 int *
00951 __xmlKeepBlanksDefaultValue(void) {
00952     if (IS_MAIN_THREAD)
00953     return (&xmlKeepBlanksDefaultValue);
00954     else
00955     return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
00956 }
00957 int xmlThrDefKeepBlanksDefaultValue(int v) {
00958     int ret;
00959     xmlMutexLock(xmlThrDefMutex);
00960     ret = xmlKeepBlanksDefaultValueThrDef;
00961     xmlKeepBlanksDefaultValueThrDef = v;
00962     xmlMutexUnlock(xmlThrDefMutex);
00963     return ret;
00964 }
00965 
00966 #undef  xmlLineNumbersDefaultValue
00967 int *
00968 __xmlLineNumbersDefaultValue(void) {
00969     if (IS_MAIN_THREAD)
00970     return (&xmlLineNumbersDefaultValue);
00971     else
00972     return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
00973 }
00974 int xmlThrDefLineNumbersDefaultValue(int v) {
00975     int ret;
00976     xmlMutexLock(xmlThrDefMutex);
00977     ret = xmlLineNumbersDefaultValueThrDef;
00978     xmlLineNumbersDefaultValueThrDef = v;
00979     xmlMutexUnlock(xmlThrDefMutex);
00980     return ret;
00981 }
00982 
00983 #undef  xmlLoadExtDtdDefaultValue
00984 int *
00985 __xmlLoadExtDtdDefaultValue(void) {
00986     if (IS_MAIN_THREAD)
00987     return (&xmlLoadExtDtdDefaultValue);
00988     else
00989     return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
00990 }
00991 int xmlThrDefLoadExtDtdDefaultValue(int v) {
00992     int ret;
00993     xmlMutexLock(xmlThrDefMutex);
00994     ret = xmlLoadExtDtdDefaultValueThrDef;
00995     xmlLoadExtDtdDefaultValueThrDef = v;
00996     xmlMutexUnlock(xmlThrDefMutex);
00997     return ret;
00998 }
00999 
01000 #undef  xmlParserDebugEntities
01001 int *
01002 __xmlParserDebugEntities(void) {
01003     if (IS_MAIN_THREAD)
01004     return (&xmlParserDebugEntities);
01005     else
01006     return (&xmlGetGlobalState()->xmlParserDebugEntities);
01007 }
01008 int xmlThrDefParserDebugEntities(int v) {
01009     int ret;
01010     xmlMutexLock(xmlThrDefMutex);
01011     ret = xmlParserDebugEntitiesThrDef;
01012     xmlParserDebugEntitiesThrDef = v;
01013     xmlMutexUnlock(xmlThrDefMutex);
01014     return ret;
01015 }
01016 
01017 #undef  xmlParserVersion
01018 const char * *
01019 __xmlParserVersion(void) {
01020     if (IS_MAIN_THREAD)
01021     return (&xmlParserVersion);
01022     else
01023     return (&xmlGetGlobalState()->xmlParserVersion);
01024 }
01025 
01026 #undef  xmlPedanticParserDefaultValue
01027 int *
01028 __xmlPedanticParserDefaultValue(void) {
01029     if (IS_MAIN_THREAD)
01030     return (&xmlPedanticParserDefaultValue);
01031     else
01032     return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
01033 }
01034 int xmlThrDefPedanticParserDefaultValue(int v) {
01035     int ret;
01036     xmlMutexLock(xmlThrDefMutex);
01037     ret = xmlPedanticParserDefaultValueThrDef;
01038     xmlPedanticParserDefaultValueThrDef = v;
01039     xmlMutexUnlock(xmlThrDefMutex);
01040     return ret;
01041 }
01042 
01043 #undef  xmlSaveNoEmptyTags
01044 int *
01045 __xmlSaveNoEmptyTags(void) {
01046     if (IS_MAIN_THREAD)
01047     return (&xmlSaveNoEmptyTags);
01048     else
01049     return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
01050 }
01051 int xmlThrDefSaveNoEmptyTags(int v) {
01052     int ret;
01053     xmlMutexLock(xmlThrDefMutex);
01054     ret = xmlSaveNoEmptyTagsThrDef;
01055     xmlSaveNoEmptyTagsThrDef = v;
01056     xmlMutexUnlock(xmlThrDefMutex);
01057     return ret;
01058 }
01059 
01060 #undef  xmlSubstituteEntitiesDefaultValue
01061 int *
01062 __xmlSubstituteEntitiesDefaultValue(void) {
01063     if (IS_MAIN_THREAD)
01064     return (&xmlSubstituteEntitiesDefaultValue);
01065     else
01066     return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
01067 }
01068 int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
01069     int ret;
01070     xmlMutexLock(xmlThrDefMutex);
01071     ret = xmlSubstituteEntitiesDefaultValueThrDef;
01072     xmlSubstituteEntitiesDefaultValueThrDef = v;
01073     xmlMutexUnlock(xmlThrDefMutex);
01074     return ret;
01075 }
01076 
01077 #undef  xmlRegisterNodeDefaultValue
01078 xmlRegisterNodeFunc *
01079 __xmlRegisterNodeDefaultValue(void) {
01080     if (IS_MAIN_THREAD)
01081     return (&xmlRegisterNodeDefaultValue);
01082     else
01083     return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
01084 }
01085 
01086 #undef  xmlDeregisterNodeDefaultValue
01087 xmlDeregisterNodeFunc *
01088 __xmlDeregisterNodeDefaultValue(void) {
01089     if (IS_MAIN_THREAD)
01090     return (&xmlDeregisterNodeDefaultValue);
01091     else
01092     return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
01093 }
01094 
01095 #undef  xmlParserInputBufferCreateFilenameValue
01096 xmlParserInputBufferCreateFilenameFunc *
01097 __xmlParserInputBufferCreateFilenameValue(void) {
01098     if (IS_MAIN_THREAD)
01099     return (&xmlParserInputBufferCreateFilenameValue);
01100     else
01101     return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
01102 }
01103 
01104 #undef  xmlOutputBufferCreateFilenameValue
01105 xmlOutputBufferCreateFilenameFunc *
01106 __xmlOutputBufferCreateFilenameValue(void) {
01107     if (IS_MAIN_THREAD)
01108     return (&xmlOutputBufferCreateFilenameValue);
01109     else
01110     return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
01111 }
01112 
01113 #define bottom_globals
01114 #include "elfgcchack.h"
01115