Blame DOCBparser.c

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