40_compare_table_element (
const uint32_t * c,
51stringprep_find_character_in_table (uint32_t ucs4,
83 (
int (*)(
const void *,
const void *)) _compare_table_element);
85 return p ? (p - table) : -1;
89stringprep_find_string_in_table (uint32_t * ucs4,
98 for (j = 0; j < ucs4len; j++)
100 stringprep_find_character_in_table (ucs4[j], table,
112stringprep_apply_table_to_string (uint32_t * ucs4,
120 uint32_t *src = ucs4;
121 size_t srclen = *ucs4len;
123 while ((pos = stringprep_find_string_in_table (src, srclen,
128 maplen > 0 && table[i].
map[maplen - 1] == 0; maplen--)
131 if (*ucs4len - 1 + maplen >= maxucs4len)
134 memmove (src + pos + maplen, src + pos + 1,
135 sizeof (uint32_t) * (srclen - pos - 1));
136 memcpy (src + pos, table[i].map,
sizeof (uint32_t) * maplen);
137 *ucs4len = *ucs4len - 1 + maplen;
145#define INVERTED(x) ((x) & ((~0UL) >> 1))
146#define UNAPPLICAPLEFLAGS(flags, profileflags) \
147 ((!INVERTED(profileflags) && !(profileflags & flags) && profileflags) || \
148 ( INVERTED(profileflags) && (profileflags & flags)))
188 size_t ucs4len = *len;
193 switch (profile[i].operation)
210 for (ucs4len = 0; q[ucs4len]; ucs4len++)
213 if (ucs4len >= maxucs4len)
219 memcpy (ucs4, q, ucs4len *
sizeof (ucs4[0]));
226 k = stringprep_find_string_in_table (ucs4, ucs4len,
227 NULL, profile[i].table,
228 profile[i].table_size);
238 k = stringprep_find_string_in_table
239 (ucs4, ucs4len, NULL, profile[i].table,
240 profile[i].table_size);
249 rc = stringprep_apply_table_to_string
250 (ucs4, &ucs4len, maxucs4len, profile[i].table,
251 profile[i].table_size);
263 int done_prohibited = 0;
266 size_t contains_ral = SIZE_MAX;
267 size_t contains_l = SIZE_MAX;
273 k = stringprep_find_string_in_table (ucs4, ucs4len,
276 profile[j].table_size);
283 if (stringprep_find_string_in_table
284 (ucs4, ucs4len, NULL, profile[j].table,
285 profile[j].table_size) != -1)
291 if (stringprep_find_string_in_table
292 (ucs4, ucs4len, NULL, profile[j].table,
293 profile[j].table_size) != -1)
297 if (!done_prohibited || !done_ral || !done_l)
300 if (contains_ral != SIZE_MAX && contains_l != SIZE_MAX)
303 if (contains_ral != SIZE_MAX)
305 if (!(stringprep_find_character_in_table
306 (ucs4[0], profile[contains_ral].table,
307 profile[contains_ral].table_size) != -1
309 stringprep_find_character_in_table (ucs4[ucs4len - 1],
311 [contains_ral].table,
313 [contains_ral].table_size)
332stringprep_4zi_1 (uint32_t * ucs4,
size_t ucs4len,
size_t maxucs4len,
338 rc =
stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
342 if (ucs4len >= maxucs4len)
381 for (ucs4len = 0; ucs4len < maxucs4len && ucs4[ucs4len] != 0; ucs4len++)
384 return stringprep_4zi_1 (ucs4, ucs4len, maxucs4len, flags, profile);
422 uint32_t *ucs4 = NULL;
423 size_t ucs4len, maxucs4len, adducs4len = strlen (in) / 10 + 1;
433 maxucs4len = ucs4len + adducs4len;
434 newp = realloc (ucs4, maxucs4len *
sizeof (uint32_t));
442 rc =
stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
457 if (strlen (utf8) >= maxlen)
501 size_t len = strlen (in) + 1, addlen = len / 10 + 1;
505 if (strcmp (p->
name, profile) == 0)
514 str = (
char *) malloc (len);
char * stringprep_ucs4_to_utf8(const uint32_t *str, ssize_t len, size_t *items_read, size_t *items_written)
uint32_t * stringprep_ucs4_nfkc_normalize(const uint32_t *str, ssize_t len)
uint32_t * stringprep_utf8_to_ucs4(const char *str, ssize_t len, size_t *items_written)
const Stringprep_profiles stringprep_profiles[]
int stringprep_4zi(uint32_t *ucs4, size_t maxucs4len, Stringprep_profile_flags flags, const Stringprep_profile *profile)
int stringprep_4i(uint32_t *ucs4, size_t *len, size_t maxucs4len, Stringprep_profile_flags flags, const Stringprep_profile *profile)
int stringprep_profile(const char *in, char **out, const char *profile, Stringprep_profile_flags flags)
#define UNAPPLICAPLEFLAGS(flags, profileflags)
int stringprep(char *in, size_t maxlen, Stringprep_profile_flags flags, const Stringprep_profile *profile)
@ STRINGPREP_BIDI_PROHIBIT_TABLE
@ STRINGPREP_BIDI_RAL_TABLE
@ STRINGPREP_PROHIBIT_TABLE
@ STRINGPREP_UNASSIGNED_TABLE
@ STRINGPREP_BIDI_L_TABLE
@ STRINGPREP_NO_UNASSIGNED
@ STRINGPREP_UNKNOWN_PROFILE
@ STRINGPREP_TOO_SMALL_BUFFER
@ STRINGPREP_MALLOC_ERROR
@ STRINGPREP_CONTAINS_UNASSIGNED
@ STRINGPREP_CONTAINS_PROHIBITED
@ STRINGPREP_BIDI_CONTAINS_PROHIBITED
@ STRINGPREP_BIDI_BOTH_L_AND_RAL
@ STRINGPREP_BIDI_LEADTRAIL_NOT_RAL
@ STRINGPREP_PROFILE_ERROR
#define STRINGPREP_MAX_MAP_CHARS
const Stringprep_profile * tables
uint32_t map[STRINGPREP_MAX_MAP_CHARS]
Stringprep_profile_steps operation