diff --git a/ChangeLog b/ChangeLog index 1487f833..8224135e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jun 8 12:14:16 CEST 2004 Daniel Veillard + + * globals.c xmlIO.c include/libxml/globals.h include/libxml/xmlIO.h: + applied patch from Rob Richards for the per thread I/O mappings + Tue Jun 8 09:58:31 HKT 2004 William Brack * xinclude.c: some further enhancement to take care of diff --git a/globals.c b/globals.c index 6297aa29..79b4a14e 100644 --- a/globals.c +++ b/globals.c @@ -650,23 +650,6 @@ xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func) 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) { @@ -674,30 +657,16 @@ xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilena xmlMutexLock(xmlThrDefMutex); old = xmlParserInputBufferCreateFilenameValueThrDef; - + if (old == NULL) { + old = __xmlParserInputBufferCreateFilename; + } + 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) { @@ -705,7 +674,11 @@ xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc fun xmlMutexLock(xmlThrDefMutex); old = xmlOutputBufferCreateFilenameValueThrDef; - +#ifdef LIBXML_OUTPUT_ENABLED + if (old == NULL) { + old = __xmlOutputBufferCreateFilename; + } +#endif xmlOutputBufferCreateFilenameValueThrDef = func; xmlMutexUnlock(xmlThrDefMutex); @@ -1071,4 +1044,3 @@ __xmlOutputBufferCreateFilenameValue(void) { else return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue); } - diff --git a/include/libxml/globals.h b/include/libxml/globals.h index ebe16277..3e78feb6 100644 --- a/include/libxml/globals.h +++ b/include/libxml/globals.h @@ -69,9 +69,6 @@ XMLPUBFUN void XMLCALL xmlCleanupGlobals(void); typedef void (*xmlRegisterNodeFunc) (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 xmlGlobalState *xmlGlobalStatePtr; struct _xmlGlobalState @@ -139,11 +136,10 @@ XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNo XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(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); +XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL + xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func); +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL + xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func); /** DOC_DISABLE */ /* diff --git a/include/libxml/xmlIO.h b/include/libxml/xmlIO.h index 9c7dc33a..8aad7a66 100644 --- a/include/libxml/xmlIO.h +++ b/include/libxml/xmlIO.h @@ -62,6 +62,9 @@ typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len); */ typedef int (*xmlInputCloseCallback) (void * context); +typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, xmlCharEncoding enc); +typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression); + #ifdef LIBXML_OUTPUT_ENABLED /* * Those are the functions and datatypes for the library output @@ -206,6 +209,16 @@ XMLPUBFUN int XMLCALL xmlInputOpenCallback openFunc, xmlInputReadCallback readFunc, xmlInputCloseCallback closeFunc); + +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL + xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func); +XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL + xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func); + +xmlParserInputBufferPtr + __xmlParserInputBufferCreateFilename(const char *URI, + xmlCharEncoding enc); + #ifdef LIBXML_OUTPUT_ENABLED /* * Interfaces for output @@ -258,6 +271,11 @@ XMLPUBFUN int XMLCALL xmlOutputOpenCallback openFunc, xmlOutputWriteCallback writeFunc, xmlOutputCloseCallback closeFunc); + +xmlOutputBufferPtr + __xmlOutputBufferCreateFilename(const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); #endif /* LIBXML_OUTPUT_ENABLED */ /* This function only exists if HTTP support built into the library */ diff --git a/xmlIO.c b/xmlIO.c index 6fddcfbf..a51bf642 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -2125,7 +2125,7 @@ xmlOutputBufferClose(xmlOutputBufferPtr out) } #endif /* LIBXML_OUTPUT_ENABLED */ -static xmlParserInputBufferPtr +xmlParserInputBufferPtr __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { xmlParserInputBufferPtr ret; int i = 0; @@ -2205,7 +2205,7 @@ xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { } #ifdef LIBXML_OUTPUT_ENABLED -static xmlOutputBufferPtr +xmlOutputBufferPtr __xmlOutputBufferCreateFilename(const char *URI, xmlCharEncodingHandlerPtr encoder, int compression ATTRIBUTE_UNUSED) { @@ -2598,6 +2598,47 @@ xmlOutputBufferCreateIO(xmlOutputWriteCallback iowrite, } #endif /* LIBXML_OUTPUT_ENABLED */ +/** + * xmlParserInputBufferCreateFilenameDefault: + * @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; + if (old == NULL) { + old = __xmlParserInputBufferCreateFilename; + } + + xmlParserInputBufferCreateFilenameValue = func; + return(old); +} + +/** + * xmlOutputBufferCreateFilenameDefault: + * @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; +#ifdef LIBXML_OUTPUT_ENABLED + if (old == NULL) { + old = __xmlOutputBufferCreateFilename; + } +#endif + xmlOutputBufferCreateFilenameValue = func; + return(old); +} + /** * xmlParserInputBufferPush: * @in: a buffered parser input