1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-26 00:37:43 +03:00

io: Rework initialization

This commit is contained in:
Nick Wellnhofer
2023-12-20 20:11:09 +01:00
parent b75fc1ab33
commit c9a46a91fe
3 changed files with 26 additions and 8 deletions

View File

@@ -5,6 +5,9 @@
#include <libxml/tree.h> #include <libxml/tree.h>
#include <libxml/xmlversion.h> #include <libxml/xmlversion.h>
XML_HIDDEN void
xmlInitIOCallbacks(void);
XML_HIDDEN int XML_HIDDEN int
__xmlIOErr(int domain, int code, const char *extra); __xmlIOErr(int domain, int code, const char *extra);

View File

@@ -30,6 +30,7 @@
#include "private/dict.h" #include "private/dict.h"
#include "private/enc.h" #include "private/enc.h"
#include "private/globals.h" #include "private/globals.h"
#include "private/io.h"
#include "private/memory.h" #include "private/memory.h"
#include "private/threads.h" #include "private/threads.h"
#include "private/xpath.h" #include "private/xpath.h"
@@ -590,6 +591,7 @@ xmlInitParser(void) {
#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
xmlInitXPathInternal(); xmlInitXPathInternal();
#endif #endif
xmlInitIOCallbacks();
xmlParserInnerInitialized = 1; xmlParserInnerInitialized = 1;
} }

29
xmlIO.c
View File

@@ -90,10 +90,8 @@ xmlIODefaultMatch(const char *filename);
#define MAX_INPUT_CALLBACK 10 #define MAX_INPUT_CALLBACK 10
static xmlInputCallback xmlInputCallbackTable[MAX_INPUT_CALLBACK] = { static xmlInputCallback xmlInputCallbackTable[MAX_INPUT_CALLBACK];
{ xmlIODefaultMatch, NULL, NULL, NULL } static int xmlInputCallbackNr;
};
static int xmlInputCallbackNr = 1;
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
/* /*
@@ -108,10 +106,8 @@ typedef struct _xmlOutputCallback {
#define MAX_OUTPUT_CALLBACK 10 #define MAX_OUTPUT_CALLBACK 10
static xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK] = { static xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK];
{ xmlIODefaultMatch, NULL, NULL, NULL }, static int xmlOutputCallbackNr;
};
static int xmlOutputCallbackNr = 1;
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
/************************************************************************ /************************************************************************
@@ -4023,6 +4019,23 @@ xmlNoNetExternalEntityLoader(const char *URL, const char *ID,
* * * *
************************************************************************/ ************************************************************************/
/**
* xmlInitIOCallbacks:
*
* Initialize callback tables.
*/
void
xmlInitIOCallbacks(void)
{
xmlInputCallbackNr = 1;
xmlInputCallbackTable[0].matchcallback = xmlIODefaultMatch;
#ifdef LIBXML_OUTPUT_ENABLED
xmlOutputCallbackNr = 1;
xmlOutputCallbackTable[0].matchcallback = xmlIODefaultMatch;
#endif
}
/** /**
* xmlRegisterInputCallbacks: * xmlRegisterInputCallbacks:
* @matchFunc: the xmlInputMatchCallback * @matchFunc: the xmlInputMatchCallback