Hubbub
parser.h
Go to the documentation of this file.
1 /*
2  * This file is part of Hubbub.
3  * Licensed under the MIT License,
4  * http://www.opensource.org/licenses/mit-license.php
5  * Copyright 2007-8 John-Mark Bell <jmb@netsurf-browser.org>
6  */
7 
8 #ifndef hubbub_parser_h_
9 #define hubbub_parser_h_
10 
11 #ifdef __cplusplus
12 extern "C"
13 {
14 #endif
15 
16 #include <stdbool.h>
17 #include <inttypes.h>
18 
19 #include <hubbub/errors.h>
20 #include <hubbub/functypes.h>
21 #include <hubbub/tree.h>
22 #include <hubbub/types.h>
23 
25 
29 typedef enum hubbub_parser_opttype {
38 
42 typedef union hubbub_parser_optparams {
43  struct {
45  void *pw;
46  } token_handler;
48  struct {
50  void *pw;
51  } error_handler;
53  struct {
55  } content_model;
59  void *document_node;
63  bool pause_parse;
65 
66 /* Create a hubbub parser */
67 hubbub_error hubbub_parser_create(const char *enc, bool fix_enc,
68  hubbub_parser **parser);
69 /* Destroy a hubbub parser */
71 
72 /* Configure a hubbub parser */
74  hubbub_parser_opttype type,
75  hubbub_parser_optparams *params);
76 
77 /* Pass a chunk of data to a hubbub parser for parsing */
78 /* This data is encoded in the input charset */
80  const uint8_t *data, size_t len);
81 
97  const uint8_t *data, size_t len);
98 /* Inform the parser that the last chunk of data has been parsed */
100 
101 /* Read the document charset */
102 const char *hubbub_parser_read_charset(hubbub_parser *parser,
103  hubbub_charset_source *source);
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif
110 
struct hubbub_parser_optparams::@0 token_handler
Token handling callback.
hubbub_parser_opttype
Hubbub parser option types.
Definition: parser.h:29
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.
Definition: parser.c:218
void * document_node
Document node.
Definition: parser.h:59
union hubbub_parser_optparams hubbub_parser_optparams
Hubbub parser option parameters.
hubbub_error hubbub_parser_setopt(hubbub_parser *parser, hubbub_parser_opttype type, hubbub_parser_optparams *params)
Configure a hubbub parser.
Definition: parser.c:126
Hubbub parser option parameters.
Definition: parser.h:42
hubbub_error hubbub_parser_completed(hubbub_parser *parser)
Inform the parser that the last chunk of data has been parsed.
Definition: parser.c:279
hubbub_token_handler handler
Definition: parser.h:44
hubbub_content_model model
Definition: parser.h:54
hubbub_charset_source
Source of charset information, in order of importance A client-dictated charset will override all oth...
Definition: types.h:22
hubbub_error(* hubbub_token_handler)(const hubbub_token *token, void *pw)
Type of token handling function.
Definition: functypes.h:29
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.
Definition: parser.c:235
struct hubbub_parser_optparams::@1 error_handler
Error handling callback.
bool pause_parse
Pause parsing.
Definition: parser.h:63
hubbub_error_handler handler
Definition: parser.h:49
Hubbub parser object.
Definition: parser.c:24
hubbub_error
Definition: errors.h:18
struct hubbub_parser_optparams::@2 content_model
Current content model.
void(* hubbub_error_handler)(uint32_t line, uint32_t col, const char *message, void *pw)
Type of parse error handling function.
Definition: functypes.h:40
element_type type
Definition: treebuilder.c:25
hubbub_content_model
Content model flag.
Definition: types.h:32
const char * hubbub_parser_read_charset(hubbub_parser *parser, hubbub_charset_source *source)
Read the document charset.
Definition: parser.c:305
size_t len
Definition: initial.c:23
hubbub_tree_handler * tree_handler
Tree handling callbacks.
Definition: parser.h:57
bool enable_scripting
Whether to enable scripting.
Definition: parser.h:61
hubbub_error hubbub_parser_destroy(hubbub_parser *parser)
Destroy a hubbub parser.
Definition: parser.c:102
hubbub_error hubbub_parser_create(const char *enc, bool fix_enc, hubbub_parser **parser)
Create a hubbub parser.
Definition: parser.c:41
Hubbub tree handler.
Definition: tree.h:273