1 Star 0 Fork 32

万智宇/libxml2-rust

forked from openEuler/libxml2-rust 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
HTMLparser.c 30.74 KB
Copy Edit Raw Blame History
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
/*
* HTMLparser.c : an HTML 4.0 non-verifying parser
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
*/
#define IN_LIBXML
#include "libxml.h"
//#define DEBUG
//#define DEBUG_PUSH
#ifdef COMPILE_WITH_RUST
#ifdef LIBXML_HTML_ENABLED
#include <string.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef LIBXML_ZLIB_ENABLED
#include <zlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlerror.h>
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
#include <libxml/entities.h>
#include <libxml/encoding.h>
#include <libxml/valid.h>
#include <libxml/xmlIO.h>
#include <libxml/globals.h>
#include <libxml/uri.h>
#include "buf.h"
#include "enc.h"
#define HTML_MAX_NAMELEN 1000
#define HTML_PARSER_BIG_BUFFER_SIZE 1000
#define HTML_PARSER_BUFFER_SIZE 100
//struct libxml2_htmlparser_defined_param{
// unsigned int html_max_namelen;
// unsigned int html_parser_big_buffer_size;
// unsigned int html_parser_buffer_size;
// unsigned int input_chunk;
//};
extern const htmlElemDesc *htmlTagLookup_rust(const xmlChar *tag);
extern int htmlAutoCloseTag_rust(htmlDocPtr doc, const xmlChar *name, htmlNodePtr elem);
extern int htmlIsAutoClosed_rust(htmlDocPtr doc, htmlNodePtr elem);
extern int htmlIsScriptAttribute_rust(const xmlChar *name);
extern const htmlEntityDesc *htmlEntityLookup_rust(const xmlChar *name);
extern const htmlEntityDesc *htmlEntityValueLookup_rust(unsigned int value);
extern int UTF8ToHtml_rust(unsigned char *out, int *outlen,
const unsigned char *in, int *inlen);
extern int htmlEncodeEntities_rust(unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, int quoteChar);
extern htmlDocPtr htmlNewDocNoDtD_rust(const xmlChar *URI, const xmlChar *ExternalID);
extern htmlDocPtr htmlNewDoc_rust(const xmlChar *URI, const xmlChar *ExternalID);
extern const htmlEntityDesc *htmlParseEntityRef_rust(htmlParserCtxtPtr ctxt, const xmlChar **str);
extern int htmlParseCharRef_rust(htmlParserCtxtPtr ctxt);
extern void htmlParseElement_rust(htmlParserCtxtPtr ctxt);
extern void __htmlParseContent_rust(void *ctxt);
extern int htmlParseDocument_rust(htmlParserCtxtPtr ctxt);
extern void htmlFreeParserCtxt_rust(htmlParserCtxtPtr ctxt);
extern htmlParserCtxtPtr htmlNewParserCtxt_rust(void);
extern htmlParserCtxtPtr htmlCreateMemoryParserCtxt_rust(const char *buffer, int size);
extern int htmlParseChunk_rust(htmlParserCtxtPtr ctxt, const char *chunk, int size,
int terminate);
extern htmlParserCtxtPtr htmlCreatePushParserCtxt_rust(htmlSAXHandlerPtr sax, void *user_data,
const char *chunk, int size, const char *filename,
xmlCharEncoding enc);
extern htmlDocPtr htmlSAXParseDoc_rust(const xmlChar *cur, const char *encoding,
htmlSAXHandlerPtr sax, void *userData);
extern htmlDocPtr htmlParseDoc_rust(const xmlChar *cur, const char *encoding);
extern htmlParserCtxtPtr
htmlCreateFileParserCtxt_rust(const char *filename, const char *encoding);
extern htmlDocPtr htmlSAXParseFile_rust(const char *filename, const char *encoding, htmlSAXHandlerPtr sax,
void *userData);
extern htmlDocPtr htmlParseFile_rust(const char *filename, const char *encoding);
extern int htmlHandleOmittedElem_rust(int val);
extern int htmlElementAllowedHere_rust(const htmlElemDesc *parent, const xmlChar *elt);
extern htmlStatus htmlElementStatusHere_rust(const htmlElemDesc *parent, const htmlElemDesc *elt);
extern htmlStatus htmlAttrAllowed_rust(const htmlElemDesc *elt, const xmlChar *attr, int legacy);
extern htmlStatus htmlNodeStatus_rust(const htmlNodePtr node, int legacy);
extern void htmlCtxtReset_rust(htmlParserCtxtPtr ctxt);
extern int htmlCtxtUseOptions_rust(htmlParserCtxtPtr ctxt, int options);
extern htmlDocPtr htmlReadDoc_rust(const xmlChar *cur, const char *URL, const char *encoding, int options);
extern htmlDocPtr htmlReadFile_rust(const char *filename, const char *encoding, int options);
extern htmlDocPtr htmlReadMemory_rust(const char *buffer, int size, const char *URL, const char *encoding, int options);
extern htmlDocPtr htmlReadFd_rust(int fd, const char *URL, const char *encoding, int options);
extern htmlDocPtr htmlReadIO_rust(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
void *ioctx, const char *URL, const char *encoding, int options);
extern htmlDocPtr htmlCtxtReadDoc_rust(htmlParserCtxtPtr ctxt, const xmlChar *cur,
const char *URL, const char *encoding, int options);
extern htmlDocPtr htmlCtxtReadFile_rust(htmlParserCtxtPtr ctxt, const char *filename,
const char *encoding, int options);
extern htmlDocPtr htmlCtxtReadMemory_rust(htmlParserCtxtPtr ctxt, const char *buffer, int size,
const char *URL, const char *encoding, int options);
extern htmlDocPtr htmlCtxtReadFd_rust(htmlParserCtxtPtr ctxt, int fd,
const char *URL, const char *encoding, int options);
extern htmlDocPtr htmlCtxtReadIO_rust(htmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
xmlInputCloseCallback ioclose, void *ioctx,
const char *URL,
const char *encoding, int options);
extern int htmlParseTryOrFinish_rust(htmlParserCtxtPtr ctxt, int terminate);
extern int htmlParseLookupSequence_rust(htmlParserCtxtPtr ctxt, xmlChar first,
xmlChar next, xmlChar third, int ignoreattrval);
extern void htmlInitAutoClose_rust();
static int htmlOmittedDefaultValue = 1;
xmlChar *htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
xmlChar end, xmlChar end2, xmlChar end3);
static void htmlParseComment(htmlParserCtxtPtr ctxt);
/************************************************************************
* *
* Some factorized error routines *
* *
************************************************************************/
/************************************************************************
* *
* Parser stacks related functions and macros *
* *
************************************************************************/
/************************************************************************
* *
* The list of HTML elements and their properties *
* *
************************************************************************/
/************************************************************************
* *
* functions to handle HTML specific data *
* *
************************************************************************/
/**
* htmlInitAutoClose:
*
* This is a no-op now.
*/
void
htmlInitAutoClose(void) {
htmlInitAutoClose_rust();
}
/**
* htmlTagLookup:
* @tag: The tag name in lowercase
*
* Lookup the HTML tag in the ElementTable
*
* Returns the related htmlElemDescPtr or NULL if not found.
*/
const htmlElemDesc *
htmlTagLookup(const xmlChar *tag) {
return htmlTagLookup_rust(tag);
}
/**
* htmlAutoCloseTag:
* @doc: the HTML document
* @name: The tag name
* @elem: the HTML element
*
* The HTML DTD allows a tag to implicitly close other tags.
* The list is kept in htmlStartClose array. This function checks
* if the element or one of it's children would autoclose the
* given tag.
*
* Returns 1 if autoclose, 0 otherwise
*/
int
htmlAutoCloseTag(htmlDocPtr doc, const xmlChar *name, htmlNodePtr elem) {
return htmlAutoCloseTag_rust(doc, name, elem);
}
/**
* htmlIsAutoClosed:
* @doc: the HTML document
* @elem: the HTML element
*
* The HTML DTD allows a tag to implicitly close other tags.
* The list is kept in htmlStartClose array. This function checks
* if a tag is autoclosed by one of it's child
*
* Returns 1 if autoclosed, 0 otherwise
*/
int
htmlIsAutoClosed(htmlDocPtr doc, htmlNodePtr elem) {
return htmlIsAutoClosed_rust(doc, elem);
}
/**
* htmlIsScriptAttribute:
* @name: an attribute name
*
* Check if an attribute is of content type Script
*
* Returns 1 is the attribute is a script 0 otherwise
*/
int
htmlIsScriptAttribute(const xmlChar *name) {
return htmlIsScriptAttribute_rust(name);
}
/************************************************************************
* *
* The list of HTML predefined entities *
* *
************************************************************************/
/************************************************************************
* *
* Commodity functions to handle entities *
* *
************************************************************************/
/**
* htmlEntityLookup:
* @name: the entity name
*
* Lookup the given entity in EntitiesTable
*
* TODO: the linear scan is really ugly, an hash table is really needed.
*
* Returns the associated htmlEntityDescPtr if found, NULL otherwise.
*/
const htmlEntityDesc *
htmlEntityLookup(const xmlChar *name) {
return htmlEntityLookup_rust(name);
}
/**
* htmlEntityValueLookup:
* @value: the entity's unicode value
*
* Lookup the given entity in EntitiesTable
*
* TODO: the linear scan is really ugly, an hash table is really needed.
*
* Returns the associated htmlEntityDescPtr if found, NULL otherwise.
*/
const htmlEntityDesc *
htmlEntityValueLookup(unsigned int value) {
return htmlEntityValueLookup_rust(value);
}
/**
* UTF8ToHtml:
* @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
*
* Take a block of UTF-8 chars in and try to convert it to an ASCII
* plus HTML entities block of chars out.
*
* 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.
*/
int
UTF8ToHtml(unsigned char *out, int *outlen,
const unsigned char *in, int *inlen) {
return UTF8ToHtml_rust(out,outlen,in,inlen);
}
/**
* htmlEncodeEntities:
* @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.
*
* Take a block of UTF-8 chars in and try to convert it to an ASCII
* plus HTML entities block of chars out.
*
* 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.
*/
int
htmlEncodeEntities(unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, int quoteChar) {
return htmlEncodeEntities_rust(out,outlen,in,inlen,quoteChar);
}
/************************************************************************
* *
* Commodity functions to handle streams *
* *
************************************************************************/
#ifdef LIBXML_PUSH_ENABLED
#endif
/************************************************************************
* *
* Commodity functions, cleanup needed ? *
* *
************************************************************************/
/**
* htmlNewDocNoDtD:
* @URI: URI for the dtd, or NULL
* @ExternalID: the external ID of the DTD, or NULL
*
* Creates a new HTML document without a DTD node if @URI and @ExternalID
* are NULL
*
* Returns a new document, do not initialize the DTD if not provided
*/
htmlDocPtr
htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *ExternalID) {
return htmlNewDocNoDtD_rust(URI,ExternalID);
}
/**
* htmlNewDoc:
* @URI: URI for the dtd, or NULL
* @ExternalID: the external ID of the DTD, or NULL
*
* Creates a new HTML document
*
* Returns a new document
*/
htmlDocPtr
htmlNewDoc(const xmlChar *URI, const xmlChar *ExternalID) {
return htmlNewDoc_rust(URI, ExternalID);
}
/************************************************************************
* *
* The parser itself *
* Relates to http://www.w3.org/TR/html40 *
* *
************************************************************************/
/************************************************************************
* *
* The parser itself *
* *
************************************************************************/
static const xmlChar *htmlParseNameComplex(xmlParserCtxtPtr ctxt);
/**
* htmlParseEntityRef:
* @ctxt: an HTML parser context
* @str: location to store the entity name
*
* parse an HTML ENTITY references
*
* [68] EntityRef ::= '&' Name ';'
*
* Returns the associated htmlEntityDescPtr if found, or NULL otherwise,
* if non-NULL *str will have to be freed by the caller.
*/
const htmlEntityDesc *
htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str) {
return htmlParseEntityRef_rust(ctxt,str);
}
/**
* htmlParseCharRef:
* @ctxt: an HTML parser context
*
* parse Reference declarations
*
* [66] CharRef ::= '&#' [0-9]+ ';' |
* '&#x' [0-9a-fA-F]+ ';'
*
* Returns the value parsed (as an int)
*/
int
htmlParseCharRef(htmlParserCtxtPtr ctxt) {
return htmlParseCharRef_rust(ctxt);
}
/**
* htmlParseElement:
* @ctxt: an HTML parser context
*
* parse an HTML element, this is highly recursive
* this is kept for compatibility with previous code versions
*
* [39] element ::= EmptyElemTag | STag content ETag
*
* [41] Attribute ::= Name Eq AttValue
*/
void
htmlParseElement(htmlParserCtxtPtr ctxt) {
htmlParseElement_rust(ctxt);
}
/**
* htmlParseContent:
* @ctxt: an HTML parser context
*
* Parse a content: comment, sub-element, reference or text.
* This is the entry point when called from parser.c
*/
void
__htmlParseContent(void *ctxt) {
__htmlParseContent_rust(ctxt);
}
/**
* htmlParseDocument:
* @ctxt: an HTML parser context
*
* parse an HTML 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
htmlParseDocument(htmlParserCtxtPtr ctxt) {
return htmlParseDocument_rust(ctxt);
}
/************************************************************************
* *
* Parser contexts handling *
* *
************************************************************************/
/**
* htmlFreeParserCtxt:
* @ctxt: an HTML parser context
*
* Free all the memory used by a parser context. However the parsed
* document in ctxt->myDoc is not freed.
*/
void
htmlFreeParserCtxt(htmlParserCtxtPtr ctxt) {
htmlFreeParserCtxt_rust(ctxt);
}
/**
* htmlNewParserCtxt:
*
* Allocate and initialize a new parser context.
*
* Returns the htmlParserCtxtPtr or NULL in case of allocation error
*/
htmlParserCtxtPtr
htmlNewParserCtxt(void) {
return htmlNewParserCtxt_rust();
}
/**
* htmlCreateMemoryParserCtxt:
* @buffer: a pointer to a char array
* @size: the size of the array
*
* Create a parser context for an HTML in-memory document.
*
* Returns the new parser context or NULL
*/
htmlParserCtxtPtr
htmlCreateMemoryParserCtxt(const char *buffer, int size) {
return htmlCreateMemoryParserCtxt_rust(buffer, size);
}
#ifdef LIBXML_PUSH_ENABLED
/************************************************************************
* *
* Progressive parsing interfaces *
* *
************************************************************************/
/**
* htmlParseLookupSequence:
* @ctxt: an HTML parser context
* @first: the first char to lookup
* @next: the next char to lookup or zero
* @third: the next char to lookup or zero
* @ignoreattrval: skip over attribute values
*
* Try to find if a sequence (first, next, third) or just (first next) or
* (first) is available in the input stream.
* This function has a side effect of (possibly) incrementing ctxt->checkIndex
* to avoid rescanning sequences of bytes, it DOES change the state of the
* parser, do not use liberally.
* This is basically similar to xmlParseLookupSequence()
*
* Returns the index to the current parsing point if the full sequence
* is available, -1 otherwise.
*/
int
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
xmlChar next, xmlChar third, int ignoreattrval)
{
return htmlParseLookupSequence_rust(ctxt,first,next,third,ignoreattrval);
}
/**
* htmlParseTryOrFinish:
* @ctxt: an HTML parser context
* @terminate: last chunk indicator
*
* Try to progress on parsing
*
* Returns zero if no parsing was possible
*/
int
htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
return htmlParseTryOrFinish_rust(ctxt,terminate);
}
/**
* htmlParseChunk:
* @ctxt: an HTML 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
htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
int terminate) {
return htmlParseChunk_rust(ctxt,chunk,size,terminate);
}
/************************************************************************
* *
* User entry points *
* *
************************************************************************/
/**
* htmlCreatePushParserCtxt:
* @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 HTML parser in push mode
* The value of @filename is used for fetching external entities
* and error/warning reports.
*
* Returns the new parser context or NULL
*/
htmlParserCtxtPtr
htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
const char *chunk, int size, const char *filename,
xmlCharEncoding enc) {
return htmlCreatePushParserCtxt_rust(sax,user_data,chunk,size,filename,enc);
}
#endif /* LIBXML_PUSH_ENABLED */
/**
* htmlSAXParseDoc:
* @cur: a pointer to an array of xmlChar
* @encoding: a free form C string describing the HTML document encoding, or NULL
* @sax: the SAX handler block
* @userData: if using SAX, this pointer will be provided on callbacks.
*
* Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks
* to handle parse events. If sax is NULL, fallback to the default DOM
* behavior and return a tree.
*
* Returns the resulting document tree unless SAX is NULL or the document is
* not well formed.
*/
htmlDocPtr
htmlSAXParseDoc(const xmlChar *cur, const char *encoding,
htmlSAXHandlerPtr sax, void *userData) {
return htmlSAXParseDoc_rust(cur, encoding, sax, userData);
}
/**
* htmlParseDoc:
* @cur: a pointer to an array of xmlChar
* @encoding: a free form C string describing the HTML document encoding, or NULL
*
* parse an HTML in-memory document and build a tree.
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlParseDoc(const xmlChar *cur, const char *encoding) {
return htmlParseDoc_rust(cur, encoding);
}
/**
* htmlCreateFileParserCtxt:
* @filename: the filename
* @encoding: a free form C string describing the HTML document encoding, or NULL
*
* 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
*/
htmlParserCtxtPtr
htmlCreateFileParserCtxt(const char *filename, const char *encoding) {
return htmlCreateFileParserCtxt_rust(filename,encoding);
}
/**
* htmlSAXParseFile:
* @filename: the filename
* @encoding: a free form C string describing the HTML document encoding, or NULL
* @sax: the SAX handler block
* @userData: if using SAX, this pointer will be provided on callbacks.
*
* parse an HTML 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 unless SAX is NULL or the document is
* not well formed.
*/
htmlDocPtr
htmlSAXParseFile(const char *filename, const char *encoding, htmlSAXHandlerPtr sax,
void *userData) {
return htmlSAXParseFile_rust(filename,encoding,sax,userData);
}
/**
* htmlParseFile:
* @filename: the filename
* @encoding: a free form C string describing the HTML document encoding, or NULL
*
* parse an HTML 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
*/
htmlDocPtr
htmlParseFile(const char *filename, const char *encoding) {
return htmlParseFile_rust(filename, encoding);
}
/**
* htmlHandleOmittedElem:
* @val: int 0 or 1
*
* Set and return the previous value for handling HTML omitted tags.
*
* Returns the last value for 0 for no handling, 1 for auto insertion.
*/
int
htmlHandleOmittedElem(int val) {
return htmlHandleOmittedElem_rust(val);
}
/**
* htmlElementAllowedHere:
* @parent: HTML parent element
* @elt: HTML element
*
* Checks whether an HTML element may be a direct child of a parent element.
* Note - doesn't check for deprecated elements
*
* Returns 1 if allowed; 0 otherwise.
*/
int
htmlElementAllowedHere(const htmlElemDesc *parent, const xmlChar *elt) {
return htmlElementAllowedHere_rust(parent, elt);
}
/**
* htmlElementStatusHere:
* @parent: HTML parent element
* @elt: HTML element
*
* Checks whether an HTML element may be a direct child of a parent element.
* and if so whether it is valid or deprecated.
*
* Returns one of HTML_VALID, HTML_DEPRECATED, HTML_INVALID
*/
htmlStatus
htmlElementStatusHere(const htmlElemDesc *parent, const htmlElemDesc *elt) {
return htmlElementStatusHere_rust(parent, elt);
}
/**
* htmlAttrAllowed:
* @elt: HTML element
* @attr: HTML attribute
* @legacy: whether to allow deprecated attributes
*
* Checks whether an attribute is valid for an element
* Has full knowledge of Required and Deprecated attributes
*
* Returns one of HTML_REQUIRED, HTML_VALID, HTML_DEPRECATED, HTML_INVALID
*/
htmlStatus
htmlAttrAllowed(const htmlElemDesc *elt, const xmlChar *attr, int legacy) {
return htmlAttrAllowed_rust(elt, attr, legacy);
}
/**
* htmlNodeStatus:
* @node: an htmlNodePtr in a tree
* @legacy: whether to allow deprecated elements (YES is faster here
* for Element nodes)
*
* Checks whether the tree node is valid. Experimental (the author
* only uses the HTML enhancements in a SAX parser)
*
* Return: for Element nodes, a return from htmlElementAllowedHere (if
* legacy allowed) or htmlElementStatusHere (otherwise).
* for Attribute nodes, a return from htmlAttrAllowed
* for other nodes, HTML_NA (no checks performed)
*/
htmlStatus
htmlNodeStatus(const htmlNodePtr node, int legacy) {
return htmlNodeStatus_rust(node, legacy);
}
/************************************************************************
* *
* New set (2.6.0) of simpler and more flexible APIs *
* *
************************************************************************/
/**
* htmlCtxtReset:
* @ctxt: an HTML parser context
*
* Reset a parser context
*/
void
htmlCtxtReset(htmlParserCtxtPtr ctxt) {
htmlCtxtReset_rust(ctxt);
}
/**
* htmlCtxtUseOptions:
* @ctxt: an HTML parser context
* @options: a combination of htmlParserOption(s)
*
* Applies the options to the parser context
*
* Returns 0 in case of success, the set of unknown or unimplemented options
* in case of error.
*/
int
htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options) {
return htmlCtxtUseOptions_rust(ctxt, options);
}
/**
* htmlReadDoc:
* @cur: a pointer to a zero terminated string
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an XML in-memory document and build a tree.
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlReadDoc(const xmlChar *cur, const char *URL, const char *encoding, int options) {
return htmlReadDoc_rust(cur, URL, encoding, options);
}
/**
* htmlReadFile:
* @filename: a file or URL
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an XML file from the filesystem or the network.
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlReadFile(const char *filename, const char *encoding, int options) {
return htmlReadFile_rust(filename,encoding,options);
}
/**
* htmlReadMemory:
* @buffer: a pointer to a char array
* @size: the size of the array
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an XML in-memory document and build a tree.
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlReadMemory(const char *buffer, int size, const char *URL, const char *encoding, int options) {
return htmlReadMemory_rust(buffer, size, URL, encoding, options);
}
/**
* htmlReadFd:
* @fd: an open file descriptor
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an XML from a file descriptor and build a tree.
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlReadFd(int fd, const char *URL, const char *encoding, int options) {
return htmlReadFd_rust(fd, URL, encoding, options);
}
/**
* htmlReadIO:
* @ioread: an I/O read function
* @ioclose: an I/O close function
* @ioctx: an I/O handler
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an HTML document from I/O functions and source and build a tree.
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
void *ioctx, const char *URL, const char *encoding, int options) {
return htmlReadIO_rust(ioread, ioclose, ioctx, URL, encoding, options);
}
/**
* htmlCtxtReadDoc:
* @ctxt: an HTML parser context
* @cur: a pointer to a zero terminated string
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an XML in-memory document and build a tree.
* This reuses the existing @ctxt parser context
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar *cur,
const char *URL, const char *encoding, int options) {
return htmlCtxtReadDoc_rust(ctxt, cur, URL, encoding, options);
}
/**
* htmlCtxtReadFile:
* @ctxt: an HTML parser context
* @filename: a file or URL
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an XML file from the filesystem or the network.
* This reuses the existing @ctxt parser context
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlCtxtReadFile(htmlParserCtxtPtr ctxt, const char *filename,
const char *encoding, int options) {
return htmlCtxtReadFile_rust(ctxt, filename, encoding, options);
}
/**
* htmlCtxtReadMemory:
* @ctxt: an HTML parser context
* @buffer: a pointer to a char array
* @size: the size of the array
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an XML in-memory document and build a tree.
* This reuses the existing @ctxt parser context
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size,
const char *URL, const char *encoding, int options) {
return htmlCtxtReadMemory_rust(ctxt, buffer, size, URL, encoding, options);
}
/**
* htmlCtxtReadFd:
* @ctxt: an HTML parser context
* @fd: an open file descriptor
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an XML from a file descriptor and build a tree.
* This reuses the existing @ctxt parser context
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlCtxtReadFd(htmlParserCtxtPtr ctxt, int fd,
const char *URL, const char *encoding, int options) {
return htmlCtxtReadFd_rust(ctxt, fd, URL, encoding, options);
}
/**
* htmlCtxtReadIO:
* @ctxt: an HTML parser context
* @ioread: an I/O read function
* @ioclose: an I/O close function
* @ioctx: an I/O handler
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
*
* parse an HTML document from I/O functions and source and build a tree.
* This reuses the existing @ctxt parser context
*
* Returns the resulting document tree
*/
htmlDocPtr
htmlCtxtReadIO(htmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
xmlInputCloseCallback ioclose, void *ioctx,
const char *URL,
const char *encoding, int options) {
return htmlCtxtReadIO_rust(ctxt, ioread, ioclose, ioctx, URL, encoding, options);
}
#define bottom_HTMLparser
#include "elfgcchack.h"
#endif /* LIBXML_HTML_ENABLED */
#else /* not COMPILE_WITH_RUST */
int get_libxml_push_enabled() {
#ifdef LIBXML_PUSH_ENABLED
return 1;
#else
return 0;
#endif
}
int get_libxml_sax1_enabled() {
#ifdef LIBXML_SAX1_ENABLED
return 1;
#else
return 0;
#endif
}
int get_libxml_iconv_enabled() {
#ifdef LIBXML_ICONV_ENABLED
return 1;
#else
return 0;
#endif
}
int get_libxml_icu_enabled() {
#ifdef LIBXML_ICU_ENABLED
return 1;
#else
return 0;
#endif
}
int get_libxml_regexp_enabled() {
#ifdef LIBXML_REGEXP_ENABLED
return 1;
#else
return 0;
#endif
}
int get_debug_push() {
#ifdef DEBUG_PUSH
return 1;
#else
return 0;
#endif
}
#endif /* COMPILE_WITH_RUST */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/joker_charles/libxml2-rust.git
git@gitee.com:joker_charles/libxml2-rust.git
joker_charles
libxml2-rust
libxml2-rust
master

Search