* posix/glob.h (__glob_opendir_hook, __glob_readdir_hook,
[glibc.git] / wcsmbs / wchar.h
blob806bafa6558857cdf6b143f46e90d2067f4ada7f
1 /* Copyright (C) 1995, 1996 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 Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
20 * ISO Standard: 7.16.4 General wide-string utilities <wchar.h>
23 #ifndef _WCHAR_H
25 #define _WCHAR_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */
31 #define __need_size_t
32 #define __need_wchar_t
33 #define __need_wint_t
34 #define __need_NULL
35 #include <stddef.h>
38 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
39 there. So define it ourselves if it remains undefined. */
40 #ifndef _WINT_T
41 /* Integral type unchanged by default argument promotions that can
42 hold any value corresponding to members of the extended character
43 set, as well as at least one value that does not correspond to any
44 member of the extended character set. */
45 #define _WINT_T
46 typedef unsigned int wint_t;
47 #endif
50 /* Conversion state information. */
51 typedef struct
53 int count; /* Number of bytes needed for the current character. */
54 wint_t value; /* Value so far. */
55 } mbstate_t;
57 #define WCHAR_MIN ((wchar_t) 0)
58 #define WCHAR_MAX (~WCHAR_MIN)
60 #ifndef WEOF
61 # define WEOF (0xffffffffu)
62 #endif
65 /* Copy SRC to DEST. */
66 extern wchar_t *wcscpy __P ((wchar_t *__dest, __const wchar_t *__src));
67 /* Copy no more than N wide-characters of SRC to DEST. */
68 extern wchar_t *wcsncpy __P ((wchar_t *__dest, __const wchar_t *__src,
69 size_t __n));
71 /* Append SRC onto DEST. */
72 extern wchar_t *wcscat __P ((wchar_t *__dest, __const wchar_t *__src));
73 /* Append no more than N wide-characters of SRC onto DEST. */
74 extern wchar_t *wcsncat __P ((wchar_t *__dest, __const wchar_t *__src,
75 size_t __n));
77 /* Compare S1 and S2. */
78 extern int wcscmp __P ((__const wchar_t *__s1, __const wchar_t *__s2));
79 /* Compare N wide-characters of S1 and S2. */
80 extern int wcsncmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
81 size_t __n));
83 /* Compare S1 and S2, both interpreted as appropriate to the
84 LC_COLLATE category of the current locale. */
85 extern int wcscoll __P ((__const wchar_t *__s1, __const wchar_t *__s2));
86 /* Transform S2 into array pointed to by S1 such that if wcscmp is
87 applied to two transformed strings the result is the as applying
88 `wcscoll' to the original strings. */
89 extern size_t wcsxfrm __P ((wchar_t *__s1, __const wchar_t *__s2, size_t __n));
91 /* Duplicate S, returning an identical malloc'd string. */
92 extern wchar_t *wcsdup __P ((__const wchar_t *__s));
94 /* Find the first occurence of WC in WCS. */
95 extern wchar_t *wcschr __P ((__const wchar_t *__wcs, wchar_t __wc));
96 /* Find the last occurence of WC in WCS. */
97 extern wchar_t *wcsrchr __P ((__const wchar_t *__wcs, wchar_t __wc));
99 /* Return the length of the initial segmet of WCS which
100 consists entirely of wide-characters not in REJECT. */
101 extern size_t wcscspn __P ((__const wchar_t *__wcs,
102 __const wchar_t *__reject));
103 /* Return the length of the initial segmet of WCS which
104 consists entirely of wide-characters in ACCEPT. */
105 extern size_t wcsspn __P ((__const wchar_t *__wcs, __const wchar_t *__accept));
106 /* Find the first occurence in WCS of any character in ACCEPT. */
107 extern wchar_t *wcspbrk __P ((__const wchar_t *__wcs,
108 __const wchar_t *__accept));
109 /* Find the first occurence of NEEDLE in HAYSTACK. */
110 extern wchar_t *wcsstr __P ((__const wchar_t *__haystack,
111 __const wchar_t *__needle));
112 /* Divide WCS into tokens separated by characters in DELIM. */
113 extern wchar_t *wcstok __P ((wchar_t *__s, __const wchar_t *__delim,
114 wchar_t **ptr));
116 /* Return the number of wide-characters in S. */
117 extern size_t wcslen __P ((__const wchar_t *__s));
120 /* Search N bytes of S for C. */
121 extern wchar_t *wmemchr __P ((__const wchar_t *__s, wchar_t __c, size_t __n));
123 /* Compare N bytes of S1 and S2. */
124 extern int wmemcmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
125 size_t __n));
127 /* Copy N bytes of SRC to DEST. */
128 extern wchar_t *wmemcpy __P ((wchar_t *__s1, __const wchar_t *__s2,
129 size_t __n));
131 /* Copy N bytes of SRC to DEST, guaranteeing
132 correct behavior for overlapping strings. */
133 extern wchar_t *wmemmove __P ((wchar_t *__s1, __const wchar_t *__s2,
134 size_t __N));
136 /* Set N bytes of S to C. */
137 extern wchar_t *wmemset __P ((wchar_t *__s, wchar_t __c, size_t __n));
140 /* Determine whether C constitutes a valid (one-byte) multibyte
141 character. */
142 extern wint_t btowc __P ((int __c));
144 /* Determine whether C corresponds to a member of the extended
145 character set whose multibyte representation is a single byte. */
146 extern int wctob __P ((wint_t __c));
148 /* Determine whether PS points to an object representing the initial
149 state. */
150 extern int mbsinit __P ((__const mbstate_t *__ps));
152 /* Write wide character representation of multibyte character pointed
153 to by S to PWC. */
154 extern size_t mbrtowc __P ((wchar_t *__pwc, __const char *__s, size_t __n,
155 mbstate_t *__p));
157 /* Write multibyte representation of wide character WC to S. */
158 extern size_t wcrtomb __P ((char *__s, wchar_t __wc, mbstate_t *__ps));
160 /* Return number of bytes in multibyte character pointed to by S. */
161 extern size_t __mbrlen __P ((__const char *__s, size_t __n, mbstate_t *__ps));
162 extern size_t mbrlen __P ((__const char *__s, size_t __n, mbstate_t *__ps));
164 #if defined (__OPTIMIZE__) \
165 && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
166 /* Define inline function as optimization. */
167 extern __inline size_t mbrlen (__const char *s, size_t n, mbstate_t *ps)
168 { return ps != NULL ? mbrtowc (NULL, s, n, ps) : __mbrlen (s, n, NULL); }
169 #endif
171 /* Write wide character representation of multibyte chracter string SRC
172 to DST. */
173 extern size_t mbsrtowcs __P ((wchar_t *__dst, __const char **__src,
174 size_t __len, mbstate_t *__ps));
176 /* Write multibyte character representation of wide character string
177 SRC to DST. */
178 extern size_t wcsrtombs __P ((char *__dst, __const wchar_t **__src,
179 size_t __len, mbstate_t *__ps));
182 #ifdef __USE_GNU
183 /* The following functions are extensions found in X/Open CAE. */
185 /* Determine number of column positions required for C. */
186 extern int wcwidth __P ((wint_t __c));
188 /* Determine number of column positions required for first N wide
189 characters (or fewer if S ends before this) in S. */
190 extern int wcswidth __P ((__const wchar_t *__s, size_t __n));
191 #endif /* use GNU */
194 /* Convert initial portion of the wide string NPTR to `double'
195 representation. */
196 extern double wcstod __P ((__const wchar_t *__nptr, wchar_t **__endptr));
198 #ifdef __USE_GNU
199 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
200 extern float wcstof __P ((__const wchar_t *__nptr, wchar_t **__endptr));
201 extern __long_double_t wcstold __P ((__const wchar_t *__nptr,
202 wchar_t **__endptr));
203 #endif /* GNU */
206 /* Convert initial portion of wide string NPTR to `long int'
207 representation. */
208 extern long int wcstol __P ((__const wchar_t *__nptr, wchar_t **__endptr,
209 int __base));
211 /* Convert initial portion of wide string NPTR to `unsigned long int'
212 representation. */
213 extern unsigned long int wcstoul __P ((__const wchar_t *__nptr,
214 wchar_t **__endptr, int __base));
216 #if defined (__GNUC__) && defined (__USE_GNU)
217 /* Convert initial portion of wide string NPTR to `long int'
218 representation. */
219 extern long long int wcstoq __P ((__const wchar_t *__nptr, wchar_t **__endptr,
220 int __base));
222 /* Convert initial portion of wide string NPTR to `unsigned long long int'
223 representation. */
224 extern unsigned long long int wcstouq __P ((__const wchar_t *__nptr,
225 wchar_t **__endptr, int __base));
226 #endif /* GCC and use GNU. */
229 /* The internal entry points for `wcstoX' take an extra flag argument
230 saying whether or not to parse locale-dependent number grouping. */
231 extern double __wcstod_internal __P ((__const wchar_t *__nptr,
232 wchar_t **_endptr, int __group));
233 extern float __wcstof_internal __P ((__const wchar_t *__nptr,
234 wchar_t **_endptr, int __group));
235 extern __long_double_t __wcstold_internal __P ((__const wchar_t *__nptr,
236 wchar_t **_endptr,
237 int __group));
239 extern long int __wcstol_internal __P ((__const wchar_t *__nptr,
240 wchar_t **__endptr, int __base,
241 int __group));
242 extern unsigned long int __wcstoul_internal __P ((__const wchar_t *__nptr,
243 wchar_t **__endptr,
244 int __base, int __group));
245 #ifdef __GNUC__
246 extern long long int __wcstoq_internal __P ((__const wchar_t *__nptr,
247 wchar_t **__endptr, int __base,
248 int __group));
249 extern unsigned long long int __wcstouq_internal __P ((__const wchar_t *__nptr,
250 wchar_t **__endptr,
251 int __base,
252 int __group));
253 #endif /* GCC */
256 #if defined (__OPTIMIZE__) && __GNUC__ >= 2
257 /* Define inline functions which call the internal entry points. */
259 extern __inline double wcstod (__const wchar_t *__nptr, wchar_t **__endptr)
260 { return __wcstod_internal (__nptr, __endptr, 0); }
261 extern __inline long int wcstol (__const wchar_t *__nptr,
262 wchar_t **__endptr, int __base)
263 { return __wcstol_internal (__nptr, __endptr, __base, 0); }
264 extern __inline unsigned long int wcstoul (__const wchar_t *__nptr,
265 wchar_t **__endptr, int __base)
266 { return __wcstoul_internal (__nptr, __endptr, __base, 0); }
268 #ifdef __USE_GNU
269 extern __inline float wcstof (__const wchar_t *__nptr, wchar_t **__endptr)
270 { return __wcstof_internal (__nptr, __endptr, 0); }
271 extern __inline __long_double_t wcstold (__const wchar_t *__nptr,
272 wchar_t **__endptr)
273 { return __wcstold_internal (__nptr, __endptr, 0); }
274 #endif
276 #ifdef __USE_BSD
277 extern __inline long long int wcstoq (__const wchar_t *__nptr,
278 wchar_t **__endptr, int __base)
279 { return __wcstoq_internal (__nptr, __endptr, __base, 0); }
280 extern __inline unsigned long long int wcstouq (__const wchar_t *__nptr,
281 wchar_t **__endptr, int __base)
282 { return __wcstouq_internal (__nptr, __endptr, __base, 0); }
283 #endif
284 #endif /* Optimizing GCC >=2. */
287 #ifdef __USE_GNU
288 /* Copy SRC to DEST, returning the address of the terminating L'\0' in
289 DEST. */
290 extern wchar_t *__wcpcpy __P ((wchar_t *__dest, __const wchar_t *__src));
291 extern wchar_t *wcpcpy __P ((wchar_t *__dest, __const wchar_t *__src));
293 /* Copy no more than N characters of SRC to DEST, returning the address of
294 the last character written into DEST. */
295 extern wchar_t *__wcpncpy __P ((wchar_t *__dest, __const wchar_t *__src,
296 size_t __n));
297 extern wchar_t *wcpncpy __P ((wchar_t *__dest, __const wchar_t *__src,
298 size_t __n));
299 #endif /* use GNU */
302 __END_DECLS
304 #endif /* wchar.h */