1 /* Copyright (C) 1995-1999, 2000, 2001 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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * ISO C99 Standard: 7.24
21 * Extended multibyte and wide character utilities <wchar.h>
26 #ifndef __need_mbstate_t
28 # include <features.h>
32 /* Get FILE definition. */
33 # define __need___FILE
37 # include <libio/stdio.h>
38 /* Get va_list definition. */
39 # define __need___va_list
42 /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */
43 # define __need_size_t
44 # define __need_wchar_t
50 #include <bits/wchar.h>
52 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
53 there. So define it ourselves if it remains undefined. */
55 /* Integral type unchanged by default argument promotions that can
56 hold any value corresponding to members of the extended character
57 set, as well as at least one value that does not correspond to any
58 member of the extended character set. */
60 typedef unsigned int wint_t;
64 #ifndef __mbstate_t_defined
65 # define __mbstate_t_defined 1
66 /* Conversion state information - for now a mixture between glibc's idea of
67 mbstate_t and our own. */
73 char data
[1024 + 8]; // 1024 bytes for data, 8 for alignment space
79 } __value
; /* Value so far. */
82 #undef __need_mbstate_t
85 /* The rest of the file is only used if used if __need_mbstate_t is not
90 typedef __mbstate_t
mbstate_t;
93 /* These constants might also be defined in <inttypes.h>. */
94 # define WCHAR_MIN __WCHAR_MIN
95 # define WCHAR_MAX __WCHAR_MAX
99 # define WEOF (0xffffffffu)
102 /* For XPG4 compliance we have to define the stuff from <wctype.h> here
104 #if defined __USE_XOPEN && !defined __USE_UNIX98
108 /* This incomplete type is defined in <time.h> but needed here because
117 /* Convert initial portion of the wide string NPTR to `double'
119 extern double wcstod (__const
wchar_t *__restrict __nptr
,
120 wchar_t **__restrict __endptr
) __THROW
;
123 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
124 extern float wcstof (__const
wchar_t *__restrict __nptr
,
125 wchar_t **__restrict __endptr
) __THROW
;
126 extern long double wcstold (__const
wchar_t *__restrict __nptr
,
127 wchar_t **__restrict __endptr
) __THROW
;
131 /* Convert initial portion of wide string NPTR to `long int'
133 extern long int wcstol (__const
wchar_t *__restrict __nptr
,
134 wchar_t **__restrict __endptr
, int __base
) __THROW
;
136 /* Convert initial portion of wide string NPTR to `unsigned long int'
138 extern unsigned long int wcstoul (__const
wchar_t *__restrict __nptr
,
139 wchar_t **__restrict __endptr
, int __base
)
142 #if defined __GNUC__ && defined __USE_GNU
143 /* Convert initial portion of wide string NPTR to `long int'
146 extern long long int wcstoq (__const
wchar_t *__restrict __nptr
,
147 wchar_t **__restrict __endptr
, int __base
)
150 /* Convert initial portion of wide string NPTR to `unsigned long long int'
153 extern unsigned long long int wcstouq (__const
wchar_t *__restrict __nptr
,
154 wchar_t **__restrict __endptr
,
156 #endif /* GCC and use GNU. */
158 #if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU)
159 /* Convert initial portion of wide string NPTR to `long int'
162 extern long long int wcstoll (__const
wchar_t *__restrict __nptr
,
163 wchar_t **__restrict __endptr
, int __base
)
166 /* Convert initial portion of wide string NPTR to `unsigned long long int'
169 extern unsigned long long int wcstoull (__const
wchar_t *__restrict __nptr
,
170 wchar_t **__restrict __endptr
,
172 #endif /* ISO C99 or GCC and GNU. */
175 /* The internal entry points for `wcstoX' take an extra flag argument
176 saying whether or not to parse locale-dependent number grouping. */
177 extern double __wcstod_internal (__const
wchar_t *__restrict __nptr
,
178 wchar_t **__restrict __endptr
, int __group
)
180 extern float __wcstof_internal (__const
wchar_t *__restrict __nptr
,
181 wchar_t **__restrict __endptr
, int __group
)
183 extern long double __wcstold_internal (__const
wchar_t *__restrict __nptr
,
184 wchar_t **__restrict __endptr
,
185 int __group
) __THROW
;
187 #ifndef __wcstol_internal_defined
188 extern long int __wcstol_internal (__const
wchar_t *__restrict __nptr
,
189 wchar_t **__restrict __endptr
,
190 int __base
, int __group
) __THROW
;
191 # define __wcstol_internal_defined 1
193 #ifndef __wcstoul_internal_defined
194 extern unsigned long int __wcstoul_internal (__const
wchar_t *__restrict __npt
,
195 wchar_t **__restrict __endptr
,
196 int __base
, int __group
) __THROW
;
197 # define __wcstoul_internal_defined 1
199 #ifndef __wcstoll_internal_defined
201 extern long long int __wcstoll_internal (__const
wchar_t *__restrict __nptr
,
202 wchar_t **__restrict __endptr
,
203 int __base
, int __group
) __THROW
;
204 # define __wcstoll_internal_defined 1
206 #ifndef __wcstoull_internal_defined
208 extern unsigned long long int __wcstoull_internal (__const
wchar_t *
213 int __group
) __THROW
;
214 # define __wcstoull_internal_defined 1
218 #if defined __OPTIMIZE__ && __GNUC__ >= 2
219 /* Define inline functions which call the internal entry points. */
221 __extern_inline
double wcstod (__const
wchar_t *__restrict __nptr
,
222 wchar_t **__restrict __endptr
) __THROW
223 { return __wcstod_internal (__nptr
, __endptr
, 0); }
224 __extern_inline
long int wcstol (__const
wchar_t *__restrict __nptr
,
225 wchar_t **__restrict __endptr
,
227 { return __wcstol_internal (__nptr
, __endptr
, __base
, 0); }
228 __extern_inline
unsigned long int wcstoul (__const
wchar_t *__restrict __nptr
,
229 wchar_t **__restrict __endptr
,
231 { return __wcstoul_internal (__nptr
, __endptr
, __base
, 0); }
234 __extern_inline
float wcstof (__const
wchar_t *__restrict __nptr
,
235 wchar_t **__restrict __endptr
) __THROW
236 { return __wcstof_internal (__nptr
, __endptr
, 0); }
237 __extern_inline
long double wcstold (__const
wchar_t *__restrict __nptr
,
238 wchar_t **__restrict __endptr
) __THROW
239 { return __wcstold_internal (__nptr
, __endptr
, 0); }
243 __extern_inline
long long int wcstoq (__const
wchar_t *__restrict __nptr
,
244 wchar_t **__restrict __endptr
,
246 { return __wcstoll_internal (__nptr
, __endptr
, __base
, 0); }
248 __extern_inline
unsigned long long int wcstouq (__const
wchar_t *
250 wchar_t **__restrict __endptr
,
252 { return __wcstoull_internal (__nptr
, __endptr
, __base
, 0); }
253 # endif /* Use GNU. */
254 #endif /* Optimizing GCC >=2. */
257 /* Wide character I/O functions. */
258 #if defined __USE_ISOC99 || defined __USE_UNIX98
260 /* Select orientation for stream. */
261 extern int fwide (__FILE
*__fp
, int __mode
) __THROW
;
264 /* Write formatted output to STREAM. */
265 extern int fwprintf (__FILE
*__restrict __stream
,
266 __const
wchar_t *__restrict __format
, ...)
267 __THROW
/* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
268 /* Write formatted output to stdout. */
269 extern int wprintf (__const
wchar_t *__restrict __format
, ...)
270 __THROW
/* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
271 /* Write formatted output of at most N characters to S. */
272 extern int swprintf (wchar_t *__restrict __s
, size_t __n
,
273 __const
wchar_t *__restrict __format
, ...)
274 __THROW
/* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
276 /* Write formatted output to S from argument list ARG. */
277 extern int vfwprintf (__FILE
*__restrict __s
,
278 __const
wchar_t *__restrict __format
,
279 __gnuc_va_list __arg
)
280 __THROW
/* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
281 /* Write formatted output to stdout from argument list ARG. */
282 extern int vwprintf (__const
wchar_t *__restrict __format
,
283 __gnuc_va_list __arg
)
284 __THROW
/* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
285 /* Write formatted output of at most N character to S from argument
287 extern int vswprintf (wchar_t *__restrict __s
, size_t __n
,
288 __const
wchar_t *__restrict __format
,
289 __gnuc_va_list __arg
)
290 __THROW
/* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
293 /* Read formatted input from STREAM. */
294 extern int fwscanf (__FILE
*__restrict __stream
,
295 __const
wchar_t *__restrict __format
, ...)
296 __THROW
/* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
297 /* Read formatted input from stdin. */
298 extern int wscanf (__const
wchar_t *__restrict __format
, ...)
299 __THROW
/* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
300 /* Read formatted input from S. */
301 extern int swscanf (__const
wchar_t *__restrict __s
,
302 __const
wchar_t *__restrict __format
, ...)
303 __THROW
/* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
304 #endif /* Use ISO C99 and Unix98. */
307 /* Read formatted input from S into argument list ARG. */
308 extern int vfwscanf (__FILE
*__restrict __s
,
309 __const
wchar_t *__restrict __format
,
310 __gnuc_va_list __arg
)
311 __THROW
/* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
312 /* Read formatted input from stdin into argument list ARG. */
313 extern int vwscanf (__const
wchar_t *__restrict __format
,
314 __gnuc_va_list __arg
)
315 __THROW
/* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
316 /* Read formatted input from S into argument list ARG. */
317 extern int vswscanf (__const
wchar_t *__restrict __s
,
318 __const
wchar_t *__restrict __format
,
319 __gnuc_va_list __arg
)
320 __THROW
/* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
321 #endif /* Use ISO C99. */
324 /* Read a character from STREAM. */
325 extern wint_t fgetwc (__FILE
*__stream
) __THROW
;
326 extern wint_t getwc (__FILE
*__stream
) __THROW
;
328 /* Read a character from stdin. */
329 extern wint_t getwchar (void) __THROW
;
332 /* Write a character to STREAM. */
333 extern wint_t fputwc (wchar_t __wc
, __FILE
*__stream
) __THROW
;
334 extern wint_t putwc (wchar_t __wc
, __FILE
*__stream
) __THROW
;
336 /* Write a character to stdout. */
337 extern wint_t putwchar (wchar_t __wc
) __THROW
;
340 /* Get a newline-terminated wide character string of finite length
342 extern wchar_t *fgetws (wchar_t *__restrict __ws
, int __n
,
343 __FILE
*__restrict __stream
) __THROW
;
345 /* Write a string to STREAM. */
346 extern int fputws (__const
wchar_t *__restrict __ws
,
347 __FILE
*__restrict __stream
) __THROW
;
350 /* Push a character back onto the input buffer of STREAM. */
351 extern wint_t ungetwc (wint_t __wc
, __FILE
*__stream
) __THROW
;
355 /* These are defined to be equivalent to the `char' functions defined
357 extern wint_t getwc_unlocked (__FILE
*__stream
) __THROW
;
358 extern wint_t getwchar_unlocked (void) __THROW
;
360 /* This is the wide character version of a GNU extension. */
361 extern wint_t fgetwc_unlocked (__FILE
*__stream
) __THROW
;
363 /* Faster version when locking is not necessary. */
364 extern wint_t fputwc_unlocked (wchar_t __wc
, __FILE
*__stream
) __THROW
;
366 /* These are defined to be equivalent to the `char' functions defined
368 extern wint_t putwc_unlocked (wchar_t __wc
, __FILE
*__stream
) __THROW
;
369 extern wint_t putwchar_unlocked (wchar_t __wc
) __THROW
;
372 /* This function does the same as `fgetws' but does not lock the stream. */
373 extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws
, int __n
,
374 __FILE
*__restrict __stream
) __THROW
;
376 /* This function does the same as `fputws' but does not lock the stream. */
377 extern int fputws_unlocked (__const
wchar_t *__restrict __ws
,
378 __FILE
*__restrict __stream
) __THROW
;
384 #endif /* _WCHAR_H defined */