applied patch from Rob Richards for the per thread I/O mappings Daniel

* globals.c xmlIO.c include/libxml/globals.h include/libxml/xmlIO.h:
  applied patch from Rob Richards for the per thread I/O mappings
Daniel
diff --git a/ChangeLog b/ChangeLog
index 1487f83..8224135 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jun  8 12:14:16 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+	* 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 <wbrack@mmm.com.hk>
 
 	* xinclude.c: some further enhancement to take care of
diff --git a/globals.c b/globals.c
index 6297aa2..79b4a14 100644
--- a/globals.c
+++ b/globals.c
@@ -650,23 +650,6 @@
     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 @@
     
     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 @@
     
     xmlMutexLock(xmlThrDefMutex);
     old = xmlOutputBufferCreateFilenameValueThrDef;
-    
+#ifdef LIBXML_OUTPUT_ENABLED
+    if (old == NULL) {
+		old = __xmlOutputBufferCreateFilename;
+	}
+#endif
     xmlOutputBufferCreateFilenameValueThrDef = func;
     xmlMutexUnlock(xmlThrDefMutex);
 
@@ -1071,4 +1044,3 @@
     else
 	return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
 }
-
diff --git a/include/libxml/globals.h b/include/libxml/globals.h
index ebe1627..3e78feb 100644
--- a/include/libxml/globals.h
+++ b/include/libxml/globals.h
@@ -69,9 +69,6 @@
 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 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 9c7dc33..8aad7a6 100644
--- a/include/libxml/xmlIO.h
+++ b/include/libxml/xmlIO.h
@@ -62,6 +62,9 @@
  */
 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 @@
 						 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 @@
 					 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 6fddcfb..a51bf64 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -2125,7 +2125,7 @@
 }
 #endif /* LIBXML_OUTPUT_ENABLED */
 
-static xmlParserInputBufferPtr
+xmlParserInputBufferPtr
 __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
     xmlParserInputBufferPtr ret;
     int i = 0;
@@ -2205,7 +2205,7 @@
 }
 
 #ifdef LIBXML_OUTPUT_ENABLED
-static xmlOutputBufferPtr
+xmlOutputBufferPtr
 __xmlOutputBufferCreateFilename(const char *URI,
                               xmlCharEncodingHandlerPtr encoder,
                               int compression ATTRIBUTE_UNUSED) {
@@ -2599,6 +2599,47 @@
 #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
  * @len:  the size in bytes of the array.