libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / system / libroot / posix / glibc / wcsmbs / wchar.h
blob579e74c9229f6ed5efb4678fa77dc746a6dfc1ec
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
17 02111-1307 USA. */
20 * ISO C99 Standard: 7.24
21 * Extended multibyte and wide character utilities <wchar.h>
24 #ifndef _WCHAR_H
26 #ifndef __need_mbstate_t
27 # define _WCHAR_H 1
28 # include <features.h>
29 #endif
31 #ifdef _WCHAR_H
32 /* Get FILE definition. */
33 # define __need___FILE
34 # ifdef __USE_UNIX98
35 # define __need_FILE
36 # endif
37 # include <libio/stdio.h>
38 /* Get va_list definition. */
39 # define __need___va_list
40 # include <stdarg.h>
42 /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */
43 # define __need_size_t
44 # define __need_wchar_t
45 # define __need_NULL
46 #endif
47 #define __need_wint_t
48 #include <stddef.h>
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. */
54 #ifndef _WINT_T
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. */
59 # define _WINT_T
60 typedef unsigned int wint_t;
61 #endif
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. */
68 typedef struct
70 void* converter;
71 char charset[64];
72 unsigned int count;
73 char data[1024 + 8]; // 1024 bytes for data, 8 for alignment space
74 int __count;
75 union
77 wint_t __wch;
78 char __wchb[4];
79 } __value; /* Value so far. */
80 } __mbstate_t;
81 #endif
82 #undef __need_mbstate_t
85 /* The rest of the file is only used if used if __need_mbstate_t is not
86 defined. */
87 #ifdef _WCHAR_H
89 /* Public type. */
90 typedef __mbstate_t mbstate_t;
92 #ifndef WCHAR_MIN
93 /* These constants might also be defined in <inttypes.h>. */
94 # define WCHAR_MIN __WCHAR_MIN
95 # define WCHAR_MAX __WCHAR_MAX
96 #endif
98 #ifndef WEOF
99 # define WEOF (0xffffffffu)
100 #endif
102 /* For XPG4 compliance we have to define the stuff from <wctype.h> here
103 as well. */
104 #if defined __USE_XOPEN && !defined __USE_UNIX98
105 # include <wctype.h>
106 #endif
108 /* This incomplete type is defined in <time.h> but needed here because
109 of `wcsftime'. */
110 struct tm;
113 __BEGIN_DECLS
117 /* Convert initial portion of the wide string NPTR to `double'
118 representation. */
119 extern double wcstod (__const wchar_t *__restrict __nptr,
120 wchar_t **__restrict __endptr) __THROW;
122 #ifdef __USE_ISOC99
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;
128 #endif /* C99 */
131 /* Convert initial portion of wide string NPTR to `long int'
132 representation. */
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'
137 representation. */
138 extern unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
139 wchar_t **__restrict __endptr, int __base)
140 __THROW;
142 #if defined __GNUC__ && defined __USE_GNU
143 /* Convert initial portion of wide string NPTR to `long int'
144 representation. */
145 __extension__
146 extern long long int wcstoq (__const wchar_t *__restrict __nptr,
147 wchar_t **__restrict __endptr, int __base)
148 __THROW;
150 /* Convert initial portion of wide string NPTR to `unsigned long long int'
151 representation. */
152 __extension__
153 extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
154 wchar_t **__restrict __endptr,
155 int __base) __THROW;
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'
160 representation. */
161 __extension__
162 extern long long int wcstoll (__const wchar_t *__restrict __nptr,
163 wchar_t **__restrict __endptr, int __base)
164 __THROW;
166 /* Convert initial portion of wide string NPTR to `unsigned long long int'
167 representation. */
168 __extension__
169 extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr,
170 wchar_t **__restrict __endptr,
171 int __base) __THROW;
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)
179 __THROW;
180 extern float __wcstof_internal (__const wchar_t *__restrict __nptr,
181 wchar_t **__restrict __endptr, int __group)
182 __THROW;
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
192 #endif
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
198 #endif
199 #ifndef __wcstoll_internal_defined
200 __extension__
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
205 #endif
206 #ifndef __wcstoull_internal_defined
207 __extension__
208 extern unsigned long long int __wcstoull_internal (__const wchar_t *
209 __restrict __nptr,
210 wchar_t **
211 __restrict __endptr,
212 int __base,
213 int __group) __THROW;
214 # define __wcstoull_internal_defined 1
215 #endif
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,
226 int __base) __THROW
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,
230 int __base) __THROW
231 { return __wcstoul_internal (__nptr, __endptr, __base, 0); }
233 # ifdef __USE_GNU
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); }
242 __extension__
243 __extern_inline long long int wcstoq (__const wchar_t *__restrict __nptr,
244 wchar_t **__restrict __endptr,
245 int __base) __THROW
246 { return __wcstoll_internal (__nptr, __endptr, __base, 0); }
247 __extension__
248 __extern_inline unsigned long long int wcstouq (__const wchar_t *
249 __restrict __nptr,
250 wchar_t **__restrict __endptr,
251 int __base) __THROW
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
286 list ARG. */
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. */
306 #ifdef __USE_ISOC99
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
341 from STREAM. */
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;
354 #ifdef __USE_GNU
355 /* These are defined to be equivalent to the `char' functions defined
356 in POSIX.1:1996. */
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
367 in POSIX.1:1996. */
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;
379 #endif
382 __END_DECLS
384 #endif /* _WCHAR_H defined */
386 #endif /* wchar.h */