Hubbub  $Id$
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 
24 typedef struct hubbub_parser hubbub_parser;
25 
29 typedef enum hubbub_parser_opttype {
38 
42 typedef union hubbub_parser_optparams {
43  struct {
45  void *pw;
48  struct {
50  void *pw;
53  struct {
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 */
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 
hubbub_charset_source
hubbub_charset_source
Source of charset information, in order of importance A client-dictated charset will override all oth...
Definition: types.h:22
hubbub_parser_optparams::model
hubbub_content_model model
Definition: parser.h:54
HUBBUB_PARSER_CONTENT_MODEL
@ HUBBUB_PARSER_CONTENT_MODEL
Definition: parser.h:32
hubbub_parser_optparams::handler
hubbub_error_handler handler
Definition: parser.h:49
hubbub_parser_optparams
Hubbub parser option parameters.
Definition: parser.h:42
hubbub_parser_optparams
union hubbub_parser_optparams hubbub_parser_optparams
Hubbub parser option parameters.
types.h
hubbub_parser_parse_chunk
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
hubbub_parser_optparams::handler
hubbub_token_handler handler
Definition: parser.h:44
hubbub_parser_optparams::document_node
void * document_node
Document node.
Definition: parser.h:59
errors.h
hubbub_parser_optparams::tree_handler
hubbub_tree_handler * tree_handler
Tree handling callbacks.
Definition: parser.h:57
hubbub_parser_optparams::enable_scripting
bool enable_scripting
Whether to enable scripting.
Definition: parser.h:61
HUBBUB_PARSER_TREE_HANDLER
@ HUBBUB_PARSER_TREE_HANDLER
Definition: parser.h:33
hubbub_tree_handler
Hubbub tree handler.
Definition: tree.h:273
HUBBUB_PARSER_ENABLE_SCRIPTING
@ HUBBUB_PARSER_ENABLE_SCRIPTING
Definition: parser.h:35
hubbub_parser_optparams::error_handler
struct hubbub_parser_optparams::@13 error_handler
Error handling callback.
hubbub_parser_destroy
hubbub_error hubbub_parser_destroy(hubbub_parser *parser)
Destroy a hubbub parser.
Definition: parser.c:102
hubbub_parser_setopt
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_create
hubbub_error hubbub_parser_create(const char *enc, bool fix_enc, hubbub_parser **parser)
Create a hubbub parser.
Definition: parser.c:41
hubbub_error_handler
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
hubbub_parser_opttype
hubbub_parser_opttype
Hubbub parser option types.
Definition: parser.h:29
hubbub_parser_optparams::pause_parse
bool pause_parse
Pause parsing.
Definition: parser.h:63
hubbub_parser
Hubbub parser object.
Definition: parser.c:24
HUBBUB_PARSER_PAUSE
@ HUBBUB_PARSER_PAUSE
Definition: parser.h:36
hubbub_error
hubbub_error
Definition: errors.h:18
type
element_type type
Definition: treebuilder.c:26
hubbub_parser_optparams::pw
void * pw
Definition: parser.h:45
tree.h
hubbub_token_handler
hubbub_error(* hubbub_token_handler)(const hubbub_token *token, void *pw)
Type of token handling function.
Definition: functypes.h:29
functypes.h
hubbub_parser_completed
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_PARSER_ERROR_HANDLER
@ HUBBUB_PARSER_ERROR_HANDLER
Definition: parser.h:31
HUBBUB_PARSER_DOCUMENT_NODE
@ HUBBUB_PARSER_DOCUMENT_NODE
Definition: parser.h:34
hubbub_content_model
hubbub_content_model
Content model flag.
Definition: types.h:32
hubbub_parser_optparams::token_handler
struct hubbub_parser_optparams::@12 token_handler
Token handling callback.
len
size_t len
Definition: initial.c:23
hubbub_parser_insert_chunk
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
HUBBUB_PARSER_TOKEN_HANDLER
@ HUBBUB_PARSER_TOKEN_HANDLER
Definition: parser.h:30
hubbub_parser_read_charset
const char * hubbub_parser_read_charset(hubbub_parser *parser, hubbub_charset_source *source)
Read the document charset.
Definition: parser.c:305
hubbub_parser_optparams::content_model
struct hubbub_parser_optparams::@14 content_model
Current content model.