Distribute contrib/*.
[libidn.git] / profiles.c
blob24d8f308c59fb829f10a7c79b32d6b7ed4a4c2b9
1 /* profiles.c Definitions of stringprep profiles.
2 * Copyright (C) 2002, 2003 Simon Josefsson
4 * This file is part of GNU Libidn.
6 * GNU Libidn is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * GNU Libidn is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with GNU Libidn; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "stringprep_generic.h"
23 #include "stringprep_nameprep.h"
24 #include "stringprep_kerberos5.h"
26 Stringprep_profile stringprep_generic[] = {
27 /* 1) Map -- For each character in the input, check if it has a
28 mapping and, if so, replace it with its mapping. This is
29 described in section 3. */
31 {STRINGPREP_MAP_TABLE, 0, stringprep_generic_B_1, "B.1"}
33 {STRINGPREP_MAP_TABLE, ~STRINGPREP_NO_NFKC, stringprep_generic_B_2, "B.2"}
35 {STRINGPREP_MAP_TABLE, STRINGPREP_NO_NFKC, stringprep_generic_B_3, "B.3"}
38 /* 2) Normalize -- Possibly normalize the result of step 1 using
39 Unicode normalization. This is described in section 4. */
41 {STRINGPREP_NFKC, ~STRINGPREP_NO_NFKC, 0, "NFKC"}
44 /* 3) Prohibit -- Check for any characters that are not allowed in
45 the output. If any are found, return an error. This is
46 described in section 5. */
48 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_1_1, "C.1.1"}
50 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_1_2, "C.1.2"}
52 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_1, "C.2.1"}
54 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_2, "C.2.2"}
56 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_3, "C.3"}
58 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_4, "C.4"}
60 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_5, "C.5"}
62 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_6, "C.6"}
64 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_7, "C.7"}
66 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_8, "C.8"}
68 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_9, "C.9"}
71 /* 4) Check bidi -- Possibly check for right-to-left characters, and
72 if any are found, make sure that the whole string satisfies
73 the requirements for bidirectional strings. If the string does
74 not satisfy the requirements for bidirectional strings, return
75 an error. This is described in section 6. */
77 {STRINGPREP_BIDI, ~STRINGPREP_NO_BIDI, 0, "BIDI"}
79 {STRINGPREP_BIDI_PROHIBIT_TABLE, ~STRINGPREP_NO_BIDI,
80 stringprep_generic_C_8, "C.8"}
82 {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_generic_D_1,
83 "D.1"}
85 {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_generic_D_2,
86 "D.2"}
89 /* 5) Check unassigned code points -- Possibly check the output for
90 unassigned code points, according to the profile. This is
91 described in section 7. */
93 {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
94 stringprep_generic_A_1, "A.1"}
97 {0}
100 Stringprep_profile stringprep_nameprep[] = {
101 {STRINGPREP_MAP_TABLE, 0, stringprep_generic_B_1, "B.1"}
103 {STRINGPREP_MAP_TABLE, 0, stringprep_generic_B_2, "B.2"}
105 {STRINGPREP_NFKC, 0, 0, "NFKC"}
107 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_1_2, "C.1.2"}
109 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_2, "C.2.2"}
111 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_3, "C.3"}
113 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_4, "C.4"}
115 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_5, "C.5"}
117 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_6, "C.6"}
119 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_7, "C.7"}
121 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_8, "C.8"}
123 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_9, "C.9"}
125 {STRINGPREP_BIDI, 0, 0, "BIDI"}
127 {STRINGPREP_BIDI_PROHIBIT_TABLE, ~STRINGPREP_NO_BIDI,
128 stringprep_generic_C_8, "C.8"}
130 {STRINGPREP_BIDI_RAL_TABLE, 0, stringprep_generic_D_1, "D.1"}
132 {STRINGPREP_BIDI_L_TABLE, 0, stringprep_generic_D_2, "D.2"}
134 {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
135 stringprep_generic_A_1, "A.1"}
140 Stringprep_profile stringprep_kerberos5[] = {
141 /* XXX this is likely to be wrong as the specification is
142 a rough draft. */
143 {STRINGPREP_MAP_TABLE, 0, stringprep_generic_B_1, "B.1"}
145 {STRINGPREP_MAP_TABLE, 0, stringprep_generic_B_3, "B.2"}
147 {STRINGPREP_NFKC, 0, 0, "NFKC"}
149 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_1_2, "C.1.2"}
151 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_2, "C.2.2"}
153 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_3, "C.3"}
155 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_4, "C.4"}
157 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_5, "C.5"}
159 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_6, "C.6"}
161 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_7, "C.7"}
163 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_8, "C.8"}
165 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_9, "C.9"}
167 {STRINGPREP_BIDI, 0, 0, "BIDI"}
169 {STRINGPREP_BIDI_PROHIBIT_TABLE, ~STRINGPREP_NO_BIDI,
170 stringprep_generic_C_8, "C.8"}
172 {STRINGPREP_BIDI_RAL_TABLE, 0, stringprep_generic_D_1, "D.1"}
174 {STRINGPREP_BIDI_L_TABLE, 0, stringprep_generic_D_2, "D.2"}
176 {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
177 stringprep_generic_A_1, "A.1"}
182 Stringprep_table_element stringprep_xmpp_nodeprep_prohibit[] = {
183 {0x000022}
184 , /* #x22 (") */
185 {0x000026}
186 , /* #x26 (&) */
187 {0x000027}
188 , /* #x27 (') */
189 {0x00002F}
190 , /* #x2F (/) */
191 {0x00003A}
192 , /* #x3A (:) */
193 {0x00003C}
194 , /* #x3C (<) */
195 {0x00003E}
196 , /* #x3E (>) */
197 {0x000040} /* #x40 (@) */
202 Stringprep_profile stringprep_xmpp_nodeprep[] = {
203 {STRINGPREP_MAP_TABLE, 0, stringprep_generic_B_1, "B.1"}
205 {STRINGPREP_MAP_TABLE, 0, stringprep_generic_B_2, "B.2"}
207 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_1_1, "C.1.1"}
209 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_1_2, "C.1.2"}
211 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_1, "C.2.1"}
213 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_2, "C.2.2"}
215 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_3, "C.3"}
217 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_4, "C.4"}
219 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_5, "C.5"}
221 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_6, "C.6"}
223 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_7, "C.7"}
225 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_8, "C.8"}
227 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_9, "C.9"}
229 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_xmpp_nodeprep_prohibit,
230 "XMPP-PROHIBIT"}
232 {STRINGPREP_BIDI, 0, 0, "BIDI"}
234 {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_generic_C_8, "C.8"}
236 {STRINGPREP_BIDI_RAL_TABLE, 0, stringprep_generic_D_1, "D.1"}
238 {STRINGPREP_BIDI_L_TABLE, 0, stringprep_generic_D_2, "D.2"}
240 {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
241 stringprep_generic_A_1, "A.1"}
246 Stringprep_profile stringprep_xmpp_resourceprep[] = {
247 {STRINGPREP_MAP_TABLE, 0, stringprep_generic_B_1, "B.1"}
249 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_1_2, "C.1.2"}
251 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_1, "C.2.1"}
253 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_2, "C.2.2"}
255 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_3, "C.3"}
257 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_4, "C.4"}
259 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_5, "C.5"}
261 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_6, "C.6"}
263 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_7, "C.7"}
265 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_8, "C.8"}
267 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_9, "C.9"}
269 {STRINGPREP_BIDI, 0, 0, "BIDI"}
271 {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_generic_C_8, "C.8"}
273 {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_generic_D_1,
274 "D.1"}
276 {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_generic_D_2,
277 "D.2"}
279 {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
280 stringprep_generic_A_1, "A.1"}
285 Stringprep_profile stringprep_plain[] = {
286 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_1, "C.2.1"}
288 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_2_2, "C.2.2"}
290 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_3, "C.3"}
292 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_4, "C.4"}
294 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_5, "C.5"}
296 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_6, "C.6"}
298 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_8, "C.8"}
300 {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_generic_C_9, "C.9"}
302 {STRINGPREP_BIDI, 0, 0, "BIDI"}
304 {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_generic_C_8, "C.8"}
306 {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_generic_D_1,
307 "D.1"}
309 {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_generic_D_2,
310 "D.2"}