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