w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

html.h (9268B)


      1 /* $Id$ */
      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 #define HTML_SPAN	113
    206 #define HTML_N_SPAN	114
    207 #define HTML_ABBR       115
    208 #define HTML_N_ABBR     116
    209 #define HTML_ACRONYM    117
    210 #define HTML_N_ACRONYM  118
    211 #define HTML_BASEFONT   119
    212 #define HTML_BDO        120
    213 #define HTML_N_BDO      121
    214 #define HTML_BIG        122
    215 #define HTML_N_BIG      123
    216 #define HTML_BUTTON     124
    217 #define HTML_FIELDSET   125
    218 #define HTML_N_FIELDSET 126
    219 #define HTML_IFRAME     127
    220 #define HTML_LABEL      128
    221 #define HTML_N_LABEL    129
    222 #define HTML_LEGEND     130
    223 #define HTML_N_LEGEND   131
    224 #define HTML_NOSCRIPT   132
    225 #define HTML_N_NOSCRIPT 133
    226 #define HTML_OBJECT     134
    227 #define HTML_OPTGROUP   135
    228 #define HTML_N_OPTGROUP 136
    229 #define HTML_PARAM      137
    230 #define HTML_SMALL      138
    231 #define HTML_N_SMALL    139
    232 
    233    /* pseudo tag */
    234 #define HTML_SELECT_INT     160
    235 #define HTML_N_SELECT_INT   161
    236 #define HTML_OPTION_INT     162
    237 #define HTML_TEXTAREA_INT   163
    238 #define HTML_N_TEXTAREA_INT 164
    239 #define HTML_TABLE_ALT      165
    240 #define HTML_SYMBOL         166
    241 #define HTML_N_SYMBOL       167
    242 #define HTML_PRE_INT        168
    243 #define HTML_N_PRE_INT      169
    244 #define HTML_TITLE_ALT      170
    245 #define HTML_FORM_INT       171
    246 #define HTML_N_FORM_INT     172
    247 #define HTML_DL_COMPACT     173
    248 #define HTML_INPUT_ALT      174
    249 #define HTML_N_INPUT_ALT    175
    250 #define HTML_IMG_ALT        176
    251 #define HTML_N_IMG_ALT      177
    252 #define HTML_NOP	    178
    253 #define HTML_PRE_PLAIN	    179
    254 #define HTML_N_PRE_PLAIN    180
    255 #define HTML_INTERNAL       181
    256 #define HTML_N_INTERNAL     182
    257 #define HTML_DIV_INT        183
    258 #define HTML_N_DIV_INT      184
    259 
    260 #define MAX_HTMLTAG	    185
    261 
    262 /* Tag attribute */
    263 
    264 #define ATTR_UNKNOWN		0
    265 #define ATTR_ACCEPT		1
    266 #define ATTR_ACCEPT_CHARSET	2
    267 #define ATTR_ACTION		3
    268 #define ATTR_ALIGN		4
    269 #define ATTR_ALT		5
    270 #define ATTR_ARCHIVE		6
    271 #define ATTR_BACKGROUND		7
    272 #define ATTR_BORDER		8
    273 #define ATTR_CELLPADDING	9
    274 #define ATTR_CELLSPACING	10
    275 #define ATTR_CHARSET		11
    276 #define ATTR_CHECKED		12
    277 #define ATTR_COLS		13
    278 #define ATTR_COLSPAN		14
    279 #define ATTR_CONTENT		15
    280 #define ATTR_ENCTYPE		16
    281 #define ATTR_HEIGHT		17
    282 #define ATTR_HREF		18
    283 #define ATTR_HTTP_EQUIV		19
    284 #define ATTR_ID			20
    285 #define ATTR_LINK		21
    286 #define ATTR_MAXLENGTH		22
    287 #define ATTR_METHOD		23
    288 #define ATTR_MULTIPLE		24
    289 #define ATTR_NAME		25
    290 #define ATTR_NOWRAP		26
    291 #define ATTR_PROMPT		27
    292 #define ATTR_ROWS		28
    293 #define ATTR_ROWSPAN		29
    294 #define ATTR_SIZE		30
    295 #define ATTR_SRC		31
    296 #define ATTR_TARGET		32
    297 #define ATTR_TYPE		33
    298 #define ATTR_USEMAP		34
    299 #define ATTR_VALIGN		35
    300 #define ATTR_VALUE		36
    301 #define ATTR_VSPACE		37
    302 #define ATTR_WIDTH		38
    303 #define ATTR_COMPACT		39
    304 #define ATTR_START		40
    305 #define ATTR_SELECTED		41
    306 #define ATTR_LABEL		42
    307 #define ATTR_READONLY		43
    308 #define ATTR_SHAPE		44
    309 #define ATTR_COORDS		45
    310 #define ATTR_ISMAP		46
    311 #define ATTR_REL		47
    312 #define ATTR_REV		48
    313 #define ATTR_TITLE		49
    314 #define ATTR_ACCESSKEY		50
    315 
    316 /* Internal attribute */
    317 #define ATTR_XOFFSET		60
    318 #define ATTR_YOFFSET		61
    319 #define ATTR_TOP_MARGIN		62
    320 #define ATTR_BOTTOM_MARGIN	63
    321 #define ATTR_TID		64
    322 #define ATTR_FID		65
    323 #define ATTR_FOR_TABLE		66
    324 #define ATTR_FRAMENAME		67
    325 #define ATTR_HBORDER		68
    326 #define ATTR_HSEQ		69
    327 #define ATTR_NO_EFFECT		70
    328 #define ATTR_REFERER		71
    329 #define ATTR_SELECTNUMBER	72
    330 #define ATTR_TEXTAREANUMBER	73
    331 #define ATTR_PRE_INT		74
    332 
    333 #define MAX_TAGATTR		75
    334 
    335 /* HTML Tag Information Table */
    336 
    337 typedef struct html_tag_info {
    338     char *name;
    339     unsigned char *accept_attribute;
    340     unsigned char max_attribute;
    341     unsigned char flag;
    342 } TagInfo;
    343 
    344 #define TFLG_END	1
    345 #define TFLG_INT	2
    346 
    347 /* HTML Tag Attribute Information Table */
    348 
    349 typedef struct tag_attribute_info {
    350     char *name;
    351     unsigned char vtype;
    352     unsigned char flag;
    353 } TagAttrInfo;
    354 
    355 #define AFLG_INT	1
    356 
    357 #define VTYPE_NONE	0
    358 #define VTYPE_STR	1
    359 #define VTYPE_NUMBER	2
    360 #define VTYPE_LENGTH	3
    361 #define VTYPE_ALIGN     4
    362 #define VTYPE_VALIGN    5
    363 #define VTYPE_ACTION    6
    364 #define VTYPE_ENCTYPE   7
    365 #define VTYPE_METHOD    8
    366 #define VTYPE_MLENGTH   9
    367 #define VTYPE_TYPE      10
    368 
    369 #define SHAPE_UNKNOWN	0
    370 #define SHAPE_DEFAULT	1
    371 #define SHAPE_RECT	2
    372 #define SHAPE_CIRCLE	3
    373 #define SHAPE_POLY	4
    374 
    375 extern TagInfo TagMAP[];
    376 extern TagAttrInfo AttrMAP[];
    377 
    378 struct environment {
    379     unsigned char env;
    380     int type;
    381     int count;
    382     char indent;
    383 };
    384 
    385 #define MAX_ENV_LEVEL    20
    386 #define MAX_INDENT_LEVEL 10
    387 
    388 #define INDENT_INCR IndentIncr
    389 
    390 #define SCM_UNKNOWN	255
    391 #define SCM_MISSING	254
    392 #define SCM_HTTP	0
    393 #define SCM_GOPHER	1
    394 #define SCM_FTP		2
    395 #define SCM_FTPDIR	3
    396 #define SCM_LOCAL	4
    397 #define SCM_LOCAL_CGI	5
    398 #define SCM_EXEC	6
    399 #define SCM_NNTP	7
    400 #define SCM_NNTP_GROUP	8
    401 #define SCM_NEWS	9
    402 #define SCM_NEWS_GROUP	10
    403 #define SCM_DATA	11
    404 #define SCM_MAILTO      12
    405 #ifdef USE_SSL
    406 #define SCM_HTTPS       13
    407 #endif				/* USE_SSL */
    408 
    409 #endif				/* _HTML_H */