/*
* 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"
#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
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
#include <libxml/xmlmemory.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>
/* #define DEBUG */
/* #define DEBUG_PUSH */
/************************************************************************
* *
* Some factorized error routines *
* *
************************************************************************/
/**
* htmlErrMemory:
* @ctxt: an HTML parser context
* @extra: extra informations
*
* Handle a redefinition of attribute error
*/
static void
{
return;
}
if (extra)
"Memory allocation failed : %s\n", extra);
else
}
/**
* htmlParseErr:
* @ctxt: an HTML parser context
* @error: the error number
* @msg: the error message
* @str1: string infor
* @str2: string infor
*
* Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/
static void
{
return;
XML_ERR_ERROR, NULL, 0,
NULL, 0, 0,
ctxt->wellFormed = 0;
}
/**
* htmlParseErrInt:
* @ctxt: an HTML parser context
* @error: the error number
* @msg: the error message
* @val: integer info
*
* Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/
static void
{
return;
ctxt->wellFormed = 0;
}
/************************************************************************
* *
* Parser stacks related functions and macros *
* *
************************************************************************/
/**
* htmlnamePush:
* @ctxt: an HTML parser context
* @value: the element name
*
* Pushes a new element name on top of the name stack
*
* Returns 0 in case of error, the index in the stack otherwise
*/
static int
{
return (0);
}
}
}
/**
* htmlnamePop:
* @ctxt: an HTML parser context
*
* Pops the top element name from the name stack
*
* Returns the name just removed
*/
static const xmlChar *
{
return (NULL);
return (NULL);
else
return (ret);
}
/*
* Macros for accessing the content. Those should be used only by the parser,
* and not exported.
*
* Dirty macros, i.e. one need to make assumption on the context to use them
*
* CUR_PTR return the current pointer to the xmlChar to be parsed.
* CUR returns the current xmlChar value, i.e. a 8 bit value if compiled
* in ISO-Latin or UTF-8, and the current 16 bit value if compiled
* in UNICODE mode. This should be used internally by the parser
* only to compare to ASCII values otherwise it would break when
* running with UTF-8 encoding.
* NXT(n) returns the n'th next xmlChar. Same as CUR is should be used only
* to compare on ASCII based substring.
* UPP(n) returns the n'th next xmlChar converted to uppercase. Same as CUR
* it should be used only to compare on ASCII based substring.
* SKIP(n) Skip n xmlChar, and must also be used only to skip ASCII defined
* strings without newlines within the parser.
*
* Clean macros, not dependent of an ASCII context, expect UTF-8 encoding
*
* CURRENT Returns the current char value, with the full decoding of
* UTF-8 if we are using this mode. It returns an int.
* NEXT Skip to the next character, this does the proper decoding
* in UTF-8 mode. It also pop-up unfinished entities on the fly.
* NEXTL(l) Skip the current unicode character of l xmlChars long.
* COPY(to) copy one char to *to, increment CUR_PTR and to accordingly
*/
/* Inported from XML */
/* #define CUR (ctxt->token ? ctxt->token : (int) (*ctxt->input->cur)) */
#define NEXTL(l) do { \
} while (0)
/************
\
if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt); \
if (*ctxt->input->cur == '&') xmlParserHandleReference(ctxt);
************/
#define COPY_BUF(l,b,i,v) \
if (l == 1) b[i++] = (xmlChar) v; \
else i += xmlCopyChar(l,&b[i],v)
/**
* htmlCurrentChar:
* @ctxt: the HTML parser context
* @len: pointer to the length of the char read
*
* The current char value, if using UTF-8 this may actually span multiple
* bytes in the input buffer. Implement the end of line normalization:
* 2.11 End-of-Line Handling
* If the encoding is unspecified, in the case we find an ISO-Latin-1
* char, then the encoding converter is plugged in automatically.
*
* Returns the current char value and its length
*/
static int
return(0);
*len = 0;
}
/*
* We are supposed to handle UTF8, check it's valid
* From rfc2044: encoding of the Unicode values on UTF-8:
*
* UCS-4 range (hex.) UTF-8 octet sequence (binary)
* 0000 0000-0000 007F 0xxxxxxx
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx
* 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
*
* Check for the 0x110000 limit too
*/
unsigned char c;
unsigned int val;
c = *cur;
if (c & 0x80) {
if (cur[1] == 0)
goto encoding_error;
if ((c & 0xe0) == 0xe0) {
if (cur[2] == 0)
goto encoding_error;
if ((c & 0xf0) == 0xf0) {
if (cur[3] == 0)
if (((c & 0xf8) != 0xf0) ||
goto encoding_error;
/* 4-byte code */
*len = 4;
} else {
/* 3-byte code */
*len = 3;
}
} else {
/* 2-byte code */
*len = 2;
}
"Char 0x%X out of allowed range\n", val);
}
return(val);
} else {
/* 1-byte code */
*len = 1;
}
}
/*
* Assume it's a fixed length encoding (1) with
* a compatible encoding for the ASCII set, since
* XML constructs only use < 128 chars
*/
*len = 1;
/*
* Humm this is bad, do an automatic flow conversion
*/
/*
* If we detect an UTF8 error that probably mean that the
* input encoding didn't get properly advertized in the
* declaration header. Report the error and switch the encoding
* to ISO-Latin-1 (if you don't like this policy, just declare the
* encoding !)
*/
{
} else {
}
"Input is not proper UTF-8, indicate encoding !\n",
}
*len = 1;
}
/**
* htmlSkipBlankChars:
* @ctxt: the HTML parser context
*
* skip all blanks character found at that point in the input streams.
*
* Returns the number of space chars skipped
*/
static int
int res = 0;
} else {
}
res++;
}
return(res);
}
/************************************************************************
* *
* The list of HTML elements and their properties *
* *
************************************************************************/
/*
* Start Tag: 1 means the start tag can be ommited
* End Tag: 1 means the end tag can be ommited
* 2 means it's forbidden (empty elements)
* 3 means the tag is stylistic and should be closed easily
* Depr: this element is deprecated
* DTD: 1 means that this element is valid only in the Loose DTD
* 2 means that this element is valid only in the Frameset DTD
*
* Name,Start Tag,End Tag,Save End,Empty,Deprecated,DTD,inline,Description
, subElements , impliedsubelt , Attributes, userdata
*/
/* Definitions and a couple of vars for HTML Elements */
#define SPECIAL "a", "img", "applet", "embed", "object", "font", "basefont", "br", "script", "map", "q", "sub", "sup", "span", "bdo", "iframe"
#define BLOCK HEADING, LIST "pre", "p", "dl", "div", "center", "noscript", "noframes", "blockquote", "form", "isindex", "hr", "table", "fieldset", "address"
#define PCDATA
#define NB_PCDATA 0
#define MODIFIER
#define NB_MODIFIER 0
/* placeholders: elts with content but no subelements */
/* ... and for HTML Attributes */
#define EVENTS "onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmouseout", "onkeypress", "onkeydown", "onkeyup"
/* Other declarations that should go inline ... */
"href", "hreflang", "rel", "rev", "accesskey", "shape", "coords",
"archive", "alt", "name", "height", "width", "align",
static const char* const basefont_attrs[] =
static const char* const form_contents[] = { HEADING, LIST, INLINE, "pre", "p", "div", "center", "noscript", "noframes", "blockquote", "isindex", "hr", "table", "fieldset", "address", NULL } ;
static const char* const form_attrs[] = { ATTRS, "method", "enctype", "accept", "name", "onsubmit", "onreset", "accept-charset", NULL } ;
static const char* const frame_attrs[] = { COREATTRS, "longdesc", "name", "src", "frameborder", "marginwidth", "marginheight", "noresize", "scrolling" , NULL } ;
static const char* const frameset_attrs[] = { COREATTRS, "rows", "cols", "onload", "onunload", NULL } ;
static const char* const head_contents[] = { "title", "isindex", "base", "script", "style", "meta", "link", "object", NULL } ;
static const char* const iframe_attrs[] = { COREATTRS, "longdesc", "name", "src", "frameborder", "marginwidth", "marginheight", "scrolling", "align", "height", "width", NULL } ;
static const char* const img_attrs[] = { ATTRS, "longdesc", "name", "height", "width", "usemap", "ismap", NULL } ;
static const char* const embed_attrs[] = { COREATTRS, "align", "alt", "border", "code", "codebase", "frameborder", "height", "hidden", "hspace", "name", "palette", "pluginspace", "pluginurl", "src", "type", "units", "vspace", "width", NULL } ;
static const char* const input_attrs[] = { ATTRS, "type", "name", "value", "checked", "disabled", "readonly", "size", "maxlength", "src", "alt", "usemap", "ismap", "tabindex", "accesskey", "onfocus", "onblur", "onselect", "onchange", "accept", NULL } ;
static const char* const link_attrs[] = { ATTRS, "charset", "href", "hreflang", "type", "rel", "rev", "media", NULL } ;
static const char* const object_attrs[] = { ATTRS, "declare", "classid", "codebase", "data", "type", "codetype", "archive", "standby", "height", "width", "usemap", "name", "tabindex", NULL } ;
static const char* const option_attrs[] = { ATTRS, "disabled", "label", "selected", "value", NULL } ;
static const char* const pre_content[] = { PHRASE, "tt", "i", "b", "u", "s", "strike", "a", "br", "script", "map", "q", "span", "bdo", "iframe", NULL } ;
static const char* const select_attrs[] = { ATTRS, "name", "size", "multiple", "disabled", "tabindex", "onfocus", "onblur", "onchange", NULL } ;
static const char* const table_attrs[] = { ATTRS "summary", "width", "border", "frame", "rules", "cellspacing", "cellpadding", "datapagesize", NULL } ;
static const char* const table_contents[] = { "caption", "col", "colgroup", "thead", "tfoot", "tbody", "tr", NULL} ;
static const char* const th_td_attr[] = { ATTRS, "abbr", "axis", "headers", "scope", "rowspan", "colspan", CELLHALIGN, CELLVALIGN, NULL } ;
static const char* const textarea_attrs[] = { ATTRS, "name", "disabled", "readonly", "tabindex", "accesskey", "onfocus", "onblur", "onselect", "onchange", NULL } ;
#define DECL (const char**)
static const htmlElemDesc
html40ElementTable[] = {
{ "a", 0, 0, 0, 0, 0, 0, 1, "anchor ",
},
{ "abbr", 0, 0, 0, 0, 0, 0, 1, "abbreviated form",
},
{ "acronym", 0, 0, 0, 0, 0, 0, 1, "",
},
{ "address", 0, 0, 0, 0, 0, 0, 0, "information on author ",
},
{ "applet", 0, 0, 0, 0, 1, 1, 2, "java applet ",
},
{ "area", 0, 2, 2, 1, 0, 0, 0, "client-side image map area ",
},
{ "b", 0, 3, 0, 0, 0, 0, 1, "bold text style",
},
{ "base", 0, 2, 2, 1, 0, 0, 0, "document base uri ",
},
{ "basefont", 0, 2, 2, 1, 1, 1, 1, "base font size " ,
},
{ "bdo", 0, 0, 0, 0, 0, 0, 1, "i18n bidi over-ride ",
},
{ "big", 0, 3, 0, 0, 0, 0, 1, "large text style",
},
{ "blockquote", 0, 0, 0, 0, 0, 0, 0, "long quotation ",
},
{ "body", 1, 1, 0, 0, 0, 0, 0, "document body ",
},
{ "br", 0, 2, 2, 1, 0, 0, 1, "forced line break ",
},
{ "button", 0, 0, 0, 0, 0, 0, 2, "push button ",
},
{ "caption", 0, 0, 0, 0, 0, 0, 0, "table caption ",
},
{ "center", 0, 3, 0, 0, 1, 1, 0, "shorthand for div align=center ",
},
{ "cite", 0, 0, 0, 0, 0, 0, 1, "citation",
},
{ "code", 0, 0, 0, 0, 0, 0, 1, "computer code fragment",
},
{ "col", 0, 2, 2, 1, 0, 0, 0, "table column ",
},
{ "colgroup", 0, 1, 0, 0, 0, 0, 0, "table column group ",
},
{ "dd", 0, 1, 0, 0, 0, 0, 0, "definition description ",
},
{ "del", 0, 0, 0, 0, 0, 0, 2, "deleted text ",
},
{ "dfn", 0, 0, 0, 0, 0, 0, 1, "instance definition",
},
{ "dir", 0, 0, 0, 0, 1, 1, 0, "directory list",
},
},
{ "dl", 0, 0, 0, 0, 0, 0, 0, "definition list ",
},
{ "dt", 0, 1, 0, 0, 0, 0, 0, "definition term ",
},
{ "em", 0, 3, 0, 0, 0, 0, 1, "emphasis",
},
{ "embed", 0, 1, 0, 0, 1, 1, 1, "generic embedded object ",
},
{ "fieldset", 0, 0, 0, 0, 0, 0, 0, "form control group ",
},
{ "font", 0, 3, 0, 0, 1, 1, 1, "local change to font ",
},
{ "form", 0, 0, 0, 0, 0, 0, 0, "interactive form ",
},
{ "frame", 0, 2, 2, 1, 0, 2, 0, "subwindow " ,
},
{ "frameset", 0, 0, 0, 0, 0, 2, 0, "window subdivision" ,
},
{ "h1", 0, 0, 0, 0, 0, 0, 0, "heading ",
},
{ "h2", 0, 0, 0, 0, 0, 0, 0, "heading ",
},
{ "h3", 0, 0, 0, 0, 0, 0, 0, "heading ",
},
{ "h4", 0, 0, 0, 0, 0, 0, 0, "heading ",
},
{ "h5", 0, 0, 0, 0, 0, 0, 0, "heading ",
},
{ "h6", 0, 0, 0, 0, 0, 0, 0, "heading ",
},
{ "head", 1, 1, 0, 0, 0, 0, 0, "document head ",
},
{ "hr", 0, 2, 2, 1, 0, 0, 0, "horizontal rule " ,
},
{ "html", 1, 1, 0, 0, 0, 0, 0, "document root element ",
},
{ "i", 0, 3, 0, 0, 0, 0, 1, "italic text style",
},
{ "iframe", 0, 0, 0, 0, 0, 1, 2, "inline subwindow ",
},
{ "img", 0, 2, 2, 1, 0, 0, 1, "embedded image ",
},
{ "input", 0, 2, 2, 1, 0, 0, 1, "form control ",
},
{ "ins", 0, 0, 0, 0, 0, 0, 2, "inserted text",
},
{ "isindex", 0, 2, 2, 1, 1, 1, 0, "single line prompt ",
},
{ "kbd", 0, 0, 0, 0, 0, 0, 1, "text to be entered by the user",
},
{ "label", 0, 0, 0, 0, 0, 0, 1, "form field label text ",
},
{ "legend", 0, 0, 0, 0, 0, 0, 0, "fieldset legend ",
},
{ "li", 0, 1, 1, 0, 0, 0, 0, "list item ",
},
{ "link", 0, 2, 2, 1, 0, 0, 0, "a media-independent link ",
},
{ "map", 0, 0, 0, 0, 0, 0, 2, "client-side image map ",
},
{ "menu", 0, 0, 0, 0, 1, 1, 0, "menu list ",
},
{ "meta", 0, 2, 2, 1, 0, 0, 0, "generic metainformation ",
},
{ "noframes", 0, 0, 0, 0, 0, 2, 0, "alternate content container for non frame-based rendering ",
},
{ "noscript", 0, 0, 0, 0, 0, 0, 0, "alternate content container for non script-based rendering ",
},
{ "object", 0, 0, 0, 0, 0, 0, 2, "generic embedded object ",
},
{ "ol", 0, 0, 0, 0, 0, 0, 0, "ordered list ",
},
{ "optgroup", 0, 0, 0, 0, 0, 0, 0, "option group ",
},
{ "option", 0, 1, 0, 0, 0, 0, 0, "selectable choice " ,
},
{ "p", 0, 1, 0, 0, 0, 0, 0, "paragraph ",
},
{ "param", 0, 2, 2, 1, 0, 0, 0, "named property value ",
},
{ "pre", 0, 0, 0, 0, 0, 0, 0, "preformatted text ",
},
{ "q", 0, 0, 0, 0, 0, 0, 1, "short inline quotation ",
},
{ "s", 0, 3, 0, 0, 1, 1, 1, "strike-through text style",
},
{ "samp", 0, 0, 0, 0, 0, 0, 1, "sample program output, scripts, etc.",
},
{ "script", 0, 0, 0, 0, 0, 0, 2, "script statements ",
},
{ "select", 0, 0, 0, 0, 0, 0, 1, "option selector ",
},
{ "small", 0, 3, 0, 0, 0, 0, 1, "small text style",
},
},
{ "strike", 0, 3, 0, 0, 1, 1, 1, "strike-through text",
},
{ "strong", 0, 3, 0, 0, 0, 0, 1, "strong emphasis",
},
{ "style", 0, 0, 0, 0, 0, 0, 0, "style info ",
},
{ "sub", 0, 3, 0, 0, 0, 0, 1, "subscript",
},
{ "sup", 0, 3, 0, 0, 0, 0, 1, "superscript ",
},
{ "table", 0, 0, 0, 0, 0, 0, 0, "",
},
{ "tbody", 1, 0, 0, 0, 0, 0, 0, "table body ",
},
{ "td", 0, 0, 0, 0, 0, 0, 0, "table data cell",
},
{ "textarea", 0, 0, 0, 0, 0, 0, 1, "multi-line text field ",
},
{ "tfoot", 0, 1, 0, 0, 0, 0, 0, "table footer ",
},
{ "th", 0, 1, 0, 0, 0, 0, 0, "table header cell",
},
{ "thead", 0, 1, 0, 0, 0, 0, 0, "table header ",
},
{ "title", 0, 0, 0, 0, 0, 0, 0, "document title ",
},
{ "tr", 0, 0, 0, 0, 0, 0, 0, "table row ",
},
{ "tt", 0, 3, 0, 0, 0, 0, 1, "teletype or monospaced text style",
},
{ "u", 0, 3, 0, 0, 1, 1, 1, "underlined text style",
},
{ "ul", 0, 0, 0, 0, 0, 0, 0, "unordered list ",
},
{ "var", 0, 0, 0, 0, 0, 0, 1, "instance of a variable or program argument",
}
};
/*
* start tags that imply the end of current element
*/
static const char * const htmlStartClose[] = {
"form", "form", "p", "hr", "h1", "h2", "h3", "h4", "h5", "h6",
"dl", "ul", "ol", "menu", "dir", "address", "pre",
"li", "p", "h1", "h2", "h3", "h4", "h5", "h6", "dl", "address",
"dl", "p", "dt", "menu", "dir", "address", "pre", "listing",
"dt", "p", "menu", "dir", "address", "pre", "listing", "xmp",
"dd", "p", "menu", "dir", "address", "pre", "listing", "xmp",
"ul", "p", "head", "ol", "menu", "dir", "address", "pre",
"table", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", "pre",
"tfoot", "th", "td", "tr", "caption", "col", "colgroup", "thead",
"tbody", "th", "td", "tr", "caption", "col", "colgroup", "thead",
"fieldset", "legend", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6",
};
/*
* The list of HTML elements which are supposed not to have
* CDATA content and where a p element will be implied
*
* TODO: extend that list by reading the HTML SGML DTD on
* implied paragraph
*/
static const char *const htmlNoContentElements[] = {
"html",
"head",
};
/*
* The list of HTML attributes which are of content %Script;
* NOTE: when adding ones, check htmlIsScriptAttribute() since
* it assumes the name starts with 'on'
*/
static const char *const htmlScriptAttributes[] = {
"onclick",
"ondblclick",
"onmousedown",
"onmouseup",
"onmouseover",
"onmousemove",
"onmouseout",
"onkeypress",
"onkeydown",
"onkeyup",
"onload",
"onunload",
"onfocus",
"onblur",
"onsubmit",
"onrest",
"onchange",
"onselect"
};
/*
* This table is used by the htmlparser to know what to do with
* broken html pages. By assigning different priorities to different
* elements the parser can decide how to handle extra endtags.
* Endtags are only allowed to close elements with lower or equal
* priority.
*/
typedef struct {
const char *name;
int priority;
{"div", 150},
{"td", 160},
{"th", 160},
{"tr", 170},
{"thead", 180},
{"tbody", 180},
{"tfoot", 180},
{"table", 190},
{"head", 200},
{"body", 200},
{"html", 220},
};
static int htmlStartCloseIndexinitialized = 0;
/************************************************************************
* *
* functions to handle HTML specific data *
* *
************************************************************************/
/**
* htmlInitAutoClose:
*
* Initialize the htmlStartCloseIndex for fast lookup of closing tags names.
* This is not reentrant. Call xmlInitParser() once before processing in
* case of use in multithreaded programs.
*/
void
htmlInitAutoClose(void) {
int indx, i = 0;
if (htmlStartCloseIndexinitialized) return;
indx = 0;
while (htmlStartClose[i] != NULL) i++;
i++;
}
}
/**
* 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 *
unsigned int i;
for (i = 0; i < (sizeof(html40ElementTable) /
sizeof(html40ElementTable[0]));i++) {
return((htmlElemDescPtr) &html40ElementTable[i]);
}
return(NULL);
}
/**
* htmlGetEndPriority:
* @name: The name of the element to look up the priority for.
*
* Return value: The "endtag" priority.
**/
static int
int i = 0;
i++;
return(htmlEndPriority[i].priority);
}
/**
* htmlCheckAutoClose:
* @newtag: The new tag name
* @oldtag: The old tag name
*
* Checks whether the new tag is one of the registered valid tags for
* closing old.
* Initialize the htmlStartCloseIndex for fast lookup of closing tags names.
*
* Returns 0 if no, 1 if yes.
*/
static int
{
int i, indx;
if (htmlStartCloseIndexinitialized == 0)
/* inefficient, but not a big deal */
return (0);
break;
}
i = closed - htmlStartClose;
i++;
while (htmlStartClose[i] != NULL) {
return (1);
}
i++;
}
return (0);
}
/**
* htmlAutoCloseOnClose:
* @ctxt: an HTML parser context
* @newtag: The new tag name
* @force: force the tag closure
*
* The HTML DTD allows an ending tag to implicitly close other tags.
*/
static void
{
int i, priority;
break;
/*
* A missplaced endtag can only close elements with lower
* or equal priority, so if we find an element with higher
* priority before we find an element with
* matching name, we just ignore this endtag
*/
return;
}
if (i < 0)
return;
"Opening and ending tag mismatch: %s and %s\n",
}
}
}
/**
* htmlAutoCloseOnEnd:
* @ctxt: an HTML parser context
*
* Close all remaining tags at the end of the stream
*/
static void
{
int i;
return;
}
}
/**
* htmlAutoClose:
* @ctxt: an HTML parser context
* @newtag: The new tag name or NULL
*
* The HTML DTD allows a tag to implicitly close other tags.
* The list is kept in htmlStartClose array. This function is
* called when a new tag has been detected and generates the
* If newtag is NULL this mean we are at the end of the resource
* and we should check
*/
static void
{
}
return;
}
}
}
/**
* 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
}
return(0);
}
/**
* 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
}
return(0);
}
/**
* htmlCheckImplied:
* @ctxt: an HTML parser context
* @newtag: The new tag name
*
* The HTML DTD allows a tag to exists only implicitly
* called when a new tag has been detected and generates the
* appropriates implicit tags if missing
*/
static void
if (!htmlOmittedDefaultValue)
return;
return;
}
return;
/*
* dropped OBJECT ... i you put it first BODY will be
* assumed !
*/
int i;
return;
}
return;
}
}
}
}
/**
* htmlCheckParagraph
* @ctxt: an HTML parser context
*
* Check whether a p element need to be implied before inserting
* characters in the current element.
*
* Returns 1 if a paragraph has been inserted, 0 if not and -1
* in case of error.
*/
static int
int i;
return(-1);
return(1);
}
if (!htmlOmittedDefaultValue)
return(0);
for (i = 0; htmlNoContentElements[i] != NULL; i++) {
return(1);
}
}
return(0);
}
/**
* 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
unsigned int i;
return(0);
/*
* all script attributes start with 'on'
*/
return(0);
for (i = 0;
i < sizeof(htmlScriptAttributes)/sizeof(htmlScriptAttributes[0]);
i++) {
return(1);
}
return(0);
}
/************************************************************************
* *
* The list of HTML predefined entities *
* *
************************************************************************/
/*
* the 4 absolute ones, plus apostrophe.
*/
{ 34, "quot", "quotation mark = APL quote, U+0022 ISOnum" },
{ 38, "amp", "ampersand, U+0026 ISOnum" },
{ 39, "apos", "single quote" },
{ 60, "lt", "less-than sign, U+003C ISOnum" },
{ 62, "gt", "greater-than sign, U+003E ISOnum" },
/*
* A bunch still in the 128-255 range
* Replacing them depend really on the charset used.
*/
{ 160, "nbsp", "no-break space = non-breaking space, U+00A0 ISOnum" },
{ 161, "iexcl","inverted exclamation mark, U+00A1 ISOnum" },
{ 162, "cent", "cent sign, U+00A2 ISOnum" },
{ 163, "pound","pound sign, U+00A3 ISOnum" },
{ 164, "curren","currency sign, U+00A4 ISOnum" },
{ 165, "yen", "yen sign = yuan sign, U+00A5 ISOnum" },
{ 166, "brvbar","broken bar = broken vertical bar, U+00A6 ISOnum" },
{ 167, "sect", "section sign, U+00A7 ISOnum" },
{ 168, "uml", "diaeresis = spacing diaeresis, U+00A8 ISOdia" },
{ 169, "copy", "copyright sign, U+00A9 ISOnum" },
{ 170, "ordf", "feminine ordinal indicator, U+00AA ISOnum" },
{ 171, "laquo","left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum" },
{ 172, "not", "not sign, U+00AC ISOnum" },
{ 173, "shy", "soft hyphen = discretionary hyphen, U+00AD ISOnum" },
{ 174, "reg", "registered sign = registered trade mark sign, U+00AE ISOnum" },
{ 175, "macr", "macron = spacing macron = overline = APL overbar, U+00AF ISOdia" },
{ 176, "deg", "degree sign, U+00B0 ISOnum" },
{ 177, "plusmn","plus-minus sign = plus-or-minus sign, U+00B1 ISOnum" },
{ 178, "sup2", "superscript two = superscript digit two = squared, U+00B2 ISOnum" },
{ 179, "sup3", "superscript three = superscript digit three = cubed, U+00B3 ISOnum" },
{ 180, "acute","acute accent = spacing acute, U+00B4 ISOdia" },
{ 181, "micro","micro sign, U+00B5 ISOnum" },
{ 182, "para", "pilcrow sign = paragraph sign, U+00B6 ISOnum" },
{ 183, "middot","middle dot = Georgian comma Greek middle dot, U+00B7 ISOnum" },
{ 184, "cedil","cedilla = spacing cedilla, U+00B8 ISOdia" },
{ 185, "sup1", "superscript one = superscript digit one, U+00B9 ISOnum" },
{ 186, "ordm", "masculine ordinal indicator, U+00BA ISOnum" },
{ 187, "raquo","right-pointing double angle quotation mark right pointing guillemet, U+00BB ISOnum" },
{ 188, "frac14","vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum" },
{ 189, "frac12","vulgar fraction one half = fraction one half, U+00BD ISOnum" },
{ 190, "frac34","vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum" },
{ 191, "iquest","inverted question mark = turned question mark, U+00BF ISOnum" },
{ 192, "Agrave","latin capital letter A with grave = latin capital letter A grave, U+00C0 ISOlat1" },
{ 193, "Aacute","latin capital letter A with acute, U+00C1 ISOlat1" },
{ 194, "Acirc","latin capital letter A with circumflex, U+00C2 ISOlat1" },
{ 195, "Atilde","latin capital letter A with tilde, U+00C3 ISOlat1" },
{ 196, "Auml", "latin capital letter A with diaeresis, U+00C4 ISOlat1" },
{ 197, "Aring","latin capital letter A with ring above = latin capital letter A ring, U+00C5 ISOlat1" },
{ 198, "AElig","latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1" },
{ 199, "Ccedil","latin capital letter C with cedilla, U+00C7 ISOlat1" },
{ 200, "Egrave","latin capital letter E with grave, U+00C8 ISOlat1" },
{ 201, "Eacute","latin capital letter E with acute, U+00C9 ISOlat1" },
{ 202, "Ecirc","latin capital letter E with circumflex, U+00CA ISOlat1" },
{ 203, "Euml", "latin capital letter E with diaeresis, U+00CB ISOlat1" },
{ 204, "Igrave","latin capital letter I with grave, U+00CC ISOlat1" },
{ 205, "Iacute","latin capital letter I with acute, U+00CD ISOlat1" },
{ 206, "Icirc","latin capital letter I with circumflex, U+00CE ISOlat1" },
{ 207, "Iuml", "latin capital letter I with diaeresis, U+00CF ISOlat1" },
{ 208, "ETH", "latin capital letter ETH, U+00D0 ISOlat1" },
{ 209, "Ntilde","latin capital letter N with tilde, U+00D1 ISOlat1" },
{ 210, "Ograve","latin capital letter O with grave, U+00D2 ISOlat1" },
{ 211, "Oacute","latin capital letter O with acute, U+00D3 ISOlat1" },
{ 212, "Ocirc","latin capital letter O with circumflex, U+00D4 ISOlat1" },
{ 213, "Otilde","latin capital letter O with tilde, U+00D5 ISOlat1" },
{ 214, "Ouml", "latin capital letter O with diaeresis, U+00D6 ISOlat1" },
{ 215, "times","multiplication sign, U+00D7 ISOnum" },
{ 216, "Oslash","latin capital letter O with stroke latin capital letter O slash, U+00D8 ISOlat1" },
{ 217, "Ugrave","latin capital letter U with grave, U+00D9 ISOlat1" },
{ 218, "Uacute","latin capital letter U with acute, U+00DA ISOlat1" },
{ 219, "Ucirc","latin capital letter U with circumflex, U+00DB ISOlat1" },
{ 220, "Uuml", "latin capital letter U with diaeresis, U+00DC ISOlat1" },
{ 221, "Yacute","latin capital letter Y with acute, U+00DD ISOlat1" },
{ 222, "THORN","latin capital letter THORN, U+00DE ISOlat1" },
{ 223, "szlig","latin small letter sharp s = ess-zed, U+00DF ISOlat1" },
{ 224, "agrave","latin small letter a with grave = latin small letter a grave, U+00E0 ISOlat1" },
{ 225, "aacute","latin small letter a with acute, U+00E1 ISOlat1" },
{ 226, "acirc","latin small letter a with circumflex, U+00E2 ISOlat1" },
{ 227, "atilde","latin small letter a with tilde, U+00E3 ISOlat1" },
{ 228, "auml", "latin small letter a with diaeresis, U+00E4 ISOlat1" },
{ 229, "aring","latin small letter a with ring above = latin small letter a ring, U+00E5 ISOlat1" },
{ 230, "aelig","latin small letter ae = latin small ligature ae, U+00E6 ISOlat1" },
{ 231, "ccedil","latin small letter c with cedilla, U+00E7 ISOlat1" },
{ 232, "egrave","latin small letter e with grave, U+00E8 ISOlat1" },
{ 233, "eacute","latin small letter e with acute, U+00E9 ISOlat1" },
{ 234, "ecirc","latin small letter e with circumflex, U+00EA ISOlat1" },
{ 235, "euml", "latin small letter e with diaeresis, U+00EB ISOlat1" },
{ 236, "igrave","latin small letter i with grave, U+00EC ISOlat1" },
{ 237, "iacute","latin small letter i with acute, U+00ED ISOlat1" },
{ 238, "icirc","latin small letter i with circumflex, U+00EE ISOlat1" },
{ 239, "iuml", "latin small letter i with diaeresis, U+00EF ISOlat1" },
{ 240, "eth", "latin small letter eth, U+00F0 ISOlat1" },
{ 241, "ntilde","latin small letter n with tilde, U+00F1 ISOlat1" },
{ 242, "ograve","latin small letter o with grave, U+00F2 ISOlat1" },
{ 243, "oacute","latin small letter o with acute, U+00F3 ISOlat1" },
{ 244, "ocirc","latin small letter o with circumflex, U+00F4 ISOlat1" },
{ 245, "otilde","latin small letter o with tilde, U+00F5 ISOlat1" },
{ 246, "ouml", "latin small letter o with diaeresis, U+00F6 ISOlat1" },
{ 247, "divide","division sign, U+00F7 ISOnum" },
{ 248, "oslash","latin small letter o with stroke, = latin small letter o slash, U+00F8 ISOlat1" },
{ 249, "ugrave","latin small letter u with grave, U+00F9 ISOlat1" },
{ 250, "uacute","latin small letter u with acute, U+00FA ISOlat1" },
{ 251, "ucirc","latin small letter u with circumflex, U+00FB ISOlat1" },
{ 252, "uuml", "latin small letter u with diaeresis, U+00FC ISOlat1" },
{ 253, "yacute","latin small letter y with acute, U+00FD ISOlat1" },
{ 254, "thorn","latin small letter thorn with, U+00FE ISOlat1" },
{ 255, "yuml", "latin small letter y with diaeresis, U+00FF ISOlat1" },
{ 338, "OElig","latin capital ligature OE, U+0152 ISOlat2" },
{ 339, "oelig","latin small ligature oe, U+0153 ISOlat2" },
{ 352, "Scaron","latin capital letter S with caron, U+0160 ISOlat2" },
{ 353, "scaron","latin small letter s with caron, U+0161 ISOlat2" },
{ 376, "Yuml", "latin capital letter Y with diaeresis, U+0178 ISOlat2" },
/*
* Anything below should really be kept as entities references
*/
{ 402, "fnof", "latin small f with hook = function = florin, U+0192 ISOtech" },
{ 710, "circ", "modifier letter circumflex accent, U+02C6 ISOpub" },
{ 732, "tilde","small tilde, U+02DC ISOdia" },
{ 913, "Alpha","greek capital letter alpha, U+0391" },
{ 914, "Beta", "greek capital letter beta, U+0392" },
{ 915, "Gamma","greek capital letter gamma, U+0393 ISOgrk3" },
{ 916, "Delta","greek capital letter delta, U+0394 ISOgrk3" },
{ 917, "Epsilon","greek capital letter epsilon, U+0395" },
{ 918, "Zeta", "greek capital letter zeta, U+0396" },
{ 919, "Eta", "greek capital letter eta, U+0397" },
{ 920, "Theta","greek capital letter theta, U+0398 ISOgrk3" },
{ 921, "Iota", "greek capital letter iota, U+0399" },
{ 922, "Kappa","greek capital letter kappa, U+039A" },
{ 923, "Lambda", "greek capital letter lambda, U+039B ISOgrk3" },
{ 924, "Mu", "greek capital letter mu, U+039C" },
{ 925, "Nu", "greek capital letter nu, U+039D" },
{ 926, "Xi", "greek capital letter xi, U+039E ISOgrk3" },
{ 927, "Omicron","greek capital letter omicron, U+039F" },
{ 928, "Pi", "greek capital letter pi, U+03A0 ISOgrk3" },
{ 929, "Rho", "greek capital letter rho, U+03A1" },
{ 931, "Sigma","greek capital letter sigma, U+03A3 ISOgrk3" },
{ 932, "Tau", "greek capital letter tau, U+03A4" },
{ 933, "Upsilon","greek capital letter upsilon, U+03A5 ISOgrk3" },
{ 934, "Phi", "greek capital letter phi, U+03A6 ISOgrk3" },
{ 935, "Chi", "greek capital letter chi, U+03A7" },
{ 936, "Psi", "greek capital letter psi, U+03A8 ISOgrk3" },
{ 937, "Omega","greek capital letter omega, U+03A9 ISOgrk3" },
{ 945, "alpha","greek small letter alpha, U+03B1 ISOgrk3" },
{ 946, "beta", "greek small letter beta, U+03B2 ISOgrk3" },
{ 947, "gamma","greek small letter gamma, U+03B3 ISOgrk3" },
{ 948, "delta","greek small letter delta, U+03B4 ISOgrk3" },
{ 949, "epsilon","greek small letter epsilon, U+03B5 ISOgrk3" },
{ 950, "zeta", "greek small letter zeta, U+03B6 ISOgrk3" },
{ 951, "eta", "greek small letter eta, U+03B7 ISOgrk3" },
{ 952, "theta","greek small letter theta, U+03B8 ISOgrk3" },
{ 953, "iota", "greek small letter iota, U+03B9 ISOgrk3" },
{ 954, "kappa","greek small letter kappa, U+03BA ISOgrk3" },
{ 955, "lambda","greek small letter lambda, U+03BB ISOgrk3" },
{ 956, "mu", "greek small letter mu, U+03BC ISOgrk3" },
{ 957, "nu", "greek small letter nu, U+03BD ISOgrk3" },
{ 958, "xi", "greek small letter xi, U+03BE ISOgrk3" },
{ 959, "omicron","greek small letter omicron, U+03BF NEW" },
{ 960, "pi", "greek small letter pi, U+03C0 ISOgrk3" },
{ 961, "rho", "greek small letter rho, U+03C1 ISOgrk3" },
{ 962, "sigmaf","greek small letter final sigma, U+03C2 ISOgrk3" },
{ 963, "sigma","greek small letter sigma, U+03C3 ISOgrk3" },
{ 964, "tau", "greek small letter tau, U+03C4 ISOgrk3" },
{ 965, "upsilon","greek small letter upsilon, U+03C5 ISOgrk3" },
{ 966, "phi", "greek small letter phi, U+03C6 ISOgrk3" },
{ 967, "chi", "greek small letter chi, U+03C7 ISOgrk3" },
{ 968, "psi", "greek small letter psi, U+03C8 ISOgrk3" },
{ 969, "omega","greek small letter omega, U+03C9 ISOgrk3" },
{ 977, "thetasym","greek small letter theta symbol, U+03D1 NEW" },
{ 978, "upsih","greek upsilon with hook symbol, U+03D2 NEW" },
{ 982, "piv", "greek pi symbol, U+03D6 ISOgrk3" },
{ 8194, "ensp", "en space, U+2002 ISOpub" },
{ 8195, "emsp", "em space, U+2003 ISOpub" },
{ 8201, "thinsp","thin space, U+2009 ISOpub" },
{ 8204, "zwnj", "zero width non-joiner, U+200C NEW RFC 2070" },
{ 8205, "zwj", "zero width joiner, U+200D NEW RFC 2070" },
{ 8206, "lrm", "left-to-right mark, U+200E NEW RFC 2070" },
{ 8207, "rlm", "right-to-left mark, U+200F NEW RFC 2070" },
{ 8211, "ndash","en dash, U+2013 ISOpub" },
{ 8212, "mdash","em dash, U+2014 ISOpub" },
{ 8216, "lsquo","left single quotation mark, U+2018 ISOnum" },
{ 8217, "rsquo","right single quotation mark, U+2019 ISOnum" },
{ 8218, "sbquo","single low-9 quotation mark, U+201A NEW" },
{ 8220, "ldquo","left double quotation mark, U+201C ISOnum" },
{ 8221, "rdquo","right double quotation mark, U+201D ISOnum" },
{ 8222, "bdquo","double low-9 quotation mark, U+201E NEW" },
{ 8224, "dagger","dagger, U+2020 ISOpub" },
{ 8225, "Dagger","double dagger, U+2021 ISOpub" },
{ 8226, "bull", "bullet = black small circle, U+2022 ISOpub" },
{ 8230, "hellip","horizontal ellipsis = three dot leader, U+2026 ISOpub" },
{ 8240, "permil","per mille sign, U+2030 ISOtech" },
{ 8242, "prime","prime = minutes = feet, U+2032 ISOtech" },
{ 8243, "Prime","double prime = seconds = inches, U+2033 ISOtech" },
{ 8249, "lsaquo","single left-pointing angle quotation mark, U+2039 ISO proposed" },
{ 8250, "rsaquo","single right-pointing angle quotation mark, U+203A ISO proposed" },
{ 8254, "oline","overline = spacing overscore, U+203E NEW" },
{ 8260, "frasl","fraction slash, U+2044 NEW" },
{ 8364, "euro", "euro sign, U+20AC NEW" },
{ 8465, "image","blackletter capital I = imaginary part, U+2111 ISOamso" },
{ 8472, "weierp","script capital P = power set = Weierstrass p, U+2118 ISOamso" },
{ 8476, "real", "blackletter capital R = real part symbol, U+211C ISOamso" },
{ 8482, "trade","trade mark sign, U+2122 ISOnum" },
{ 8501, "alefsym","alef symbol = first transfinite cardinal, U+2135 NEW" },
{ 8592, "larr", "leftwards arrow, U+2190 ISOnum" },
{ 8593, "uarr", "upwards arrow, U+2191 ISOnum" },
{ 8594, "rarr", "rightwards arrow, U+2192 ISOnum" },
{ 8595, "darr", "downwards arrow, U+2193 ISOnum" },
{ 8596, "harr", "left right arrow, U+2194 ISOamsa" },
{ 8629, "crarr","downwards arrow with corner leftwards = carriage return, U+21B5 NEW" },
{ 8656, "lArr", "leftwards double arrow, U+21D0 ISOtech" },
{ 8657, "uArr", "upwards double arrow, U+21D1 ISOamsa" },
{ 8658, "rArr", "rightwards double arrow, U+21D2 ISOtech" },
{ 8659, "dArr", "downwards double arrow, U+21D3 ISOamsa" },
{ 8660, "hArr", "left right double arrow, U+21D4 ISOamsa" },
{ 8704, "forall","for all, U+2200 ISOtech" },
{ 8706, "part", "partial differential, U+2202 ISOtech" },
{ 8707, "exist","there exists, U+2203 ISOtech" },
{ 8709, "empty","empty set = null set = diameter, U+2205 ISOamso" },
{ 8711, "nabla","nabla = backward difference, U+2207 ISOtech" },
{ 8712, "isin", "element of, U+2208 ISOtech" },
{ 8713, "notin","not an element of, U+2209 ISOtech" },
{ 8715, "ni", "contains as member, U+220B ISOtech" },
{ 8719, "prod", "n-ary product = product sign, U+220F ISOamsb" },
{ 8721, "sum", "n-ary summation, U+2211 ISOamsb" },
{ 8722, "minus","minus sign, U+2212 ISOtech" },
{ 8727, "lowast","asterisk operator, U+2217 ISOtech" },
{ 8730, "radic","square root = radical sign, U+221A ISOtech" },
{ 8733, "prop", "proportional to, U+221D ISOtech" },
{ 8734, "infin","infinity, U+221E ISOtech" },
{ 8736, "ang", "angle, U+2220 ISOamso" },
{ 8743, "and", "logical and = wedge, U+2227 ISOtech" },
{ 8744, "or", "logical or = vee, U+2228 ISOtech" },
{ 8745, "cap", "intersection = cap, U+2229 ISOtech" },
{ 8746, "cup", "union = cup, U+222A ISOtech" },
{ 8747, "int", "integral, U+222B ISOtech" },
{ 8756, "there4","therefore, U+2234 ISOtech" },
{ 8764, "sim", "tilde operator = varies with = similar to, U+223C ISOtech" },
{ 8773, "cong", "approximately equal to, U+2245 ISOtech" },
{ 8776, "asymp","almost equal to = asymptotic to, U+2248 ISOamsr" },
{ 8800, "ne", "not equal to, U+2260 ISOtech" },
{ 8801, "equiv","identical to, U+2261 ISOtech" },
{ 8804, "le", "less-than or equal to, U+2264 ISOtech" },
{ 8805, "ge", "greater-than or equal to, U+2265 ISOtech" },
{ 8834, "sub", "subset of, U+2282 ISOtech" },
{ 8835, "sup", "superset of, U+2283 ISOtech" },
{ 8836, "nsub", "not a subset of, U+2284 ISOamsn" },
{ 8838, "sube", "subset of or equal to, U+2286 ISOtech" },
{ 8839, "supe", "superset of or equal to, U+2287 ISOtech" },
{ 8853, "oplus","circled plus = direct sum, U+2295 ISOamsb" },
{ 8855, "otimes","circled times = vector product, U+2297 ISOamsb" },
{ 8869, "perp", "up tack = orthogonal to = perpendicular, U+22A5 ISOtech" },
{ 8901, "sdot", "dot operator, U+22C5 ISOamsb" },
{ 8968, "lceil","left ceiling = apl upstile, U+2308 ISOamsc" },
{ 8969, "rceil","right ceiling, U+2309 ISOamsc" },
{ 8970, "lfloor","left floor = apl downstile, U+230A ISOamsc" },
{ 8971, "rfloor","right floor, U+230B ISOamsc" },
{ 9001, "lang", "left-pointing angle bracket = bra, U+2329 ISOtech" },
{ 9002, "rang", "right-pointing angle bracket = ket, U+232A ISOtech" },
{ 9674, "loz", "lozenge, U+25CA ISOpub" },
{ 9824, "spades","black spade suit, U+2660 ISOpub" },
{ 9827, "clubs","black club suit = shamrock, U+2663 ISOpub" },
{ 9829, "hearts","black heart suit = valentine, U+2665 ISOpub" },
{ 9830, "diams","black diamond suit, U+2666 ISOpub" },
};
/************************************************************************
* *
* Commodity functions to handle entities *
* *
************************************************************************/
/*
* Macro used to grow the current buffer.
*/
return(NULL); \
} \
}
/**
* 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 *
unsigned int i;
for (i = 0;i < (sizeof(html40EntitiesTable)/
sizeof(html40EntitiesTable[0]));i++) {
return((htmlEntityDescPtr) &html40EntitiesTable[i]);
}
}
return(NULL);
}
/**
* 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 *
unsigned int i;
for (i = 0;i < (sizeof(html40EntitiesTable)/
sizeof(html40EntitiesTable[0]));i++) {
break;
return((htmlEntityDescPtr) &html40EntitiesTable[i]);
}
}
return(NULL);
}
/**
* 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
const unsigned char* outend;
const unsigned char* inend;
unsigned int c, d;
int trailing;
/*
* initialization nothing to do
*/
*outlen = 0;
*inlen = 0;
return(0);
}
d = *in++;
if (d < 0x80) { c= d; trailing= 0; }
else if (d < 0xC0) {
/* trailing byte in leading position */
return(-2);
else {
/* no chance for this in Ascii */
return(-2);
}
break;
}
break;
c <<= 6;
c |= d & 0x3F;
}
/* assertion: c is a single UTF-4 value */
if (c < 0x80) {
break;
*out++ = c;
} else {
int len;
const char *cp;
/*
* Try to lookup a predefined HTML entity for it
*/
ent = htmlEntityValueLookup(c);
}
else
break;
*out++ = '&';
*out++ = ';';
}
}
return(0);
}
/**
* 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
const unsigned char* outend;
const unsigned char* inend;
unsigned int c, d;
int trailing;
return(-1);
d = *in++;
if (d < 0x80) { c= d; trailing= 0; }
else if (d < 0xC0) {
/* trailing byte in leading position */
return(-2);
else {
/* no chance for this in Ascii */
return(-2);
}
break;
while (trailing--) {
return(-2);
}
c <<= 6;
c |= d & 0x3F;
}
/* assertion: c is a single UTF-4 value */
if ((c < 0x80) && (c != (unsigned int) quoteChar) &&
(c != '&') && (c != '<') && (c != '>')) {
break;
*out++ = c;
} else {
const char *cp;
int len;
/*
* Try to lookup a predefined HTML entity for it
*/
ent = htmlEntityValueLookup(c);
}
else
break;
*out++ = '&';
*out++ = ';';
}
}
return(0);
}
/************************************************************************
* *
* Commodity functions to handle streams *
* *
************************************************************************/
/**
* htmlNewInputStream:
* @ctxt: an HTML parser context
*
* Create a new input stream structure
* Returns the new input stream or NULL
*/
static htmlParserInputPtr
return(NULL);
}
return(input);
}
/************************************************************************
* *
* Commodity functions, cleanup needed ? *
* *
************************************************************************/
/*
* all tags allowing pc data from the html 4.01 loose dtd
* NOTE: it might be more apropriate to integrate this information
* into the html40ElementTable array but I don't want to risk any
* binary incomptibility
*/
static const char *allowPCData[] = {
"a", "abbr", "acronym", "address", "applet", "b", "bdo", "big",
"blockquote", "body", "button", "caption", "center", "cite", "code",
"dd", "del", "dfn", "div", "dt", "em", "font", "form", "h1", "h2",
"h3", "h4", "h5", "h6", "i", "iframe", "ins", "kbd", "label", "legend",
"li", "noframes", "noscript", "object", "p", "pre", "q", "s", "samp",
"small", "span", "strike", "strong", "td", "th", "tt", "u", "var"
};
/**
* areBlanks:
* @ctxt: an HTML parser context
* @str: a xmlChar *
* @len: the size of @str
*
* Is this a sequence of blank chars that one can ignore ?
*
* Returns 1 if ignorable 0 otherwise.
*/
unsigned int i;
int j;
for (j = 0;j < len;j++)
if (!(IS_BLANK_CH(str[j]))) return(0);
if (CUR == 0) return(1);
if (CUR != '<') return(0);
return(1);
return(1);
return(1);
/* Only strip CDATA children of the body tag for strict HTML DTDs */
return(1);
}
}
/* keep ws in constructs like ...<b> </b>...
for all tags "b" allowing PCDATA */
for ( i = 0; i < sizeof(allowPCData)/sizeof(allowPCData[0]); i++ ) {
return(0);
}
}
} else if (xmlNodeIsText(lastChild)) {
return(0);
} else {
/* keep ws in constructs like <p><b>xy</b> <i>z</i><p>
for all tags "p" allowing PCDATA */
for ( i = 0; i < sizeof(allowPCData)/sizeof(allowPCData[0]); i++ ) {
return(0);
}
}
}
return(1);
}
/**
* 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
*/
/*
* Allocate a new document and fill the fields.
*/
return(NULL);
}
cur->compression = 0;
if ((ExternalID != NULL) ||
return(cur);
}
/**
* 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
*/
return(htmlNewDocNoDtD(
BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN"));
}
/************************************************************************
* *
* The parser itself *
* Relates to http://www.w3.org/TR/html40 *
* *
************************************************************************/
/************************************************************************
* *
* The parser itself *
* *
************************************************************************/
/**
* htmlParseHTMLName:
* @ctxt: an HTML parser context
*
* parse an HTML tag or attribute name, note that we convert it to lowercase
* since HTML names are not case-sensitive.
*
* Returns the Tag Name parsed or NULL
*/
static const xmlChar *
int i = 0;
while ((i < HTML_PARSER_BUFFER_SIZE) &&
i++;
NEXT;
}
}
/**
* htmlParseHTMLName_nonInvasive:
* @ctxt: an HTML parser context
*
* parse an HTML tag or attribute name, note that we convert it to lowercase
* since HTML names are not case-sensitive, this doesn't consume the data
* from the stream, it's a look-ahead
*
* Returns the Tag Name parsed or NULL
*/
static const xmlChar *
int i = 0;
while ((i < HTML_PARSER_BUFFER_SIZE) &&
i++;
}
}
/**
* htmlParseName:
* @ctxt: an HTML parser context
*
* parse an HTML name, this routine is case sensitive.
*
* Returns the Name parsed or NULL
*/
static const xmlChar *
int count = 0;
GROW;
/*
* Accelerator for simple ASCII names
*/
in++;
in++;
return(ret);
}
}
return(htmlParseNameComplex(ctxt));
}
static const xmlChar *
int len = 0, l;
int c;
int count = 0;
/*
* Handler for more complex cases
*/
GROW;
c = CUR_CHAR(l);
if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
(!IS_LETTER(c) && (c != '_') &&
(c != ':'))) {
return(NULL);
}
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
if (count++ > 100) {
count = 0;
GROW;
}
len += l;
NEXTL(l);
c = CUR_CHAR(l);
}
}
/**
* htmlParseHTMLAttribute:
* @ctxt: an HTML parser context
* @stop: a char stop value
*
* parse an HTML attribute value till the stop (quote), if
* stop is 0 then it stops at the first space
*
* Returns the attribute parsed or NULL
*/
static xmlChar *
int buffer_size = 0;
/*
* allocate a translation buffer.
*/
return(NULL);
}
/*
* Ok loop until we reach one of the ending chars
*/
if (CUR == '&') {
unsigned int c;
int bits;
c = htmlParseCharRef(ctxt);
if (c < 0x80)
else if (c < 0x800)
else if (c < 0x10000)
else
}
}
} else {
*out++ = '&';
}
*out++ = '&';
while (*cur != 0) {
}
}
} else {
unsigned int c;
int bits;
}
if (c < 0x80)
else if (c < 0x800)
else if (c < 0x10000)
else
}
}
}
} else {
unsigned int c;
int bits, l;
}
c = CUR_CHAR(l);
if (c < 0x80)
else if (c < 0x800)
else if (c < 0x10000)
else
}
NEXT;
}
}
*out++ = 0;
return(buffer);
}
/**
* 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 *
if (CUR == '&') {
NEXT;
} else {
GROW;
if (CUR == ';') {
/*
* Lookup the entity in the table.
*/
NEXT;
} else {
"htmlParseEntityRef: expecting ';'\n",
}
}
}
return(ent);
}
/**
* htmlParseAttValue:
* @ctxt: an HTML parser context
*
* parse a value for an attribute
* Note: the parser won't do substitution of entities here, this
* will be handled later in xmlStringGetNodeList, unless it was
* asked for ctxt->replaceEntities != 0
*
* Returns the AttValue parsed or NULL.
*/
static xmlChar *
if (CUR == '"') {
NEXT;
if (CUR != '"') {
} else
NEXT;
} else if (CUR == '\'') {
NEXT;
if (CUR != '\'') {
} else
NEXT;
} else {
/*
* That's an HTMLism, the attribute value may not be quoted
*/
}
}
return(ret);
}
/**
* htmlParseSystemLiteral:
* @ctxt: an HTML parser context
*
* parse an HTML Literal
*
* [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
*
* Returns the SystemLiteral parsed or NULL
*/
static xmlChar *
const xmlChar *q;
if (CUR == '"') {
NEXT;
q = CUR_PTR;
NEXT;
if (!IS_CHAR_CH(CUR)) {
} else {
NEXT;
}
} else if (CUR == '\'') {
NEXT;
q = CUR_PTR;
NEXT;
if (!IS_CHAR_CH(CUR)) {
} else {
NEXT;
}
} else {
}
return(ret);
}
/**
* htmlParsePubidLiteral:
* @ctxt: an HTML parser context
*
* parse an HTML public literal
*
* [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
*
* Returns the PubidLiteral parsed or NULL.
*/
static xmlChar *
const xmlChar *q;
/*
* Name ::= (Letter | '_') (NameChar)*
*/
if (CUR == '"') {
NEXT;
q = CUR_PTR;
if (CUR != '"') {
} else {
NEXT;
}
} else if (CUR == '\'') {
NEXT;
q = CUR_PTR;
NEXT;
if (CUR != '\'') {
} else {
NEXT;
}
} else {
}
return(ret);
}
/**
* htmlParseScript:
* @ctxt: an HTML parser context
*
* parse the content of an HTML SCRIPT or STYLE element
* http://www.w3.org/TR/html4/sgml/dtd.html#StyleSheet
* http://www.w3.org/TR/html4/types.html#type-script
* http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.2.1
*
* Script data ( %Script; in the DTD) can be the content of the SCRIPT
* element and the value of intrinsic event attributes. User agents must
* not evaluate script data as HTML markup but instead must pass it on as
* data to a script engine.
* NOTES:
* - The content is passed like CDATA
* - the attributes for style and scripting "onXXX" are also described
* as CDATA but SGML allows entities references in attributes so their
* processing is identical as other attributes
*/
static void
int nbchar = 0;
int cur,l;
while (IS_CHAR_CH(cur)) {
/*
* One should break here, the specification is clear:
* Authors should therefore escape "</" within the content.
* Escape mechanisms are specific to each scripting or
* style sheet language.
*
* In recovery mode, only break if end tag match the
* current tag, effectively ignoring all tags inside the
* CDATA.
*/
{
break; /* while */
} else {
"Element %s embeds close tag\n",
}
} else {
{
break; /* while */
}
}
}
if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) {
/*
* Insert as CDATA, which is the same as HTML_PRESERVE_NODE
*/
}
nbchar = 0;
}
GROW;
NEXTL(l);
}
"Invalid char in CDATA 0x%X\n", cur);
NEXT;
}
/*
* Insert as CDATA, which is the same as HTML_PRESERVE_NODE
*/
}
}
}
/**
* htmlParseCharData:
* @ctxt: an HTML parser context
*
* parse a CharData section.
* if we are within a CDATA section ']]>' marks an end of section.
*
* [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
*/
static void
int nbchar = 0;
int cur, l;
(cur != 0)) {
"Invalid char in CDATA 0x%X\n", cur);
} else {
}
if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) {
/*
* Ok the segment is to be consumed as chars.
*/
} else {
}
}
nbchar = 0;
}
NEXTL(l);
if (cur == 0) {
GROW;
}
}
if (nbchar != 0) {
/*
* Ok the segment is to be consumed as chars.
*/
} else {
}
}
} else {
/*
* Loop detection
*/
if (cur == 0)
}
}
/**
* htmlParseExternalID:
* @ctxt: an HTML parser context
* @publicID: a xmlChar** receiving PubidLiteral
*
* Parse an External ID or a Public ID
*
* [75] ExternalID ::= 'SYSTEM' S SystemLiteral
* | 'PUBLIC' S PubidLiteral S SystemLiteral
*
* [83] PublicID ::= 'PUBLIC' S PubidLiteral
*
* Returns the function returns SystemLiteral and in the second
* case publicID receives PubidLiteral, is strict is off
* it is possible to return NULL and have publicID set.
*/
static xmlChar *
SKIP(6);
if (!IS_BLANK_CH(CUR)) {
}
}
SKIP(6);
if (!IS_BLANK_CH(CUR)) {
}
"htmlParseExternalID: PUBLIC, no Public Identifier\n",
}
}
}
return(URI);
}
/**
* xmlParsePI:
* @ctxt: an XML parser context
*
* parse an XML Processing Instruction.
*
* [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
*/
static void
int len = 0;
int cur, l;
int count = 0;
/*
* this is a Processing Instruction.
*/
SKIP(2);
/*
* Parse the target name and check for special support like
* namespace.
*/
if (RAW == '>') {
SKIP(1);
/*
* SAX: PI detected.
*/
return;
}
return;
}
}
size *= 2;
return;
}
}
count++;
if (count > 50) {
GROW;
count = 0;
}
NEXTL(l);
if (cur == 0) {
GROW;
}
}
if (cur != '>') {
} else {
SKIP(1);
/*
* SAX: PI detected.
*/
}
} else {
}
}
}
/**
* htmlParseComment:
* @ctxt: an HTML parser context
*
* Parse an XML (SGML) comment <!-- .... -->
*
* [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
*/
static void
int len;
int q, ql;
int r, rl;
int cur, l;
/*
* Check that there is a comment right here.
*/
SKIP(4);
return;
}
len = 0;
((cur != '>') ||
(r != '-') || (q != '-'))) {
size *= 2;
return;
}
}
q = r;
r = cur;
rl = l;
NEXTL(l);
if (cur == 0) {
GROW;
}
}
} else {
NEXT;
(!ctxt->disableSAX))
}
}
/**
* 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
int val = 0;
"htmlParseCharRef: context error\n",
return(0);
}
SKIP(3);
while (CUR != ';') {
else {
"htmlParseCharRef: invalid hexadecimal value\n",
return(0);
}
NEXT;
}
if (CUR == ';')
NEXT;
SKIP(2);
while (CUR != ';') {
else {
"htmlParseCharRef: invalid decimal value\n",
return(0);
}
NEXT;
}
if (CUR == ';')
NEXT;
} else {
}
/*
* Check the value IS_CHAR ...
*/
return(val);
} else {
"htmlParseCharRef: invalid xmlChar value %d\n",
val);
}
return(0);
}
/**
* htmlParseDocTypeDecl:
* @ctxt: an HTML parser context
*
* parse a DOCTYPE declaration
*
* [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S?
* ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
*/
static void
/*
* We know that '<!DOCTYPE' has been detected.
*/
SKIP(9);
/*
* Parse the DOCTYPE name.
*/
"htmlParseDocTypeDecl : no DOCTYPE name !\n",
}
/*
* Check that upper(name) == "HTML" !!!!!!!!!!!!!
*/
/*
* Check for SystemID and ExternalID
*/
/*
* We should be at the end of the DOCTYPE declaration.
*/
if (CUR != '>') {
/* We shouldn't try to resynchronize ... */
}
NEXT;
/*
* Create or update the document accordingly to the DOCTYPE
*/
(!ctxt->disableSAX))
/*
* Cleanup, since we don't use all those identifiers
*/
}
/**
* htmlParseAttribute:
* @ctxt: an HTML parser context
* @value: a xmlChar ** used to store the value of the attribute
*
* parse an attribute
*
* [41] Attribute ::= Name Eq AttValue
*
* [25] Eq ::= S? '=' S?
*
* With namespace:
*
* [NS 11] Attribute ::= QName Eq AttValue
*
* Also the case QName == xmlns:??? is handled independently as a namespace
* definition.
*
* Returns the attribute name, and the value in *value.
*/
static const xmlChar *
return(NULL);
}
/*
* read the value
*/
if (CUR == '=') {
NEXT;
} else if (htmlIsBooleanAttr(name)) {
/*
* assume a minimized attribute
*/
}
return(name);
}
/**
* htmlCheckEncoding:
* @ctxt: an HTML parser context
* @attvalue: the attribute value
*
* Checks an http-equiv attribute from a Meta tag to detect
* the encoding
* If a new encoding is detected the parser is switched to decode
* it and pass UTF8
*/
static void
return;
/* do not change encoding */
return;
encoding += 8;
} else {
encoding += 9;
}
/*
* registered set of known encodings
*/
if (enc != XML_CHAR_ENCODING_ERROR) {
if (((enc == XML_CHAR_ENCODING_UTF16LE) ||
(enc == XML_CHAR_ENCODING_UTF16BE) ||
(enc == XML_CHAR_ENCODING_UCS4LE) ||
(enc == XML_CHAR_ENCODING_UCS4BE)) &&
"htmlCheckEncoding: wrong encoding meta\n",
} else {
}
} else {
/*
* fallback for unknown encodings
*/
} else {
}
}
int nbchars;
int processed;
/*
* convert as much as possible to the parser reading buffer.
*/
if (nbchars < 0) {
"htmlCheckEncoding: encoder error\n",
}
}
}
}
/**
* htmlCheckMeta:
* @ctxt: an HTML parser context
* @atts: the attributes values
*
* Checks an attributes from a Meta tag
*/
static void
int i;
int http = 0;
return;
i = 0;
http = 1;
}
}
/**
* htmlParseStartTag:
* @ctxt: an HTML parser context
*
* parse a start of tag either for rule element or
* EmptyElement. In both case we don't parse the tag closing chars.
*
* [40] STag ::= '<' Name (S Attribute)* S? '>'
*
* [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
*
* With namespace:
*
* [NS 8] STag ::= '<' QName (S Attribute)* S? '>'
*
* [NS 10] EmptyElement ::= '<' QName (S Attribute)* S? '/>'
*
* Returns 0 in case of success and -1 in case of error.
*/
static int
int nbatts = 0;
int maxatts;
int meta = 0;
int i;
return -1;
}
NEXT;
GROW;
"htmlParseStartTag: invalid element name\n",
/* Dump the bogus tag like browsers do */
NEXT;
return -1;
}
meta = 1;
/*
* Check for auto-closure of HTML elements.
*/
/*
* Check for implied HTML elements.
*/
/*
* Avoid html at any level > 0, head at any level != 1
* or any attempt to recurse body
*/
"htmlParseStartTag: misplaced <html> tag\n",
return 0;
}
"htmlParseStartTag: misplaced <head> tag\n",
return 0;
}
int indx;
"htmlParseStartTag: misplaced <body> tag\n",
NEXT;
return 0;
}
}
}
/*
* Now parse the attributes, it ends up with the ending
*
* (S Attribute)* S?
*/
while ((IS_CHAR_CH(CUR)) &&
(CUR != '>') &&
GROW;
/*
* Well formedness requires at most one declaration of an attribute
*/
for (i = 0; i < nbatts;i += 2) {
goto failed;
}
}
/*
* Add the pair to atts
*/
goto failed;
}
const xmlChar **n;
maxatts *= 2;
if (n == NULL) {
goto failed;
}
atts = n;
}
}
else {
/* Dump the bogus attribute string up to the next blank or
* the end of the tag. */
while ((IS_CHAR_CH(CUR)) &&
NEXT;
}
"htmlParseStartTag: problem parsing attributes\n",
break;
}
}
/*
* Handle specific association to the META tag
*/
/*
* SAX: Start of Element !
*/
if (nbatts != 0)
else
}
}
}
return 0;
}
/**
* htmlParseEndTag:
* @ctxt: an HTML parser context
*
* parse an end of tag
*
* [42] ETag ::= '</' Name S? '>'
*
* With namespace
*
* [NS 9] ETag ::= '</' QName S? '>'
*
* Returns 1 if the current level should be closed.
*/
static int
{
int i, ret;
return (0);
}
SKIP(2);
return (0);
/*
* We should definitely be at the ending "S? '>'" part
*/
/*
* We're not at the ending > !!
* Error, unless in recover mode where we search forwards
* until we find a >
*/
NEXT;
}
} else
NEXT;
/*
* If the name read is not one of the element in the parsing stack
* then return, it's just an error.
*/
break;
}
if (i < 0) {
return (0);
}
/*
* Check for auto-closure of HTML elements.
*/
/*
* Well formedness constraints, opening and closing must match.
* With the exception that the autoclose may have popped stuff out
* of the stack.
*/
"Opening and ending tag mismatch: %s and %s\n",
}
}
/*
* SAX: End of Tag
*/
ret = 1;
} else {
ret = 0;
}
return (ret);
}
/**
* htmlParseReference:
* @ctxt: an HTML parser context
*
* parse and handle entity references in content,
* this will end-up in a call to character() since this is either a
* CharRef, or a predefined entity.
*/
static void
if (CUR != '&') return;
unsigned int c;
int bits, i = 0;
c = htmlParseCharRef(ctxt);
if (c == 0)
return;
}
out[i] = 0;
} else {
return;
}
/* ctxt->sax->characters(ctxt->userData, BAD_CAST ";", 1); */
}
} else {
unsigned int c;
int bits, i = 0;
if (c < 0x80)
else if (c < 0x800)
else if (c < 0x10000)
else
}
out[i] = 0;
}
}
}
/**
* htmlParseContent:
* @ctxt: an HTML parser context
*
* Parse a content: comment, sub-element, reference or text.
*/
static void
int depth;
while (1) {
GROW;
/*
* Our tag or one of it's parent or children is ending.
*/
if (htmlParseEndTag(ctxt) &&
if (currentNode != NULL)
return;
}
continue; /* while */
}
else if ((CUR == '<') &&
"htmlParseStartTag: invalid element name\n",
/* Dump the bogus tag like browsers do */
NEXT;
if (currentNode != NULL)
return;
}
continue;
}
}
}
/*
* Has this node been popped out during parsing of
* the next element
*/
{
return;
}
/*
*/
} else {
/*
* Sometimes DOCTYPE arrives in the middle of the document
*/
"Misplaced DOCTYPE declaration\n",
}
/*
* First case : a comment
*/
}
/*
* Second case : a Processing Instruction.
*/
}
/*
* Third case : a sub-element.
*/
else if (CUR == '<') {
}
/*
* Fourth case : a reference. If if has not been resolved,
* parsing returns it's Name, create the node
*/
else if (CUR == '&') {
}
/*
* Fifth case : end of the resource
*/
else if (CUR == 0) {
break;
}
/*
* Last case, text. Note that References are handled directly.
*/
else {
}
"detected an error in element content\n",
}
break;
}
}
GROW;
}
}
/**
* htmlParseContent:
* @ctxt: an HTML parser context
*
* Parse a content: comment, sub-element, reference or text.
*/
void
}
/**
* htmlParseElement:
* @ctxt: an HTML parser context
*
* parse an HTML element, this is highly recursive
*
* [39] element ::= EmptyElemTag | STag content ETag
*
* [41] Attribute ::= Name Eq AttValue
*/
void
int failed;
int depth;
return;
}
/* Capture start position */
if (ctxt->record_info) {
}
if (CUR == '>')
NEXT;
return;
}
/*
* Lookup the info for that element.
*/
}
/*
*/
SKIP(2);
return;
}
if (CUR == '>') {
NEXT;
} else {
/*
* end of parsing of this node.
*/
}
/*
* Capture end position and add node
*/
if (ctxt->record_info) {
}
return;
}
/*
* Check for an Empty Element from DTD definition
*/
return;
}
/*
* Parse the content of the element:
*/
while (IS_CHAR_CH(CUR)) {
}
/*
* Capture end position and add node
*/
}
if (!IS_CHAR_CH(CUR)) {
}
if (currentNode != NULL)
}
/**
* 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
return(XML_ERR_INTERNAL_ERROR);
}
GROW;
/*
* SAX: beginning of the document processing.
*/
/*
* Wipe out everything which is before the first '<'
*/
if (CUR == 0) {
}
/*
* Parse possible comments and PIs before any content
*/
}
/*
* Then possibly doc type declaration(s) and more Misc
* (doctypedecl Misc*)?
*/
}
/*
* Parse possible comments and PIs before any content
*/
}
/*
* Time to start parsing the tree itself
*/
/*
* autoclose
*/
if (CUR == 0)
/*
* SAX: end of the document processing.
*/
BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN",
}
return(0);
}
/************************************************************************
* *
* Parser contexts handling *
* *
************************************************************************/
/**
* htmlInitParserCtxt:
* @ctxt: an HTML parser context
*
* Initialize a parser context
*
* Returns 0 in case of success and -1 in case of error
*/
static int
{
return(-1);
}
return(-1);
}
else
/* Allocate the Input stack */
return(-1);
}
/* Allocate the Node stack */
return(-1);
}
/* Allocate the Name stack */
return(-1);
}
else {
}
ctxt->replaceEntities = 0;
ctxt->record_info = 0;
ctxt->checkIndex = 0;
return(0);
}
/**
* 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
{
}
/**
* htmlNewParserCtxt:
*
* Allocate and initialize a new parser context.
*
* Returns the htmlParserCtxtPtr or NULL in case of allocation error
*/
htmlNewParserCtxt(void)
{
return(NULL);
}
if (htmlInitParserCtxt(ctxt) < 0) {
return(NULL);
}
return(ctxt);
}
/**
* 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
*/
return(NULL);
if (size <= 0)
return(NULL);
ctxt = htmlNewParserCtxt();
return(NULL);
return(NULL);
}
return(ctxt);
}
/**
* htmlCreateDocParserCtxt:
* @cur: a pointer to an array of xmlChar
* @encoding: a free form C string describing the HTML document encoding, or NULL
*
* Create a parser context for an HTML document.
*
* TODO: check the need to add encoding handling there
*
* Returns the new parser context or NULL
*/
static htmlParserCtxtPtr
int len;
return(NULL);
return(NULL);
/*
* registered set of known encodings
*/
if (enc != XML_CHAR_ENCODING_ERROR) {
"Unsupported encoding %s\n",
}
} else {
/*
* fallback for unknown encodings
*/
} else {
"Unsupported encoding %s\n",
}
}
}
return(ctxt);
}
#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
* @comment: flag to force checking inside comments
*
* 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.
*/
static int
int incomment = 0;
if (base < 0) return(-1);
} else {
}
/* take into account the sequence length */
incomment = 1;
/* do not increment past <! - some people use <!--> */
base += 2;
}
}
if (incomment) {
return(-1);
incomment = 0;
base += 2;
}
continue;
}
if (third != 0) {
} else if (next != 0) {
}
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
if (next == 0)
"HPP: lookup '%c' found at %d\n",
else if (third == 0)
"HPP: lookup '%c%c' found at %d\n",
else
"HPP: lookup '%c%c%c' found at %d\n",
#endif
}
}
#ifdef DEBUG_PUSH
if (next == 0)
"HPP: lookup '%c' failed\n", first);
else if (third == 0)
else
#endif
return(-1);
}
/**
* htmlParseTryOrFinish:
* @ctxt: an HTML parser context
* @terminate: last chunk indicator
*
* Try to progress on parsing
*
* Returns zero if no parsing was possible
*/
static int
int ret = 0;
int avail = 0;
#ifdef DEBUG_PUSH
case XML_PARSER_EOF:
"HPP: try EOF\n"); break;
case XML_PARSER_START:
"HPP: try START\n"); break;
case XML_PARSER_MISC:
"HPP: try MISC\n");break;
case XML_PARSER_COMMENT:
"HPP: try COMMENT\n");break;
case XML_PARSER_PROLOG:
"HPP: try PROLOG\n");break;
case XML_PARSER_START_TAG:
"HPP: try START_TAG\n");break;
case XML_PARSER_CONTENT:
"HPP: try CONTENT\n");break;
case XML_PARSER_CDATA_SECTION:
"HPP: try CDATA_SECTION\n");break;
case XML_PARSER_END_TAG:
"HPP: try END_TAG\n");break;
case XML_PARSER_ENTITY_DECL:
"HPP: try ENTITY_DECL\n");break;
case XML_PARSER_ENTITY_VALUE:
"HPP: try ENTITY_VALUE\n");break;
"HPP: try ATTRIBUTE_VALUE\n");break;
case XML_PARSER_DTD:
"HPP: try DTD\n");break;
case XML_PARSER_EPILOG:
"HPP: try EPILOG\n");break;
case XML_PARSER_PI:
"HPP: try PI\n");break;
"HPP: try SYSTEM_LITERAL\n");break;
}
#endif
while (1) {
else
/*
* SAX: end of the document processing.
*/
}
}
if (avail < 1)
goto done;
if (cur == 0) {
SKIP(1);
continue;
}
case XML_PARSER_EOF:
/*
* Document parsing is done !
*/
goto done;
case XML_PARSER_START:
/*
* Very first chars read from the document flow.
*/
if (IS_BLANK_CH(cur)) {
else
}
(!ctxt->disableSAX))
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing internal subset\n");
#endif
#ifdef DEBUG_PUSH
"HPP: entering PROLOG\n");
#endif
} else {
#ifdef DEBUG_PUSH
"HPP: entering MISC\n");
#endif
}
break;
case XML_PARSER_MISC:
else
if (avail < 2)
goto done;
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing Comment\n");
#endif
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing PI\n");
#endif
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing internal subset\n");
#endif
#ifdef DEBUG_PUSH
"HPP: entering PROLOG\n");
#endif
(avail < 9)) {
goto done;
} else {
#ifdef DEBUG_PUSH
"HPP: entering START_TAG\n");
#endif
}
break;
case XML_PARSER_PROLOG:
else
if (avail < 2)
goto done;
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing Comment\n");
#endif
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing PI\n");
#endif
(avail < 4)) {
goto done;
} else {
#ifdef DEBUG_PUSH
"HPP: entering START_TAG\n");
#endif
}
break;
case XML_PARSER_EPILOG:
else
if (avail < 1)
goto done;
if (IS_BLANK_CH(cur)) {
goto done;
}
if (avail < 2)
goto done;
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing Comment\n");
#endif
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing PI\n");
#endif
(avail < 4)) {
goto done;
} else {
ctxt->wellFormed = 0;
#ifdef DEBUG_PUSH
"HPP: entering EOF\n");
#endif
goto done;
}
break;
case XML_PARSER_START_TAG: {
int failed;
if (avail < 2)
goto done;
if (cur != '<') {
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
}
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering END_TAG\n");
#endif
break;
}
if ((!terminate) &&
goto done;
if (failed ||
if (CUR == '>')
NEXT;
break;
}
/*
* Lookup the info for that element.
*/
}
/*
*/
SKIP(2);
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
}
if (CUR == '>') {
NEXT;
} else {
"Couldn't find end of Start Tag %s\n",
/*
* end of parsing of this node.
*/
}
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
}
/*
* Check for an Empty Element from DTD definition
*/
}
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
}
case XML_PARSER_CONTENT: {
long cons;
/*
* Handle preparsed entities and charRef
*/
ctxt->checkIndex = 0;
}
if (IS_BLANK_CH(cur)) {
} else {
}
}
ctxt->checkIndex = 0;
break;
}
}
if (avail < 2)
goto done;
/*
*/
if (!terminate) {
int idx;
if (idx < 0)
goto done;
if (val == 0) /* bad cut of input */
goto done;
}
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering END_TAG\n");
#endif
break;
}
} else {
/*
* Sometimes DOCTYPE arrives in the middle of the document
*/
if ((!terminate) &&
goto done;
"Misplaced DOCTYPE declaration\n",
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing Comment\n");
#endif
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing PI\n");
#endif
goto done;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering END_TAG\n");
#endif
break;
} else if (cur == '<') {
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering START_TAG\n");
#endif
break;
} else if (cur == '&') {
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"HPP: Parsing Reference\n");
#endif
/* TODO: check generation of subtrees if noent !!! */
} else {
/*
* check that the text sequence is complete
* before handing out the data to the parser
* to avoid problems with erroneous end of
* data detection.
*/
if ((!terminate) &&
goto done;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: Parsing char data\n");
#endif
}
}
"detected an error in element content\n",
}
NEXT;
break;
}
break;
}
case XML_PARSER_END_TAG:
if (avail < 2)
goto done;
if ((!terminate) &&
goto done;
} else {
}
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
case XML_PARSER_CDATA_SECTION:
"HPP: internal error, state == CDATA\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
case XML_PARSER_DTD:
"HPP: internal error, state == DTD\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
case XML_PARSER_COMMENT:
"HPP: internal error, state == COMMENT\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
case XML_PARSER_PI:
"HPP: internal error, state == PI\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
case XML_PARSER_ENTITY_DECL:
"HPP: internal error, state == ENTITY_DECL\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
case XML_PARSER_ENTITY_VALUE:
"HPP: internal error, state == ENTITY_VALUE\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering DTD\n");
#endif
break;
"HPP: internal error, state == ATTRIBUTE_VALUE\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering START_TAG\n");
#endif
break;
"HPP: internal error, state == XML_PARSER_SYSTEM_LITERAL\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
case XML_PARSER_IGNORE:
"HPP: internal error, state == XML_PARSER_IGNORE\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
"HPP: internal error, state == XML_PARSER_LITERAL\n",
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"HPP: entering CONTENT\n");
#endif
break;
}
}
done:
/*
* SAX: end of the document processing.
*/
}
}
BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN",
}
#ifdef DEBUG_PUSH
#endif
return(ret);
}
/**
* 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
int terminate) {
return(XML_ERR_INTERNAL_ERROR);
}
int res;
if (res < 0) {
return (XML_PARSER_EOF);
}
#ifdef DEBUG_PUSH
#endif
#if 0
#endif
int nbchars;
if (nbchars < 0) {
return(XML_ERR_INVALID_ENCODING);
}
}
}
}
if (terminate) {
ctxt->wellFormed = 0;
}
}
}
}
/************************************************************************
* *
* 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
*
* Returns the new parser context or NULL
*/
ctxt = htmlNewParserCtxt();
return(NULL);
}
return(NULL);
}
}
} else {
}
if (inputStream == NULL) {
return(NULL);
}
else
inputStream->filename = (char *)
inputStream->end =
#ifdef DEBUG_PUSH
#endif
}
return(ctxt);
}
#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.
*/
}
}
return(ret);
}
/**
* 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
*/
}
/**
* 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.
* by default if found at compile-time.
*
* Returns the new parser context or NULL
*/
{
char *canonicFilename;
/* htmlCharEncoding enc; */
return(NULL);
ctxt = htmlNewParserCtxt();
return(NULL);
}
if (canonicFilename == NULL) {
#ifdef LIBXML_SAX1_ENABLED
}
#endif
return(NULL);
}
if (inputStream == NULL) {
return(NULL);
}
/* set encoding */
if (encoding) {
if (content) {
}
}
return(ctxt);
}
/**
* 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.
*
* 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.
*/
void *userData) {
}
}
return(ret);
}
/**
* htmlParseFile:
* @filename: the filename
* @encoding: a free form C string describing the HTML document encoding, or NULL
*
* compressed document is provided by default if found at compile-time.
*
* Returns the resulting document tree
*/
}
/**
* 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
return(old);
}
/**
* 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
const char** p ;
return 0 ;
return 1 ;
return 0 ;
}
/**
* 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
*/
return HTML_INVALID ;
return HTML_INVALID ;
}
/**
* 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
*/
const char** p ;
return HTML_INVALID ;
return HTML_REQUIRED ;
return HTML_VALID ;
for ( p = elt->attrs_depr; *p; ++p)
return HTML_DEPRECATED ;
return HTML_INVALID ;
}
/**
* 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)
*/
if ( ! node )
return HTML_INVALID ;
case XML_ELEMENT_NODE:
return legacy
? ( htmlElementAllowedHere (
) ? HTML_VALID : HTML_INVALID )
;
case XML_ATTRIBUTE_NODE:
return htmlAttrAllowed(
default: return HTML_NA ;
}
}
/************************************************************************
* *
* New set (2.6.0) of simpler and more flexible APIs *
* *
************************************************************************/
/**
* DICT_FREE:
* @str: a string
*
* Free a string if it is not owned by the "dict" dictionnary in the
* current scope
*/
/**
* htmlCtxtReset:
* @ctxt: an HTML parser context
*
* Reset a parser context
*/
void
{
return;
}
} else {
}
ctxt->hasExternalSubset = 0;
ctxt->record_info = 0;
ctxt->checkIndex = 0;
}
}
}
/**
* 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
{
return(-1);
if (options & HTML_PARSE_NOWARNING) {
}
if (options & HTML_PARSE_NOERROR) {
}
if (options & HTML_PARSE_PEDANTIC) {
} else
if (options & XML_PARSE_NOBLANKS) {
ctxt->keepBlanks = 0;
} else
if (options & HTML_PARSE_RECOVER) {
} else
if (options & HTML_PARSE_COMPACT) {
}
return (options);
}
/**
* htmlDoRead:
* @ctxt: an HTML parser context
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of htmlParserOption(s)
* @reuse: keep the context for reuse
*
* Common front-end for the htmlRead functions
*
* Returns the resulting document tree or NULL
*/
static htmlDocPtr
{
}
if (!reuse) {
}
return (ret);
}
/**
* 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
*/
{
return (NULL);
return (NULL);
}
/**
* 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
*/
{
return (NULL);
}
/**
* 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
*/
{
return (NULL);
}
/**
* 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
*/
{
if (fd < 0)
return (NULL);
return (NULL);
ctxt = xmlNewParserCtxt();
return (NULL);
}
return (NULL);
}
}
/**
* 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
*/
{
return (NULL);
return (NULL);
ctxt = htmlNewParserCtxt();
return (NULL);
}
return (NULL);
}
}
/**
* 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
*/
{
return (NULL);
return (NULL);
return (NULL);
}
}
/**
* 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
*/
{
return (NULL);
return (NULL);
return (NULL);
}
}
/**
* 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
*/
{
return (NULL);
return (NULL);
return(NULL);
}
return(NULL);
}
}
/**
* 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
*/
{
if (fd < 0)
return (NULL);
return (NULL);
return (NULL);
return (NULL);
}
}
/**
* 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
*/
const char *URL,
{
return (NULL);
return (NULL);
return (NULL);
return (NULL);
}
}
#define bottom_HTMLparser
#include "elfgcchack.h"
#endif /* LIBXML_HTML_ENABLED */