mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2024-12-12 14:45:40 +00:00
applied patch from Rob Richards for custom I/O BufferCreateFilenane fixes
* globals.c xmlIO.c include/libxml/globals.h: applied patch from Rob Richards for custom I/O BufferCreateFilenane fixes bug #143366 Daniel
This commit is contained in:
parent
8fad8bff2c
commit
0335a846ad
@ -1,3 +1,9 @@
|
|||||||
|
Wed Jun 2 18:15:51 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* globals.c xmlIO.c include/libxml/globals.h: applied patch from
|
||||||
|
Rob Richards for custom I/O BufferCreateFilenane fixes bug
|
||||||
|
#143366
|
||||||
|
|
||||||
Wed Jun 02 16:25:32 HKT 2004 William Brack <wbrack@mmm.com.hk>
|
Wed Jun 02 16:25:32 HKT 2004 William Brack <wbrack@mmm.com.hk>
|
||||||
|
|
||||||
* xpath.c: fixed problem with predicate evaluation on an
|
* xpath.c: fixed problem with predicate evaluation on an
|
||||||
|
90
globals.c
90
globals.c
@ -169,6 +169,8 @@ xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
|
|||||||
#undef xmlMemStrdup
|
#undef xmlMemStrdup
|
||||||
#undef xmlRealloc
|
#undef xmlRealloc
|
||||||
|
|
||||||
|
#undef xmlParserInputBufferCreateFilenameValue
|
||||||
|
#undef xmlOutputBufferCreateFilenameValue
|
||||||
/**
|
/**
|
||||||
* xmlParserVersion:
|
* xmlParserVersion:
|
||||||
*
|
*
|
||||||
@ -282,6 +284,12 @@ static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
|
|||||||
xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
|
xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
|
||||||
static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
|
static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
|
||||||
|
|
||||||
|
xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL;
|
||||||
|
static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL;
|
||||||
|
|
||||||
|
xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
|
||||||
|
static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Error handling
|
* Error handling
|
||||||
*/
|
*/
|
||||||
@ -545,6 +553,9 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
|
|||||||
gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
|
gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
|
||||||
gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
|
gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
|
||||||
gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
|
gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
|
||||||
|
|
||||||
|
gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
|
||||||
|
gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
|
||||||
memset(&gs->xmlLastError, 0, sizeof(xmlError));
|
memset(&gs->xmlLastError, 0, sizeof(xmlError));
|
||||||
|
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
xmlMutexUnlock(xmlThrDefMutex);
|
||||||
@ -639,6 +650,67 @@ xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
|
|||||||
return(old);
|
return(old);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlParserInputBufferCreateFilename:
|
||||||
|
* @func: function pointer to the new ParserInputBufferCreateFilenameFunc
|
||||||
|
*
|
||||||
|
* Registers a callback for URI input file handling
|
||||||
|
*
|
||||||
|
* Returns the old value of the registration function
|
||||||
|
*/
|
||||||
|
xmlParserInputBufferCreateFilenameFunc
|
||||||
|
xmlParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
|
||||||
|
{
|
||||||
|
xmlParserInputBufferCreateFilenameFunc old = xmlParserInputBufferCreateFilenameValue;
|
||||||
|
|
||||||
|
xmlParserInputBufferCreateFilenameValue = func;
|
||||||
|
return(old);
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlParserInputBufferCreateFilenameFunc
|
||||||
|
xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
|
||||||
|
{
|
||||||
|
xmlParserInputBufferCreateFilenameFunc old;
|
||||||
|
|
||||||
|
xmlMutexLock(xmlThrDefMutex);
|
||||||
|
old = xmlParserInputBufferCreateFilenameValueThrDef;
|
||||||
|
|
||||||
|
xmlParserInputBufferCreateFilenameValueThrDef = func;
|
||||||
|
xmlMutexUnlock(xmlThrDefMutex);
|
||||||
|
|
||||||
|
return(old);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlOutputBufferCreateFilename:
|
||||||
|
* @func: function pointer to the new OutputBufferCreateFilenameFunc
|
||||||
|
*
|
||||||
|
* Registers a callback for URI output file handling
|
||||||
|
*
|
||||||
|
* Returns the old value of the registration function
|
||||||
|
*/
|
||||||
|
xmlOutputBufferCreateFilenameFunc
|
||||||
|
xmlOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
|
||||||
|
{
|
||||||
|
xmlOutputBufferCreateFilenameFunc old = xmlOutputBufferCreateFilenameValue;
|
||||||
|
|
||||||
|
xmlOutputBufferCreateFilenameValue = func;
|
||||||
|
return(old);
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlOutputBufferCreateFilenameFunc
|
||||||
|
xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
|
||||||
|
{
|
||||||
|
xmlOutputBufferCreateFilenameFunc old;
|
||||||
|
|
||||||
|
xmlMutexLock(xmlThrDefMutex);
|
||||||
|
old = xmlOutputBufferCreateFilenameValueThrDef;
|
||||||
|
|
||||||
|
xmlOutputBufferCreateFilenameValueThrDef = func;
|
||||||
|
xmlMutexUnlock(xmlThrDefMutex);
|
||||||
|
|
||||||
|
return(old);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef LIBXML_DOCB_ENABLED
|
#ifdef LIBXML_DOCB_ENABLED
|
||||||
#undef docbDefaultSAXHandler
|
#undef docbDefaultSAXHandler
|
||||||
@ -981,3 +1053,21 @@ __xmlDeregisterNodeDefaultValue(void) {
|
|||||||
else
|
else
|
||||||
return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
|
return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef xmlParserInputBufferCreateFilenameValue
|
||||||
|
xmlParserInputBufferCreateFilenameFunc *
|
||||||
|
__xmlParserInputBufferCreateFilenameValue(void) {
|
||||||
|
if (IS_MAIN_THREAD)
|
||||||
|
return (&xmlParserInputBufferCreateFilenameValue);
|
||||||
|
else
|
||||||
|
return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef xmlOutputBufferCreateFilenameValue
|
||||||
|
xmlOutputBufferCreateFilenameFunc *
|
||||||
|
__xmlOutputBufferCreateFilenameValue(void) {
|
||||||
|
if (IS_MAIN_THREAD)
|
||||||
|
return (&xmlOutputBufferCreateFilenameValue);
|
||||||
|
else
|
||||||
|
return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
|
||||||
|
}
|
@ -63,10 +63,15 @@ XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
|
|||||||
#undef xmlRegisterNodeDefaultValue
|
#undef xmlRegisterNodeDefaultValue
|
||||||
#undef xmlDeregisterNodeDefaultValue
|
#undef xmlDeregisterNodeDefaultValue
|
||||||
#undef xmlLastError
|
#undef xmlLastError
|
||||||
|
#undef xmlParserInputBufferCreateFilenameValue
|
||||||
|
#undef xmlOutputBufferCreateFilenameValue
|
||||||
|
|
||||||
typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
|
typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
|
||||||
typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
|
typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
|
||||||
|
|
||||||
|
typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, xmlCharEncoding enc);
|
||||||
|
typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression);
|
||||||
|
|
||||||
typedef struct _xmlGlobalState xmlGlobalState;
|
typedef struct _xmlGlobalState xmlGlobalState;
|
||||||
typedef xmlGlobalState *xmlGlobalStatePtr;
|
typedef xmlGlobalState *xmlGlobalStatePtr;
|
||||||
struct _xmlGlobalState
|
struct _xmlGlobalState
|
||||||
@ -110,6 +115,9 @@ struct _xmlGlobalState
|
|||||||
|
|
||||||
xmlMallocFunc xmlMallocAtomic;
|
xmlMallocFunc xmlMallocAtomic;
|
||||||
xmlError xmlLastError;
|
xmlError xmlLastError;
|
||||||
|
|
||||||
|
xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
|
||||||
|
xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -131,6 +139,12 @@ XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNo
|
|||||||
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
||||||
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
||||||
|
|
||||||
|
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL xmlParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func);
|
||||||
|
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func);
|
||||||
|
|
||||||
|
XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL xmlOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
|
||||||
|
XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
|
||||||
|
|
||||||
/** DOC_DISABLE */
|
/** DOC_DISABLE */
|
||||||
/*
|
/*
|
||||||
* In general the memory allocation entry points are not kept
|
* In general the memory allocation entry points are not kept
|
||||||
@ -415,6 +429,22 @@ XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void);
|
|||||||
XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
|
XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL __xmlParserInputBufferCreateFilenameValue(void);
|
||||||
|
#ifdef LIBXML_THREAD_ENABLED
|
||||||
|
#define xmlParserInputBufferCreateFilenameValue \
|
||||||
|
(*(__xmlParserInputBufferCreateFilenameValue()))
|
||||||
|
#else
|
||||||
|
XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void);
|
||||||
|
#ifdef LIBXML_THREAD_ENABLED
|
||||||
|
#define xmlOutputBufferCreateFilenameValue \
|
||||||
|
(*(__xmlOutputBufferCreateFilenameValue()))
|
||||||
|
#else
|
||||||
|
XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
72
xmlIO.c
72
xmlIO.c
@ -2125,21 +2125,8 @@ xmlOutputBufferClose(xmlOutputBufferPtr out)
|
|||||||
}
|
}
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
|
||||||
/**
|
static xmlParserInputBufferPtr
|
||||||
* xmlParserInputBufferCreateFilename:
|
__xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
||||||
* @URI: a C string containing the URI or filename
|
|
||||||
* @enc: the charset encoding if known
|
|
||||||
*
|
|
||||||
* Create a buffered parser input for the progressive parsing of a file
|
|
||||||
* If filename is "-' then we use stdin as the input.
|
|
||||||
* Automatic support for ZLIB/Compress compressed document is provided
|
|
||||||
* by default if found at compile-time.
|
|
||||||
* Do an encoding check if enc == XML_CHAR_ENCODING_NONE
|
|
||||||
*
|
|
||||||
* Returns the new parser input or NULL
|
|
||||||
*/
|
|
||||||
xmlParserInputBufferPtr
|
|
||||||
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
|
||||||
xmlParserInputBufferPtr ret;
|
xmlParserInputBufferPtr ret;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
void *context = NULL;
|
void *context = NULL;
|
||||||
@ -2196,26 +2183,32 @@ xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
|
||||||
/**
|
/**
|
||||||
* xmlOutputBufferCreateFilename:
|
* xmlParserInputBufferCreateFilename:
|
||||||
* @URI: a C string containing the URI or filename
|
* @URI: a C string containing the URI or filename
|
||||||
* @encoder: the encoding converter or NULL
|
* @enc: the charset encoding if known
|
||||||
* @compression: the compression ration (0 none, 9 max).
|
|
||||||
*
|
*
|
||||||
* Create a buffered output for the progressive saving of a file
|
* Create a buffered parser input for the progressive parsing of a file
|
||||||
* If filename is "-' then we use stdout as the output.
|
* If filename is "-' then we use stdin as the input.
|
||||||
* Automatic support for ZLIB/Compress compressed document is provided
|
* Automatic support for ZLIB/Compress compressed document is provided
|
||||||
* by default if found at compile-time.
|
* by default if found at compile-time.
|
||||||
* TODO: currently if compression is set, the library only support
|
* Do an encoding check if enc == XML_CHAR_ENCODING_NONE
|
||||||
* writing to a local file.
|
|
||||||
*
|
*
|
||||||
* Returns the new output or NULL
|
* Returns the new parser input or NULL
|
||||||
*/
|
*/
|
||||||
xmlOutputBufferPtr
|
xmlParserInputBufferPtr
|
||||||
xmlOutputBufferCreateFilename(const char *URI,
|
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
||||||
|
if ((xmlParserInputBufferCreateFilenameValue)) {
|
||||||
|
return xmlParserInputBufferCreateFilenameValue(URI, enc);
|
||||||
|
}
|
||||||
|
return __xmlParserInputBufferCreateFilename(URI, enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
|
static xmlOutputBufferPtr
|
||||||
|
__xmlOutputBufferCreateFilename(const char *URI,
|
||||||
xmlCharEncodingHandlerPtr encoder,
|
xmlCharEncodingHandlerPtr encoder,
|
||||||
int compression ATTRIBUTE_UNUSED) {
|
int compression ATTRIBUTE_UNUSED) {
|
||||||
xmlOutputBufferPtr ret;
|
xmlOutputBufferPtr ret;
|
||||||
xmlURIPtr puri;
|
xmlURIPtr puri;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -2329,6 +2322,31 @@ xmlOutputBufferCreateFilename(const char *URI,
|
|||||||
}
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlOutputBufferCreateFilename:
|
||||||
|
* @URI: a C string containing the URI or filename
|
||||||
|
* @encoder: the encoding converter or NULL
|
||||||
|
* @compression: the compression ration (0 none, 9 max).
|
||||||
|
*
|
||||||
|
* Create a buffered output for the progressive saving of a file
|
||||||
|
* If filename is "-' then we use stdout as the output.
|
||||||
|
* Automatic support for ZLIB/Compress compressed document is provided
|
||||||
|
* by default if found at compile-time.
|
||||||
|
* TODO: currently if compression is set, the library only support
|
||||||
|
* writing to a local file.
|
||||||
|
*
|
||||||
|
* Returns the new output or NULL
|
||||||
|
*/
|
||||||
|
xmlOutputBufferPtr
|
||||||
|
xmlOutputBufferCreateFilename(const char *URI,
|
||||||
|
xmlCharEncodingHandlerPtr encoder,
|
||||||
|
int compression ATTRIBUTE_UNUSED) {
|
||||||
|
if ((xmlOutputBufferCreateFilenameValue)) {
|
||||||
|
return xmlOutputBufferCreateFilenameValue(URI, encoder, compression);
|
||||||
|
}
|
||||||
|
return __xmlOutputBufferCreateFilename(URI, encoder, compression);
|
||||||
|
}
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user