Forgotten changes in commit 09301b6e73e4af1b03b6f19d340dd909cf527bcc
[claws.git] / src / html.h
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2017 Hiroyuki Yamamoto and the Claws Mail team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __HTML_H__
20 #define __HTML_H__
21
22 #include <glib.h>
23 #include <stdio.h>
24
25 #include "codeconv.h"
26
27 typedef enum
28 {
29         SC_HTML_NORMAL,
30         SC_HTML_PAR,
31         SC_HTML_BR,
32         SC_HTML_HR,
33         SC_HTML_HREF,
34         SC_HTML_IMG,
35         SC_HTML_FONT,
36         SC_HTML_PRE,
37         SC_HTML_UNKNOWN,
38         SC_HTML_CONV_FAILED,
39         SC_HTML_ERR,
40         SC_HTML_EOF,
41         SC_HTML_HREF_BEG
42 } SC_HTMLState;
43
44 typedef struct _SC_HTMLParser   SC_HTMLParser;
45 typedef struct _SC_HTMLAttr             SC_HTMLAttr;
46 typedef struct _SC_HTMLTag              SC_HTMLTag;
47
48 struct _SC_HTMLParser
49 {
50         FILE *fp;
51         CodeConverter *conv;
52
53         GString *str;
54         GString *buf;
55
56         gchar *bufp;
57
58         SC_HTMLState state;
59
60         gchar *href;
61
62         gboolean newline;
63         gboolean empty_line;
64         gboolean space;
65         gboolean pre;
66
67         gint indent;
68 };
69
70 struct _SC_HTMLAttr
71 {
72         gchar *name;
73         gchar *value;
74 };
75
76 struct _SC_HTMLTag
77 {
78         gchar *name;
79         GList *attr;
80 };
81
82 SC_HTMLParser *sc_html_parser_new       (FILE           *fp,
83                                  CodeConverter  *conv);
84 void sc_html_parser_destroy     (SC_HTMLParser  *parser);
85 gchar *sc_html_parse            (SC_HTMLParser  *parser);
86
87 #endif /* __HTML_H__ */