libdom
Loading...
Searching...
No Matches
parser.h
Go to the documentation of this file.
1/*
2 * This file is part of libdom.
3 * Licensed under the MIT License,
4 * http://www.opensource.org/licenses/mit-license.php
5 * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
6 */
7
8#ifndef dom_hubbub_parser_h_
9#define dom_hubbub_parser_h_
10
11#include <stddef.h>
12#include <inttypes.h>
13
14#include <hubbub/errors.h>
15
16#include <dom/dom.h>
17
18#include "errors.h"
19
23typedef dom_hubbub_error (*dom_script)(void *ctx, struct dom_node *node);
24
26
27/* The encoding source of the document */
33
34/* The recommended way to use the parser is:
35 *
36 * dom_hubbub_parser_create(...);
37 * dom_hubbub_parser_parse_chunk(...);
38 * call _parse_chunk for all chunks of data
39 *
40 * After you have parsed the data,
41 *
42 * dom_hubbub_parser_completed(...);
43 * dom_hubbub_parser_destroy(...);
44 *
45 * Clients must ensure that these function calls above are called in
46 * the order shown. dom_hubbub_parser_create() will pass the ownership
47 * of the document to the client. After that, the parser should be destroyed.
48 * The client must not call any method of this parser after destruction.
49 */
50
67
68/* Create a Hubbub parser instance */
70 dom_hubbub_parser **parser,
71 dom_document **document);
72
73/* Create a Hubbub parser instance for a document fragment */
75 dom_document *document,
76 dom_hubbub_parser **parser,
77 dom_document_fragment **fragment);
78
79/* Destroy a Hubbub parser instance */
81
82/* Parse a chunk of data */
84 const uint8_t *data, size_t len);
85
86/* insert data into the parse stream but do not parse it */
88 const uint8_t *data, size_t length);
89
90/* Notify parser that datastream is empty */
92
93/* Retrieve the document's encoding */
96
106
107#endif
dom_hubbub_error
Definition errors.h:11
void(* dom_msg)(uint32_t severity, void *ctx, const char *msg,...)
Definition functypes.h:31
dom_default_action_callback(* dom_events_default_action_fetcher)(dom_string *type, dom_default_action_phase phase, void **pw)
Definition document_event.h:83
void dom_hubbub_parser_destroy(dom_hubbub_parser *parser)
Definition parser.c:997
dom_hubbub_error dom_hubbub_parser_parse_chunk(dom_hubbub_parser *parser, const uint8_t *data, size_t len)
Definition parser.c:1019
dom_hubbub_error dom_hubbub_parser_pause(dom_hubbub_parser *parser, bool pause)
Definition parser.c:1079
dom_hubbub_error dom_hubbub_parser_create(dom_hubbub_parser_params *params, dom_hubbub_parser **parser, dom_document **document)
Definition parser.c:750
dom_hubbub_error dom_hubbub_fragment_parser_create(dom_hubbub_parser_params *params, dom_document *document, dom_hubbub_parser **parser, dom_document_fragment **fragment)
Definition parser.c:877
dom_hubbub_error(* dom_script)(void *ctx, struct dom_node *node)
Definition parser.h:23
dom_hubbub_error dom_hubbub_parser_completed(dom_hubbub_parser *parser)
Definition parser.c:1039
struct dom_hubbub_parser_params dom_hubbub_parser_params
dom_hubbub_encoding_source
Definition parser.h:28
@ DOM_HUBBUB_ENCODING_SOURCE_HEADER
Definition parser.h:29
@ DOM_HUBBUB_ENCODING_SOURCE_DETECTED
Definition parser.h:30
@ DOM_HUBBUB_ENCODING_SOURCE_META
Definition parser.h:31
const char * dom_hubbub_parser_get_encoding(dom_hubbub_parser *parser, dom_hubbub_encoding_source *source)
Definition parser.c:1062
dom_hubbub_error dom_hubbub_parser_insert_chunk(dom_hubbub_parser *parser, const uint8_t *data, size_t length)
Definition parser.c:982
Definition doc_fragment.c:21
Definition document.h:43
Definition parser.h:54
dom_events_default_action_fetcher daf
Definition parser.h:65
const char * enc
Definition parser.h:55
bool fix_enc
Definition parser.h:56
bool enable_script
Definition parser.h:58
dom_script script
Definition parser.h:59
dom_msg msg
Definition parser.h:61
void * ctx
Definition parser.h:62
Definition parser.c:37
Definition node.h:79