preparing for a 2.4.3 release even if it may not be ready yet redirected

* Makefile.am configure.in include/libxml/xmlwin32version.h:
  preparing for a 2.4.3 release even if it may not be ready yet
* catalog.c parser.c xmlIO.c include/libxml/catalog.h: redirected
  all file parsing lookup to go through the entity resolver, add
  to add an API to bypass it (needed to load catalogs themselves),
  some cleanup on the catalog code too.
* nanoftp.c: small cleanup
* doc/catalog.html: small update
Daniel
diff --git a/ChangeLog b/ChangeLog
index dd73f27..9eac734 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Thu Aug 23 17:26:58 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+	* Makefile.am configure.in include/libxml/xmlwin32version.h:
+	  preparing for a 2.4.3 release even if it may not be ready yet
+	* catalog.c parser.c xmlIO.c include/libxml/catalog.h: redirected
+	  all file parsing lookup to go through the entity resolver, add
+	  to add an API to bypass it (needed to load catalogs themselves),
+	  some cleanup on the catalog code too.
+	* nanoftp.c: small cleanup
+	* doc/catalog.html: small update
+
 Thu Aug 23 12:22:26 CEST 2001 Daniel Veillard <daniel@veillard.com>
 
 	* catalog.c: fixed bugi #59406 in SGML catalog parsing reported by
diff --git a/Makefile.am b/Makefile.am
index 5a3f70d..9b2aa40 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -509,7 +509,8 @@
              example/Makefile.am example/gjobread.c example/gjobs.xml \
 	     $(man_MANS) libxml-2.0.pc.in \
 	     vms/build_libxml.com vms/config.vms \
-	     strio.c strio.h trio.c trio.h triop.h libxml.h
+	     trionan.c trionan.h strio.c strio.h trio.c trio.h \
+	     triop.h triodef.h libxml.h
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libxml-2.0.pc
diff --git a/catalog.c b/catalog.c
index 2fec3b4..c5961af 100644
--- a/catalog.c
+++ b/catalog.c
@@ -58,6 +58,7 @@
 typedef enum {
     XML_CATA_NONE = 0,
     XML_CATA_CATALOG,
+    XML_CATA_BROKEN_CATALOG,
     XML_CATA_NEXT_CATALOG,
     XML_CATA_PUBLIC,
     XML_CATA_SYSTEM,
@@ -311,6 +312,71 @@
     return(xmlStrdup(result));
 }
 
+/**
+ * xmlParseCatalogFile:
+ * @filename:  the filename
+ *
+ * parse an XML file and build a tree. It's like xmlParseFile()
+ * except it bypass all catalog lookups.
+ *
+ * Returns the resulting document tree or NULL in case of error
+ */
+
+xmlDocPtr
+xmlParseCatalogFile(const char *filename) {
+    xmlDocPtr ret;
+    xmlParserCtxtPtr ctxt;
+    char *directory = NULL;
+    xmlParserInputPtr inputStream;
+    xmlParserInputBufferPtr buf;
+
+    ctxt = xmlNewParserCtxt();
+    if (ctxt == NULL) {
+	if (xmlDefaultSAXHandler.error != NULL) {
+	    xmlDefaultSAXHandler.error(NULL, "out of memory\n");
+	}
+	return(NULL);
+    }
+
+    buf = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE);
+    if (buf == NULL) {
+	xmlFreeParserCtxt(ctxt);
+	return(NULL);
+    }
+
+    inputStream = xmlNewInputStream(ctxt);
+    if (inputStream == NULL) {
+	xmlFreeParserCtxt(ctxt);
+	return(NULL);
+    }
+
+    inputStream->filename = xmlMemStrdup(filename);
+    inputStream->buf = buf;
+    inputStream->base = inputStream->buf->buffer->content;
+    inputStream->cur = inputStream->buf->buffer->content;
+    inputStream->end = 
+	&inputStream->buf->buffer->content[inputStream->buf->buffer->use];
+
+    inputPush(ctxt, inputStream);
+    if ((ctxt->directory == NULL) && (directory == NULL))
+        directory = xmlParserGetDirectory(filename);
+    if ((ctxt->directory == NULL) && (directory != NULL))
+        ctxt->directory = directory;
+
+    xmlParseDocument(ctxt);
+
+    if (ctxt->wellFormed)
+	ret = ctxt->myDoc;
+    else {
+        ret = NULL;
+        xmlFreeDoc(ctxt->myDoc);
+        ctxt->myDoc = NULL;
+    }
+    xmlFreeParserCtxt(ctxt);
+    
+    return(ret);
+}
+
 /************************************************************************
  *									*
  *			The XML Catalog parser				*
@@ -585,7 +651,7 @@
     if (filename == NULL)
         return(NULL);
 
-    doc = xmlParseFile((const char *) filename);
+    doc = xmlParseCatalogFile((const char *) filename);
     if (doc == NULL) {
 	if (xmlDebugCatalogs)
 	    xmlGenericError(xmlGenericErrorContext,
@@ -659,8 +725,10 @@
      * Fetch and parse
      */
     children = xmlParseXMLCatalogFile(catal->prefer, catal->value);
-    if (children == NULL)
+    if (children == NULL) {
+	catal->type = XML_CATA_BROKEN_CATALOG;
 	return(-1);
+    }
 
     /*
      * Where a real test and set would be needed !
@@ -718,12 +786,13 @@
     cur = catal;
     while (cur != NULL) {
 	switch (cur->type) {
+	    case XML_CATA_BROKEN_CATALOG:
 	    case XML_CATA_CATALOG:
 		if (cur == catal) {
 		    cur = cur->children;
 		    continue;
 		}
-                break;
+		break;
 	    case XML_CATA_NEXT_CATALOG:
 		node = xmlNewDocNode(doc, ns, BAD_CAST "nextCatalog", NULL);
 		xmlSetProp(node, BAD_CAST "catalog", cur->value);
@@ -832,7 +901,9 @@
     xmlCatalogEntryPtr cur;
     xmlCatalogEntryType typ;
 
-    if ((catal == NULL) || (catal->type != XML_CATA_CATALOG))
+    if ((catal == NULL) || 
+	((catal->type != XML_CATA_CATALOG) &&
+	 (catal->type != XML_CATA_BROKEN_CATALOG)))
 	return(-1);
     typ = xmlGetXMLCatalogEntryType(type);
     if (typ == XML_CATA_NONE) {
@@ -888,7 +959,9 @@
     xmlCatalogEntryPtr cur, prev, tmp;
     int ret = 0;
 
-    if ((catal == NULL) || (catal->type != XML_CATA_CATALOG))
+    if ((catal == NULL) || 
+	((catal->type != XML_CATA_CATALOG) &&
+	 (catal->type != XML_CATA_BROKEN_CATALOG)))
 	return(-1);
     if (value == NULL)
 	return(-1);
diff --git a/config.h.in b/config.h.in
index 07ded07..bf54bc0 100644
--- a/config.h.in
+++ b/config.h.in
@@ -91,9 +91,6 @@
 /* Define if you have the <dirent.h> header file.  */
 #undef HAVE_DIRENT_H
 
-/* Define if you have the <dlfcn.h> header file.  */
-#undef HAVE_DLFCN_H
-
 /* Define if you have the <errno.h> header file.  */
 #undef HAVE_ERRNO_H
 
diff --git a/configure.in b/configure.in
index cf59ef3..622d901 100644
--- a/configure.in
+++ b/configure.in
@@ -6,7 +6,7 @@
 
 LIBXML_MAJOR_VERSION=2
 LIBXML_MINOR_VERSION=4
-LIBXML_MICRO_VERSION=2
+LIBXML_MICRO_VERSION=3
 LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION
 LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
 
diff --git a/doc/catalog.html b/doc/catalog.html
index e01b69a..2ee0986 100644
--- a/doc/catalog.html
+++ b/doc/catalog.html
@@ -18,7 +18,7 @@
 <p>Mailing-list archive:  <a
 href="http://mail.gnome.org/archives/xml/">http://mail.gnome.org/archives/xml/</a></p>
 
-<p>Version: $Revision: 1.1 $</p>
+<p>Version: $Revision: 1.2 $</p>
 
 <p>Table of Content:</p>
 <ol>
@@ -92,8 +92,7 @@
 starts with the following DOCTYPE definition:</p>
 <pre>&lt;?xml version='1.0'?&gt;
 &lt;!DOCTYPE book PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4//EN"
-                         "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd"&gt;
-</pre>
+                         "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd"&gt;</pre>
 
 <p>When validating the document with libxml, the catalog will be
 automatically consulted to lookup the public identifier "-//Norman Walsh//DTD
@@ -349,6 +348,10 @@
 sure that exposing more complex interfaces (like navigation ones) would be
 really useful.</p>
 
+<p>The xmlParseCatalogFile() is a function used to load XML Catalog files,
+it's similar as xmlParseFile() except it bypass all catalog lookups, it's
+provided because this functionality may be useful for client tools.</p>
+
 <h3>threaded environments:</h3>
 
 <p>Since the catalog tree is built progressively, some care has been taken to
@@ -385,6 +388,6 @@
 
 <p><a href="mailto:daniel@veillard.com">Daniel Veillard</a></p>
 
-<p>$Id: catalog.html,v 1.1 2001/08/22 23:44:08 veillard Exp $</p>
+<p>$Id: catalog.html,v 1.2 2001/08/23 00:52:23 veillard Exp $</p>
 </body>
 </html>
diff --git a/include/libxml/catalog.h b/include/libxml/catalog.h
index 57afcaf..ac5373b 100644
--- a/include/libxml/catalog.h
+++ b/include/libxml/catalog.h
@@ -68,6 +68,7 @@
 					 const xmlChar *orig,
 					 const xmlChar *replace);
 int		xmlCatalogRemove	(const xmlChar *value);
+xmlDocPtr	xmlParseCatalogFile	(const char *filename);
 
 /*
  * Strictly minimal interfaces for per-document catalogs used
diff --git a/include/libxml/xmlwin32version.h b/include/libxml/xmlwin32version.h
index c908317..e5f2140 100644
--- a/include/libxml/xmlwin32version.h
+++ b/include/libxml/xmlwin32version.h
@@ -27,21 +27,21 @@
  *
  * the version string like "1.2.3"
  */
-#define LIBXML_DOTTED_VERSION "2.4.2"
+#define LIBXML_DOTTED_VERSION "2.4.3"
 
 /**
  * LIBXML_VERSION:
  *
  * the version number: 1.2.3 value is 1002003
  */
-#define LIBXML_VERSION 20402
+#define LIBXML_VERSION 20403
 
 /**
  * LIBXML_VERSION_STRING:
  *
  * the version number string, 1.2.3 value is "1002003"
  */
-#define LIBXML_VERSION_STRING "20402"
+#define LIBXML_VERSION_STRING "20403"
 
 /**
  * LIBXML_TEST_VERSION:
@@ -49,7 +49,7 @@
  * Macro to check that the libxml version in use is compatible with
  * the version the software has been compiled against
  */
-#define LIBXML_TEST_VERSION xmlCheckVersion(20402);
+#define LIBXML_TEST_VERSION xmlCheckVersion(20403);
 
 /**
  * WITH_TRIO:
diff --git a/nanoftp.c b/nanoftp.c
index bb6bae6..c8ff261 100644
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -1220,7 +1220,6 @@
     struct sockaddr_in dataAddr;
     SOCKLEN_T dataAddrLen;
 
-retry:
     ctxt->dataFd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
     if (ctxt->dataFd < 0) {
         xmlGenericError(xmlGenericErrorContext,
diff --git a/parser.c b/parser.c
index ca96696..8f7646e 100644
--- a/parser.c
+++ b/parser.c
@@ -9674,14 +9674,8 @@
 {
     xmlParserCtxtPtr ctxt;
     xmlParserInputPtr inputStream;
-    xmlParserInputBufferPtr buf;
     char *directory = NULL;
 
-    buf = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE);
-    if (buf == NULL) {
-	return(NULL);
-    }
-
     ctxt = xmlNewParserCtxt();
     if (ctxt == NULL) {
 	if (xmlDefaultSAXHandler.error != NULL) {
@@ -9690,19 +9684,12 @@
 	return(NULL);
     }
 
-    inputStream = xmlNewInputStream(ctxt);
+    inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
     if (inputStream == NULL) {
 	xmlFreeParserCtxt(ctxt);
 	return(NULL);
     }
 
-    inputStream->filename = xmlMemStrdup(filename);
-    inputStream->buf = buf;
-    inputStream->base = inputStream->buf->buffer->content;
-    inputStream->cur = inputStream->buf->buffer->content;
-    inputStream->end = 
-	&inputStream->buf->buffer->content[inputStream->buf->buffer->use];
-
     inputPush(ctxt, inputStream);
     if ((ctxt->directory == NULL) && (directory == NULL))
         directory = xmlParserGetDirectory(filename);
diff --git a/xmlIO.c b/xmlIO.c
index 72a56bf..9aca472 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -1595,6 +1595,9 @@
 
     if (URI == NULL) return(NULL);
 
+#ifdef LIBXML_CATALOG_ENABLED
+#endif
+
     /*
      * Try to find one of the input accept method accepting taht scheme
      * Go in reverse to give precedence to user defined handlers.
@@ -2373,7 +2376,9 @@
     xmlParserInputPtr ret = NULL;
     xmlChar *resource = NULL;
 #ifdef LIBXML_CATALOG_ENABLED
+#ifdef HAVE_STAT
     struct stat info;
+#endif
     xmlCatalogAllow pref;
 #endif
 
@@ -2413,7 +2418,7 @@
 					 (const xmlChar *)URL);
 	}
 	if ((resource == NULL) && (URL != NULL))
-	    resource = xmlStrdup(URL);
+	    resource = xmlStrdup((const xmlChar *) URL);
 
 	/*
 	 * TODO: do an URI lookup on the reference
@@ -2431,8 +2436,8 @@
 		tmp = xmlCatalogLocalResolveURI(ctxt->catalogs, resource);
 	    }
 	    if ((tmp == NULL) &&
-		(pref == XML_CATA_ALLOW_ALL) ||
-	        (pref == XML_CATA_ALLOW_GLOBAL)) {
+		((pref == XML_CATA_ALLOW_ALL) ||
+	         (pref == XML_CATA_ALLOW_GLOBAL))) {
 		tmp = xmlCatalogResolveURI(resource);
 	    }
 
@@ -2501,7 +2506,7 @@
 /**
  * xmlLoadExternalEntity:
  * @URL:  the URL for the entity to load
- * @ID:  the System ID for the entity to load
+ * @ID:  the Public ID for the entity to load
  * @ctxt:  the context in which the entity is called or NULL
  *
  * Load an external entity, note that the use of this function for