File: facilities.c

package info (click to toggle)
netrik 1.16.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 3,272 kB
  • ctags: 729
  • sloc: ansic: 6,657; sh: 994; makefile: 114
file content (238 lines) | stat: -rw-r--r-- 6,620 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/*
   netrik -- The ANTRIK Internet Viewer
   Copyright (C) Olaf D. Buddenhagen AKA antrik, et al (see AUTHORS)
   Published under the GNU GPL; see LICENSE for details.
*/
/*
 * facilities.c -- contains all information about element types, attribute
 * types and entity references.
 *
 * (C) 2001, 2002 antrik
 *     2001, 2002 Patrice Neff
 *
 * necessary for syntax & element parsing, and to make something useful from
 * the syntax tree.
 *
 * In the future there will be more data-driven parameters, to make adding
 * elements or altering their behaviour easier.
 *
 * There are only very few elements and attributes implemented for now.
 */
#include "syntax.h"

/* miscallenous information about all element types
 * {name, breaks, force_box, group, visible} */
/* update syntax.h also! */
const struct Element_data	element_table[]={
   {"html", 0, 0, GROUP_HTML, 1}, {"head", 0, 0, GROUP_HEAD, 0}, {"body", 0, 0, GROUP_HEAD, 1},
   {"title", 0, 0, GROUP_OBLIGATE, 0}, {"meta", 0, 0, GROUP_SINGLE, 0}, {"style", 0, 0, GROUP_OBLIGATE, 0}, {"script", 0, 0, GROUP_OBLIGATE, 0},
   {"h1", 2, 0, GROUP_OBLIGATE, 1}, {"h2", 2, 0, GROUP_OBLIGATE, 1}, {"h3", 2, 0, GROUP_OBLIGATE, 1}, {"h4", 2, 0, GROUP_OBLIGATE, 1}, {"h5", 2, 0, GROUP_OBLIGATE, 1}, {"h6", 2, 0, GROUP_OBLIGATE, 1},
   {"p", 2, 0, GROUP_PARAGRAPH, 1},
   {"em", 0, 0, GROUP_OBLIGATE, 1}, {"i", 0, 0, GROUP_OBLIGATE, 1},
   {"strong", 0, 0, GROUP_OBLIGATE, 1}, {"b", 0, 0, GROUP_OBLIGATE, 1},
   {"center", 1, 0, GROUP_OBLIGATE, 1},
   {"a", 0, 0, GROUP_OBLIGATE, 1},
   {"br", 0, 0, GROUP_SINGLE, 1},    /* no longer creates new text block (a '\n' is stored instead) */
   {"pre", 2, 0, GROUP_OBLIGATE, 1},
   {"table", 2, 1, GROUP_OBLIGATE, 1},
   {"tr", 1, 0, GROUP_TABLE_ROW, 1},
   {"td", 0, 0, GROUP_TABLE_CELL, 1}, {"th", 0, 0, GROUP_TABLE_CELL, 1},
   {"ul", 2, 0, GROUP_OBLIGATE, 1}, {"li", 1, 0, GROUP_LIST_ITEM, 1},
   {"ol", 2, 0, GROUP_OBLIGATE, 1},
   {"dl", 2, 0, GROUP_OBLIGATE, 1}, {"dt", 1, 0, GROUP_LIST_ITEM, 1}, {"dd", 1, 0, GROUP_LIST_ITEM, 1},
   {"hr", 1, 0, GROUP_SINGLE, 1},
   {"ins", 0, 0, GROUP_OBLIGATE, 1}, {"del", 0, 0, GROUP_OBLIGATE, 1},
   {"u", 0, 0, GROUP_OBLIGATE, 1}, {"s", 0, 0, GROUP_OBLIGATE, 1}, {"strike", 0, 0, GROUP_OBLIGATE, 1},
   {"form", 2, 1, GROUP_OBLIGATE, 1}, {"input", 0, 0, GROUP_SINGLE, 1}, {"select", 0, 0, GROUP_OBLIGATE, 1}, {"button", 0, 0, GROUP_OBLIGATE, 1}, {"option", 0, 0, GROUP_OPTION, 1}, {"textarea", 0, 0, GROUP_OBLIGATE, 0},
   {"img", 0, 0, GROUP_SINGLE, 1},
   {"div", 1, 0, GROUP_OBLIGATE, 1}, {"span", 0, 0, GROUP_OBLIGATE, 1},
   {"?", 0, 0, GROUP_SINGLE, 1},    /* making all unknown elements SINGLE we are on the safe side (otherwise, unknown single tags will "capture" following elements) */
   {"!", 1, 1, GROUP_OBLIGATE, 1}
};

/* update syntax.h also! */
/* if the same attribute exists for a specific element and for EL_NO, put the
   specific one first */
const struct Attr_data	attr_table[]={
   /* name, numeric, el, def_val */
   {"name", 0, EL_NO, ""},
   {"href", 0, EL_NO, ""},
   {"title", 0, EL_NO, ""},
   {"colspan", 0, EL_NO, ""},
   {"align", 0, EL_NO, ""},
   {"type", 0, EL_INPUT, "text"},
   {"size", 1, EL_INPUT, "10"},
   {"alt", 0, EL_NO, ""},
   {"value", 0, EL_NO, ""},
   {"cols", 1, EL_TEXTAREA, "50"},
   {"rows", 1, EL_TEXTAREA, "1"},
   {"id", 0, EL_NO, ""},
   {"action", 0, EL_FORM, ""},
   {"method", 0, EL_FORM, "GET"},
   {"enctype", 0, EL_NO, ""},
   {"checked", 0, EL_NO, ""},
   {"multiple", 0, EL_NO, ""},
   {"selected", 0, EL_NO, ""},
   {"?", 0, EL_NO, ""}
};

const struct Ref	ref_table[]={
   {"lt",'<'},
   {"gt",'>'},
   {"amp",'&'},
   {"quot",'"'},
   {"apos",'\''},

   /* all iso-8859-1 non-ascii chars */
   {"nbsp",160},
   {"iexcl",'\xa1'},
   {"cent",'\xa2'},
   {"pound",'\xa3'},
   {"curren",'\xa4'},
   {"yen",'\xa5'},
   {"brvbar",'\xa6'},
   {"sect",'\xa7'},
   {"uml",'\xa8'},
   {"copy",'\xa9'},
   {"ordf",'\xaa'},
   {"laquo",'\xab'},
   {"not",'\xac'},
   {"shy",'\xad'},
   {"reg",'\xae'},
   {"macr",'\xaf'},
   {"deg",'\xb0'},
   {"plusmn",'\xb1'},
   {"sup2",'\xb2'},
   {"sup3",'\xb3'},
   {"acute",'\xb4'},
   {"micro",'\xb5'},
   {"para",'\xb6'},
   {"middot",'\xb7'},
   {"cedil",'\xb8'},
   {"sup1",'\xb9'},
   {"ordm",'\xba'},
   {"raquo",'\xbb'},
   {"frac14",'\xbc'},
   {"frac12",'\xbd'},
   {"frac34",'\xbe'},
   {"iquest",'\xbf'},
   {"Agrave",'\xc0'},
   {"Aacute",'\xc1'},
   {"Acirc",'\xc2'},
   {"Atilde",'\xc3'},
   {"Auml",'\xc4'},
   {"Aring",'\xc5'},
   {"AElig",'\xc6'},
   {"Ccedil",'\xc7'},
   {"Egrave",'\xc8'},
   {"Eacute",'\xc9'},
   {"Ecirc",'\xca'},
   {"Euml",'\xcb'},
   {"Igrave",'\xcc'},
   {"Iacute",'\xcd'},
   {"Icirc",'\xce'},
   {"Iuml",'\xcf'},
   {"ETH",'\xd0'},
   {"Ntilde",'\xd1'},
   {"Ograve",'\xd2'},
   {"Oacute",'\xd3'},
   {"Ocirc",'\xd4'},
   {"Otilde",'\xd5'},
   {"Ouml",'\xd6'},
   {"times",'\xd7'},
   {"Oslash",'\xd8'},
   {"Ugrave",'\xd9'},
   {"Uacute",'\xda'},
   {"Ucirc",'\xdb'},
   {"Uuml",'\xdc'},
   {"Yacute",'\xdd'},
   {"THORN",'\xde'},
   {"szlig",'\xdf'},
   {"agrave",'\xe0'},
   {"aacute",'\xe1'},
   {"acirc",'\xe2'},
   {"atilde",'\xe3'},
   {"auml",'\xe4'},
   {"aring",'\xe5'},
   {"aelig",'\xe6'},
   {"ccedil",'\xe7'},
   {"egrave",'\xe8'},
   {"eacute",'\xe9'},
   {"ecirc",'\xea'},
   {"euml",'\xeb'},
   {"igrave",'\xec'},
   {"iacute",'\xed'},
   {"icirc",'\xee'},
   {"iuml",'\xef'},
   {"eth",'\xf0'},
   {"ntilde",'\xf1'},
   {"ograve",'\xf2'},
   {"oacute",'\xf3'},
   {"ocirc",'\xf4'},
   {"otilde",'\xf5'},
   {"ouml",'\xf6'},
   {"divide",'\xf7'},
   {"oslash",'\xf8'},
   {"ugrave",'\xf9'},
   {"uacute",'\xfa'},
   {"ucirc",'\xfb'},
   {"uuml",'\xfc'},
   {"yacute",'\xfd'},
   {"thorn",'\xfe'},
   {"yuml",'\xff'},
/* not implemented yet 
   {"Alpha",''},
   {"alpha",''},
   {"Beta",''},
   {"beta",''},
   {"Gamma",''},
   {"gamma",''},
   {"Delta",''},
   {"delta",''},
   {"Epsilon",''},
   {"epsilon",''},
   {"Zeta",''},
   {"zeta",''},
   {"Eta",''},
   {"eta",''},
   {"Theta",''},
   {"theta",''},
   {"Iota",''},
   {"iota",''},
   {"Kappa",''},
   {"kappa",''},
   {"Lambda",''},
   {"lambda",''},
   {"Mu",''},
   {"mu",''},
   {"Nu",''},
   {"nu",''},
   {"Xi",''},
   {"xi",''},
   {"Omicron",''},
   {"omicron",''},
   {"Pi",''},
   {"pi",''},
   {"Rho",''},
   {"rho",''},
   {"Sigma",''},
   {"sigmaf",''},
   {"sigma",''},
   {"Tau",''},
   {"tau",''},
   {"Upsilon",''},
   {"upsilon",''},
   {"Phi",''},
   {"phi",''},
   {"Chi",''},
   {"chi",''},
   {"Psi",''},
   {"psi",''},
   {"Omega",''},
   {"omega",''},
   {"thetasym",''},
   {"upsih",''},
   {"piv",''},
*/
   {"",0}    /* table end */
};