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