Intial commit
[profile/ivi/w3m.git] / html.h
1 /* $Id: html.h,v 1.29 2007/05/23 12:01:43 inu Exp $ */
2 #ifndef _HTML_H
3 #define _HTML_H
4 #ifdef USE_SSL
5 #include <openssl/bio.h>
6 #include <openssl/x509.h>
7 #include <openssl/ssl.h>
8 #endif                          /* USE_SSL */
9
10 #include "istream.h"
11
12 #define StrUFgets(f) StrISgets((f)->stream)
13 #define StrmyUFgets(f) StrmyISgets((f)->stream)
14 #define UFgetc(f) ISgetc((f)->stream)
15 #define UFundogetc(f) ISundogetc((f)->stream)
16 #define UFread(f,buf,len) ISread((f)->stream,buf,len)
17 #define UFclose(f) (void)(ISclose((f)->stream) == 0 && ((f)->stream = NULL))
18 #define UFfileno(f) ISfileno((f)->stream)
19
20 struct cmdtable {
21     char *cmdname;
22     int cmd;
23 };
24
25 struct mailcap {
26     char *type;
27     char *viewer;
28     int flags;
29     char *test;
30     char *nametemplate;
31     char *edit;
32 };
33
34 #define MAILCAP_NEEDSTERMINAL   0x01
35 #define MAILCAP_COPIOUSOUTPUT   0x02
36 #define MAILCAP_HTMLOUTPUT      0x04
37
38 #define MCSTAT_REPNAME          0x01
39 #define MCSTAT_REPTYPE          0x02
40 #define MCSTAT_REPPARAM         0x04
41
42 struct table2 {
43     char *item1;
44     char *item2;
45 };
46
47 typedef struct {
48     char *referer;
49     int flag;
50 } URLOption;
51
52 typedef struct _ParsedURL {
53     int scheme;
54     char *user;
55     char *pass;
56     char *host;
57     int port;
58     char *file;
59     char *real_file;
60     char *query;
61     char *label;
62     int is_nocache;
63 } ParsedURL;
64
65 typedef struct {
66     unsigned char scheme;
67     char is_cgi;
68     char encoding;
69     InputStream stream;
70     char *ext;
71     int compression;
72     int content_encoding;
73     char *guess_type;
74 #ifdef USE_SSL
75     char *ssl_certificate;
76 #endif
77     char *url;
78     time_t modtime;
79 } URLFile;
80
81 #define CMP_NOCOMPRESS   0
82 #define CMP_COMPRESS     1
83 #define CMP_GZIP         2
84 #define CMP_BZIP2        3
85 #define CMP_DEFLATE      4
86
87 #define ENC_7BIT        0
88 #define ENC_BASE64      1
89 #define ENC_QUOTE       2
90 #define ENC_UUENCODE    3
91
92 #define HTML_UNKNOWN    0
93 #define HTML_A          1
94 #define HTML_N_A        2
95 #define HTML_H          3
96 #define HTML_N_H        4
97 #define HTML_P          5
98 #define HTML_BR         6
99 #define HTML_B          7
100 #define HTML_N_B        8
101 #define HTML_UL         9
102 #define HTML_N_UL       10
103 #define HTML_LI         11
104 #define HTML_OL         12
105 #define HTML_N_OL       13
106 #define HTML_TITLE      14
107 #define HTML_N_TITLE    15
108 #define HTML_HR         16
109 #define HTML_DL         17
110 #define HTML_N_DL       18
111 #define HTML_DT         19
112 #define HTML_DD         20
113 #define HTML_PRE        21
114 #define HTML_N_PRE      22
115 #define HTML_BLQ        23
116 #define HTML_N_BLQ      24
117 #define HTML_IMG        25
118 #define HTML_LISTING    26
119 #define HTML_N_LISTING  27
120 #define HTML_XMP        28
121 #define HTML_N_XMP      29
122 #define HTML_PLAINTEXT  30
123 #define HTML_TABLE      31
124 #define HTML_N_TABLE    32
125 #define HTML_META       33
126 #define HTML_N_P        34
127 #define HTML_FRAME      35
128 #define HTML_FRAMESET   36
129 #define HTML_N_FRAMESET 37
130 #define HTML_CENTER     38
131 #define HTML_N_CENTER   39
132 #define HTML_FONT       40
133 #define HTML_N_FONT     41
134 #define HTML_FORM       42
135 #define HTML_N_FORM     43
136 #define HTML_INPUT      44
137 #define HTML_TEXTAREA   45
138 #define HTML_N_TEXTAREA 46
139 #define HTML_SELECT     47
140 #define HTML_N_SELECT   48
141 #define HTML_OPTION     49
142 #define HTML_NOBR       50
143 #define HTML_N_NOBR     51
144 #define HTML_DIV        52
145 #define HTML_N_DIV      53
146 #define HTML_ISINDEX    54
147 #define HTML_MAP        55
148 #define HTML_N_MAP      56
149 #define HTML_AREA       57
150 #define HTML_SCRIPT     58
151 #define HTML_N_SCRIPT   59
152 #define HTML_BASE       60
153 #define HTML_DEL        61
154 #define HTML_N_DEL      62
155 #define HTML_INS        63
156 #define HTML_N_INS      64
157 #define HTML_U          65
158 #define HTML_N_U        66
159 #define HTML_STYLE      67
160 #define HTML_N_STYLE    68
161 #define HTML_WBR        69
162 #define HTML_EM         70
163 #define HTML_N_EM       71
164 #define HTML_BODY       72
165 #define HTML_N_BODY     73
166 #define HTML_TR         74
167 #define HTML_N_TR       75
168 #define HTML_TD         76
169 #define HTML_N_TD       77
170 #define HTML_CAPTION    78
171 #define HTML_N_CAPTION  79
172 #define HTML_TH         80
173 #define HTML_N_TH       81
174 #define HTML_THEAD      82
175 #define HTML_N_THEAD    83
176 #define HTML_TBODY      84
177 #define HTML_N_TBODY    85
178 #define HTML_TFOOT      86
179 #define HTML_N_TFOOT    87
180 #define HTML_COLGROUP   88
181 #define HTML_N_COLGROUP 89
182 #define HTML_COL        90
183 #define HTML_BGSOUND    91
184 #define HTML_APPLET     92
185 #define HTML_EMBED      93
186 #define HTML_N_OPTION   94
187 #define HTML_HEAD       95
188 #define HTML_N_HEAD     96
189 #define HTML_DOCTYPE    97
190 #define HTML_NOFRAMES   98
191 #define HTML_N_NOFRAMES 99
192 #define HTML_SUP        100
193 #define HTML_N_SUP      101
194 #define HTML_SUB        102
195 #define HTML_N_SUB      103
196 #define HTML_LINK       104
197 #define HTML_S          105
198 #define HTML_N_S        106
199 #define HTML_Q          107
200 #define HTML_N_Q        108
201 #define HTML_I          109
202 #define HTML_N_I        110
203 #define HTML_STRONG     111
204 #define HTML_N_STRONG   112
205
206    /* pseudo tag */
207 #define HTML_SELECT_INT     120
208 #define HTML_N_SELECT_INT   121
209 #define HTML_OPTION_INT     122
210 #define HTML_TEXTAREA_INT   123
211 #define HTML_N_TEXTAREA_INT 124
212 #define HTML_TABLE_ALT      125
213 #define HTML_SYMBOL         126
214 #define HTML_N_SYMBOL       127
215 #define HTML_PRE_INT        128
216 #define HTML_N_PRE_INT      129
217 #define HTML_TITLE_ALT      130
218 #define HTML_FORM_INT       131
219 #define HTML_N_FORM_INT     132
220 #define HTML_DL_COMPACT     133
221 #define HTML_INPUT_ALT      134
222 #define HTML_N_INPUT_ALT    135
223 #define HTML_IMG_ALT        136
224 #define HTML_N_IMG_ALT      137
225 #define HTML_NOP            138
226 #define HTML_PRE_PLAIN      139
227 #define HTML_N_PRE_PLAIN    140
228 #define HTML_INTERNAL       141
229 #define HTML_N_INTERNAL     142
230 #define HTML_DIV_INT        143
231 #define HTML_N_DIV_INT      144
232
233 #define MAX_HTMLTAG         145
234
235 /* Tag attribute */
236
237 #define ATTR_UNKNOWN            0
238 #define ATTR_ACCEPT             1
239 #define ATTR_ACCEPT_CHARSET     2
240 #define ATTR_ACTION             3
241 #define ATTR_ALIGN              4
242 #define ATTR_ALT                5
243 #define ATTR_ARCHIVE            6
244 #define ATTR_BACKGROUND         7
245 #define ATTR_BORDER             8
246 #define ATTR_CELLPADDING        9
247 #define ATTR_CELLSPACING        10
248 #define ATTR_CHARSET            11
249 #define ATTR_CHECKED            12
250 #define ATTR_COLS               13
251 #define ATTR_COLSPAN            14
252 #define ATTR_CONTENT            15
253 #define ATTR_ENCTYPE            16
254 #define ATTR_HEIGHT             17
255 #define ATTR_HREF               18
256 #define ATTR_HTTP_EQUIV         19
257 #define ATTR_ID                 20
258 #define ATTR_LINK               21
259 #define ATTR_MAXLENGTH          22
260 #define ATTR_METHOD             23
261 #define ATTR_MULTIPLE           24
262 #define ATTR_NAME               25
263 #define ATTR_NOWRAP             26
264 #define ATTR_PROMPT             27
265 #define ATTR_ROWS               28
266 #define ATTR_ROWSPAN            29
267 #define ATTR_SIZE               30
268 #define ATTR_SRC                31
269 #define ATTR_TARGET             32
270 #define ATTR_TYPE               33
271 #define ATTR_USEMAP             34
272 #define ATTR_VALIGN             35
273 #define ATTR_VALUE              36
274 #define ATTR_VSPACE             37
275 #define ATTR_WIDTH              38
276 #define ATTR_COMPACT            39
277 #define ATTR_START              40
278 #define ATTR_SELECTED           41
279 #define ATTR_LABEL              42
280 #define ATTR_READONLY           43
281 #define ATTR_SHAPE              44
282 #define ATTR_COORDS             45
283 #define ATTR_ISMAP              46
284 #define ATTR_REL                47
285 #define ATTR_REV                48
286 #define ATTR_TITLE              49
287 #define ATTR_ACCESSKEY          50
288
289 /* Internal attribute */
290 #define ATTR_XOFFSET            60
291 #define ATTR_YOFFSET            61
292 #define ATTR_TOP_MARGIN         62
293 #define ATTR_BOTTOM_MARGIN      63
294 #define ATTR_TID                64
295 #define ATTR_FID                65
296 #define ATTR_FOR_TABLE          66
297 #define ATTR_FRAMENAME          67
298 #define ATTR_HBORDER            68
299 #define ATTR_HSEQ               69
300 #define ATTR_NO_EFFECT          70
301 #define ATTR_REFERER            71
302 #define ATTR_SELECTNUMBER       72
303 #define ATTR_TEXTAREANUMBER     73
304 #define ATTR_PRE_INT            74
305
306 #define MAX_TAGATTR             75
307
308 /* HTML Tag Information Table */
309
310 typedef struct html_tag_info {
311     char *name;
312     unsigned char *accept_attribute;
313     unsigned char max_attribute;
314     unsigned char flag;
315 } TagInfo;
316
317 #define TFLG_END        1
318 #define TFLG_INT        2
319
320 /* HTML Tag Attribute Information Table */
321
322 typedef struct tag_attribute_info {
323     char *name;
324     unsigned char vtype;
325     unsigned char flag;
326 } TagAttrInfo;
327
328 #define AFLG_INT        1
329
330 #define VTYPE_NONE      0
331 #define VTYPE_STR       1
332 #define VTYPE_NUMBER    2
333 #define VTYPE_LENGTH    3
334 #define VTYPE_ALIGN     4
335 #define VTYPE_VALIGN    5
336 #define VTYPE_ACTION    6
337 #define VTYPE_ENCTYPE   7
338 #define VTYPE_METHOD    8
339 #define VTYPE_MLENGTH   9
340 #define VTYPE_TYPE      10
341
342 #define SHAPE_UNKNOWN   0
343 #define SHAPE_DEFAULT   1
344 #define SHAPE_RECT      2
345 #define SHAPE_CIRCLE    3
346 #define SHAPE_POLY      4
347
348 extern TagInfo TagMAP[];
349 extern TagAttrInfo AttrMAP[];
350
351 struct environment {
352     unsigned char env;
353     int type;
354     int count;
355     char indent;
356 };
357
358 #define MAX_ENV_LEVEL    20
359 #define MAX_INDENT_LEVEL 10
360
361 #define INDENT_INCR IndentIncr
362
363 #define SCM_UNKNOWN     255
364 #define SCM_MISSING     254
365 #define SCM_HTTP        0
366 #define SCM_GOPHER      1
367 #define SCM_FTP         2
368 #define SCM_FTPDIR      3
369 #define SCM_LOCAL       4
370 #define SCM_LOCAL_CGI   5
371 #define SCM_EXEC        6
372 #define SCM_NNTP        7
373 #define SCM_NNTP_GROUP  8
374 #define SCM_NEWS        9
375 #define SCM_NEWS_GROUP  10
376 #define SCM_DATA        11
377 #define SCM_MAILTO      12
378 #ifdef USE_SSL
379 #define SCM_HTTPS       13
380 #endif                          /* USE_SSL */
381
382 #endif                          /* _HTML_H */