1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/*
* This file is part of LibCSS.
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2008 John-Mark Bell <jmb@netsurf-browser.org>
*/
#ifndef css_parse_parse_h_
#define css_parse_parse_h_
#include <parserutils/utils/hash.h>
#include <parserutils/utils/vector.h>
#include <libcss/errors.h>
#include <libcss/functypes.h>
#include <libcss/types.h>
typedef struct css_parser css_parser;
/**
* Parser event types
*/
typedef enum css_parser_event {
CSS_PARSER_START_STYLESHEET,
CSS_PARSER_END_STYLESHEET,
CSS_PARSER_START_RULESET,
CSS_PARSER_END_RULESET,
CSS_PARSER_START_ATRULE,
CSS_PARSER_END_ATRULE,
CSS_PARSER_START_BLOCK,
CSS_PARSER_END_BLOCK,
CSS_PARSER_BLOCK_CONTENT,
CSS_PARSER_DECLARATION,
} css_parser_event;
typedef css_error (*css_parser_event_handler)(css_parser_event type,
const parserutils_vector *tokens, void *pw);
/**
* Parser option types
*/
typedef enum css_parser_opttype {
CSS_PARSER_QUIRKS,
CSS_PARSER_EVENT_HANDLER,
} css_parser_opttype;
/**
* Parser option parameters
*/
typedef union css_parser_optparams {
bool quirks;
struct {
css_parser_event_handler handler;
void *pw;
} event_handler;
} css_parser_optparams;
css_error css_parser_create(const char *charset, css_charset_source cs_source,
parserutils_hash *dict, css_alloc alloc, void *pw,
css_parser **parser);
css_error css_parser_destroy(css_parser *parser);
css_error css_parser_setopt(css_parser *parser, css_parser_opttype type,
css_parser_optparams *params);
css_error css_parser_parse_chunk(css_parser *parser, const uint8_t *data,
size_t len);
css_error css_parser_completed(css_parser *parser);
const char *css_parser_read_charset(css_parser *parser,
css_charset_source *source);
const parserutils_hash_entry *css_parser_dict_add(css_parser *parser,
const uint8_t *ptr, size_t len);
#endif
|