1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +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/xmlversion.h>
XML_HIDDEN void
xmlInitIOCallbacks(void);
XML_HIDDEN int
__xmlIOErr(int domain, int code, const char *extra);

View File

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

29
xmlIO.c
View File

@@ -90,10 +90,8 @@ xmlIODefaultMatch(const char *filename);
#define MAX_INPUT_CALLBACK 10
static xmlInputCallback xmlInputCallbackTable[MAX_INPUT_CALLBACK] = {
{ xmlIODefaultMatch, NULL, NULL, NULL }
};
static int xmlInputCallbackNr = 1;
static xmlInputCallback xmlInputCallbackTable[MAX_INPUT_CALLBACK];
static int xmlInputCallbackNr;
#ifdef LIBXML_OUTPUT_ENABLED
/*
@@ -108,10 +106,8 @@ typedef struct _xmlOutputCallback {
#define MAX_OUTPUT_CALLBACK 10
static xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK] = {
{ xmlIODefaultMatch, NULL, NULL, NULL },
};
static int xmlOutputCallbackNr = 1;
static xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK];
static int xmlOutputCallbackNr;
#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:
* @matchFunc: the xmlInputMatchCallback