Fix SetGenericErrorFunc and SetStructured clash
* include/libxml/globals.h globals.c global.data: define a new global
variable (per thread) for structured error reporting, to not conflict
with generic one
* error.c: when defined use the structured error report over any generic
one
diff --git a/globals.c b/globals.c
index cbc6625..9b4a551 100644
--- a/globals.c
+++ b/globals.c
@@ -148,6 +148,7 @@
#undef xmlGenericError
#undef xmlStructuredError
#undef xmlGenericErrorContext
+#undef xmlStructuredErrorContext
#undef xmlGetWarningsDefaultValue
#undef xmlIndentTreeOutput
#undef xmlTreeIndentString
@@ -314,6 +315,13 @@
*/
void *xmlGenericErrorContext = NULL;
static void *xmlGenericErrorContextThrDef = NULL;
+/**
+ * xmlStructuredErrorContext:
+ *
+ * Global setting passed to structured error callbacks
+ */
+void *xmlStructuredErrorContext = NULL;
+static void *xmlStructuredErrorContextThrDef = NULL;
xmlError xmlLastError;
/*
@@ -545,6 +553,7 @@
gs->xmlGenericError = xmlGenericErrorThrDef;
gs->xmlStructuredError = xmlStructuredErrorThrDef;
gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
+ gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
@@ -573,7 +582,7 @@
void
xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
xmlMutexLock(xmlThrDefMutex);
- xmlGenericErrorContextThrDef = ctx;
+ xmlStructuredErrorContextThrDef = ctx;
xmlStructuredErrorThrDef = handler;
xmlMutexUnlock(xmlThrDefMutex);
}
@@ -876,6 +885,15 @@
return (&xmlGetGlobalState()->xmlGenericErrorContext);
}
+#undef xmlStructuredErrorContext
+void * *
+__xmlStructuredErrorContext(void) {
+ if (IS_MAIN_THREAD)
+ return (&xmlStructuredErrorContext);
+ else
+ return (&xmlGetGlobalState()->xmlStructuredErrorContext);
+}
+
#undef xmlGetWarningsDefaultValue
int *
__xmlGetWarningsDefaultValue(void) {
@@ -910,7 +928,7 @@
return ret;
}
-#undef xmlTreeIndentString
+#undef xmlTreeIndentString
const char * *
__xmlTreeIndentString(void) {
if (IS_MAIN_THREAD)