2005-10-12 [colin] 1.9.15cvs33
[claws.git] / src / html.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2005 Hiroyuki Yamamoto
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 2 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, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __HTML_H__
21 #define __HTML_H__
22
23 #include <glib.h>
24 #include <stdio.h>
25
26 #include "codeconv.h"
27
28 typedef enum
29 {
30         HTML_NORMAL,
31         HTML_PAR,
32         HTML_BR,
33         HTML_HR,
34         HTML_HREF,
35         HTML_IMG,
36         HTML_FONT,
37         HTML_PRE,
38         HTML_UNKNOWN,
39         HTML_CONV_FAILED,
40         HTML_ERR,
41         HTML_EOF,
42         HTML_HREF_BEG
43 } HTMLState;
44
45 typedef struct _HTMLParser      HTMLParser;
46 typedef struct _HTMLAttr        HTMLAttr;
47 typedef struct _HTMLTag         HTMLTag;
48
49 struct _HTMLParser
50 {
51         FILE *fp;
52         CodeConverter *conv;
53
54         GHashTable *symbol_table;
55
56         GString *str;
57         GString *buf;
58
59         gchar *bufp;
60
61         HTMLState state;
62
63         gchar *href;
64
65         gboolean newline;
66         gboolean empty_line;
67         gboolean space;
68         gboolean pre;
69 };
70
71 struct _HTMLAttr
72 {
73         gchar *name;
74         gchar *value;
75 };
76
77 struct _HTMLTag
78 {
79         gchar *name;
80         GList *attr;
81 };
82
83 HTMLParser *html_parser_new     (FILE           *fp,
84                                  CodeConverter  *conv);
85 void html_parser_destroy        (HTMLParser     *parser);
86 gchar *html_parse               (HTMLParser     *parser);
87
88 #endif /* __HTML_H__ */