Setting up the framework for structured error reporting, touches a lot of
* HTMLparser.c c14n.c catalog.c error.c globals.c parser.c
parserInternals.c relaxng.c valid.c xinclude.c xmlIO.c xmlregexp.c
xmlschemas.c xpath.c xpointer.c include/libxml/globals.h
include/libxml/parser.h include/libxml/valid.h
include/libxml/xmlerror.h: Setting up the framework for structured
error reporting, touches a lot of modules, but little code now
the error handling trail has been cleaned up.
Daniel
diff --git a/globals.c b/globals.c
index fd61cf4..8de87e4 100644
--- a/globals.c
+++ b/globals.c
@@ -136,6 +136,7 @@
#undef xmlDefaultSAXLocator
#undef xmlDoValidityCheckingDefaultValue
#undef xmlGenericError
+#undef xmlStructuredError
#undef xmlGenericErrorContext
#undef xmlGetWarningsDefaultValue
#undef xmlIndentTreeOutput
@@ -288,6 +289,13 @@
xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
/**
+ * xmlStructuredError:
+ *
+ * Global setting: function used for structured error callbacks
+ */
+xmlStructuredErrorFunc xmlStructuredError = NULL;
+static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
+/**
* xmlGenericErrorContext:
*
* Global setting passed to generic error callbacks
@@ -523,6 +531,7 @@
xmlSubstituteEntitiesDefaultValueThrDef;
gs->xmlGenericError = xmlGenericErrorThrDef;
+ gs->xmlStructuredError = xmlStructuredErrorThrDef;
gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
@@ -542,6 +551,14 @@
xmlMutexUnlock(xmlThrDefMutex);
}
+void
+xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
+ xmlMutexLock(xmlThrDefMutex);
+ xmlGenericErrorContextThrDef = ctx;
+ xmlStructuredErrorThrDef = handler;
+ xmlMutexUnlock(xmlThrDefMutex);
+}
+
/**
* xmlRegisterNodeDefault:
* @func: function pointer to the new RegisterNodeFunc
@@ -736,6 +753,15 @@
return (&xmlGetGlobalState()->xmlGenericError);
}
+#undef xmlStructuredError
+xmlStructuredErrorFunc *
+__xmlStructuredError(void) {
+ if (IS_MAIN_THREAD)
+ return (&xmlStructuredError);
+ else
+ return (&xmlGetGlobalState()->xmlStructuredError);
+}
+
#undef xmlGenericErrorContext
void * *
__xmlGenericErrorContext(void) {