Refactor some code in libm-test-driver.c.
[glibc.git] / wcsmbs / wchar.h
blobde7ef8bf4f146f2733e2c90f82a98787a19a0178
1 /* Copyright (C) 1995-2017 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 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.
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.
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/>. */
19 * ISO C99 Standard: 7.24
20 * Extended multibyte and wide character utilities <wchar.h>
23 #ifndef _WCHAR_H
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
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>
42 # include <bits/wchar.h>
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>
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
62 typedef 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
69 typedef __WINT_TYPE__ wint_t;
70 __END_NAMESPACE_STD
71 # endif
72 # endif
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
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
85 int __count;
86 union
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
100 /* The rest of the file is only used if used if __need_mbstate_t is not
101 defined. */
102 #ifdef _WCHAR_H
104 # ifndef __mbstate_t_defined
105 __BEGIN_NAMESPACE_C99
106 /* Public type. */
107 typedef __mbstate_t mbstate_t;
108 __END_NAMESPACE_C99
109 # define __mbstate_t_defined 1
110 # endif
112 #ifdef __USE_GNU
113 __USING_NAMESPACE_C99(mbstate_t)
114 #endif
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
122 #ifndef WEOF
123 # define WEOF (0xffffffffu)
124 #endif
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
133 __BEGIN_DECLS
135 __BEGIN_NAMESPACE_STD
136 /* This incomplete type is defined in <time.h> but needed here because
137 of `wcsftime'. */
138 struct 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)
146 __BEGIN_NAMESPACE_STD
147 /* Copy SRC to DEST. */
148 extern wchar_t *wcscpy (wchar_t *__restrict __dest,
149 const wchar_t *__restrict __src)
150 __THROW __nonnull ((1, 2));
152 /* Copy no more than N wide-characters of SRC to DEST. */
153 extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
154 const wchar_t *__restrict __src, size_t __n)
155 __THROW __nonnull ((1, 2));
157 /* Append SRC onto DEST. */
158 extern 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. */
162 extern wchar_t *wcsncat (wchar_t *__restrict __dest,
163 const wchar_t *__restrict __src, size_t __n)
164 __THROW __nonnull ((1, 2));
166 /* Compare S1 and S2. */
167 extern 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. */
170 extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
171 __THROW __attribute_pure__ __nonnull ((1, 2));
172 __END_NAMESPACE_STD
174 #ifdef __USE_XOPEN2K8
175 /* Compare S1 and S2, ignoring case. */
176 extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW;
178 /* Compare no more than N chars of S1 and S2, ignoring case. */
179 extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
180 size_t __n) __THROW;
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>
186 extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
187 __locale_t __loc) __THROW;
189 extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
190 size_t __n, __locale_t __loc) __THROW;
191 #endif
193 __BEGIN_NAMESPACE_STD
194 /* Compare S1 and S2, both interpreted as appropriate to the
195 LC_COLLATE category of the current locale. */
196 extern 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. */
200 extern size_t wcsxfrm (wchar_t *__restrict __s1,
201 const wchar_t *__restrict __s2, size_t __n) __THROW;
202 __END_NAMESPACE_STD
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. */
208 /* Compare S1 and S2, both interpreted as appropriate to the
209 LC_COLLATE category of the given locale. */
210 extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2,
211 __locale_t __loc) __THROW;
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. */
216 extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
217 size_t __n, __locale_t __loc) __THROW;
219 /* Duplicate S, returning an identical malloc'd string. */
220 extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__;
221 #endif
223 __BEGIN_NAMESPACE_STD
224 /* Find the first occurrence of WC in WCS. */
225 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
226 extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc)
227 __THROW __asm ("wcschr") __attribute_pure__;
228 extern "C++" const wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
229 __THROW __asm ("wcschr") __attribute_pure__;
230 #else
231 extern 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
236 extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc)
237 __THROW __asm ("wcsrchr") __attribute_pure__;
238 extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
239 __THROW __asm ("wcsrchr") __attribute_pure__;
240 #else
241 extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
242 __THROW __attribute_pure__;
243 #endif
244 __END_NAMESPACE_STD
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. */
249 extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc)
250 __THROW __attribute_pure__;
251 #endif
253 __BEGIN_NAMESPACE_STD
254 /* Return the length of the initial segmet of WCS which
255 consists entirely of wide characters not in REJECT. */
256 extern 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. */
260 extern 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
264 extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, const wchar_t *__accept)
265 __THROW __asm ("wcspbrk") __attribute_pure__;
266 extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs,
267 const wchar_t *__accept)
268 __THROW __asm ("wcspbrk") __attribute_pure__;
269 #else
270 extern 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
275 extern "C++" wchar_t *wcsstr (wchar_t *__haystack, const wchar_t *__needle)
276 __THROW __asm ("wcsstr") __attribute_pure__;
277 extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack,
278 const wchar_t *__needle)
279 __THROW __asm ("wcsstr") __attribute_pure__;
280 #else
281 extern wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle)
282 __THROW __attribute_pure__;
283 #endif
285 /* Divide WCS into tokens separated by characters in DELIM. */
286 extern wchar_t *wcstok (wchar_t *__restrict __s,
287 const wchar_t *__restrict __delim,
288 wchar_t **__restrict __ptr) __THROW;
290 /* Return the number of wide characters in S. */
291 extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
292 __END_NAMESPACE_STD
294 #ifdef __USE_XOPEN
295 /* Another name for `wcsstr' from XPG4. */
296 # ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
297 extern "C++" wchar_t *wcswcs (wchar_t *__haystack, const wchar_t *__needle)
298 __THROW __asm ("wcswcs") __attribute_pure__;
299 extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack,
300 const wchar_t *__needle)
301 __THROW __asm ("wcswcs") __attribute_pure__;
302 # else
303 extern wchar_t *wcswcs (const wchar_t *__haystack, const wchar_t *__needle)
304 __THROW __attribute_pure__;
305 # endif
306 #endif
308 #ifdef __USE_XOPEN2K8
309 /* Return the number of wide characters in S, but at most MAXLEN. */
310 extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
311 __THROW __attribute_pure__;
312 #endif
315 __BEGIN_NAMESPACE_STD
316 /* Search N wide characters of S for C. */
317 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
318 extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
319 __THROW __asm ("wmemchr") __attribute_pure__;
320 extern "C++" const wchar_t *wmemchr (const wchar_t *__s, wchar_t __c,
321 size_t __n)
322 __THROW __asm ("wmemchr") __attribute_pure__;
323 #else
324 extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
325 __THROW __attribute_pure__;
326 #endif
328 /* Compare N wide characters of S1 and S2. */
329 extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
330 __THROW __attribute_pure__;
332 /* Copy N wide characters of SRC to DEST. */
333 extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
334 const wchar_t *__restrict __s2, size_t __n) __THROW;
336 /* Copy N wide characters of SRC to DEST, guaranteeing
337 correct behavior for overlapping strings. */
338 extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
339 __THROW;
341 /* Set N wide characters of S to C. */
342 extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
343 __END_NAMESPACE_STD
345 #ifdef __USE_GNU
346 /* Copy N wide characters of SRC to DEST and return pointer to following
347 wide character. */
348 extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
349 const wchar_t *__restrict __s2, size_t __n)
350 __THROW;
351 #endif
354 __BEGIN_NAMESPACE_STD
355 /* Determine whether C constitutes a valid (one-byte) multibyte
356 character. */
357 extern wint_t btowc (int __c) __THROW;
359 /* Determine whether C corresponds to a member of the extended
360 character set whose multibyte representation is a single byte. */
361 extern int wctob (wint_t __c) __THROW;
363 /* Determine whether PS points to an object representing the initial
364 state. */
365 extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
367 /* Write wide character representation of multibyte character pointed
368 to by S to PWC. */
369 extern size_t mbrtowc (wchar_t *__restrict __pwc,
370 const char *__restrict __s, size_t __n,
371 mbstate_t *__restrict __p) __THROW;
373 /* Write multibyte representation of wide character WC to S. */
374 extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
375 mbstate_t *__restrict __ps) __THROW;
377 /* Return number of bytes in multibyte character pointed to by S. */
378 extern size_t __mbrlen (const char *__restrict __s, size_t __n,
379 mbstate_t *__restrict __ps) __THROW;
380 extern size_t mbrlen (const char *__restrict __s, size_t __n,
381 mbstate_t *__restrict __ps) __THROW;
382 __END_NAMESPACE_STD
384 #ifdef __USE_EXTERN_INLINES
385 /* Define inline function as optimization. */
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. */
390 extern 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)); }
396 extern 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)); }
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
409 __BEGIN_NAMESPACE_STD
410 /* Write wide character representation of multibyte character string
411 SRC to DST. */
412 extern size_t mbsrtowcs (wchar_t *__restrict __dst,
413 const char **__restrict __src, size_t __len,
414 mbstate_t *__restrict __ps) __THROW;
416 /* Write multibyte character representation of wide character string
417 SRC to DST. */
418 extern 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
424 #ifdef __USE_XOPEN2K8
425 /* Write wide character representation of at most NMC bytes of the
426 multibyte character string SRC to DST. */
427 extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
428 const char **__restrict __src, size_t __nmc,
429 size_t __len, mbstate_t *__restrict __ps) __THROW;
431 /* Write multibyte character representation of at most NWC characters
432 from the wide character string SRC to DST. */
433 extern 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 */
440 /* The following functions are extensions found in X/Open CAE. */
441 #ifdef __USE_XOPEN
442 /* Determine number of column positions required for C. */
443 extern int wcwidth (wchar_t __c) __THROW;
445 /* Determine number of column positions required for first N wide
446 characters (or fewer if S ends before this) in S. */
447 extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
448 #endif /* Use X/Open. */
451 __BEGIN_NAMESPACE_STD
452 /* Convert initial portion of the wide string NPTR to `double'
453 representation. */
454 extern double wcstod (const wchar_t *__restrict __nptr,
455 wchar_t **__restrict __endptr) __THROW;
456 __END_NAMESPACE_STD
458 #ifdef __USE_ISOC99
459 __BEGIN_NAMESPACE_C99
460 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
461 extern float wcstof (const wchar_t *__restrict __nptr,
462 wchar_t **__restrict __endptr) __THROW;
463 extern long double wcstold (const wchar_t *__restrict __nptr,
464 wchar_t **__restrict __endptr) __THROW;
465 __END_NAMESPACE_C99
466 #endif /* C99 */
469 __BEGIN_NAMESPACE_STD
470 /* Convert initial portion of wide string NPTR to `long int'
471 representation. */
472 extern long int wcstol (const wchar_t *__restrict __nptr,
473 wchar_t **__restrict __endptr, int __base) __THROW;
475 /* Convert initial portion of wide string NPTR to `unsigned long int'
476 representation. */
477 extern unsigned long int wcstoul (const wchar_t *__restrict __nptr,
478 wchar_t **__restrict __endptr, int __base)
479 __THROW;
480 __END_NAMESPACE_STD
482 #ifdef __USE_ISOC99
483 __BEGIN_NAMESPACE_C99
484 /* Convert initial portion of wide string NPTR to `long long int'
485 representation. */
486 __extension__
487 extern long long int wcstoll (const wchar_t *__restrict __nptr,
488 wchar_t **__restrict __endptr, int __base)
489 __THROW;
491 /* Convert initial portion of wide string NPTR to `unsigned long long int'
492 representation. */
493 __extension__
494 extern 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. */
500 #ifdef __USE_GNU
501 /* Convert initial portion of wide string NPTR to `long long int'
502 representation. */
503 __extension__
504 extern long long int wcstoq (const wchar_t *__restrict __nptr,
505 wchar_t **__restrict __endptr, int __base)
506 __THROW;
508 /* Convert initial portion of wide string NPTR to `unsigned long long int'
509 representation. */
510 __extension__
511 extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
512 wchar_t **__restrict __endptr,
513 int __base) __THROW;
514 #endif /* Use GNU. */
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.
525 Attention: all these functions are *not* standardized in any form.
526 This is a proof-of-concept implementation. */
528 /* Structure for reentrant locale using functions. This is an
529 (almost) opaque type for the user level programs. */
530 # include <xlocale.h>
532 /* Special versions of the functions above which take the locale to
533 use as an additional parameter. */
534 extern long int wcstol_l (const wchar_t *__restrict __nptr,
535 wchar_t **__restrict __endptr, int __base,
536 __locale_t __loc) __THROW;
538 extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr,
539 wchar_t **__restrict __endptr,
540 int __base, __locale_t __loc) __THROW;
542 __extension__
543 extern long long int wcstoll_l (const wchar_t *__restrict __nptr,
544 wchar_t **__restrict __endptr,
545 int __base, __locale_t __loc) __THROW;
547 __extension__
548 extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr,
549 wchar_t **__restrict __endptr,
550 int __base, __locale_t __loc)
551 __THROW;
553 extern double wcstod_l (const wchar_t *__restrict __nptr,
554 wchar_t **__restrict __endptr, __locale_t __loc)
555 __THROW;
557 extern float wcstof_l (const wchar_t *__restrict __nptr,
558 wchar_t **__restrict __endptr, __locale_t __loc)
559 __THROW;
561 extern long double wcstold_l (const wchar_t *__restrict __nptr,
562 wchar_t **__restrict __endptr,
563 __locale_t __loc) __THROW;
564 #endif /* use GNU */
567 #ifdef __USE_XOPEN2K8
568 /* Copy SRC to DEST, returning the address of the terminating L'\0' in
569 DEST. */
570 extern wchar_t *wcpcpy (wchar_t *__restrict __dest,
571 const wchar_t *__restrict __src) __THROW;
573 /* Copy no more than N characters of SRC to DEST, returning the address of
574 the last character written into DEST. */
575 extern wchar_t *wcpncpy (wchar_t *__restrict __dest,
576 const wchar_t *__restrict __src, size_t __n)
577 __THROW;
578 #endif
581 /* Wide character I/O functions. */
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. */
586 extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW;
587 #endif
589 #if defined __USE_ISOC95 || defined __USE_UNIX98
590 __BEGIN_NAMESPACE_STD
592 /* Select orientation for stream. */
593 extern int fwide (__FILE *__fp, int __mode) __THROW;
596 /* Write formatted output to STREAM.
598 This function is a possible cancellation point and therefore not
599 marked with __THROW. */
600 extern int fwprintf (__FILE *__restrict __stream,
601 const wchar_t *__restrict __format, ...)
602 /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
603 /* Write formatted output to stdout.
605 This function is a possible cancellation point and therefore not
606 marked with __THROW. */
607 extern int wprintf (const wchar_t *__restrict __format, ...)
608 /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
609 /* Write formatted output of at most N characters to S. */
610 extern int swprintf (wchar_t *__restrict __s, size_t __n,
611 const wchar_t *__restrict __format, ...)
612 __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
614 /* Write formatted output to S from argument list ARG.
616 This function is a possible cancellation point and therefore not
617 marked with __THROW. */
618 extern 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.
624 This function is a possible cancellation point and therefore not
625 marked with __THROW. */
626 extern 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. */
631 extern 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))) */;
637 /* Read formatted input from STREAM.
639 This function is a possible cancellation point and therefore not
640 marked with __THROW. */
641 extern int fwscanf (__FILE *__restrict __stream,
642 const wchar_t *__restrict __format, ...)
643 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
644 /* Read formatted input from stdin.
646 This function is a possible cancellation point and therefore not
647 marked with __THROW. */
648 extern int wscanf (const wchar_t *__restrict __format, ...)
649 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
650 /* Read formatted input from S. */
651 extern int swscanf (const wchar_t *__restrict __s,
652 const wchar_t *__restrict __format, ...)
653 __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
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 [. */
662 extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
663 const wchar_t *__restrict __format, ...),
664 __isoc99_fwscanf)
665 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
666 extern int __REDIRECT (wscanf, (const wchar_t *__restrict __format, ...),
667 __isoc99_wscanf)
668 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
669 extern 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
674 extern int __isoc99_fwscanf (__FILE *__restrict __stream,
675 const wchar_t *__restrict __format, ...);
676 extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...);
677 extern 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
686 __END_NAMESPACE_STD
687 #endif /* Use ISO C95, C99 and Unix98. */
689 #ifdef __USE_ISOC99
690 __BEGIN_NAMESPACE_C99
691 /* Read formatted input from S into argument list ARG.
693 This function is a possible cancellation point and therefore not
694 marked with __THROW. */
695 extern 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.
701 This function is a possible cancellation point and therefore not
702 marked with __THROW. */
703 extern 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. */
707 extern 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))) */;
712 # if !defined __USE_GNU \
713 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
714 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
715 # ifdef __REDIRECT
716 extern 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))) */;
720 extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format,
721 __gnuc_va_list __arg), __isoc99_vwscanf)
722 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
723 extern 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
728 extern int __isoc99_vfwscanf (__FILE *__restrict __s,
729 const wchar_t *__restrict __format,
730 __gnuc_va_list __arg);
731 extern int __isoc99_vwscanf (const wchar_t *__restrict __format,
732 __gnuc_va_list __arg);
733 extern 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
742 __END_NAMESPACE_C99
743 #endif /* Use ISO C99. */
746 __BEGIN_NAMESPACE_STD
747 /* Read a character from STREAM.
749 These functions are possible cancellation points and therefore not
750 marked with __THROW. */
751 extern wint_t fgetwc (__FILE *__stream);
752 extern wint_t getwc (__FILE *__stream);
754 /* Read a character from stdin.
756 This function is a possible cancellation point and therefore not
757 marked with __THROW. */
758 extern wint_t getwchar (void);
761 /* Write a character to STREAM.
763 These functions are possible cancellation points and therefore not
764 marked with __THROW. */
765 extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
766 extern wint_t putwc (wchar_t __wc, __FILE *__stream);
768 /* Write a character to stdout.
770 This function is a possible cancellation point and therefore not
771 marked with __THROW. */
772 extern wint_t putwchar (wchar_t __wc);
775 /* Get a newline-terminated wide character string of finite length
776 from STREAM.
778 This function is a possible cancellation point and therefore not
779 marked with __THROW. */
780 extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
781 __FILE *__restrict __stream);
783 /* Write a string to STREAM.
785 This function is a possible cancellation point and therefore not
786 marked with __THROW. */
787 extern int fputws (const wchar_t *__restrict __ws,
788 __FILE *__restrict __stream);
791 /* Push a character back onto the input buffer of STREAM.
793 This function is a possible cancellation point and therefore not
794 marked with __THROW. */
795 extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
796 __END_NAMESPACE_STD
799 #ifdef __USE_GNU
800 /* These are defined to be equivalent to the `char' functions defined
801 in POSIX.1:1996.
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. */
807 extern wint_t getwc_unlocked (__FILE *__stream);
808 extern wint_t getwchar_unlocked (void);
810 /* This is the wide character version of a GNU extension.
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 fgetwc_unlocked (__FILE *__stream);
818 /* Faster version when locking is not necessary.
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. */
824 extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
826 /* These are defined to be equivalent to the `char' functions defined
827 in POSIX.1:1996.
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. */
833 extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
834 extern wint_t putwchar_unlocked (wchar_t __wc);
837 /* This function does the same as `fgetws' but does not lock the stream.
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. */
843 extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
844 __FILE *__restrict __stream);
846 /* This function does the same as `fputws' but does not lock the stream.
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. */
852 extern int fputws_unlocked (const wchar_t *__restrict __ws,
853 __FILE *__restrict __stream);
854 #endif
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. */
861 extern 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
866 # ifdef __USE_GNU
867 # include <xlocale.h>
869 /* Similar to `wcsftime' but takes the information from
870 the provided locale and not the global locale. */
871 extern 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
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
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
893 #ifdef __LDBL_COMPAT
894 # include <bits/wchar-ldbl.h>
895 #endif
897 __END_DECLS
899 #endif /* _WCHAR_H defined */
901 #endif /* wchar.h */
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