Blame DOCBparser.c

Packit 423ecb
/*
Packit 423ecb
 * DOCBparser.c : an attempt to parse SGML Docbook documents
Packit 423ecb
 *
Packit 423ecb
 * This is deprecated !!!
Packit 423ecb
 * Code removed with release 2.6.0 it was broken.
Packit 423ecb
 * The doc are expect to be migrated to XML DocBook
Packit 423ecb
 *
Packit 423ecb
 * See Copyright for the status of this software.
Packit 423ecb
 *
Packit 423ecb
 * daniel@veillard.com
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
#define IN_LIBXML
Packit 423ecb
#include "libxml.h"
Packit 423ecb
#ifdef LIBXML_DOCB_ENABLED
Packit 423ecb
Packit 423ecb
#include <libxml/xmlerror.h>
Packit 423ecb
#include <libxml/DOCBparser.h>
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbEncodeEntities:
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @in:  a pointer to an array of UTF-8 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 * @quoteChar: the quote character to escape (' or ") or zero.
Packit 423ecb
 *
Packit 423ecb
 * Take a block of UTF-8 chars in and try to convert it to an ASCII
Packit 423ecb
 * plus SGML entities block of chars out.
Packit 423ecb
 *
Packit 423ecb
 * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
Packit 423ecb
 * The value of @inlen after return is the number of octets consumed
Packit 423ecb
 *     as the return value is positive, else unpredictable.
Packit 423ecb
 * The value of @outlen after return is the number of octets consumed.
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
docbEncodeEntities(unsigned char *out ATTRIBUTE_UNUSED,
Packit 423ecb
                   int *outlen ATTRIBUTE_UNUSED,
Packit 423ecb
                   const unsigned char *in ATTRIBUTE_UNUSED,
Packit 423ecb
                   int *inlen ATTRIBUTE_UNUSED,
Packit 423ecb
                   int quoteChar ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbEncodeEntities() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
    return(-1);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbParseDocument:
Packit 423ecb
 * @ctxt:  an SGML parser context
Packit 423ecb
 *
Packit 423ecb
 * parse an SGML document (and build a tree if using the standard SAX
Packit 423ecb
 * interface).
Packit 423ecb
 *
Packit 423ecb
 * Returns 0, -1 in case of error. the parser context is augmented
Packit 423ecb
 *                as a result of the parsing.
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
int
Packit 423ecb
docbParseDocument(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbParseDocument() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
    return (xmlParseDocument(ctxt));
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbFreeParserCtxt:
Packit 423ecb
 * @ctxt:  an SGML parser context
Packit 423ecb
 *
Packit 423ecb
 * Free all the memory used by a parser context. However the parsed
Packit 423ecb
 * document in ctxt->myDoc is not freed.
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
void
Packit 423ecb
docbFreeParserCtxt(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbFreeParserCtxt() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
    xmlFreeParserCtxt(ctxt);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbParseChunk:
Packit 423ecb
 * @ctxt:  an XML parser context
Packit 423ecb
 * @chunk:  an char array
Packit 423ecb
 * @size:  the size in byte of the chunk
Packit 423ecb
 * @terminate:  last chunk indicator
Packit 423ecb
 *
Packit 423ecb
 * Parse a Chunk of memory
Packit 423ecb
 *
Packit 423ecb
 * Returns zero if no error, the xmlParserErrors otherwise.
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
docbParseChunk(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
Packit 423ecb
               const char *chunk ATTRIBUTE_UNUSED,
Packit 423ecb
	       int size ATTRIBUTE_UNUSED,
Packit 423ecb
               int terminate ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbParseChunk() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    return (xmlParseChunk(ctxt, chunk, size, terminate));
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbCreatePushParserCtxt:
Packit 423ecb
 * @sax:  a SAX handler
Packit 423ecb
 * @user_data:  The user data returned on SAX callbacks
Packit 423ecb
 * @chunk:  a pointer to an array of chars
Packit 423ecb
 * @size:  number of chars in the array
Packit 423ecb
 * @filename:  an optional file name or URI
Packit 423ecb
 * @enc:  an optional encoding
Packit 423ecb
 *
Packit 423ecb
 * Create a parser context for using the DocBook SGML parser in push mode
Packit 423ecb
 * To allow content encoding detection, @size should be >= 4
Packit 423ecb
 * The value of @filename is used for fetching external entities
Packit 423ecb
 * and error/warning reports.
Packit 423ecb
 *
Packit 423ecb
 * Returns the new parser context or NULL
Packit 423ecb
 */
Packit 423ecb
docbParserCtxtPtr
Packit 423ecb
docbCreatePushParserCtxt(docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
Packit 423ecb
                         void *user_data ATTRIBUTE_UNUSED,
Packit 423ecb
                         const char *chunk ATTRIBUTE_UNUSED,
Packit 423ecb
			 int size ATTRIBUTE_UNUSED,
Packit 423ecb
			 const char *filename ATTRIBUTE_UNUSED,
Packit 423ecb
                         xmlCharEncoding enc ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbParseChunk() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    return(xmlCreatePushParserCtxt(sax, user_data, chunk, size, filename));
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbSAXParseDoc:
Packit 423ecb
 * @cur:  a pointer to an array of xmlChar
Packit 423ecb
 * @encoding:  a free form C string describing the SGML document encoding, or NULL
Packit 423ecb
 * @sax:  the SAX handler block
Packit 423ecb
 * @userData: if using SAX, this pointer will be provided on callbacks.
Packit 423ecb
 *
Packit 423ecb
 * parse an SGML in-memory document and build a tree.
Packit 423ecb
 * It use the given SAX function block to handle the parsing callback.
Packit 423ecb
 * If sax is NULL, fallback to the default DOM tree building routines.
Packit 423ecb
 *
Packit 423ecb
 * Returns the resulting document tree
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
docbDocPtr
Packit 423ecb
docbSAXParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
Packit 423ecb
                const char *encoding ATTRIBUTE_UNUSED,
Packit 423ecb
		docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
Packit 423ecb
                void *userData ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbParseChunk() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    return (xmlSAXParseMemoryWithData(sax, (const char *)cur,
Packit 423ecb
			  xmlStrlen((const xmlChar *) cur), 0,  userData));
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbParseDoc:
Packit 423ecb
 * @cur:  a pointer to an array of xmlChar
Packit 423ecb
 * @encoding:  a free form C string describing the SGML document encoding, or NULL
Packit 423ecb
 *
Packit 423ecb
 * parse an SGML in-memory document and build a tree.
Packit 423ecb
 *
Packit 423ecb
 * Returns the resulting document tree
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
docbDocPtr
Packit 423ecb
docbParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
Packit 423ecb
             const char *encoding ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbParseChunk() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    return (xmlParseDoc(cur));
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbCreateFileParserCtxt:
Packit 423ecb
 * @filename:  the filename
Packit 423ecb
 * @encoding:  the SGML document encoding, or NULL
Packit 423ecb
 *
Packit 423ecb
 * Create a parser context for a file content.
Packit 423ecb
 * Automatic support for ZLIB/Compress compressed document is provided
Packit 423ecb
 * by default if found at compile-time.
Packit 423ecb
 *
Packit 423ecb
 * Returns the new parser context or NULL
Packit 423ecb
 */
Packit 423ecb
docbParserCtxtPtr
Packit 423ecb
docbCreateFileParserCtxt(const char *filename ATTRIBUTE_UNUSED,
Packit 423ecb
                         const char *encoding ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbCreateFileParserCtxt() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    return (xmlCreateFileParserCtxt(filename));
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbSAXParseFile:
Packit 423ecb
 * @filename:  the filename
Packit 423ecb
 * @encoding:  a free form C string describing the SGML document encoding, or NULL
Packit 423ecb
 * @sax:  the SAX handler block
Packit 423ecb
 * @userData: if using SAX, this pointer will be provided on callbacks.
Packit 423ecb
 *
Packit 423ecb
 * parse an SGML file and build a tree. Automatic support for ZLIB/Compress
Packit 423ecb
 * compressed document is provided by default if found at compile-time.
Packit 423ecb
 * It use the given SAX function block to handle the parsing callback.
Packit 423ecb
 * If sax is NULL, fallback to the default DOM tree building routines.
Packit 423ecb
 *
Packit 423ecb
 * Returns the resulting document tree
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
docbDocPtr
Packit 423ecb
docbSAXParseFile(const char *filename ATTRIBUTE_UNUSED,
Packit 423ecb
                 const char *encoding ATTRIBUTE_UNUSED,
Packit 423ecb
                 docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
Packit 423ecb
		 void *userData ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbSAXParseFile() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    return (xmlSAXParseFileWithData(sax, filename, 0, userData));
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * docbParseFile:
Packit 423ecb
 * @filename:  the filename
Packit 423ecb
 * @encoding:  a free form C string describing document encoding, or NULL
Packit 423ecb
 *
Packit 423ecb
 * parse a Docbook SGML file and build a tree. Automatic support for
Packit 423ecb
 * ZLIB/Compress compressed document is provided by default if found
Packit 423ecb
 * at compile-time.
Packit 423ecb
 *
Packit 423ecb
 * Returns the resulting document tree
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
docbDocPtr
Packit 423ecb
docbParseFile(const char *filename ATTRIBUTE_UNUSED,
Packit 423ecb
              const char *encoding ATTRIBUTE_UNUSED)
Packit 423ecb
{
Packit 423ecb
    static int deprecated = 0;
Packit 423ecb
Packit 423ecb
    if (!deprecated) {
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "docbParseFile() deprecated function reached\n");
Packit 423ecb
        deprecated = 1;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    return (xmlParseFile(filename));
Packit 423ecb
}
Packit 423ecb
#define bottom_DOCBparser
Packit 423ecb
#include "elfgcchack.h"
Packit 423ecb
#endif /* LIBXML_DOCB_ENABLED */