diff --git a/ChangeLog b/ChangeLog index dd73f27c..9eac734b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Aug 23 17:26:58 CEST 2001 Daniel Veillard + + * 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 * catalog.c: fixed bugi #59406 in SGML catalog parsing reported by diff --git a/Makefile.am b/Makefile.am index 5a3f70db..9b2aa40f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -509,7 +509,8 @@ EXTRA_DIST = xml2-config.in xml2Conf.sh.in libxml.spec.in libxml.spec \ 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 2fec3b4d..c5961afa 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 @@ xmlCatalogUnWrapURN(const xmlChar *urn) { 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 @@ xmlParseXMLCatalogFile(xmlCatalogPrefer prefer, const xmlChar *filename) { 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 @@ xmlFetchXMLCatalogFile(xmlCatalogEntryPtr catal) { * 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 @@ BAD_CAST "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"); 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 @@ xmlAddXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *type, 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 @@ xmlDelXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *value) { 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 07ded072..bf54bc04 100644 --- a/config.h.in +++ b/config.h.in @@ -91,9 +91,6 @@ /* Define if you have the header file. */ #undef HAVE_DIRENT_H -/* Define if you have the header file. */ -#undef HAVE_DLFCN_H - /* Define if you have the header file. */ #undef HAVE_ERRNO_H diff --git a/configure.in b/configure.in index cf59ef3a..622d9012 100644 --- a/configure.in +++ b/configure.in @@ -6,7 +6,7 @@ AC_CANONICAL_HOST 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 e01b69a6..2ee09867 100644 --- a/doc/catalog.html +++ b/doc/catalog.html @@ -18,7 +18,7 @@ href="http://xmlsoft.org/catalog.html">http://xmlsoft.org/catalog.html

Mailing-list archive: http://mail.gnome.org/archives/xml/

-

Version: $Revision: 1.1 $

+

Version: $Revision: 1.2 $

Table of Content:

    @@ -92,8 +92,7 @@ concrete example, suppose you are authoring a DocBook document, this one starts with the following DOCTYPE definition:

    <?xml version='1.0'?>
     <!DOCTYPE book PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4//EN"
    -                         "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd">
    -
    + "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd">

    When validating the document with libxml, the catalog will be automatically consulted to lookup the public identifier "-//Norman Walsh//DTD @@ -349,6 +348,10 @@ catalog state, those routines are primarily designed for xmlcatalog, I'm not sure that exposing more complex interfaces (like navigation ones) would be really useful.

    +

    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.

    +

    threaded environments:

    Since the catalog tree is built progressively, some care has been taken to @@ -385,6 +388,6 @@ me:

    Daniel Veillard

    -

    $Id: catalog.html,v 1.1 2001/08/22 23:44:08 veillard Exp $

    +

    $Id: catalog.html,v 1.2 2001/08/23 00:52:23 veillard Exp $

    diff --git a/include/libxml/catalog.h b/include/libxml/catalog.h index 57afcaf2..ac5373be 100644 --- a/include/libxml/catalog.h +++ b/include/libxml/catalog.h @@ -68,6 +68,7 @@ int xmlCatalogAdd (const xmlChar *type, 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 c908317c..e5f21404 100644 --- a/include/libxml/xmlwin32version.h +++ b/include/libxml/xmlwin32version.h @@ -27,21 +27,21 @@ extern void xmlCheckVersion(int version); * * 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 @@ extern void xmlCheckVersion(int version); * 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 bb6bae6b..c8ff2617 100644 --- a/nanoftp.c +++ b/nanoftp.c @@ -1220,7 +1220,6 @@ xmlNanoFTPGetConnection(void *ctx) { 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 ca966966..8f7646eb 100644 --- a/parser.c +++ b/parser.c @@ -9674,14 +9674,8 @@ xmlCreateFileParserCtxt(const char *filename) { 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 @@ xmlCreateFileParserCtxt(const char *filename) 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 72a56bf7..9aca4721 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -1595,6 +1595,9 @@ xmlParserInputBufferCreateFilename 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 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID, xmlParserInputPtr ret = NULL; xmlChar *resource = NULL; #ifdef LIBXML_CATALOG_ENABLED +#ifdef HAVE_STAT struct stat info; +#endif xmlCatalogAllow pref; #endif @@ -2413,7 +2418,7 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID, (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 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID, 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 @@ xmlGetExternalEntityLoader(void) { /** * 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