master
1/*-
2 * Copyright (c)1999 Citrus Project,
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: /repoman/r/ncvs/src/include/wchar.h,v 1.34 2003/03/13 06:29:53 tjr Exp $
27 */
28
29/*-
30 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
31 * All rights reserved.
32 *
33 * This code is derived from software contributed to The NetBSD Foundation
34 * by Julian Coleman.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by the NetBSD
47 * Foundation, Inc. and its contributors.
48 * 4. Neither the name of The NetBSD Foundation nor the names of its
49 * contributors may be used to endorse or promote products derived
50 * from this software without specific prior written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
53 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
54 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
56 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
57 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
58 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
59 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
60 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
61 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
62 * POSSIBILITY OF SUCH DAMAGE.
63 *
64 * $NetBSD: wchar.h,v 1.8 2000/12/22 05:31:42 itojun Exp $
65 */
66
67#ifndef _WCHAR_H_
68#define _WCHAR_H_
69
70#include <_bounds.h>
71#include <_types.h>
72#include <sys/cdefs.h>
73#include <Availability.h>
74
75#include <sys/_types/_null.h>
76#include <sys/_types/_size_t.h>
77#include <sys/_types/_mbstate_t.h>
78#include <sys/_types/_ct_rune_t.h>
79#include <sys/_types/_rune_t.h>
80#include <sys/_types/_wchar_t.h>
81
82#ifndef WCHAR_MIN
83#define WCHAR_MIN __DARWIN_WCHAR_MIN
84#endif
85
86#ifndef WCHAR_MAX
87#define WCHAR_MAX __DARWIN_WCHAR_MAX
88#endif
89
90#include <stdarg.h>
91#include <stdio.h>
92#include <time.h>
93#include <__wctype.h>
94
95_LIBC_SINGLE_BY_DEFAULT()
96
97/* Initially added in Issue 4 */
98__BEGIN_DECLS
99wint_t btowc(int);
100wint_t fgetwc(FILE *);
101wchar_t *_LIBC_CSTR
102 fgetws(wchar_t * __restrict _LIBC_COUNT(__n), int __n,
103 FILE * __restrict);
104wint_t fputwc(wchar_t, FILE *);
105int fputws(const wchar_t * __restrict, FILE * __restrict);
106int fwide(FILE *, int);
107int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
108int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
109wint_t getwc(FILE *);
110wint_t getwchar(void);
111size_t mbrlen(const char * __restrict _LIBC_COUNT(__n), size_t __n,
112 mbstate_t * __restrict);
113size_t mbrtowc(wchar_t * __restrict, const char * __restrict _LIBC_COUNT(__n),
114 size_t __n, mbstate_t * __restrict);
115int mbsinit(const mbstate_t *);
116size_t mbsrtowcs(wchar_t * __restrict _LIBC_COUNT(__len),
117 const char ** __restrict, size_t __len, mbstate_t * __restrict);
118wint_t putwc(wchar_t, FILE *);
119wint_t putwchar(wchar_t);
120int swprintf(wchar_t * __restrict _LIBC_COUNT(__maxlen), size_t __maxlen,
121 const wchar_t * __restrict, ...);
122int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...);
123wint_t ungetwc(wint_t, FILE *);
124int vfwprintf(FILE * __restrict, const wchar_t * __restrict,
125 __darwin_va_list);
126int vswprintf(wchar_t * __restrict _LIBC_COUNT(__maxlen), size_t __maxlen,
127 const wchar_t * __restrict, __darwin_va_list);
128int vwprintf(const wchar_t * __restrict, __darwin_va_list);
129size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
130wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict);
131wchar_t *wcschr(const wchar_t *, wchar_t);
132int wcscmp(const wchar_t *, const wchar_t *);
133int wcscoll(const wchar_t *, const wchar_t *);
134wchar_t *wcscpy(wchar_t * __restrict _LIBC_UNSAFE_INDEXABLE,
135 const wchar_t * __restrict) _LIBC_PTRCHECK_REPLACED(wcslcpy);
136size_t wcscspn(const wchar_t *, const wchar_t *);
137size_t wcsftime(wchar_t * __restrict _LIBC_COUNT(__maxlen), size_t __maxlen,
138 const wchar_t * __restrict, const struct tm * __restrict)
139 __DARWIN_ALIAS(wcsftime);
140size_t wcslen(const wchar_t *);
141wchar_t *_LIBC_UNSAFE_INDEXABLE
142 wcsncat(wchar_t * __restrict _LIBC_UNSAFE_INDEXABLE,
143 const wchar_t * __restrict _LIBC_COUNT(__n), size_t __n)
144 _LIBC_PTRCHECK_REPLACED(wcslcat);
145int wcsncmp(const wchar_t *_LIBC_UNSAFE_INDEXABLE,
146 const wchar_t *_LIBC_UNSAFE_INDEXABLE, size_t);
147wchar_t *_LIBC_COUNT(__n)
148 wcsncpy(wchar_t * __restrict _LIBC_COUNT(__n),
149 const wchar_t * __restrict _LIBC_UNSAFE_INDEXABLE, size_t __n)
150 _LIBC_PTRCHECK_REPLACED(wcslcpy);
151wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
152wchar_t *wcsrchr(const wchar_t *, wchar_t);
153size_t wcsrtombs(char * __restrict _LIBC_COUNT(__len),
154 const wchar_t ** __restrict, size_t __len, mbstate_t * __restrict);
155size_t wcsspn(const wchar_t *, const wchar_t *);
156wchar_t *wcsstr(const wchar_t * __restrict, const wchar_t * __restrict);
157size_t wcsxfrm(wchar_t * __restrict _LIBC_COUNT(__n),
158 const wchar_t * __restrict, size_t __n);
159int wctob(wint_t);
160double wcstod(const wchar_t * __restrict, wchar_t ** __restrict);
161wchar_t *_LIBC_CSTR
162 wcstok(wchar_t * __restrict _LIBC_CSTR, const wchar_t * __restrict,
163 wchar_t *_LIBC_CSTR * __restrict);
164long wcstol(const wchar_t * __restrict, wchar_t *_LIBC_CSTR * __restrict,
165 int);
166unsigned long
167 wcstoul(const wchar_t * __restrict, wchar_t *_LIBC_CSTR * __restrict, int);
168wchar_t *_LIBC_UNSAFE_INDEXABLE /* in bounds of arg1 */
169 wmemchr(const wchar_t *_LIBC_COUNT(__n) /*arg1*/, wchar_t, size_t __n);
170int wmemcmp(const wchar_t *_LIBC_COUNT(__n), const wchar_t *_LIBC_COUNT(__n),
171 size_t __n);
172wchar_t *_LIBC_COUNT(__n)
173 wmemcpy(wchar_t * __restrict _LIBC_COUNT(__n),
174 const wchar_t * __restrict _LIBC_COUNT(__n), size_t __n);
175wchar_t *_LIBC_COUNT(__n)
176 wmemmove(wchar_t *_LIBC_COUNT(__n), const wchar_t *_LIBC_COUNT(__n),
177 size_t __n);
178wchar_t *_LIBC_COUNT(__n)
179 wmemset(wchar_t *_LIBC_COUNT(__n), wchar_t, size_t __n);
180int wprintf(const wchar_t * __restrict, ...);
181int wscanf(const wchar_t * __restrict, ...);
182int wcswidth(const wchar_t *_LIBC_COUNT(__n), size_t __n);
183int wcwidth(wchar_t);
184__END_DECLS
185
186
187
188/* Additional functionality provided by:
189 * POSIX.1-2001
190 * ISO C99
191 */
192
193#if __DARWIN_C_LEVEL >= 200112L || defined(_C99_SOURCE) || defined(__cplusplus)
194__BEGIN_DECLS
195int vfwscanf(FILE * __restrict, const wchar_t * __restrict,
196 __darwin_va_list);
197int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict,
198 __darwin_va_list);
199int vwscanf(const wchar_t * __restrict, __darwin_va_list);
200float wcstof(const wchar_t * __restrict, wchar_t *_LIBC_CSTR * __restrict);
201long double
202 wcstold(const wchar_t * __restrict, wchar_t *_LIBC_CSTR * __restrict);
203#if !__DARWIN_NO_LONG_LONG
204long long
205 wcstoll(const wchar_t * __restrict, wchar_t *_LIBC_CSTR * __restrict, int);
206unsigned long long
207 wcstoull(const wchar_t * __restrict, wchar_t *_LIBC_CSTR * __restrict, int);
208#endif /* !__DARWIN_NO_LONG_LONG */
209__END_DECLS
210#endif
211
212
213
214/* Additional functionality provided by:
215 * POSIX.1-2008
216 */
217
218#if __DARWIN_C_LEVEL >= 200809L
219__BEGIN_DECLS
220size_t mbsnrtowcs(wchar_t * __restrict _LIBC_COUNT(__len),
221 const char *_LIBC_UNSAFE_INDEXABLE* __restrict, size_t, size_t __len,
222 mbstate_t * __restrict);
223wchar_t *_LIBC_UNSAFE_INDEXABLE wcpcpy(
224 wchar_t * __restrict _LIBC_UNSAFE_INDEXABLE,
225 const wchar_t * __restrict) _LIBC_PTRCHECK_REPLACED(wcslcpy)
226 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3)
227 _LIBC_PTRCHECK_REPLACED(wcslcpy);
228wchar_t *_LIBC_COUNT(__n) wcpncpy(
229 wchar_t * __restrict _LIBC_COUNT(__n),
230 const wchar_t * __restrict _LIBC_UNSAFE_INDEXABLE, size_t __n)
231 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3)
232 _LIBC_PTRCHECK_REPLACED(wcslcpy);
233wchar_t *_LIBC_CSTR wcsdup(const wchar_t *)
234 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
235int wcscasecmp(const wchar_t *, const wchar_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
236int wcsncasecmp(const wchar_t *_LIBC_UNSAFE_INDEXABLE, const wchar_t *_LIBC_UNSAFE_INDEXABLE, size_t n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
237size_t wcsnlen(const wchar_t *_LIBC_COUNT(__n), size_t __n) __pure __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
238size_t wcsnrtombs(char * __restrict _LIBC_COUNT(__len), const wchar_t ** __restrict, size_t,
239 size_t __len, mbstate_t * __restrict);
240FILE *open_wmemstream(wchar_t *_LIBC_COUNT(*__sizep) * __bufp, size_t * __sizep) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
241__END_DECLS
242#endif /* __DARWIN_C_LEVEL >= 200809L */
243
244
245
246/* Darwin extensions */
247
248#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
249__BEGIN_DECLS
250wchar_t *_LIBC_COUNT(*__len)
251 fgetwln(FILE * __restrict, size_t *__len) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
252size_t wcslcat(wchar_t *_LIBC_COUNT(__len), const wchar_t *, size_t __len);
253size_t wcslcpy(wchar_t *_LIBC_COUNT(__len), const wchar_t *, size_t __len);
254__END_DECLS
255#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
256
257
258/* Poison the following routines if -fshort-wchar is set */
259#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU
260#pragma GCC poison fgetwln fgetws fputwc fputws fwprintf fwscanf mbrtowc mbsnrtowcs mbsrtowcs putwc putwchar swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf vwprintf vwscanf wcrtomb wcscat wcschr wcscmp wcscoll wcscpy wcscspn wcsftime wcsftime wcslcat wcslcpy wcslen wcsncat wcsncmp wcsncpy wcsnrtombs wcspbrk wcsrchr wcsrtombs wcsspn wcsstr wcstod wcstof wcstok wcstol wcstold wcstoll wcstoul wcstoull wcswidth wcsxfrm wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset wprintf wscanf
261#endif
262
263#endif /* !_WCHAR_H_ */