Wrapper around resource/ulimit.h.
[glibc/history.git] / wcsmbs / wchar.h
blob4c8f9a4dcf7a54e23736d34eb6a71c240f244dac
1 /* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library 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.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * ISO C Standard, Amendment 1, 7.16.4
21 * General wide-string utilities <wchar.h>
24 #ifndef _WCHAR_H
25 #define _WCHAR_H 1
27 #include <features.h>
29 __BEGIN_DECLS
31 /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */
32 #define __need_size_t
33 #define __need_wchar_t
34 #define __need_wint_t
35 #define __need_NULL
36 #include <stddef.h>
39 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
40 there. So define it ourselves if it remains undefined. */
41 #ifndef _WINT_T
42 /* Integral type unchanged by default argument promotions that can
43 hold any value corresponding to members of the extended character
44 set, as well as at least one value that does not correspond to any
45 member of the extended character set. */
46 # define _WINT_T
47 typedef unsigned int wint_t;
48 #endif
51 /* Conversion state information. */
52 typedef struct
54 int count; /* Number of bytes needed for the current character. */
55 wint_t value; /* Value so far. */
56 } mbstate_t;
58 #ifndef WCHAR_MIN
59 /* These constants might also be defined in <inttypes.h>. */
60 # define WCHAR_MIN ((wchar_t) 0)
61 # define WCHAR_MAX (~WCHAR_MIN)
62 #endif
64 #ifndef WEOF
65 # define WEOF (0xffffffffu)
66 #endif
69 /* Copy SRC to DEST. */
70 extern wchar_t *wcscpy __P ((wchar_t *__restrict __dest,
71 __const wchar_t *__restrict __src));
72 /* Copy no more than N wide-characters of SRC to DEST. */
73 extern wchar_t *wcsncpy __P ((wchar_t *__restrict __dest,
74 __const wchar_t *__restrict __src, size_t __n));
76 /* Append SRC onto DEST. */
77 extern wchar_t *wcscat __P ((wchar_t *__restrict __dest,
78 __const wchar_t *__restrict __src));
79 /* Append no more than N wide-characters of SRC onto DEST. */
80 extern wchar_t *wcsncat __P ((wchar_t *__restrict __dest,
81 __const wchar_t *__restrict __src, size_t __n));
83 /* Compare S1 and S2. */
84 extern int wcscmp __P ((__const wchar_t *__s1, __const wchar_t *__s2));
85 /* Compare N wide-characters of S1 and S2. */
86 extern int wcsncmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
87 size_t __n));
89 #ifdef __USE_GNU
90 /* Compare S1 and S2, ignoring case. */
91 extern int __wcscasecmp __P ((__const wchar_t *__s1, __const wchar_t *__s2));
92 extern int wcscasecmp __P ((__const wchar_t *__s1, __const wchar_t *__s2));
94 /* Compare no more than N chars of S1 and S2, ignoring case. */
95 extern int __wcsncasecmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
96 size_t __n));
97 extern int wcsncasecmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
98 size_t __n));
100 /* Similar to the two functions above but take the information from
101 the provided locale and not the global locale. */
102 # include <xlocale.h>
104 extern int __wcscasecmp_l __P ((__const wchar_t *__s1, __const wchar_t *__s2,
105 __locale_t __loc));
107 extern int __wcsncasecmp_l __P ((__const wchar_t *__s1, __const wchar_t *__s2,
108 size_t __n, __locale_t __loc));
109 #endif
111 /* Compare S1 and S2, both interpreted as appropriate to the
112 LC_COLLATE category of the current locale. */
113 extern int wcscoll __P ((__const wchar_t *__s1, __const wchar_t *__s2));
114 /* Transform S2 into array pointed to by S1 such that if wcscmp is
115 applied to two transformed strings the result is the as applying
116 `wcscoll' to the original strings. */
117 extern size_t wcsxfrm __P ((wchar_t *__restrict __s1,
118 __const wchar_t *__restrict __s2, size_t __n));
120 #ifdef __USE_GNU
121 /* Similar to the two functions above but take the information from
122 the provided locale and not the global locale. */
124 /* Compare S1 and S2, both interpreted as appropriate to the
125 LC_COLLATE category of the given locale. */
126 extern int __wcscoll_l __P ((__const wchar_t *__s1, __const wchar_t *__s2,
127 __locale_t __loc));
128 /* Transform S2 into array pointed to by S1 such that if wcscmp is
129 applied to two transformed strings the result is the as applying
130 `wcscoll' to the original strings. */
131 extern size_t __wcsxfrm_l __P ((wchar_t *__s1, __const wchar_t *__s2,
132 size_t __n, __locale_t __loc));
134 /* Duplicate S, returning an identical malloc'd string. */
135 extern wchar_t *wcsdup __P ((__const wchar_t *__s));
136 #endif
138 /* Find the first occurrence of WC in WCS. */
139 extern wchar_t *wcschr __P ((__const wchar_t *__wcs, wchar_t __wc));
140 /* Find the last occurrence of WC in WCS. */
141 extern wchar_t *wcsrchr __P ((__const wchar_t *__wcs, wchar_t __wc));
143 /* Return the length of the initial segmet of WCS which
144 consists entirely of wide characters not in REJECT. */
145 extern size_t wcscspn __P ((__const wchar_t *__wcs,
146 __const wchar_t *__reject));
147 /* Return the length of the initial segmet of WCS which
148 consists entirely of wide characters in ACCEPT. */
149 extern size_t wcsspn __P ((__const wchar_t *__wcs, __const wchar_t *__accept));
150 /* Find the first occurrence in WCS of any character in ACCEPT. */
151 extern wchar_t *wcspbrk __P ((__const wchar_t *__wcs,
152 __const wchar_t *__accept));
153 /* Find the first occurrence of NEEDLE in HAYSTACK. */
154 extern wchar_t *wcsstr __P ((__const wchar_t *__haystack,
155 __const wchar_t *__needle));
156 /* Divide WCS into tokens separated by characters in DELIM. */
157 extern wchar_t *wcstok __P ((wchar_t *__restrict __s,
158 __const wchar_t *__restrict __delim,
159 wchar_t **__restrict __ptr));
161 /* Return the number of wide characters in S. */
162 extern size_t wcslen __P ((__const wchar_t *__s));
165 /* Search N wide characters of S for C. */
166 extern wchar_t *wmemchr __P ((__const wchar_t *__s, wchar_t __c, size_t __n));
168 /* Compare N wide characters of S1 and S2. */
169 extern int wmemcmp __P ((__const wchar_t *__restrict __s1,
170 __const wchar_t *__restrict __s2, size_t __n));
172 /* Copy N wide characters of SRC to DEST. */
173 extern wchar_t *wmemcpy __P ((wchar_t *__restrict __s1,
174 __const wchar_t *__restrict __s2, size_t __n));
176 /* Copy N wide characters of SRC to DEST, guaranteeing
177 correct behavior for overlapping strings. */
178 extern wchar_t *wmemmove __P ((wchar_t *__s1, __const wchar_t *__s2,
179 size_t __n));
181 /* Set N wide characters of S to C. */
182 extern wchar_t *wmemset __P ((wchar_t *__s, wchar_t __c, size_t __n));
185 /* Determine whether C constitutes a valid (one-byte) multibyte
186 character. */
187 extern wint_t btowc __P ((int __c));
189 /* Determine whether C corresponds to a member of the extended
190 character set whose multibyte representation is a single byte. */
191 extern int wctob __P ((wint_t __c));
193 /* Determine whether PS points to an object representing the initial
194 state. */
195 extern int mbsinit __P ((__const mbstate_t *__ps));
197 /* Write wide character representation of multibyte character pointed
198 to by S to PWC. */
199 extern size_t __mbrtowc __P ((wchar_t *__restrict __pwc,
200 __const char *__restrict __s, size_t __n,
201 mbstate_t *__restrict __p));
202 extern size_t mbrtowc __P ((wchar_t *__restrict __pwc,
203 __const char *__restrict __s, size_t __n,
204 mbstate_t *__p));
206 /* Write multibyte representation of wide character WC to S. */
207 extern size_t __wcrtomb __P ((char *__restrict __s, wchar_t __wc,
208 mbstate_t *__restrict __ps));
209 extern size_t wcrtomb __P ((char *__restrict __s, wchar_t __wc,
210 mbstate_t *__restrict __ps));
212 /* Return number of bytes in multibyte character pointed to by S. */
213 extern size_t __mbrlen __P ((__const char *__restrict __s, size_t __n,
214 mbstate_t *__restrict __ps));
215 extern size_t mbrlen __P ((__const char *__restrict __s, size_t __n,
216 mbstate_t *__restrict __ps));
218 #if defined __OPTIMIZE__ \
219 && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
220 /* Define inline function as optimization. */
221 extern __inline size_t mbrlen (__const char *__restrict __s, size_t __n,
222 mbstate_t *__restrict __ps)
223 { return (__ps != NULL
224 ? __mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
225 #endif
227 /* Write wide character representation of multibyte character string
228 SRC to DST. */
229 extern size_t __mbsrtowcs __P ((wchar_t *__restrict __dst,
230 __const char **__restrict __src,
231 size_t __len, mbstate_t *__restrict __ps));
232 extern size_t mbsrtowcs __P ((wchar_t *__restrict __dst,
233 __const char **__restrict __src,
234 size_t __len, mbstate_t *__restrict __ps));
236 /* Write multibyte character representation of wide character string
237 SRC to DST. */
238 extern size_t __wcsrtombs __P ((char *__restrict __dst,
239 __const wchar_t **__restrict __src,
240 size_t __len, mbstate_t *__restrict __ps));
241 extern size_t wcsrtombs __P ((char *__restrict __dst,
242 __const wchar_t **__restrict __src,
243 size_t __len, mbstate_t *__restrict __ps));
246 #ifdef __USE_GNU
247 /* Write wide character representation of at most NMC bytes of the
248 multibyte character string SRC to DST. */
249 extern size_t __mbsnrtowcs __P ((wchar_t *__restrict __dst,
250 __const char **__restrict __src, size_t __nmc,
251 size_t __len, mbstate_t *__restrict __ps));
252 extern size_t mbsnrtowcs __P ((wchar_t *__restrict __dst,
253 __const char **__restrict __src, size_t __nmc,
254 size_t __len, mbstate_t *__restrict __ps));
256 /* Similar function to the above but this does not stop at NUL bytes. */
257 extern size_t __wmemrtowcs __P ((wchar_t *__restrict __dst,
258 __const char **__restrict __src,
259 size_t __nmc, size_t __len,
260 mbstate_t *__restrict __ps));
261 extern size_t wmemrtowcs __P ((wchar_t *__restrict __dst,
262 __const char **__restrict __src,
263 size_t __nmc, size_t __len,
264 mbstate_t *__restrict __ps));
266 /* Write multibyte character representation of at most NWC characters
267 from the wide character string SRC to DST. */
268 extern size_t __wcsnrtombs __P ((char *__restrict __dst,
269 __const wchar_t **__restrict __src,
270 size_t __nwc, size_t __len,
271 mbstate_t *__restrict __ps));
272 extern size_t wcsnrtombs __P ((char *__restrict __dst,
273 __const wchar_t **__restrict __src,
274 size_t __nwc, size_t __len,
275 mbstate_t *__restrict __ps));
277 /* Similar function to the above but this does not stop at NUL bytes. */
278 extern size_t __wmemrtombs __P ((char *__restrict __dst,
279 __const wchar_t **__restrict __src,
280 size_t __nwc, size_t len,
281 mbstate_t *__restrict __ps));
282 extern size_t wmemrtombs __P ((char *__restrict __dst,
283 __const wchar_t **__restrict __src,
284 size_t __nwc, size_t len,
285 mbstate_t *__restrict __ps));
288 /* The following functions are extensions found in X/Open CAE. */
290 /* Determine number of column positions required for C. */
291 extern int wcwidth __P ((wint_t __c));
293 /* Determine number of column positions required for first N wide
294 characters (or fewer if S ends before this) in S. */
295 extern int wcswidth __P ((__const wchar_t *__s, size_t __n));
296 #endif /* use GNU */
299 /* Convert initial portion of the wide string NPTR to `double'
300 representation. */
301 extern double wcstod __P ((__const wchar_t *__restrict __nptr,
302 wchar_t **__restrict __endptr));
304 #ifdef __USE_GNU
305 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
306 extern float wcstof __P ((__const wchar_t *__restrict __nptr,
307 wchar_t **__restrict __endptr));
308 extern __long_double_t wcstold __P ((__const wchar_t *__restrict __nptr,
309 wchar_t **__restrict __endptr));
310 #endif /* GNU */
313 /* Convert initial portion of wide string NPTR to `long int'
314 representation. */
315 extern long int wcstol __P ((__const wchar_t *__restrict __nptr,
316 wchar_t **__restrict __endptr, int __base));
318 /* Convert initial portion of wide string NPTR to `unsigned long int'
319 representation. */
320 extern unsigned long int wcstoul __P ((__const wchar_t *__restrict __nptr,
321 wchar_t **__restrict __endptr,
322 int __base));
324 #if defined __GNUC__ && defined __USE_GNU
325 /* Convert initial portion of wide string NPTR to `long int'
326 representation. */
327 extern long long int wcstoq __P ((__const wchar_t *__restrict __nptr,
328 wchar_t **__restrict __endptr, int __base));
330 /* Convert initial portion of wide string NPTR to `unsigned long long int'
331 representation. */
332 extern unsigned long long int wcstouq __P ((__const wchar_t *__restrict __nptr,
333 wchar_t **__restrict __endptr,
334 int __base));
335 #endif /* GCC and use GNU. */
337 #if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_GNU)
338 /* Convert initial portion of wide string NPTR to `long int'
339 representation. */
340 extern long long int wcstoll __P ((__const wchar_t *__restrict __nptr,
341 wchar_t **__restrict __endptr, int __base));
343 /* Convert initial portion of wide string NPTR to `unsigned long long int'
344 representation. */
345 extern unsigned long long int wcstoull __P ((__const wchar_t *
346 __restrict __nptr,
347 wchar_t **__restrict __endptr,
348 int __base));
349 #endif /* ISO C 9X or GCC and GNU. */
351 #ifdef __USE_GNU
352 /* The concept of one static locale per category is not very well
353 thought out. Many applications will need to process its data using
354 information from several different locales. Another application is
355 the implementation of the internationalization handling in the
356 upcoming ISO C++ standard library. To support this another set of
357 the functions using locale data exist which have an additional
358 argument.
360 Attention: all these functions are *not* standardized in any form.
361 This is a proof-of-concept implementation. */
363 /* Structure for reentrant locale using functions. This is an
364 (almost) opaque type for the user level programs. */
365 # include <xlocale.h>
367 /* Special versions of the functions above which take the locale to
368 use as an additional parameter. */
369 extern long int __wcstol_l __P ((__const wchar_t *__restrict __nptr,
370 wchar_t **__restrict __endptr, int __base,
371 __locale_t __loc));
373 extern unsigned long int __wcstoul_l __P ((__const wchar_t *__restrict __nptr,
374 wchar_t **__restrict __endptr,
375 int __base, __locale_t __loc));
377 extern long long int __wcstoll_l __P ((__const wchar_t *__restrict __nptr,
378 wchar_t **__restrict __endptr,
379 int __base, __locale_t __loc));
381 extern unsigned long long int __wcstoull_l __P ((__const wchar_t *__restrict
382 __nptr,
383 wchar_t **__restrict __endptr,
384 int __base,
385 __locale_t __loc));
387 extern double __wcstod_l __P ((__const wchar_t *__restrict __nptr,
388 wchar_t **__restrict __endptr,
389 __locale_t __loc));
391 extern float __wcstof_l __P ((__const wchar_t *__restrict __nptr,
392 wchar_t **__restrict __endptr,
393 __locale_t __loc));
395 extern __long_double_t __wcstold_l __P ((__const wchar_t *__restrict __nptr,
396 wchar_t **__restrict __endptr,
397 __locale_t __loc));
398 #endif /* GNU */
401 /* The internal entry points for `wcstoX' take an extra flag argument
402 saying whether or not to parse locale-dependent number grouping. */
403 extern double __wcstod_internal __P ((__const wchar_t *__restrict __nptr,
404 wchar_t **__restrict __endptr,
405 int __group));
406 extern float __wcstof_internal __P ((__const wchar_t *__restrict __nptr,
407 wchar_t **__restrict __endptr,
408 int __group));
409 extern __long_double_t __wcstold_internal __P ((__const wchar_t *
410 __restrict __nptr,
411 wchar_t **__restrict __endptr,
412 int __group));
414 #ifndef __wcstol_internal_defined
415 extern long int __wcstol_internal __P ((__const wchar_t *__restrict __nptr,
416 wchar_t **__restrict __endptr,
417 int __base, int __group));
418 # define __wcstol_internal_defined 1
419 #endif
420 #ifndef __wcstoul_internal_defined
421 extern unsigned long int __wcstoul_internal __P ((__const wchar_t *
422 __restrict __nptr,
423 wchar_t **
424 __restrict __endptr,
425 int __base, int __group));
426 # define __wcstoul_internal_defined 1
427 #endif
428 #ifndef __wcstoll_internal_defined
429 extern long long int __wcstoll_internal __P ((__const wchar_t *
430 __restrict __nptr,
431 wchar_t **__restrict __endptr,
432 int __base, int __group));
433 # define __wcstoll_internal_defined 1
434 #endif
435 #ifndef __wcstoull_internal_defined
436 extern unsigned long long int __wcstoull_internal __P ((__const wchar_t *
437 __restrict __nptr,
438 wchar_t **
439 __restrict __endptr,
440 int __base,
441 int __group));
442 # define __wcstoull_internal_defined 1
443 #endif
446 #if defined __OPTIMIZE__ && __GNUC__ >= 2
447 /* Define inline functions which call the internal entry points. */
449 extern __inline double wcstod (__const wchar_t *__restrict __nptr,
450 wchar_t **__restrict __endptr)
451 { return __wcstod_internal (__nptr, __endptr, 0); }
452 extern __inline long int wcstol (__const wchar_t *__restrict __nptr,
453 wchar_t **__restrict __endptr, int __base)
454 { return __wcstol_internal (__nptr, __endptr, __base, 0); }
455 extern __inline unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
456 wchar_t **__restrict __endptr,
457 int __base)
458 { return __wcstoul_internal (__nptr, __endptr, __base, 0); }
460 # ifdef __USE_GNU
461 extern __inline float wcstof (__const wchar_t *__restrict __nptr,
462 wchar_t **__restrict __endptr)
463 { return __wcstof_internal (__nptr, __endptr, 0); }
464 extern __inline __long_double_t wcstold (__const wchar_t *__restrict __nptr,
465 wchar_t **__restrict __endptr)
466 { return __wcstold_internal (__nptr, __endptr, 0); }
469 extern __inline long long int wcstoq (__const wchar_t *__restrict __nptr,
470 wchar_t **__restrict __endptr,
471 int __base)
472 { return __wcstoll_internal (__nptr, __endptr, __base, 0); }
473 extern __inline unsigned long long int wcstouq (__const wchar_t *
474 __restrict __nptr,
475 wchar_t **__restrict __endptr,
476 int __base)
477 { return __wcstoull_internal (__nptr, __endptr, __base, 0); }
478 # endif /* Use GNU. */
479 #endif /* Optimizing GCC >=2. */
482 #ifdef __USE_GNU
483 /* Copy SRC to DEST, returning the address of the terminating L'\0' in
484 DEST. */
485 extern wchar_t *__wcpcpy __P ((wchar_t *__dest, __const wchar_t *__src));
486 extern wchar_t *wcpcpy __P ((wchar_t *__dest, __const wchar_t *__src));
488 /* Copy no more than N characters of SRC to DEST, returning the address of
489 the last character written into DEST. */
490 extern wchar_t *__wcpncpy __P ((wchar_t *__dest, __const wchar_t *__src,
491 size_t __n));
492 extern wchar_t *wcpncpy __P ((wchar_t *__dest, __const wchar_t *__src,
493 size_t __n));
494 #endif /* use GNU */
497 __END_DECLS
499 #endif /* wchar.h */