*/
void xmlInitGlobals(void)
{
- xmlThrDefMutex = xmlNewMutex();
+ if (xmlThrDefMutex == NULL)
+ xmlThrDefMutex = xmlNewMutex();
}
/**
xmlFreeMutex(xmlThrDefMutex);
xmlThrDefMutex = NULL;
}
+ __xmlGlobalInitMutexDestroy();
}
/************************************************************************
- * *
+ * *
* All the user accessible global variables of the library *
- * *
+ * *
************************************************************************/
/*
#undef xmlGenericError
#undef xmlStructuredError
#undef xmlGenericErrorContext
+#undef xmlStructuredErrorContext
#undef xmlGetWarningsDefaultValue
#undef xmlIndentTreeOutput
#undef xmlTreeIndentString
* xmlLineNumbersDefaultValue:
*
* Global setting, indicate that the parser should store the line number
- * in the content field of elements in the DOM tree.
+ * in the content field of elements in the DOM tree.
* Disabled by default since this may not be safe for old classes of
* applicaton.
*/
*/
void *xmlGenericErrorContext = NULL;
static void *xmlGenericErrorContextThrDef = NULL;
+/**
+ * xmlStructuredErrorContext:
+ *
+ * Global setting passed to structured error callbacks
+ */
+void *xmlStructuredErrorContext = NULL;
+static void *xmlStructuredErrorContextThrDef = NULL;
xmlError xmlLastError;
/*
#if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
#endif
-#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
#endif
gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
- gs->xmlDoValidityCheckingDefaultValue =
+ gs->xmlDoValidityCheckingDefaultValue =
xmlDoValidityCheckingDefaultValueThrDef;
#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
gs->xmlFree = (xmlFreeFunc) xmlMemFree;
gs->xmlParserVersion = LIBXML_VERSION_STRING;
gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
- gs->xmlSubstituteEntitiesDefaultValue =
+ gs->xmlSubstituteEntitiesDefaultValue =
xmlSubstituteEntitiesDefaultValueThrDef;
gs->xmlGenericError = xmlGenericErrorThrDef;
gs->xmlStructuredError = xmlStructuredErrorThrDef;
gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
+ gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
void
xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
xmlMutexLock(xmlThrDefMutex);
- xmlGenericErrorContextThrDef = ctx;
+ xmlStructuredErrorContextThrDef = ctx;
xmlStructuredErrorThrDef = handler;
xmlMutexUnlock(xmlThrDefMutex);
}
xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
{
xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
-
+
__xmlRegisterCallbacks = 1;
xmlRegisterNodeDefaultValue = func;
return(old);
xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
{
xmlRegisterNodeFunc old;
-
+
xmlMutexLock(xmlThrDefMutex);
old = xmlRegisterNodeDefaultValueThrDef;
-
+
__xmlRegisterCallbacks = 1;
xmlRegisterNodeDefaultValueThrDef = func;
xmlMutexUnlock(xmlThrDefMutex);
xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
{
xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
-
+
__xmlRegisterCallbacks = 1;
xmlDeregisterNodeDefaultValue = func;
return(old);
xmlMutexLock(xmlThrDefMutex);
old = xmlDeregisterNodeDefaultValueThrDef;
-
+
__xmlRegisterCallbacks = 1;
xmlDeregisterNodeDefaultValueThrDef = func;
xmlMutexUnlock(xmlThrDefMutex);
xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
{
xmlParserInputBufferCreateFilenameFunc old;
-
+
xmlMutexLock(xmlThrDefMutex);
old = xmlParserInputBufferCreateFilenameValueThrDef;
if (old == NULL) {
xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
{
xmlOutputBufferCreateFilenameFunc old;
-
+
xmlMutexLock(xmlThrDefMutex);
old = xmlOutputBufferCreateFilenameValueThrDef;
#ifdef LIBXML_OUTPUT_ENABLED
if (IS_MAIN_THREAD)
return (&xmlMalloc);
else
- return (&xmlGetGlobalState()->xmlMalloc);
+ return (&xmlGetGlobalState()->xmlMalloc);
}
#undef xmlMallocAtomic
return (&xmlGetGlobalState()->xmlGenericErrorContext);
}
+#undef xmlStructuredErrorContext
+void * *
+__xmlStructuredErrorContext(void) {
+ if (IS_MAIN_THREAD)
+ return (&xmlStructuredErrorContext);
+ else
+ return (&xmlGetGlobalState()->xmlStructuredErrorContext);
+}
+
#undef xmlGetWarningsDefaultValue
int *
__xmlGetWarningsDefaultValue(void) {
return ret;
}
-#undef xmlTreeIndentString
+#undef xmlTreeIndentString
const char * *
__xmlTreeIndentString(void) {
if (IS_MAIN_THREAD)