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