From 89f4976728bc73363c57c9966a34b21901210fa8 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 18 Sep 2023 18:44:32 +0200 Subject: [PATCH] globals: Make xmlGlobalState private This removes a public struct but it seems impossible to use its members in a sensible way from external code. --- globals.c | 50 +++++++++++++++++++++++ include/libxml/globals.h | 85 ---------------------------------------- 2 files changed, 50 insertions(+), 85 deletions(-) diff --git a/globals.c b/globals.c index adbd26bc..1147e63f 100644 --- a/globals.c +++ b/globals.c @@ -40,6 +40,56 @@ */ static xmlMutex xmlThrDefMutex; +struct _xmlGlobalState { + const char *gsParserVersion; + + xmlSAXLocator gsDefaultSAXLocator; +#ifdef LIBXML_SAX1_ENABLED + xmlSAXHandlerV1 gsDefaultSAXHandler; +#ifdef LIBXML_HTML_ENABLED + xmlSAXHandlerV1 gsHtmlDefaultSAXHandler; +#endif +#endif + + xmlFreeFunc gsFree; + xmlMallocFunc gsMalloc; + xmlStrdupFunc gsMemStrdup; + xmlReallocFunc gsRealloc; + + xmlGenericErrorFunc gsGenericError; + xmlStructuredErrorFunc gsStructuredError; + void *gsGenericErrorContext; + + int gsOldXMLWDcompatibility; + + xmlBufferAllocationScheme gsBufferAllocScheme; + int gsDefaultBufferSize; + + int gsSubstituteEntitiesDefaultValue; + int gsDoValidityCheckingDefaultValue; + int gsGetWarningsDefaultValue; + int gsKeepBlanksDefaultValue; + int gsLineNumbersDefaultValue; + int gsLoadExtDtdDefaultValue; + int gsParserDebugEntities; + int gsPedanticParserDefaultValue; + + int gsSaveNoEmptyTags; + int gsIndentTreeOutput; + const char *gsTreeIndentString; + + xmlRegisterNodeFunc gsRegisterNodeDefaultValue; + xmlDeregisterNodeFunc gsDeregisterNodeDefaultValue; + + xmlMallocFunc gsMallocAtomic; + xmlError gsLastError; + + xmlParserInputBufferCreateFilenameFunc gsParserInputBufferCreateFilenameValue; + xmlOutputBufferCreateFilenameFunc gsOutputBufferCreateFilenameValue; + + void *gsStructuredErrorContext; +}; + #ifdef LIBXML_THREAD_ENABLED static void xmlFreeGlobalState(void *state); diff --git a/include/libxml/globals.h b/include/libxml/globals.h index f05443fb..1cc8477b 100644 --- a/include/libxml/globals.h +++ b/include/libxml/globals.h @@ -64,44 +64,6 @@ xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFun XMLPUBFUN xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func); -/* - * Externally global symbols which need to be protected for backwards - * compatibility support. - */ - -#undef htmlDefaultSAXHandler -#undef oldXMLWDcompatibility -#undef xmlBufferAllocScheme -#undef xmlDefaultBufferSize -#undef xmlDefaultSAXHandler -#undef xmlDefaultSAXLocator -#undef xmlDoValidityCheckingDefaultValue -#undef xmlFree -#undef xmlGenericError -#undef xmlStructuredError -#undef xmlGenericErrorContext -#undef xmlStructuredErrorContext -#undef xmlGetWarningsDefaultValue -#undef xmlIndentTreeOutput -#undef xmlTreeIndentString -#undef xmlKeepBlanksDefaultValue -#undef xmlLineNumbersDefaultValue -#undef xmlLoadExtDtdDefaultValue -#undef xmlMalloc -#undef xmlMallocAtomic -#undef xmlMemStrdup -#undef xmlParserDebugEntities -#undef xmlParserVersion -#undef xmlPedanticParserDefaultValue -#undef xmlRealloc -#undef xmlSaveNoEmptyTags -#undef xmlSubstituteEntitiesDefaultValue -#undef xmlRegisterNodeDefaultValue -#undef xmlDeregisterNodeDefaultValue -#undef xmlLastError -#undef xmlParserInputBufferCreateFilenameValue -#undef xmlOutputBufferCreateFilenameValue - /** * xmlRegisterNodeFunc: * @node: the current node @@ -119,53 +81,6 @@ typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node); typedef struct _xmlGlobalState xmlGlobalState; typedef xmlGlobalState *xmlGlobalStatePtr; -struct _xmlGlobalState -{ - const char *gsParserVersion; - - xmlSAXLocator gsDefaultSAXLocator; - xmlSAXHandlerV1 gsDefaultSAXHandler; - xmlSAXHandlerV1 gsDocbDefaultSAXHandler; /* unused */ - xmlSAXHandlerV1 gsHtmlDefaultSAXHandler; - - xmlFreeFunc gsFree; - xmlMallocFunc gsMalloc; - xmlStrdupFunc gsMemStrdup; - xmlReallocFunc gsRealloc; - - xmlGenericErrorFunc gsGenericError; - xmlStructuredErrorFunc gsStructuredError; - void *gsGenericErrorContext; - - int gsOldXMLWDcompatibility; - - xmlBufferAllocationScheme gsBufferAllocScheme; - int gsDefaultBufferSize; - - int gsSubstituteEntitiesDefaultValue; - int gsDoValidityCheckingDefaultValue; - int gsGetWarningsDefaultValue; - int gsKeepBlanksDefaultValue; - int gsLineNumbersDefaultValue; - int gsLoadExtDtdDefaultValue; - int gsParserDebugEntities; - int gsPedanticParserDefaultValue; - - int gsSaveNoEmptyTags; - int gsIndentTreeOutput; - const char *gsTreeIndentString; - - xmlRegisterNodeFunc gsRegisterNodeDefaultValue; - xmlDeregisterNodeFunc gsDeregisterNodeDefaultValue; - - xmlMallocFunc gsMallocAtomic; - xmlError gsLastError; - - xmlParserInputBufferCreateFilenameFunc gsParserInputBufferCreateFilenameValue; - xmlOutputBufferCreateFilenameFunc gsOutputBufferCreateFilenameValue; - - void *gsStructuredErrorContext; -}; XML_DEPRECATED XMLPUBFUN void xmlInitializeGlobalState(xmlGlobalStatePtr gs);