11 #include <parserutils/charset/mibenum.h>
12 #include <parserutils/input/inputstream.h>
44 parserutils_error perror;
57 if (enc != NULL && fix_enc ==
true) {
58 uint16_t mibenum = parserutils_charset_mibenum_from_name(enc,
64 enc = parserutils_charset_mibenum_to_name(mibenum);
68 perror = parserutils_inputstream_create(enc,
71 if (perror != PARSERUTILS_OK) {
78 parserutils_inputstream_destroy(p->
stream);
86 parserutils_inputstream_destroy(p->
stream);
111 parserutils_inputstream_destroy(parser->
stream);
132 if (parser == NULL || params == NULL)
137 if (parser->
tb != NULL) {
151 if (parser->
tb != NULL) {
176 if (parser->
tb != NULL) {
184 if (parser->
tb != NULL) {
192 if (parser->
tb != NULL) {
219 const uint8_t *data,
size_t len)
221 if (parser == NULL || data == NULL)
236 const uint8_t *data,
size_t len)
238 parserutils_error perror;
241 if (parser == NULL || data == NULL)
244 perror = parserutils_inputstream_append(parser->
stream, data, len);
245 if (perror != PARSERUTILS_OK)
254 perror = parserutils_inputstream_change_charset(parser->
stream,
259 assert(perror != PARSERUTILS_INVALID);
260 if (perror != PARSERUTILS_OK)
281 parserutils_error perror;
287 perror = parserutils_inputstream_append(parser->
stream, NULL, 0);
288 if (perror != PARSERUTILS_OK)
311 if (parser == NULL || source == NULL)
314 name = parserutils_inputstream_read_charset(parser->
stream, &src);
Charset may be changed with further data.
hubbub_parser_opttype
Hubbub parser option types.
Hubbub parser option parameters.
hubbub_error hubbub_tokeniser_setopt(hubbub_tokeniser *tokeniser, hubbub_tokeniser_opttype type, hubbub_tokeniser_optparams *params)
Configure a hubbub tokeniser.
Hubbub treebuilder option parameters.
parserutils_inputstream * stream
Input stream instance.
hubbub_charset_source
Source of charset information, in order of importance A client-dictated charset will override all oth...
Tokeniser data structure.
Hubbub tokeniser option parameters.
hubbub_error hubbub_tokeniser_destroy(hubbub_tokeniser *tokeniser)
Destroy a hubbub tokeniser.
hubbub_error hubbub_tokeniser_insert_chunk(hubbub_tokeniser *tokeniser, const uint8_t *data, size_t len)
Insert a chunk of data into the input stream.
hubbub_error hubbub_parser_completed(hubbub_parser *parser)
Inform the parser that the last chunk of data has been parsed.
hubbub_error hubbub_parser_destroy(hubbub_parser *parser)
Destroy a hubbub parser.
hubbub_treebuilder * tb
Treebuilder instance.
hubbub_error hubbub_parser_insert_chunk(hubbub_parser *parser, const uint8_t *data, size_t len)
Insert a chunk of data into a hubbub parser input stream.
hubbub_error hubbub_parser_setopt(hubbub_parser *parser, hubbub_parser_opttype type, hubbub_parser_optparams *params)
Configure a hubbub parser.
hubbub_error hubbub_treebuilder_destroy(hubbub_treebuilder *treebuilder)
Destroy a hubbub treebuilder.
hubbub_error hubbub_tokeniser_create(parserutils_inputstream *input, hubbub_tokeniser **tokeniser)
Create a hubbub tokeniser.
hubbub_error hubbub_treebuilder_setopt(hubbub_treebuilder *treebuilder, hubbub_treebuilder_opttype type, hubbub_treebuilder_optparams *params)
Configure a hubbub treebuilder.
static hubbub_error hubbub_error_from_parserutils_error(parserutils_error error)
Convert a ParserUtils error into a Hubbub error.
const char * hubbub_parser_read_charset(hubbub_parser *parser, hubbub_charset_source *source)
Read the document charset.
parserutils_error hubbub_charset_extract(const uint8_t *data, size_t len, uint16_t *mibenum, uint32_t *source)
Extract a charset from a chunk of data.
hubbub_error hubbub_tokeniser_run(hubbub_tokeniser *tokeniser)
Process remaining data in the input stream.
void hubbub_charset_fix_charset(uint16_t *charset)
Fix charsets, according to the override table in HTML5, section 8.2.2.2.
hubbub_error hubbub_parser_parse_chunk(hubbub_parser *parser, const uint8_t *data, size_t len)
Pass a chunk of data to a hubbub parser for parsing.
hubbub_error hubbub_parser_create(const char *enc, bool fix_enc, hubbub_parser **parser)
Create a hubbub parser.
hubbub_tokeniser * tok
Tokeniser instance.
hubbub_error hubbub_treebuilder_create(hubbub_tokeniser *tokeniser, hubbub_treebuilder **treebuilder)
Create a hubbub treebuilder.