* lib/utimens.c (gl_futimens): Rename from futimens,
[gnulib.git] / lib / unistr.h
1 /* Elementary Unicode string functions.
2    Copyright (C) 2001-2002, 2005-2007 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify it
5    under the terms of the GNU Library General Public License as published
6    by the Free Software Foundation; either version 2, or (at your option)
7    any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public
15    License along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17    USA.  */
18
19 #ifndef _UNISTR_H
20 #define _UNISTR_H
21
22 #include "unitypes.h"
23
24 /* Get bool.  */
25 #include <stdbool.h>
26
27 /* Get size_t.  */
28 #include <stddef.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34
35 /* Conventions:
36
37    All functions prefixed with u8_ operate on UTF-8 encoded strings.
38    Their unit is an uint8_t (1 byte).
39
40    All functions prefixed with u16_ operate on UTF-16 encoded strings.
41    Their unit is an uint16_t (a 2-byte word).
42
43    All functions prefixed with u32_ operate on UCS-4 encoded strings.
44    Their unit is an uint32_t (a 4-byte word).
45
46    All argument pairs (s, n) denote a Unicode string s[0..n-1] with exactly
47    n units.
48
49    All arguments starting with "str" and the arguments of functions starting
50    with u8_str/u16_str/u32_str denote a NUL terminated string, i.e. a string
51    which terminates at the first NUL unit.  This termination unit is
52    considered part of the string for all memory allocation purposes, but
53    is not considered part of the string for all other logical purposes.
54
55    Functions returning a string result take a (resultbuf, lengthp) argument
56    pair.  If resultbuf is not NULL and the result fits into *lengthp units,
57    it is put in resultbuf, and resultbuf is returned.  Otherwise, a freshly
58    allocated string is returned.  In both cases, *lengthp is set to the
59    length (number of units) of the returned string.  In case of error,
60    NULL is returned and errno is set.  */
61
62
63 /* Elementary string checks.  */
64
65 /* Check whether an UTF-8 string is well-formed.
66    Return NULL if valid, or a pointer to the first invalid unit otherwise.  */
67 extern const uint8_t *
68        u8_check (const uint8_t *s, size_t n);
69
70 /* Check whether an UTF-16 string is well-formed.
71    Return NULL if valid, or a pointer to the first invalid unit otherwise.  */
72 extern const uint16_t *
73        u16_check (const uint16_t *s, size_t n);
74
75 /* Check whether an UCS-4 string is well-formed.
76    Return NULL if valid, or a pointer to the first invalid unit otherwise.  */
77 extern const uint32_t *
78        u32_check (const uint32_t *s, size_t n);
79
80
81 /* Elementary string conversions.  */
82
83 /* Convert an UTF-8 string to an UTF-16 string.  */
84 extern uint16_t *
85        u8_to_u16 (const uint8_t *s, size_t n, uint16_t *resultbuf,
86                   size_t *lengthp);
87
88 /* Convert an UTF-8 string to an UCS-4 string.  */
89 extern uint32_t *
90        u8_to_u32 (const uint8_t *s, size_t n, uint32_t *resultbuf,
91                   size_t *lengthp);
92
93 /* Convert an UTF-16 string to an UTF-8 string.  */
94 extern uint8_t *
95        u16_to_u8 (const uint16_t *s, size_t n, uint8_t *resultbuf,
96                   size_t *lengthp);
97
98 /* Convert an UTF-16 string to an UCS-4 string.  */
99 extern uint32_t *
100        u16_to_u32 (const uint16_t *s, size_t n, uint32_t *resultbuf,
101                    size_t *lengthp);
102
103 /* Convert an UCS-4 string to an UTF-8 string.  */
104 extern uint8_t *
105        u32_to_u8 (const uint32_t *s, size_t n, uint8_t *resultbuf,
106                   size_t *lengthp);
107
108 /* Convert an UCS-4 string to an UTF-16 string.  */
109 extern uint16_t *
110        u32_to_u16 (const uint32_t *s, size_t n, uint16_t *resultbuf,
111                    size_t *lengthp);
112
113
114 /* Elementary string functions.  */
115
116 /* Return the length (number of units) of the first character in S, which is
117    no longer than N.  Return 0 if it is the NUL character.  Return -1 upon
118    failure.  */
119 /* Similar to mblen(), except that s must not be NULL.  */
120 extern int
121        u8_mblen (const uint8_t *s, size_t n);
122 extern int
123        u16_mblen (const uint16_t *s, size_t n);
124 extern int
125        u32_mblen (const uint32_t *s, size_t n);
126
127 /* Return the length (number of units) of the first character in S, putting
128    its 'ucs4_t' representation in *PUC.  Upon failure, *PUC is set to 0xfffd,
129    and an appropriate number of units is returned.
130    The number of available units, N, must be > 0.  */
131 /* Similar to mbtowc(), except that puc and s must not be NULL, n must be > 0,
132    and the NUL character is not treated specially.  */
133 /* The variants with _safe suffix are safe, even if the library is compiled
134    without --enable-safety.  */
135
136 #ifdef GNULIB_UNISTR_U8_MBTOUC_UNSAFE
137 # if !HAVE_INLINE
138 extern int
139        u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n);
140 # else
141 extern int
142        u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n);
143 static inline int
144 u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
145 {
146   uint8_t c = *s;
147
148   if (c < 0x80)
149     {
150       *puc = c;
151       return 1;
152     }
153   else
154     return u8_mbtouc_unsafe_aux (puc, s, n);
155 }
156 # endif
157 #endif
158
159 #ifdef GNULIB_UNISTR_U16_MBTOUC_UNSAFE
160 # if !HAVE_INLINE
161 extern int
162        u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n);
163 # else
164 extern int
165        u16_mbtouc_unsafe_aux (ucs4_t *puc, const uint16_t *s, size_t n);
166 static inline int
167 u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n)
168 {
169   uint16_t c = *s;
170
171   if (c < 0xd800 || c >= 0xe000)
172     {
173       *puc = c;
174       return 1;
175     }
176   else
177     return u16_mbtouc_unsafe_aux (puc, s, n);
178 }
179 # endif
180 #endif
181
182 #ifdef GNULIB_UNISTR_U32_MBTOUC_UNSAFE
183 # if !HAVE_INLINE
184 extern int
185        u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n);
186 # else
187 static inline int
188 u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n)
189 {
190   uint32_t c = *s;
191
192 #  if CONFIG_UNICODE_SAFETY
193   if (c < 0xd800 || (c >= 0xe000 && c < 0x110000))
194 #  endif
195     *puc = c;
196 #  if CONFIG_UNICODE_SAFETY
197   else
198     /* invalid multibyte character */
199     *puc = 0xfffd;
200 #  endif
201   return 1;
202 }
203 # endif
204 #endif
205
206 #ifdef GNULIB_UNISTR_U8_MBTOUC
207 # if !HAVE_INLINE
208 extern int
209        u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n);
210 # else
211 extern int
212        u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n);
213 static inline int
214 u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
215 {
216   uint8_t c = *s;
217
218   if (c < 0x80)
219     {
220       *puc = c;
221       return 1;
222     }
223   else
224     return u8_mbtouc_aux (puc, s, n);
225 }
226 # endif
227 #endif
228
229 #ifdef GNULIB_UNISTR_U16_MBTOUC
230 # if !HAVE_INLINE
231 extern int
232        u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n);
233 # else
234 extern int
235        u16_mbtouc_aux (ucs4_t *puc, const uint16_t *s, size_t n);
236 static inline int
237 u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n)
238 {
239   uint16_t c = *s;
240
241   if (c < 0xd800 || c >= 0xe000)
242     {
243       *puc = c;
244       return 1;
245     }
246   else
247     return u16_mbtouc_aux (puc, s, n);
248 }
249 # endif
250 #endif
251
252 #ifdef GNULIB_UNISTR_U32_MBTOUC
253 # if !HAVE_INLINE
254 extern int
255        u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n);
256 # else
257 static inline int
258 u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n)
259 {
260   uint32_t c = *s;
261
262   if (c < 0xd800 || (c >= 0xe000 && c < 0x110000))
263     *puc = c;
264   else
265     /* invalid multibyte character */
266     *puc = 0xfffd;
267   return 1;
268 }
269 # endif
270 #endif
271
272 /* Return the length (number of units) of the first character in S, putting
273    its 'ucs4_t' representation in *PUC.  Upon failure, *PUC is set to 0xfffd,
274    and -1 is returned for an invalid sequence of units, -2 is returned for an
275    incomplete sequence of units.
276    The number of available units, N, must be > 0.  */
277 /* Similar to u*_mbtouc(), except that the return value gives more details
278    about the failure, similar to mbrtowc().  */
279
280 #ifdef GNULIB_UNISTR_U8_MBTOUCR
281 extern int
282        u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n);
283 #endif
284
285 #ifdef GNULIB_UNISTR_U16_MBTOUCR
286 extern int
287        u16_mbtoucr (ucs4_t *puc, const uint16_t *s, size_t n);
288 #endif
289
290 #ifdef GNULIB_UNISTR_U32_MBTOUCR
291 extern int
292        u32_mbtoucr (ucs4_t *puc, const uint32_t *s, size_t n);
293 #endif
294
295 /* Put the multibyte character represented by UC in S, returning its
296    length.  Return -1 upon failure, -2 if the number of available units, N,
297    is too small.  The latter case cannot occur if N >= 6/2/1, respectively.  */
298 /* Similar to wctomb(), except that s must not be NULL, and the argument n
299    must be specified.  */
300
301 #ifdef GNULIB_UNISTR_U8_UCTOMB
302 # if !HAVE_INLINE
303 extern int
304        u8_uctomb (uint8_t *s, ucs4_t uc, int n);
305 # else
306 extern int
307        u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n);
308 static inline int
309 u8_uctomb (uint8_t *s, ucs4_t uc, int n)
310 {
311   if (uc < 0x80 && n > 0)
312     {
313       s[0] = uc;
314       return 1;
315     }
316   else
317     return u8_uctomb_aux (s, uc, n);
318 }
319 # endif
320 #endif
321
322 #ifdef GNULIB_UNISTR_U16_UCTOMB
323 # if !HAVE_INLINE
324 extern int
325        u16_uctomb (uint16_t *s, ucs4_t uc, int n);
326 # else
327 extern int
328        u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n);
329 static inline int
330 u16_uctomb (uint16_t *s, ucs4_t uc, int n)
331 {
332   if (uc < 0xd800 && n > 0)
333     {
334       s[0] = uc;
335       return 1;
336     }
337   else
338     return u16_uctomb_aux (s, uc, n);
339 }
340 # endif
341 #endif
342
343 #ifdef GNULIB_UNISTR_U32_UCTOMB
344 # if !HAVE_INLINE
345 extern int
346        u32_uctomb (uint32_t *s, ucs4_t uc, int n);
347 # else
348 static inline int
349 u32_uctomb (uint32_t *s, ucs4_t uc, int n)
350 {
351   if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000))
352     {
353       if (n > 0)
354         {
355           *s = uc;
356           return 1;
357         }
358       else
359         return -2;
360     }
361   else
362     return -1;
363 }
364 # endif
365 #endif
366
367 /* Copy N units from SRC to DEST.  */
368 /* Similar to memcpy().  */
369 extern uint8_t *
370        u8_cpy (uint8_t *dest, const uint8_t *src, size_t n);
371 extern uint16_t *
372        u16_cpy (uint16_t *dest, const uint16_t *src, size_t n);
373 extern uint32_t *
374        u32_cpy (uint32_t *dest, const uint32_t *src, size_t n);
375
376 /* Copy N units from SRC to DEST, guaranteeing correct behavior for
377    overlapping memory areas.  */
378 /* Similar to memmove().  */
379 extern uint8_t *
380        u8_move (uint8_t *dest, const uint8_t *src, size_t n);
381 extern uint16_t *
382        u16_move (uint16_t *dest, const uint16_t *src, size_t n);
383 extern uint32_t *
384        u32_move (uint32_t *dest, const uint32_t *src, size_t n);
385
386 /* Set the first N characters of S to UC.  UC should be a character that
387    occupies only 1 unit.  */
388 /* Similar to memset().  */
389 extern uint8_t *
390        u8_set (uint8_t *s, ucs4_t uc, size_t n);
391 extern uint16_t *
392        u16_set (uint16_t *s, ucs4_t uc, size_t n);
393 extern uint32_t *
394        u32_set (uint32_t *s, ucs4_t uc, size_t n);
395
396 /* Compare S1 and S2, each of length N.  */
397 /* Similar to memcmp().  */
398 extern int
399        u8_cmp (const uint8_t *s1, const uint8_t *s2, size_t n);
400 extern int
401        u16_cmp (const uint16_t *s1, const uint16_t *s2, size_t n);
402 extern int
403        u32_cmp (const uint32_t *s1, const uint32_t *s2, size_t n);
404
405 /* Search the string at S for UC.  */
406 /* Similar to memchr().  */
407 extern uint8_t *
408        u8_chr (const uint8_t *s, size_t n, ucs4_t uc);
409 extern uint16_t *
410        u16_chr (const uint16_t *s, size_t n, ucs4_t uc);
411 extern uint32_t *
412        u32_chr (const uint32_t *s, size_t n, ucs4_t uc);
413
414 /* Elementary string functions with memory allocation.  */
415
416 /* Make a freshly allocated copy of S, of length N.  */
417 extern uint8_t *
418        u8_cpy_alloc (const uint8_t *s, size_t n);
419 extern uint16_t *
420        u16_cpy_alloc (const uint16_t *s, size_t n);
421 extern uint32_t *
422        u32_cpy_alloc (const uint32_t *s, size_t n);
423
424 /* Elementary string functions on NUL terminated strings.  */
425
426 /* Return the length (number of units) of the first character in S.
427    Return 0 if it is the NUL character.  Return -1 upon failure.  */
428 extern int
429        u8_strmblen (const uint8_t *s);
430 extern int
431        u16_strmblen (const uint16_t *s);
432 extern int
433        u32_strmblen (const uint32_t *s);
434
435 /* Return the length (number of units) of the first character in S, putting
436    its 'ucs4_t' representation in *PUC.  Return 0 if it is the NUL
437    character.  Return -1 upon failure.  */
438 extern int
439        u8_strmbtouc (ucs4_t *puc, const uint8_t *s);
440 extern int
441        u16_strmbtouc (ucs4_t *puc, const uint16_t *s);
442 extern int
443        u32_strmbtouc (ucs4_t *puc, const uint32_t *s);
444
445 /* Forward iteration step.  Advances the pointer past the next character,
446    or returns NULL if the end of the string has been reached.  Puts the
447    character's 'ucs4_t' representation in *PUC.  */
448 extern const uint8_t *
449        u8_next (ucs4_t *puc, const uint8_t *s);
450 extern const uint16_t *
451        u16_next (ucs4_t *puc, const uint16_t *s);
452 extern const uint32_t *
453        u32_next (ucs4_t *puc, const uint32_t *s);
454
455 /* Backward iteration step.  Advances the pointer to point to the previous
456    character, or returns NULL if the beginning of the string had been reached.
457    Puts the character's 'ucs4_t' representation in *PUC.  */
458 extern const uint8_t *
459        u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start);
460 extern const uint16_t *
461        u16_prev (ucs4_t *puc, const uint16_t *s, const uint16_t *start);
462 extern const uint32_t *
463        u32_prev (ucs4_t *puc, const uint32_t *s, const uint32_t *start);
464
465 /* Return the number of units in S.  */
466 /* Similar to strlen(), wcslen().  */
467 extern size_t
468        u8_strlen (const uint8_t *s);
469 extern size_t
470        u16_strlen (const uint16_t *s);
471 extern size_t
472        u32_strlen (const uint32_t *s);
473
474 /* Return the number of units in S, but at most MAXLEN.  */
475 /* Similar to strnlen(), wcsnlen().  */
476 extern size_t
477        u8_strnlen (const uint8_t *s, size_t maxlen);
478 extern size_t
479        u16_strnlen (const uint16_t *s, size_t maxlen);
480 extern size_t
481        u32_strnlen (const uint32_t *s, size_t maxlen);
482
483 /* Copy SRC to DEST.  */
484 /* Similar to strcpy(), wcscpy().  */
485 extern uint8_t *
486        u8_strcpy (uint8_t *dest, const uint8_t *src);
487 extern uint16_t *
488        u16_strcpy (uint16_t *dest, const uint16_t *src);
489 extern uint32_t *
490        u32_strcpy (uint32_t *dest, const uint32_t *src);
491
492 /* Copy SRC to DEST, returning the address of the terminating NUL in DEST.  */
493 /* Similar to stpcpy().  */
494 extern uint8_t *
495        u8_stpcpy (uint8_t *dest, const uint8_t *src);
496 extern uint16_t *
497        u16_stpcpy (uint16_t *dest, const uint16_t *src);
498 extern uint32_t *
499        u32_stpcpy (uint32_t *dest, const uint32_t *src);
500
501 /* Copy no more than N units of SRC to DEST.  */
502 /* Similar to strncpy(), wcsncpy().  */
503 extern uint8_t *
504        u8_strncpy (uint8_t *dest, const uint8_t *src, size_t n);
505 extern uint16_t *
506        u16_strncpy (uint16_t *dest, const uint16_t *src, size_t n);
507 extern uint32_t *
508        u32_strncpy (uint32_t *dest, const uint32_t *src, size_t n);
509
510 /* Copy no more than N characters of SRC to DEST, returning the address of
511    the last character written into DEST.  */
512 /* Similar to stpncpy().  */
513 extern uint8_t *
514        u8_stpncpy (uint8_t *dest, const uint8_t *src, size_t n);
515 extern uint16_t *
516        u16_stpncpy (uint16_t *dest, const uint16_t *src, size_t n);
517 extern uint32_t *
518        u32_stpncpy (uint32_t *dest, const uint32_t *src, size_t n);
519
520 /* Append SRC onto DEST.  */
521 /* Similar to strcat(), wcscat().  */
522 extern uint8_t *
523        u8_strcat (uint8_t *dest, const uint8_t *src);
524 extern uint16_t *
525        u16_strcat (uint16_t *dest, const uint16_t *src);
526 extern uint32_t *
527        u32_strcat (uint32_t *dest, const uint32_t *src);
528
529 /* Append no more than N units of SRC onto DEST.  */
530 /* Similar to strncat(), wcsncat().  */
531 extern uint8_t *
532        u8_strncat (uint8_t *dest, const uint8_t *src, size_t n);
533 extern uint16_t *
534        u16_strncat (uint16_t *dest, const uint16_t *src, size_t n);
535 extern uint32_t *
536        u32_strncat (uint32_t *dest, const uint32_t *src, size_t n);
537
538 /* Compare S1 and S2.  */
539 /* Similar to strcmp(), wcscmp().  */
540 extern int
541        u8_strcmp (const uint8_t *s1, const uint8_t *s2);
542 extern int
543        u16_strcmp (const uint16_t *s1, const uint16_t *s2);
544 extern int
545        u32_strcmp (const uint32_t *s1, const uint32_t *s2);
546
547 /* Compare no more than N units of S1 and S2.  */
548 /* Similar to strncmp(), wcsncmp().  */
549 extern int
550        u8_strncmp (const uint8_t *s1, const uint8_t *s2, size_t n);
551 extern int
552        u16_strncmp (const uint16_t *s1, const uint16_t *s2, size_t n);
553 extern int
554        u32_strncmp (const uint32_t *s1, const uint32_t *s2, size_t n);
555
556 /* Duplicate S, returning an identical malloc'd string.  */
557 /* Similar to strdup(), wcsdup().  */
558 extern uint8_t *
559        u8_strdup (const uint8_t *s);
560 extern uint16_t *
561        u16_strdup (const uint16_t *s);
562 extern uint32_t *
563        u32_strdup (const uint32_t *s);
564
565 /* Find the first occurrence of UC in STR.  */
566 /* Similar to strchr(), wcschr().  */
567 extern uint8_t *
568        u8_strchr (const uint8_t *str, ucs4_t uc);
569 extern uint16_t *
570        u16_strchr (const uint16_t *str, ucs4_t uc);
571 extern uint32_t *
572        u32_strchr (const uint32_t *str, ucs4_t uc);
573
574 /* Find the last occurrence of UC in STR.  */
575 /* Similar to strrchr(), wcsrchr().  */
576 extern uint8_t *
577        u8_strrchr (const uint8_t *str, ucs4_t uc);
578 extern uint16_t *
579        u16_strrchr (const uint16_t *str, ucs4_t uc);
580 extern uint32_t *
581        u32_strrchr (const uint32_t *str, ucs4_t uc);
582
583 /* Return the length of the initial segment of STR which consists entirely
584    of Unicode characters not in REJECT.  */
585 /* Similar to strcspn(), wcscspn().  */
586 extern size_t
587        u8_strcspn (const uint8_t *str, const uint8_t *reject);
588 extern size_t
589        u16_strcspn (const uint16_t *str, const uint16_t *reject);
590 extern size_t
591        u32_strcspn (const uint32_t *str, const uint32_t *reject);
592
593 /* Return the length of the initial segment of STR which consists entirely
594    of Unicode characters in ACCEPT.  */
595 /* Similar to strspn(), wcsspn().  */
596 extern size_t
597        u8_strspn (const uint8_t *str, const uint8_t *accept);
598 extern size_t
599        u16_strspn (const uint16_t *str, const uint16_t *accept);
600 extern size_t
601        u32_strspn (const uint32_t *str, const uint32_t *accept);
602
603 /* Find the first occurrence in STR of any character in ACCEPT.  */
604 /* Similar to strpbrk(), wcspbrk().  */
605 extern uint8_t *
606        u8_strpbrk (const uint8_t *str, const uint8_t *accept);
607 extern uint16_t *
608        u16_strpbrk (const uint16_t *str, const uint16_t *accept);
609 extern uint32_t *
610        u32_strpbrk (const uint32_t *str, const uint32_t *accept);
611
612 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
613 /* Similar to strstr(), wcsstr().  */
614 extern uint8_t *
615        u8_strstr (const uint8_t *haystack, const uint8_t *needle);
616 extern uint16_t *
617        u16_strstr (const uint16_t *haystack, const uint16_t *needle);
618 extern uint32_t *
619        u32_strstr (const uint32_t *haystack, const uint32_t *needle);
620
621 /* Test whether STR starts with PREFIX.  */
622 extern bool
623        u8_startswith (const uint8_t *str, const uint8_t *prefix);
624 extern bool
625        u16_startswith (const uint16_t *str, const uint16_t *prefix);
626 extern bool
627        u32_startswith (const uint32_t *str, const uint32_t *prefix);
628
629 /* Test whether STR ends with SUFFIX.  */
630 extern bool
631        u8_endswith (const uint8_t *str, const uint8_t *suffix);
632 extern bool
633        u16_endswith (const uint16_t *str, const uint16_t *suffix);
634 extern bool
635        u32_endswith (const uint32_t *str, const uint32_t *suffix);
636
637 /* Divide STR into tokens separated by characters in DELIM.
638    This interface is actually more similar to wcstok than to strtok.  */
639 /* Similar to strtok_r(), wcstok().  */
640 extern uint8_t *
641        u8_strtok (uint8_t *str, const uint8_t *delim, uint8_t **ptr);
642 extern uint16_t *
643        u16_strtok (uint16_t *str, const uint16_t *delim, uint16_t **ptr);
644 extern uint32_t *
645        u32_strtok (uint32_t *str, const uint32_t *delim, uint32_t **ptr);
646
647
648 #ifdef __cplusplus
649 }
650 #endif
651
652 #endif /* _UNISTR_H */