Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3584 sourcerer 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 John-Mark Bell 
6
 */
7
 
8
#ifndef hubbub_tokeniser_tokeniser_h_
9
#define hubbub_tokeniser_tokeniser_h_
10
 
11
#include 
12
#include 
13
 
14
#include 
15
#include 
16
#include 
17
 
18
#include 
19
 
20
typedef struct hubbub_tokeniser hubbub_tokeniser;
21
 
22
/**
23
 * Hubbub tokeniser option types
24
 */
25
typedef enum hubbub_tokeniser_opttype {
26
	HUBBUB_TOKENISER_TOKEN_HANDLER,
27
	HUBBUB_TOKENISER_ERROR_HANDLER,
28
	HUBBUB_TOKENISER_CONTENT_MODEL,
29
	HUBBUB_TOKENISER_PROCESS_CDATA,
30
	HUBBUB_TOKENISER_PAUSE
31
} hubbub_tokeniser_opttype;
32
 
33
/**
34
 * Hubbub tokeniser option parameters
35
 */
36
typedef union hubbub_tokeniser_optparams {
37
	struct {
38
		hubbub_token_handler handler;
39
		void *pw;
40
	} token_handler;		/**< Token handling callback */
41
 
42
	struct {
43
		hubbub_error_handler handler;
44
		void *pw;
45
	} error_handler;		/**< Error handling callback */
46
 
47
	struct {
48
		hubbub_content_model model;
49
	} content_model;		/**< Current content model */
50
 
51
	bool process_cdata;		/**< Whether to process CDATA sections*/
52
 
53
	bool pause_parse;		/**< Pause parsing */
54
} hubbub_tokeniser_optparams;
55
 
56
/* Create a hubbub tokeniser */
57
hubbub_error hubbub_tokeniser_create(parserutils_inputstream *input,
58
		hubbub_allocator_fn alloc, void *pw,
59
		hubbub_tokeniser **tokeniser);
60
/* Destroy a hubbub tokeniser */
61
hubbub_error hubbub_tokeniser_destroy(hubbub_tokeniser *tokeniser);
62
 
63
/* Configure a hubbub tokeniser */
64
hubbub_error hubbub_tokeniser_setopt(hubbub_tokeniser *tokeniser,
65
		hubbub_tokeniser_opttype type,
66
		hubbub_tokeniser_optparams *params);
67
 
68
/* Insert a chunk of data into the input stream */
69
hubbub_error hubbub_tokeniser_insert_chunk(hubbub_tokeniser *tokeniser,
70
		const uint8_t *data, size_t len);
71
 
72
/* Process remaining data in the input stream */
73
hubbub_error hubbub_tokeniser_run(hubbub_tokeniser *tokeniser);
74
 
75
#endif
76