40 stringprep_find_character_in_table (uint32_t ucs4,
53 for (i = 0; table[i].
start || table[i].
end; i++)
54 if (ucs4 >= table[i].start &&
55 ucs4 <= (table[i].end ? table[i].end : table[i].start))
62 stringprep_find_string_in_table (uint32_t * ucs4,
70 for (j = 0; j < ucs4len; j++)
71 if ((pos = stringprep_find_character_in_table (ucs4[j], table)) != -1)
82 stringprep_apply_table_to_string (uint32_t * ucs4,
90 while ((pos = stringprep_find_string_in_table (ucs4, *ucs4len,
94 maplen > 0 && table[i].
map[maplen - 1] == 0; maplen--)
97 if (*ucs4len - 1 + maplen >= maxucs4len)
100 memmove (&ucs4[pos + maplen], &ucs4[pos + 1],
101 sizeof (uint32_t) * (*ucs4len - pos - 1));
102 memcpy (&ucs4[pos], table[i].map,
sizeof (uint32_t) * maplen);
103 *ucs4len = *ucs4len - 1 + maplen;
109 #define INVERTED(x) ((x) & ((~0UL) >> 1))
110 #define UNAPPLICAPLEFLAGS(flags, profileflags) \
111 ((!INVERTED(profileflags) && !(profileflags & flags) && profileflags) || \
112 ( INVERTED(profileflags) && (profileflags & flags)))
152 size_t ucs4len = *len;
157 switch (profile[i].operation)
174 for (ucs4len = 0; q[ucs4len]; ucs4len++)
177 if (ucs4len >= maxucs4len)
183 memcpy (ucs4, q, ucs4len *
sizeof (ucs4[0]));
190 k = stringprep_find_string_in_table (ucs4, ucs4len,
191 NULL, profile[i].table);
201 k = stringprep_find_string_in_table
202 (ucs4, ucs4len, NULL, profile[i].table);
211 rc = stringprep_apply_table_to_string
212 (ucs4, &ucs4len, maxucs4len, profile[i].table);
224 int done_prohibited = 0;
227 size_t contains_ral = SIZE_MAX;
228 size_t contains_l = SIZE_MAX;
234 k = stringprep_find_string_in_table (ucs4, ucs4len,
243 if (stringprep_find_string_in_table
244 (ucs4, ucs4len, NULL, profile[j].table) != -1)
250 if (stringprep_find_string_in_table
251 (ucs4, ucs4len, NULL, profile[j].table) != -1)
255 if (!done_prohibited || !done_ral || !done_l)
258 if (contains_ral != SIZE_MAX && contains_l != SIZE_MAX)
261 if (contains_ral != SIZE_MAX)
263 if (!(stringprep_find_character_in_table
264 (ucs4[0], profile[contains_ral].table) != -1 &&
265 stringprep_find_character_in_table
266 (ucs4[ucs4len - 1], profile[contains_ral].table) != -1))
284 stringprep_4zi_1 (uint32_t * ucs4,
size_t ucs4len,
size_t maxucs4len,
290 rc =
stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
294 if (ucs4len >= maxucs4len)
333 for (ucs4len = 0; ucs4len < maxucs4len && ucs4[ucs4len] != 0; ucs4len++)
336 return stringprep_4zi_1 (ucs4, ucs4len, maxucs4len, flags, profile);
374 uint32_t *ucs4 = NULL;
375 size_t ucs4len, maxucs4len, adducs4len = 50;
383 maxucs4len = ucs4len + adducs4len;
384 newp = realloc (ucs4, maxucs4len *
sizeof (uint32_t));
392 rc =
stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
407 if (strlen (utf8) >= maxlen)
451 size_t len = strlen (in) + 1;
455 if (strcmp (p->
name, profile) == 0)
464 str = (
char *) malloc (len);