]> git.ipfire.org Git - thirdparty/glibc.git/blame - wcsmbs/wchar.h
update from 961105, second try
[thirdparty/glibc.git] / wcsmbs / wchar.h
CommitLineData
30de3b18 1/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
b5791037 2 This file is part of the GNU C Library.
30de3b18 3
b5791037
UD
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.
30de3b18 8
b5791037
UD
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.
30de3b18 13
b5791037
UD
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 not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
30de3b18
RM
18
19/*
b5791037
UD
20 * ISO C Standard, Amendment 1, 7.16.4
21 * General wide-string utilities <wchar.h>
30de3b18
RM
22 */
23
24#ifndef _WCHAR_H
25
26#define _WCHAR_H 1
27#include <features.h>
28
29__BEGIN_DECLS
30
59dd8641 31/* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */
30de3b18
RM
32#define __need_size_t
33#define __need_wchar_t
59dd8641 34#define __need_wint_t
30de3b18 35#define __need_NULL
30de3b18
RM
36#include <stddef.h>
37
71a40c74
RM
38
39/* We try to get wint_t from <stddef.h>, but not all GCC versions define it
40 there. So define it ourselves if it remains undefined. */
41#ifndef _WINT_T
42/* Integral type unchanged by default argument promotions that can
43 hold any value corresponding to members of the extended character
44 set, as well as at least one value that does not correspond to any
45 member of the extended character set. */
46#define _WINT_T
47typedef unsigned int wint_t;
48#endif
49
50
30de3b18 51/* Conversion state information. */
07a4742f
RM
52typedef struct
53{
54 int count; /* Number of bytes needed for the current character. */
55 wint_t value; /* Value so far. */
56} mbstate_t;
30de3b18 57
59dd8641
RM
58#define WCHAR_MIN ((wchar_t) 0)
59#define WCHAR_MAX (~WCHAR_MIN)
30de3b18
RM
60
61#ifndef WEOF
62# define WEOF (0xffffffffu)
63#endif
64
30de3b18
RM
65
66/* Copy SRC to DEST. */
67extern wchar_t *wcscpy __P ((wchar_t *__dest, __const wchar_t *__src));
68/* Copy no more than N wide-characters of SRC to DEST. */
69extern wchar_t *wcsncpy __P ((wchar_t *__dest, __const wchar_t *__src,
70 size_t __n));
71
72/* Append SRC onto DEST. */
73extern wchar_t *wcscat __P ((wchar_t *__dest, __const wchar_t *__src));
74/* Append no more than N wide-characters of SRC onto DEST. */
75extern wchar_t *wcsncat __P ((wchar_t *__dest, __const wchar_t *__src,
76 size_t __n));
77
78/* Compare S1 and S2. */
79extern int wcscmp __P ((__const wchar_t *__s1, __const wchar_t *__s2));
80/* Compare N wide-characters of S1 and S2. */
81extern int wcsncmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
82 size_t __n));
83
75cd5204
RM
84/* Compare S1 and S2, both interpreted as appropriate to the
85 LC_COLLATE category of the current locale. */
86extern int wcscoll __P ((__const wchar_t *__s1, __const wchar_t *__s2));
87/* Transform S2 into array pointed to by S1 such that if wcscmp is
88 applied to two transformed strings the result is the as applying
89 `wcscoll' to the original strings. */
90extern size_t wcsxfrm __P ((wchar_t *__s1, __const wchar_t *__s2, size_t __n));
91
30de3b18
RM
92/* Duplicate S, returning an identical malloc'd string. */
93extern wchar_t *wcsdup __P ((__const wchar_t *__s));
94
95/* Find the first occurence of WC in WCS. */
96extern wchar_t *wcschr __P ((__const wchar_t *__wcs, wchar_t __wc));
97/* Find the last occurence of WC in WCS. */
98extern wchar_t *wcsrchr __P ((__const wchar_t *__wcs, wchar_t __wc));
99
100/* Return the length of the initial segmet of WCS which
101 consists entirely of wide-characters not in REJECT. */
102extern size_t wcscspn __P ((__const wchar_t *__wcs,
103 __const wchar_t *__reject));
104/* Return the length of the initial segmet of WCS which
105 consists entirely of wide-characters in ACCEPT. */
106extern size_t wcsspn __P ((__const wchar_t *__wcs, __const wchar_t *__accept));
107/* Find the first occurence in WCS of any character in ACCEPT. */
108extern wchar_t *wcspbrk __P ((__const wchar_t *__wcs,
109 __const wchar_t *__accept));
110/* Find the first occurence of NEEDLE in HAYSTACK. */
111extern wchar_t *wcsstr __P ((__const wchar_t *__haystack,
112 __const wchar_t *__needle));
113/* Divide WCS into tokens separated by characters in DELIM. */
114extern wchar_t *wcstok __P ((wchar_t *__s, __const wchar_t *__delim,
115 wchar_t **ptr));
116
117/* Return the number of wide-characters in S. */
118extern size_t wcslen __P ((__const wchar_t *__s));
119
120
121/* Search N bytes of S for C. */
122extern wchar_t *wmemchr __P ((__const wchar_t *__s, wchar_t __c, size_t __n));
123
124/* Compare N bytes of S1 and S2. */
125extern int wmemcmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
126 size_t __n));
127
128/* Copy N bytes of SRC to DEST. */
129extern wchar_t *wmemcpy __P ((wchar_t *__s1, __const wchar_t *__s2,
130 size_t __n));
131
132/* Copy N bytes of SRC to DEST, guaranteeing
133 correct behavior for overlapping strings. */
134extern wchar_t *wmemmove __P ((wchar_t *__s1, __const wchar_t *__s2,
036cc82f 135 size_t __n));
30de3b18
RM
136
137/* Set N bytes of S to C. */
138extern wchar_t *wmemset __P ((wchar_t *__s, wchar_t __c, size_t __n));
139
140
141/* Determine whether C constitutes a valid (one-byte) multibyte
142 character. */
143extern wint_t btowc __P ((int __c));
144
145/* Determine whether C corresponds to a member of the extended
146 character set whose multibyte representation is a single byte. */
147extern int wctob __P ((wint_t __c));
148
149/* Determine whether PS points to an object representing the initial
150 state. */
151extern int mbsinit __P ((__const mbstate_t *__ps));
152
30de3b18
RM
153/* Write wide character representation of multibyte character pointed
154 to by S to PWC. */
23396375
UD
155extern size_t __mbrtowc __P ((wchar_t *__pwc, __const char *__s, size_t __n,
156 mbstate_t *__p));
30de3b18
RM
157extern size_t mbrtowc __P ((wchar_t *__pwc, __const char *__s, size_t __n,
158 mbstate_t *__p));
159
160/* Write multibyte representation of wide character WC to S. */
23396375 161extern size_t __wcrtomb __P ((char *__s, wchar_t __wc, mbstate_t *__ps));
30de3b18
RM
162extern size_t wcrtomb __P ((char *__s, wchar_t __wc, mbstate_t *__ps));
163
07a4742f
RM
164/* Return number of bytes in multibyte character pointed to by S. */
165extern size_t __mbrlen __P ((__const char *__s, size_t __n, mbstate_t *__ps));
166extern size_t mbrlen __P ((__const char *__s, size_t __n, mbstate_t *__ps));
167
168#if defined (__OPTIMIZE__) \
169 && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
170/* Define inline function as optimization. */
171extern __inline size_t mbrlen (__const char *s, size_t n, mbstate_t *ps)
23396375 172{ return ps != NULL ? __mbrtowc (NULL, s, n, ps) : __mbrlen (s, n, NULL); }
07a4742f
RM
173#endif
174
036cc82f
RM
175/* Write wide character representation of multibyte character string
176 SRC to DST. */
23396375
UD
177extern size_t __mbsrtowcs __P ((wchar_t *__dst, __const char **__src,
178 size_t __len, mbstate_t *__ps));
30de3b18
RM
179extern size_t mbsrtowcs __P ((wchar_t *__dst, __const char **__src,
180 size_t __len, mbstate_t *__ps));
181
182/* Write multibyte character representation of wide character string
183 SRC to DST. */
23396375
UD
184extern size_t __wcsrtombs __P ((char *__dst, __const wchar_t **__src,
185 size_t __len, mbstate_t *__ps));
30de3b18
RM
186extern size_t wcsrtombs __P ((char *__dst, __const wchar_t **__src,
187 size_t __len, mbstate_t *__ps));
188
75cd5204
RM
189
190#ifdef __USE_GNU
036cc82f
RM
191/* Write wide character representation of at most NMC bytes of the
192 multibyte character string SRC to DST. */
193extern size_t __mbsnrtowcs __P ((wchar_t *__dst, __const char **__src,
194 size_t __nmc, size_t __len, mbstate_t *__ps));
195extern size_t mbsnrtowcs __P ((wchar_t *__dst, __const char **__src,
196 size_t __nmc, size_t __len, mbstate_t *__ps));
197
198/* Write multibyte character representation of at most NWC characters
199 from the wide character string SRC to DST. */
200extern size_t __wcsnrtombs __P ((char *__dst, __const wchar_t **__src,
201 size_t __nwc, size_t __len, mbstate_t *__ps));
202extern size_t wcsnrtombs __P ((char *__dst, __const wchar_t **__src,
203 size_t __nwc, size_t __len, mbstate_t *__ps));
204
205
75cd5204
RM
206/* The following functions are extensions found in X/Open CAE. */
207
208/* Determine number of column positions required for C. */
209extern int wcwidth __P ((wint_t __c));
210
211/* Determine number of column positions required for first N wide
212 characters (or fewer if S ends before this) in S. */
213extern int wcswidth __P ((__const wchar_t *__s, size_t __n));
214#endif /* use GNU */
215
216
217/* Convert initial portion of the wide string NPTR to `double'
218 representation. */
219extern double wcstod __P ((__const wchar_t *__nptr, wchar_t **__endptr));
220
fa0bc87c 221#ifdef __USE_GNU
75cd5204
RM
222/* Likewise for `float' and `long double' sizes of floating-point numbers. */
223extern float wcstof __P ((__const wchar_t *__nptr, wchar_t **__endptr));
224extern __long_double_t wcstold __P ((__const wchar_t *__nptr,
225 wchar_t **__endptr));
226#endif /* GNU */
227
228
229/* Convert initial portion of wide string NPTR to `long int'
230 representation. */
231extern long int wcstol __P ((__const wchar_t *__nptr, wchar_t **__endptr,
232 int __base));
233
234/* Convert initial portion of wide string NPTR to `unsigned long int'
235 representation. */
236extern unsigned long int wcstoul __P ((__const wchar_t *__nptr,
237 wchar_t **__endptr, int __base));
238
239#if defined (__GNUC__) && defined (__USE_GNU)
240/* Convert initial portion of wide string NPTR to `long int'
241 representation. */
242extern long long int wcstoq __P ((__const wchar_t *__nptr, wchar_t **__endptr,
243 int __base));
244
245/* Convert initial portion of wide string NPTR to `unsigned long long int'
246 representation. */
247extern unsigned long long int wcstouq __P ((__const wchar_t *__nptr,
248 wchar_t **__endptr, int __base));
249#endif /* GCC and use GNU. */
250
251
252/* The internal entry points for `wcstoX' take an extra flag argument
253 saying whether or not to parse locale-dependent number grouping. */
254extern double __wcstod_internal __P ((__const wchar_t *__nptr,
036cc82f 255 wchar_t **__endptr, int __group));
75cd5204 256extern float __wcstof_internal __P ((__const wchar_t *__nptr,
036cc82f 257 wchar_t **__endptr, int __group));
75cd5204 258extern __long_double_t __wcstold_internal __P ((__const wchar_t *__nptr,
036cc82f 259 wchar_t **__endptr,
75cd5204
RM
260 int __group));
261
262extern long int __wcstol_internal __P ((__const wchar_t *__nptr,
263 wchar_t **__endptr, int __base,
264 int __group));
265extern unsigned long int __wcstoul_internal __P ((__const wchar_t *__nptr,
266 wchar_t **__endptr,
267 int __base, int __group));
57ba7bb4 268#if defined __GNUC__ && defined __USE_GNU
75cd5204
RM
269extern long long int __wcstoq_internal __P ((__const wchar_t *__nptr,
270 wchar_t **__endptr, int __base,
271 int __group));
272extern unsigned long long int __wcstouq_internal __P ((__const wchar_t *__nptr,
273 wchar_t **__endptr,
274 int __base,
275 int __group));
57ba7bb4 276#endif /* GCC and use GNU. */
75cd5204
RM
277
278
279#if defined (__OPTIMIZE__) && __GNUC__ >= 2
280/* Define inline functions which call the internal entry points. */
281
282extern __inline double wcstod (__const wchar_t *__nptr, wchar_t **__endptr)
283{ return __wcstod_internal (__nptr, __endptr, 0); }
284extern __inline long int wcstol (__const wchar_t *__nptr,
285 wchar_t **__endptr, int __base)
286{ return __wcstol_internal (__nptr, __endptr, __base, 0); }
287extern __inline unsigned long int wcstoul (__const wchar_t *__nptr,
288 wchar_t **__endptr, int __base)
289{ return __wcstoul_internal (__nptr, __endptr, __base, 0); }
290
291#ifdef __USE_GNU
292extern __inline float wcstof (__const wchar_t *__nptr, wchar_t **__endptr)
293{ return __wcstof_internal (__nptr, __endptr, 0); }
294extern __inline __long_double_t wcstold (__const wchar_t *__nptr,
295 wchar_t **__endptr)
296{ return __wcstold_internal (__nptr, __endptr, 0); }
75cd5204 297
57ba7bb4 298
75cd5204
RM
299extern __inline long long int wcstoq (__const wchar_t *__nptr,
300 wchar_t **__endptr, int __base)
301{ return __wcstoq_internal (__nptr, __endptr, __base, 0); }
302extern __inline unsigned long long int wcstouq (__const wchar_t *__nptr,
303 wchar_t **__endptr, int __base)
304{ return __wcstouq_internal (__nptr, __endptr, __base, 0); }
57ba7bb4 305#endif /* Use GNU. */
75cd5204
RM
306#endif /* Optimizing GCC >=2. */
307
308
309#ifdef __USE_GNU
310/* Copy SRC to DEST, returning the address of the terminating L'\0' in
311 DEST. */
312extern wchar_t *__wcpcpy __P ((wchar_t *__dest, __const wchar_t *__src));
313extern wchar_t *wcpcpy __P ((wchar_t *__dest, __const wchar_t *__src));
314
315/* Copy no more than N characters of SRC to DEST, returning the address of
316 the last character written into DEST. */
317extern wchar_t *__wcpncpy __P ((wchar_t *__dest, __const wchar_t *__src,
318 size_t __n));
319extern wchar_t *wcpncpy __P ((wchar_t *__dest, __const wchar_t *__src,
320 size_t __n));
321#endif /* use GNU */
322
323
30de3b18
RM
324__END_DECLS
325
326#endif /* wchar.h */