50 stringprep_find_character_in_table (uint32_t ucs4,
82 (
int (*)(
const void *,
const void *)) _compare_table_element);
84 return p ? (p - table) : -1;
88 stringprep_find_string_in_table (uint32_t *ucs4,
97 for (j = 0; j < ucs4len; j++)
99 stringprep_find_character_in_table (ucs4[j], table,
111 stringprep_apply_table_to_string (uint32_t *ucs4,
119 uint32_t *src = ucs4;
120 size_t srclen = *ucs4len;
122 while ((pos = stringprep_find_string_in_table (src, srclen,
127 maplen > 0 && table[i].
map[maplen - 1] == 0; maplen--)
130 if (*ucs4len - 1 + maplen >= maxucs4len)
133 memmove (src + pos + maplen, src + pos + 1,
134 sizeof (uint32_t) * (srclen - pos - 1));
135 memcpy (src + pos, table[i].map,
sizeof (uint32_t) * maplen);
136 *ucs4len = *ucs4len - 1 + maplen;
144 #define INVERTED(x) ((x) & ((~0UL) >> 1))
145 #define UNAPPLICAPLEFLAGS(flags, profileflags) \
146 ((!INVERTED(profileflags) && !(profileflags & flags) && profileflags) || \
147 ( INVERTED(profileflags) && (profileflags & flags)))
187 size_t ucs4len = *len;
192 switch (profile[i].operation)
209 for (ucs4len = 0; q[ucs4len]; ucs4len++)
212 if (ucs4len >= maxucs4len)
218 memcpy (ucs4, q, ucs4len *
sizeof (ucs4[0]));
225 k = stringprep_find_string_in_table (ucs4, ucs4len,
226 NULL, profile[i].table,
227 profile[i].table_size);
237 k = stringprep_find_string_in_table
238 (ucs4, ucs4len, NULL, profile[i].table,
239 profile[i].table_size);
248 rc = stringprep_apply_table_to_string
249 (ucs4, &ucs4len, maxucs4len, profile[i].table,
250 profile[i].table_size);
262 int done_prohibited = 0;
265 size_t contains_ral = SIZE_MAX;
266 size_t contains_l = SIZE_MAX;
272 k = stringprep_find_string_in_table (ucs4, ucs4len,
275 profile[j].table_size);
282 if (stringprep_find_string_in_table
283 (ucs4, ucs4len, NULL, profile[j].table,
284 profile[j].table_size) != -1)
290 if (stringprep_find_string_in_table
291 (ucs4, ucs4len, NULL, profile[j].table,
292 profile[j].table_size) != -1)
296 if (!done_prohibited || !done_ral || !done_l)
299 if (contains_ral != SIZE_MAX && contains_l != SIZE_MAX)
302 if (contains_ral != SIZE_MAX)
304 if (!(stringprep_find_character_in_table
305 (ucs4[0], profile[contains_ral].table,
306 profile[contains_ral].table_size) != -1
308 stringprep_find_character_in_table (ucs4[ucs4len - 1],
310 [contains_ral].table,
312 [contains_ral].table_size)
331 stringprep_4zi_1 (uint32_t *ucs4,
size_t ucs4len,
size_t maxucs4len,
337 rc =
stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
341 if (ucs4len >= maxucs4len)
380 for (ucs4len = 0; ucs4len < maxucs4len && ucs4[ucs4len] != 0; ucs4len++)
383 return stringprep_4zi_1 (ucs4, ucs4len, maxucs4len, flags, profile);
420 uint32_t *ucs4 = NULL;
421 size_t ucs4len, maxucs4len, adducs4len = strlen (in) / 10 + 1;
431 maxucs4len = ucs4len + adducs4len;
432 newp = realloc (ucs4, maxucs4len *
sizeof (uint32_t));
440 rc =
stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
455 if (strlen (utf8) >= maxlen)
499 size_t len = strlen (in) + 1, addlen = len / 10 + 1;
503 if (strcmp (p->
name, profile) == 0)
512 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_utf8_to_ucs4(const char *str, ssize_t len, size_t *items_written)
uint32_t * stringprep_ucs4_nfkc_normalize(const uint32_t *str, ssize_t len)
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