-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhtml.h
51 lines (39 loc) · 1.21 KB
/
html.h
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
/*
* html - a simple html parser lacking a better name
* The contents of this file is licensed under the MIT License,
* see the file COPYING or http://opensource.org/licenses/MIT
*/
#ifndef __HTML_H_
#define __HTML_H_
#include "stack.h"
#include "attrib.h"
#include "tag.h"
#ifndef HTML_PARSE_STATE_TYPE
/* Do not expose internals to calling application */
#define HTML_PARSE_STATE_TYPE void
#endif
typedef struct HtmlElement HtmlElement;
struct HtmlElement {
HtmlTag tag;
char *tag_name;
char *text;
HtmlAttrib *attrib;
HtmlElement *child;
HtmlElement *sibling;
};
typedef struct HtmlDocument HtmlDocument;
struct HtmlDocument {
HtmlElement *root_element;
};
typedef HTML_PARSE_STATE_TYPE HtmlParseState;
extern const char const *html_tag[HTML_TAGS];
HtmlTag html_lookup_tag(const char *string);
HtmlParseState *html_parse_begin();
const char *html_parse_stream(HtmlParseState *state, const char *stream, const char *token, size_t len);
HtmlDocument *html_parse_end(HtmlParseState *state);
void *html_free_element(HtmlElement *element);
// printing
void *html_print_dom(HtmlDocument *document);
void *html_print_dom_element(HtmlElement *element, int level);
void *html_free_document(HtmlDocument *document);
#endif