chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / wcsmbs / wchar.h
1 /* Copyright (C) 1995-2008, 2009 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
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    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18
19 /*
20  *      ISO C99 Standard: 7.24
21  *      Extended multibyte and wide character utilities <wchar.h>
22  */
23
24 #ifndef _WCHAR_H
25
26 #if !defined __need_mbstate_t && !defined __need_wint_t
27 # define _WCHAR_H 1
28 # include <features.h>
29 #endif
30
31 #ifdef _WCHAR_H
32 /* Get FILE definition.  */
33 # define __need___FILE
34 # if defined __USE_UNIX98 || defined __USE_XOPEN2K
35 #  define __need_FILE
36 # endif
37 # include <stdio.h>
38 /* Get va_list definition.  */
39 # define __need___va_list
40 # include <stdarg.h>
41
42 # include <bits/wchar.h>
43
44 /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>.  */
45 # define __need_size_t
46 # define __need_wchar_t
47 # define __need_NULL
48 #endif
49 #if defined _WCHAR_H || defined __need_wint_t || !defined __WINT_TYPE__
50 # undef __need_wint_t
51 # define __need_wint_t
52 # include <stddef.h>
53
54 /* Tell the caller that we provide correct C++ prototypes.  */
55 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
56 # define __CORRECT_ISO_CPP_WCHAR_H_PROTO
57 #endif
58
59 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
60    there.  So define it ourselves if it remains undefined.  */
61 # ifndef _WINT_T
62 /* Integral type unchanged by default argument promotions that can
63    hold any value corresponding to members of the extended character
64    set, as well as at least one value that does not correspond to any
65    member of the extended character set.  */
66 #  define _WINT_T
67 typedef unsigned int wint_t;
68 # else
69 /* Work around problems with the <stddef.h> file which doesn't put
70    wint_t in the std namespace.  */
71 #  if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \
72       && defined __WINT_TYPE__
73 __BEGIN_NAMESPACE_STD
74 typedef __WINT_TYPE__ wint_t;
75 __END_NAMESPACE_STD
76 #  endif
77 # endif
78 #endif
79
80 #if (defined _WCHAR_H || defined __need_mbstate_t) && !defined __mbstate_t_defined
81 # define __mbstate_t_defined    1
82 /* Conversion state information.  */
83 typedef struct
84 {
85   int __count;
86   union
87   {
88 # ifdef __WINT_TYPE__
89     __WINT_TYPE__ __wch;
90 # else
91     wint_t __wch;
92 # endif
93     char __wchb[4];
94   } __value;            /* Value so far.  */
95 } __mbstate_t;
96 #endif
97 #undef __need_mbstate_t
98
99
100 /* The rest of the file is only used if used if __need_mbstate_t is not
101    defined.  */
102 #ifdef _WCHAR_H
103
104 __BEGIN_NAMESPACE_C99
105 /* Public type.  */
106 typedef __mbstate_t mbstate_t;
107 __END_NAMESPACE_C99
108 #ifdef __USE_GNU
109 __USING_NAMESPACE_C99(mbstate_t)
110 #endif
111
112 #ifndef WCHAR_MIN
113 /* These constants might also be defined in <inttypes.h>.  */
114 # define WCHAR_MIN __WCHAR_MIN
115 # define WCHAR_MAX __WCHAR_MAX
116 #endif
117
118 #ifndef WEOF
119 # define WEOF (0xffffffffu)
120 #endif
121
122 /* For XPG4 compliance we have to define the stuff from <wctype.h> here
123    as well.  */
124 #if defined __USE_XOPEN && !defined __USE_UNIX98
125 # include <wctype.h>
126 #endif
127
128
129 __BEGIN_DECLS
130
131 __BEGIN_NAMESPACE_STD
132 /* This incomplete type is defined in <time.h> but needed here because
133    of `wcsftime'.  */
134 struct tm;
135 __END_NAMESPACE_STD
136 /* XXX We have to clean this up at some point.  Since tm is in the std
137    namespace but wcsftime is in __c99 the type wouldn't be found
138    without inserting it in the global namespace.  */
139 __USING_NAMESPACE_STD(tm)
140
141
142 __BEGIN_NAMESPACE_STD
143 /* Copy SRC to DEST.  */
144 extern wchar_t *wcscpy (wchar_t *__restrict __dest,
145                         __const wchar_t *__restrict __src) __THROW;
146 /* Copy no more than N wide-characters of SRC to DEST.  */
147 extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
148                          __const wchar_t *__restrict __src, size_t __n)
149      __THROW;
150
151 /* Append SRC onto DEST.  */
152 extern wchar_t *wcscat (wchar_t *__restrict __dest,
153                         __const wchar_t *__restrict __src) __THROW;
154 /* Append no more than N wide-characters of SRC onto DEST.  */
155 extern wchar_t *wcsncat (wchar_t *__restrict __dest,
156                          __const wchar_t *__restrict __src, size_t __n)
157      __THROW;
158
159 /* Compare S1 and S2.  */
160 extern int wcscmp (__const wchar_t *__s1, __const wchar_t *__s2)
161      __THROW __attribute_pure__;
162 /* Compare N wide-characters of S1 and S2.  */
163 extern int wcsncmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n)
164      __THROW __attribute_pure__;
165 __END_NAMESPACE_STD
166
167 #ifdef __USE_XOPEN2K8
168 /* Compare S1 and S2, ignoring case.  */
169 extern int wcscasecmp (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
170
171 /* Compare no more than N chars of S1 and S2, ignoring case.  */
172 extern int wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2,
173                         size_t __n) __THROW;
174
175 /* Similar to the two functions above but take the information from
176    the provided locale and not the global locale.  */
177 # include <xlocale.h>
178
179 extern int wcscasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
180                          __locale_t __loc) __THROW;
181
182 extern int wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
183                           size_t __n, __locale_t __loc) __THROW;
184 #endif
185
186 __BEGIN_NAMESPACE_STD
187 /* Compare S1 and S2, both interpreted as appropriate to the
188    LC_COLLATE category of the current locale.  */
189 extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
190 /* Transform S2 into array pointed to by S1 such that if wcscmp is
191    applied to two transformed strings the result is the as applying
192    `wcscoll' to the original strings.  */
193 extern size_t wcsxfrm (wchar_t *__restrict __s1,
194                        __const wchar_t *__restrict __s2, size_t __n) __THROW;
195 __END_NAMESPACE_STD
196
197 #ifdef __USE_XOPEN2K8
198 /* Similar to the two functions above but take the information from
199    the provided locale and not the global locale.  */
200
201 /* Compare S1 and S2, both interpreted as appropriate to the
202    LC_COLLATE category of the given locale.  */
203 extern int wcscoll_l (__const wchar_t *__s1, __const wchar_t *__s2,
204                       __locale_t __loc) __THROW;
205
206 /* Transform S2 into array pointed to by S1 such that if wcscmp is
207    applied to two transformed strings the result is the as applying
208    `wcscoll' to the original strings.  */
209 extern size_t wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2,
210                          size_t __n, __locale_t __loc) __THROW;
211
212 /* Duplicate S, returning an identical malloc'd string.  */
213 extern wchar_t *wcsdup (__const wchar_t *__s) __THROW __attribute_malloc__;
214 #endif
215
216 __BEGIN_NAMESPACE_STD
217 /* Find the first occurrence of WC in WCS.  */
218 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
219 extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc)
220      __THROW __asm ("wcschr") __attribute_pure__;
221 extern "C++" __const wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
222      __THROW __asm ("wcschr")  __attribute_pure__;
223 #else
224 extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
225      __THROW __attribute_pure__;
226 #endif
227 /* Find the last occurrence of WC in WCS.  */
228 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
229 extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc)
230      __THROW __asm ("wcsrchr") __attribute_pure__;
231 extern "C++" __const wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
232      __THROW __asm ("wcsrchr") __attribute_pure__;
233 #else
234 extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
235      __THROW __attribute_pure__;
236 #endif
237 __END_NAMESPACE_STD
238
239 #ifdef __USE_GNU
240 /* This function is similar to `wcschr'.  But it returns a pointer to
241    the closing NUL wide character in case C is not found in S.  */
242 extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc)
243      __THROW __attribute_pure__;
244 #endif
245
246 __BEGIN_NAMESPACE_STD
247 /* Return the length of the initial segmet of WCS which
248    consists entirely of wide characters not in REJECT.  */
249 extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject)
250      __THROW __attribute_pure__;
251 /* Return the length of the initial segmet of WCS which
252    consists entirely of wide characters in  ACCEPT.  */
253 extern size_t wcsspn (__const wchar_t *__wcs, __const wchar_t *__accept)
254      __THROW __attribute_pure__;
255 /* Find the first occurrence in WCS of any character in ACCEPT.  */
256 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
257 extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, __const wchar_t *__accept)
258      __THROW __asm ("wcspbrk") __attribute_pure__;
259 extern "C++" __const wchar_t *wcspbrk (__const wchar_t *__wcs,
260                                        __const wchar_t *__accept)
261      __THROW __asm ("wcspbrk") __attribute_pure__;
262 #else
263 extern wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept)
264      __THROW __attribute_pure__;
265 #endif
266 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
267 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
268 extern "C++" wchar_t *wcsstr (wchar_t *__haystack, __const wchar_t *__needle)
269      __THROW __asm ("wcsstr") __attribute_pure__;
270 extern "C++" __const wchar_t *wcsstr (__const wchar_t *__haystack,
271                                       __const wchar_t *__needle)
272      __THROW __asm ("wcsstr") __attribute_pure__;
273 #else
274 extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle)
275      __THROW __attribute_pure__;
276 #endif
277
278 /* Divide WCS into tokens separated by characters in DELIM.  */
279 extern wchar_t *wcstok (wchar_t *__restrict __s,
280                         __const wchar_t *__restrict __delim,
281                         wchar_t **__restrict __ptr) __THROW;
282
283 /* Return the number of wide characters in S.  */
284 extern size_t wcslen (__const wchar_t *__s) __THROW __attribute_pure__;
285 __END_NAMESPACE_STD
286
287 #ifdef __USE_XOPEN
288 /* Another name for `wcsstr' from XPG4.  */
289 # ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
290 extern "C++" wchar_t *wcswcs (wchar_t *__haystack, __const wchar_t *__needle)
291      __THROW __asm ("wcswcs") __attribute_pure__;
292 extern "C++" __const wchar_t *wcswcs (__const wchar_t *__haystack,
293                                       __const wchar_t *__needle)
294      __THROW __asm ("wcswcs") __attribute_pure__;
295 # else
296 extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle)
297      __THROW __attribute_pure__;
298 # endif
299 #endif
300
301 #ifdef __USE_XOPEN2K8
302 /* Return the number of wide characters in S, but at most MAXLEN.  */
303 extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen)
304      __THROW __attribute_pure__;
305 #endif
306
307
308 __BEGIN_NAMESPACE_STD
309 /* Search N wide characters of S for C.  */
310 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
311 extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
312      __THROW __asm ("wmemchr") __attribute_pure__;
313 extern "C++" __const wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c,
314                                        size_t __n)
315      __THROW __asm ("wmemchr") __attribute_pure__;
316 #else
317 extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n)
318      __THROW __attribute_pure__;
319 #endif
320
321 /* Compare N wide characters of S1 and S2.  */
322 extern int wmemcmp (__const wchar_t *__restrict __s1,
323                     __const wchar_t *__restrict __s2, size_t __n)
324      __THROW __attribute_pure__;
325
326 /* Copy N wide characters of SRC to DEST.  */
327 extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
328                          __const wchar_t *__restrict __s2, size_t __n) __THROW;
329
330 /* Copy N wide characters of SRC to DEST, guaranteeing
331    correct behavior for overlapping strings.  */
332 extern wchar_t *wmemmove (wchar_t *__s1, __const wchar_t *__s2, size_t __n)
333      __THROW;
334
335 /* Set N wide characters of S to C.  */
336 extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
337 __END_NAMESPACE_STD
338
339 #ifdef __USE_GNU
340 /* Copy N wide characters of SRC to DEST and return pointer to following
341    wide character.  */
342 extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
343                           __const wchar_t *__restrict __s2, size_t __n)
344      __THROW;
345 #endif
346
347
348 __BEGIN_NAMESPACE_STD
349 /* Determine whether C constitutes a valid (one-byte) multibyte
350    character.  */
351 extern wint_t btowc (int __c) __THROW;
352
353 /* Determine whether C corresponds to a member of the extended
354    character set whose multibyte representation is a single byte.  */
355 extern int wctob (wint_t __c) __THROW;
356
357 /* Determine whether PS points to an object representing the initial
358    state.  */
359 extern int mbsinit (__const mbstate_t *__ps) __THROW __attribute_pure__;
360
361 /* Write wide character representation of multibyte character pointed
362    to by S to PWC.  */
363 extern size_t mbrtowc (wchar_t *__restrict __pwc,
364                        __const char *__restrict __s, size_t __n,
365                        mbstate_t *__p) __THROW;
366
367 /* Write multibyte representation of wide character WC to S.  */
368 extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
369                        mbstate_t *__restrict __ps) __THROW;
370
371 /* Return number of bytes in multibyte character pointed to by S.  */
372 extern size_t __mbrlen (__const char *__restrict __s, size_t __n,
373                         mbstate_t *__restrict __ps) __THROW;
374 extern size_t mbrlen (__const char *__restrict __s, size_t __n,
375                       mbstate_t *__restrict __ps) __THROW;
376 __END_NAMESPACE_STD
377
378 #ifdef __USE_EXTERN_INLINES
379 /* Define inline function as optimization.  */
380
381 /* We can use the BTOWC and WCTOB optimizations since we know that all
382    locales must use ASCII encoding for the values in the ASCII range
383    and because the wchar_t encoding is always ISO 10646.  */
384 extern wint_t __btowc_alias (int __c) __asm ("btowc");
385 __extern_inline wint_t
386 __NTH (btowc (int __c))
387 { return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f'
388           ? (wint_t) __c : __btowc_alias (__c)); }
389
390 extern int __wctob_alias (wint_t __c) __asm ("wctob");
391 __extern_inline int
392 __NTH (wctob (wint_t __wc))
393 { return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
394           ? (int) __wc : __wctob_alias (__wc)); }
395
396 __extern_inline size_t
397 __NTH (mbrlen (__const char *__restrict __s, size_t __n,
398                mbstate_t *__restrict __ps))
399 { return (__ps != NULL
400           ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
401 #endif
402
403 __BEGIN_NAMESPACE_STD
404 /* Write wide character representation of multibyte character string
405    SRC to DST.  */
406 extern size_t mbsrtowcs (wchar_t *__restrict __dst,
407                          __const char **__restrict __src, size_t __len,
408                          mbstate_t *__restrict __ps) __THROW;
409
410 /* Write multibyte character representation of wide character string
411    SRC to DST.  */
412 extern size_t wcsrtombs (char *__restrict __dst,
413                          __const wchar_t **__restrict __src, size_t __len,
414                          mbstate_t *__restrict __ps) __THROW;
415 __END_NAMESPACE_STD
416
417
418 #ifdef  __USE_XOPEN2K8
419 /* Write wide character representation of at most NMC bytes of the
420    multibyte character string SRC to DST.  */
421 extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
422                           __const char **__restrict __src, size_t __nmc,
423                           size_t __len, mbstate_t *__restrict __ps) __THROW;
424
425 /* Write multibyte character representation of at most NWC characters
426    from the wide character string SRC to DST.  */
427 extern size_t wcsnrtombs (char *__restrict __dst,
428                           __const wchar_t **__restrict __src,
429                           size_t __nwc, size_t __len,
430                           mbstate_t *__restrict __ps) __THROW;
431 #endif  /* use POSIX 2008 */
432
433
434 /* The following functions are extensions found in X/Open CAE.  */
435 #ifdef __USE_XOPEN
436 /* Determine number of column positions required for C.  */
437 extern int wcwidth (wchar_t __c) __THROW;
438
439 /* Determine number of column positions required for first N wide
440    characters (or fewer if S ends before this) in S.  */
441 extern int wcswidth (__const wchar_t *__s, size_t __n) __THROW;
442 #endif  /* Use X/Open.  */
443
444
445 __BEGIN_NAMESPACE_STD
446 /* Convert initial portion of the wide string NPTR to `double'
447    representation.  */
448 extern double wcstod (__const wchar_t *__restrict __nptr,
449                       wchar_t **__restrict __endptr) __THROW;
450 __END_NAMESPACE_STD
451
452 #ifdef __USE_ISOC99
453 __BEGIN_NAMESPACE_C99
454 /* Likewise for `float' and `long double' sizes of floating-point numbers.  */
455 extern float wcstof (__const wchar_t *__restrict __nptr,
456                      wchar_t **__restrict __endptr) __THROW;
457 extern long double wcstold (__const wchar_t *__restrict __nptr,
458                             wchar_t **__restrict __endptr) __THROW;
459 __END_NAMESPACE_C99
460 #endif /* C99 */
461
462
463 __BEGIN_NAMESPACE_STD
464 /* Convert initial portion of wide string NPTR to `long int'
465    representation.  */
466 extern long int wcstol (__const wchar_t *__restrict __nptr,
467                         wchar_t **__restrict __endptr, int __base) __THROW;
468
469 /* Convert initial portion of wide string NPTR to `unsigned long int'
470    representation.  */
471 extern unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
472                                   wchar_t **__restrict __endptr, int __base)
473      __THROW;
474 __END_NAMESPACE_STD
475
476 #if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU)
477 __BEGIN_NAMESPACE_C99
478 /* Convert initial portion of wide string NPTR to `long long int'
479    representation.  */
480 __extension__
481 extern long long int wcstoll (__const wchar_t *__restrict __nptr,
482                               wchar_t **__restrict __endptr, int __base)
483      __THROW;
484
485 /* Convert initial portion of wide string NPTR to `unsigned long long int'
486    representation.  */
487 __extension__
488 extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr,
489                                         wchar_t **__restrict __endptr,
490                                         int __base) __THROW;
491 __END_NAMESPACE_C99
492 #endif /* ISO C99 or GCC and GNU.  */
493
494 #if defined __GNUC__ && defined __USE_GNU
495 /* Convert initial portion of wide string NPTR to `long long int'
496    representation.  */
497 __extension__
498 extern long long int wcstoq (__const wchar_t *__restrict __nptr,
499                              wchar_t **__restrict __endptr, int __base)
500      __THROW;
501
502 /* Convert initial portion of wide string NPTR to `unsigned long long int'
503    representation.  */
504 __extension__
505 extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
506                                        wchar_t **__restrict __endptr,
507                                        int __base) __THROW;
508 #endif /* GCC and use GNU.  */
509
510 #ifdef __USE_GNU
511 /* The concept of one static locale per category is not very well
512    thought out.  Many applications will need to process its data using
513    information from several different locales.  Another application is
514    the implementation of the internationalization handling in the
515    upcoming ISO C++ standard library.  To support this another set of
516    the functions using locale data exist which have an additional
517    argument.
518
519    Attention: all these functions are *not* standardized in any form.
520    This is a proof-of-concept implementation.  */
521
522 /* Structure for reentrant locale using functions.  This is an
523    (almost) opaque type for the user level programs.  */
524 # include <xlocale.h>
525
526 /* Special versions of the functions above which take the locale to
527    use as an additional parameter.  */
528 extern long int wcstol_l (__const wchar_t *__restrict __nptr,
529                           wchar_t **__restrict __endptr, int __base,
530                           __locale_t __loc) __THROW;
531
532 extern unsigned long int wcstoul_l (__const wchar_t *__restrict __nptr,
533                                     wchar_t **__restrict __endptr,
534                                     int __base, __locale_t __loc) __THROW;
535
536 __extension__
537 extern long long int wcstoll_l (__const wchar_t *__restrict __nptr,
538                                 wchar_t **__restrict __endptr,
539                                 int __base, __locale_t __loc) __THROW;
540
541 __extension__
542 extern unsigned long long int wcstoull_l (__const wchar_t *__restrict __nptr,
543                                           wchar_t **__restrict __endptr,
544                                           int __base, __locale_t __loc)
545      __THROW;
546
547 extern double wcstod_l (__const wchar_t *__restrict __nptr,
548                         wchar_t **__restrict __endptr, __locale_t __loc)
549      __THROW;
550
551 extern float wcstof_l (__const wchar_t *__restrict __nptr,
552                        wchar_t **__restrict __endptr, __locale_t __loc)
553      __THROW;
554
555 extern long double wcstold_l (__const wchar_t *__restrict __nptr,
556                               wchar_t **__restrict __endptr,
557                               __locale_t __loc) __THROW;
558 #endif /* GNU */
559
560
561 #ifdef  __USE_XOPEN2K8
562 /* Copy SRC to DEST, returning the address of the terminating L'\0' in
563    DEST.  */
564 extern wchar_t *wcpcpy (wchar_t *__dest, __const wchar_t *__src) __THROW;
565
566 /* Copy no more than N characters of SRC to DEST, returning the address of
567    the last character written into DEST.  */
568 extern wchar_t *wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)
569      __THROW;
570 #endif  /* use GNU */
571
572
573 /* Wide character I/O functions.  */
574
575 #ifdef  __USE_XOPEN2K8
576 /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
577    a wide character string.  */
578 extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW;
579 #endif
580
581 #if defined __USE_ISOC95 || defined __USE_UNIX98
582 __BEGIN_NAMESPACE_STD
583
584 /* Select orientation for stream.  */
585 extern int fwide (__FILE *__fp, int __mode) __THROW;
586
587
588 /* Write formatted output to STREAM.
589
590    This function is a possible cancellation point and therefore not
591    marked with __THROW.  */
592 extern int fwprintf (__FILE *__restrict __stream,
593                      __const wchar_t *__restrict __format, ...)
594      /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
595 /* Write formatted output to stdout.
596
597    This function is a possible cancellation point and therefore not
598    marked with __THROW.  */
599 extern int wprintf (__const wchar_t *__restrict __format, ...)
600      /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
601 /* Write formatted output of at most N characters to S.  */
602 extern int swprintf (wchar_t *__restrict __s, size_t __n,
603                      __const wchar_t *__restrict __format, ...)
604      __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
605
606 /* Write formatted output to S from argument list ARG.
607
608    This function is a possible cancellation point and therefore not
609    marked with __THROW.  */
610 extern int vfwprintf (__FILE *__restrict __s,
611                       __const wchar_t *__restrict __format,
612                       __gnuc_va_list __arg)
613      /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
614 /* Write formatted output to stdout from argument list ARG.
615
616    This function is a possible cancellation point and therefore not
617    marked with __THROW.  */
618 extern int vwprintf (__const wchar_t *__restrict __format,
619                      __gnuc_va_list __arg)
620      /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
621 /* Write formatted output of at most N character to S from argument
622    list ARG.  */
623 extern int vswprintf (wchar_t *__restrict __s, size_t __n,
624                       __const wchar_t *__restrict __format,
625                       __gnuc_va_list __arg)
626      __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
627
628
629 /* Read formatted input from STREAM.
630
631    This function is a possible cancellation point and therefore not
632    marked with __THROW.  */
633 extern int fwscanf (__FILE *__restrict __stream,
634                     __const wchar_t *__restrict __format, ...)
635      /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
636 /* Read formatted input from stdin.
637
638    This function is a possible cancellation point and therefore not
639    marked with __THROW.  */
640 extern int wscanf (__const wchar_t *__restrict __format, ...)
641      /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
642 /* Read formatted input from S.  */
643 extern int swscanf (__const wchar_t *__restrict __s,
644                     __const wchar_t *__restrict __format, ...)
645      __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
646
647 # if defined __USE_ISOC99 && !defined __USE_GNU \
648      && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
649      && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
650 #  ifdef __REDIRECT
651 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
652    GNU extension which conflicts with valid %a followed by letter
653    s, S or [.  */
654 extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
655                                  __const wchar_t *__restrict __format, ...),
656                        __isoc99_fwscanf)
657      /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
658 extern int __REDIRECT (wscanf, (__const wchar_t *__restrict __format, ...),
659                        __isoc99_wscanf)
660      /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
661 extern int __REDIRECT_NTH (swscanf, (__const wchar_t *__restrict __s,
662                                      __const wchar_t *__restrict __format,
663                                      ...), __isoc99_swscanf)
664      /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
665 #  else
666 extern int __isoc99_fwscanf (__FILE *__restrict __stream,
667                              __const wchar_t *__restrict __format, ...);
668 extern int __isoc99_wscanf (__const wchar_t *__restrict __format, ...);
669 extern int __isoc99_swscanf (__const wchar_t *__restrict __s,
670                              __const wchar_t *__restrict __format, ...)
671      __THROW;
672 #   define fwscanf __isoc99_fwscanf
673 #   define wscanf __isoc99_wscanf
674 #   define swscanf __isoc99_swscanf
675 #  endif
676 # endif
677
678 __END_NAMESPACE_STD
679 #endif /* Use ISO C95, C99 and Unix98. */
680
681 #ifdef __USE_ISOC99
682 __BEGIN_NAMESPACE_C99
683 /* Read formatted input from S into argument list ARG.
684
685    This function is a possible cancellation point and therefore not
686    marked with __THROW.  */
687 extern int vfwscanf (__FILE *__restrict __s,
688                      __const wchar_t *__restrict __format,
689                      __gnuc_va_list __arg)
690      /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
691 /* Read formatted input from stdin into argument list ARG.
692
693    This function is a possible cancellation point and therefore not
694    marked with __THROW.  */
695 extern int vwscanf (__const wchar_t *__restrict __format,
696                     __gnuc_va_list __arg)
697      /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
698 /* Read formatted input from S into argument list ARG.  */
699 extern int vswscanf (__const wchar_t *__restrict __s,
700                      __const wchar_t *__restrict __format,
701                      __gnuc_va_list __arg)
702      __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
703
704 # if !defined __USE_GNU \
705      && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
706      && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
707 #  ifdef __REDIRECT
708 extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
709                                   __const wchar_t *__restrict __format,
710                                   __gnuc_va_list __arg), __isoc99_vfwscanf)
711      /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
712 extern int __REDIRECT (vwscanf, (__const wchar_t *__restrict __format,
713                                  __gnuc_va_list __arg), __isoc99_vwscanf)
714      /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
715 extern int __REDIRECT_NTH (vswscanf, (__const wchar_t *__restrict __s,
716                                       __const wchar_t *__restrict __format,
717                                       __gnuc_va_list __arg), __isoc99_vswscanf)
718      /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
719 #  else
720 extern int __isoc99_vfwscanf (__FILE *__restrict __s,
721                               __const wchar_t *__restrict __format,
722                               __gnuc_va_list __arg);
723 extern int __isoc99_vwscanf (__const wchar_t *__restrict __format,
724                              __gnuc_va_list __arg);
725 extern int __isoc99_vswscanf (__const wchar_t *__restrict __s,
726                               __const wchar_t *__restrict __format,
727                               __gnuc_va_list __arg) __THROW;
728 #   define vfwscanf __isoc99_vfwscanf
729 #   define vwscanf __isoc99_vwscanf
730 #   define vswscanf __isoc99_vswscanf
731 #  endif
732 # endif
733
734 __END_NAMESPACE_C99
735 #endif /* Use ISO C99. */
736
737
738 __BEGIN_NAMESPACE_STD
739 /* Read a character from STREAM.
740
741    These functions are possible cancellation points and therefore not
742    marked with __THROW.  */
743 extern wint_t fgetwc (__FILE *__stream);
744 extern wint_t getwc (__FILE *__stream);
745
746 /* Read a character from stdin.
747
748    This function is a possible cancellation point and therefore not
749    marked with __THROW.  */
750 extern wint_t getwchar (void);
751
752
753 /* Write a character to STREAM.
754
755    These functions are possible cancellation points and therefore not
756    marked with __THROW.  */
757 extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
758 extern wint_t putwc (wchar_t __wc, __FILE *__stream);
759
760 /* Write a character to stdout.
761
762    This function is a possible cancellation points and therefore not
763    marked with __THROW.  */
764 extern wint_t putwchar (wchar_t __wc);
765
766
767 /* Get a newline-terminated wide character string of finite length
768    from STREAM.
769
770    This function is a possible cancellation points and therefore not
771    marked with __THROW.  */
772 extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
773                         __FILE *__restrict __stream);
774
775 /* Write a string to STREAM.
776
777    This function is a possible cancellation points and therefore not
778    marked with __THROW.  */
779 extern int fputws (__const wchar_t *__restrict __ws,
780                    __FILE *__restrict __stream);
781
782
783 /* Push a character back onto the input buffer of STREAM.
784
785    This function is a possible cancellation points and therefore not
786    marked with __THROW.  */
787 extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
788 __END_NAMESPACE_STD
789
790
791 #ifdef __USE_GNU
792 /* These are defined to be equivalent to the `char' functions defined
793    in POSIX.1:1996.
794
795    These functions are not part of POSIX and therefore no official
796    cancellation point.  But due to similarity with an POSIX interface
797    or due to the implementation they are cancellation points and
798    therefore not marked with __THROW.  */
799 extern wint_t getwc_unlocked (__FILE *__stream);
800 extern wint_t getwchar_unlocked (void);
801
802 /* This is the wide character version of a GNU extension.
803
804    This function is not part of POSIX and therefore no official
805    cancellation point.  But due to similarity with an POSIX interface
806    or due to the implementation it is a cancellation point and
807    therefore not marked with __THROW.  */
808 extern wint_t fgetwc_unlocked (__FILE *__stream);
809
810 /* Faster version when locking is not necessary.
811
812    This function is not part of POSIX and therefore no official
813    cancellation point.  But due to similarity with an POSIX interface
814    or due to the implementation it is a cancellation point and
815    therefore not marked with __THROW.  */
816 extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
817
818 /* These are defined to be equivalent to the `char' functions defined
819    in POSIX.1:1996.
820
821    These functions are not part of POSIX and therefore no official
822    cancellation point.  But due to similarity with an POSIX interface
823    or due to the implementation they are cancellation points and
824    therefore not marked with __THROW.  */
825 extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
826 extern wint_t putwchar_unlocked (wchar_t __wc);
827
828
829 /* This function does the same as `fgetws' but does not lock the stream.
830
831    This function is not part of POSIX and therefore no official
832    cancellation point.  But due to similarity with an POSIX interface
833    or due to the implementation it is a cancellation point and
834    therefore not marked with __THROW.  */
835 extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
836                                  __FILE *__restrict __stream);
837
838 /* This function does the same as `fputws' but does not lock the stream.
839
840    This function is not part of POSIX and therefore no official
841    cancellation point.  But due to similarity with an POSIX interface
842    or due to the implementation it is a cancellation point and
843    therefore not marked with __THROW.  */
844 extern int fputws_unlocked (__const wchar_t *__restrict __ws,
845                             __FILE *__restrict __stream);
846 #endif
847
848
849 __BEGIN_NAMESPACE_C99
850 /* Format TP into S according to FORMAT.
851    Write no more than MAXSIZE wide characters and return the number
852    of wide characters written, or 0 if it would exceed MAXSIZE.  */
853 extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
854                         __const wchar_t *__restrict __format,
855                         __const struct tm *__restrict __tp) __THROW;
856 __END_NAMESPACE_C99
857
858 # ifdef __USE_GNU
859 # include <xlocale.h>
860
861 /* Similar to `wcsftime' but takes the information from
862    the provided locale and not the global locale.  */
863 extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
864                           __const wchar_t *__restrict __format,
865                           __const struct tm *__restrict __tp,
866                           __locale_t __loc) __THROW;
867 # endif
868
869 /* The X/Open standard demands that most of the functions defined in
870    the <wctype.h> header must also appear here.  This is probably
871    because some X/Open members wrote their implementation before the
872    ISO C standard was published and introduced the better solution.
873    We have to provide these definitions for compliance reasons but we
874    do this nonsense only if really necessary.  */
875 #if defined __USE_UNIX98 && !defined __USE_GNU
876 # define __need_iswxxx
877 # include <wctype.h>
878 #endif
879
880 /* Define some macros helping to catch buffer overflows.  */
881 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
882 # include <bits/wchar2.h>
883 #endif
884
885 #ifdef __LDBL_COMPAT
886 # include <bits/wchar-ldbl.h>
887 #endif
888
889 __END_DECLS
890
891 #endif  /* _WCHAR_H defined */
892
893 #endif /* wchar.h  */
894
895 /* Undefined all __need_* constants in case we are included to get those
896    constants but the whole file was already read.  */
897 #undef __need_mbstate_t
898 #undef __need_wint_t