xref: /openbsd/include/wchar.h (revision 3a628b46)
1*3a628b46Sschwarze /*	$OpenBSD: wchar.h,v 1.31 2017/09/05 03:16:13 schwarze Exp $	*/
2bc92a556Sespie /*	$NetBSD: wchar.h,v 1.16 2003/03/07 07:11:35 tshiozak Exp $	*/
3bc92a556Sespie 
4bc92a556Sespie /*-
5bc92a556Sespie  * Copyright (c)1999 Citrus Project,
6bc92a556Sespie  * All rights reserved.
7bc92a556Sespie  *
8bc92a556Sespie  * Redistribution and use in source and binary forms, with or without
9bc92a556Sespie  * modification, are permitted provided that the following conditions
10bc92a556Sespie  * are met:
11bc92a556Sespie  * 1. Redistributions of source code must retain the above copyright
12bc92a556Sespie  *    notice, this list of conditions and the following disclaimer.
13bc92a556Sespie  * 2. Redistributions in binary form must reproduce the above copyright
14bc92a556Sespie  *    notice, this list of conditions and the following disclaimer in the
15bc92a556Sespie  *    documentation and/or other materials provided with the distribution.
16bc92a556Sespie  *
17bc92a556Sespie  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18bc92a556Sespie  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19bc92a556Sespie  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20bc92a556Sespie  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21bc92a556Sespie  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22bc92a556Sespie  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23bc92a556Sespie  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24bc92a556Sespie  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25bc92a556Sespie  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26bc92a556Sespie  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27bc92a556Sespie  * SUCH DAMAGE.
28bc92a556Sespie  */
29bc92a556Sespie 
30bc92a556Sespie /*-
31bc92a556Sespie  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
32bc92a556Sespie  * All rights reserved.
33bc92a556Sespie  *
34bc92a556Sespie  * This code is derived from software contributed to The NetBSD Foundation
35bc92a556Sespie  * by Julian Coleman.
36bc92a556Sespie  *
37bc92a556Sespie  * Redistribution and use in source and binary forms, with or without
38bc92a556Sespie  * modification, are permitted provided that the following conditions
39bc92a556Sespie  * are met:
40bc92a556Sespie  * 1. Redistributions of source code must retain the above copyright
41bc92a556Sespie  *    notice, this list of conditions and the following disclaimer.
42bc92a556Sespie  * 2. Redistributions in binary form must reproduce the above copyright
43bc92a556Sespie  *    notice, this list of conditions and the following disclaimer in the
44bc92a556Sespie  *    documentation and/or other materials provided with the distribution.
45bc92a556Sespie  *
46bc92a556Sespie  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
47bc92a556Sespie  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
48bc92a556Sespie  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49bc92a556Sespie  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
50bc92a556Sespie  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
51bc92a556Sespie  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
52bc92a556Sespie  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
53bc92a556Sespie  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
54bc92a556Sespie  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55bc92a556Sespie  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
56bc92a556Sespie  * POSSIBILITY OF SUCH DAMAGE.
57bc92a556Sespie  */
58bc92a556Sespie 
59bc92a556Sespie #ifndef _WCHAR_H_
60bc92a556Sespie #define _WCHAR_H_
61bc92a556Sespie 
62bc92a556Sespie #include <sys/cdefs.h>
636ecde746Smillert #include <sys/_null.h>
64c916d948Smillert #include <sys/_types.h>
65bc92a556Sespie 
66bc92a556Sespie #include <stdio.h> /* for FILE* */
67bc92a556Sespie 
68c916d948Smillert #if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus)
69c916d948Smillert #define _WCHAR_T_DEFINED_
70c916d948Smillert typedef	__wchar_t	wchar_t;
71bc92a556Sespie #endif
72bc92a556Sespie 
73c916d948Smillert #ifndef	_MBSTATE_T_DEFINED_
74c916d948Smillert #define	_MBSTATE_T_DEFINED_
75c916d948Smillert typedef	__mbstate_t	mbstate_t;
76561d433dSespie #endif
77561d433dSespie 
78c916d948Smillert #ifndef	_WINT_T_DEFINED_
79c916d948Smillert #define	_WINT_T_DEFINED_
80c916d948Smillert typedef	__wint_t	wint_t;
81bc92a556Sespie #endif
82bc92a556Sespie 
83c916d948Smillert #ifndef	_SIZE_T_DEFINED_
84c916d948Smillert #define	_SIZE_T_DEFINED_
85c916d948Smillert typedef	__size_t	size_t;
86bc92a556Sespie #endif
87bc92a556Sespie 
88bc92a556Sespie #ifndef	WEOF
89bc92a556Sespie #define	WEOF 	((wint_t)-1)
90bc92a556Sespie #endif
91bc92a556Sespie 
92ff74d4c2Skettenis #ifndef	WCHAR_MIN
93ff74d4c2Skettenis #define	WCHAR_MIN	(-0x7fffffff - 1)
94ff74d4c2Skettenis #endif
95ff74d4c2Skettenis #ifndef	WCHAR_MAX
96ff74d4c2Skettenis #define	WCHAR_MAX	0x7fffffff
97ff74d4c2Skettenis #endif
98ff74d4c2Skettenis 
99*3a628b46Sschwarze #if __POSIX_VISIBLE >= 200809
100*3a628b46Sschwarze #ifndef	_LOCALE_T_DEFINED_
101*3a628b46Sschwarze #define	_LOCALE_T_DEFINED_
102*3a628b46Sschwarze typedef void	*locale_t;
103*3a628b46Sschwarze #endif
104*3a628b46Sschwarze #endif
105*3a628b46Sschwarze 
106bc92a556Sespie __BEGIN_DECLS
107561d433dSespie wint_t	btowc(int);
108561d433dSespie size_t	mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
109561d433dSespie size_t	mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
110561d433dSespie 	    mbstate_t * __restrict);
111561d433dSespie int	mbsinit(const mbstate_t *);
112561d433dSespie size_t	mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
1130ad9e877Smartynas 	    mbstate_t * __restrict)
1140ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,3)));
115561d433dSespie size_t	wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
116bc92a556Sespie wchar_t	*wcscat(wchar_t * __restrict, const wchar_t * __restrict);
117bc92a556Sespie wchar_t	*wcschr(const wchar_t *, wchar_t);
118bc92a556Sespie int	wcscmp(const wchar_t *, const wchar_t *);
119bc92a556Sespie int	wcscoll(const wchar_t *, const wchar_t *);
120bc92a556Sespie wchar_t	*wcscpy(wchar_t * __restrict, const wchar_t * __restrict);
121bc92a556Sespie size_t	wcscspn(const wchar_t *, const wchar_t *);
122bc92a556Sespie size_t	wcslen(const wchar_t *);
123bc92a556Sespie wchar_t	*wcsncat(wchar_t * __restrict, const wchar_t * __restrict,
1240ad9e877Smartynas 	    size_t)
1250ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,3)));
126bc92a556Sespie int	wcsncmp(const wchar_t *, const wchar_t *, size_t);
127bc92a556Sespie wchar_t	*wcsncpy(wchar_t * __restrict , const wchar_t * __restrict,
1280ad9e877Smartynas 	    size_t)
1290ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,3)));
130bc92a556Sespie wchar_t	*wcspbrk(const wchar_t *, const wchar_t *);
131bc92a556Sespie wchar_t	*wcsrchr(const wchar_t *, wchar_t);
132561d433dSespie size_t	wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
1330ad9e877Smartynas 	    mbstate_t * __restrict)
1340ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,3)));
135bc92a556Sespie size_t	wcsspn(const wchar_t *, const wchar_t *);
136bc92a556Sespie wchar_t	*wcsstr(const wchar_t *, const wchar_t *);
137bc92a556Sespie wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict,
138bc92a556Sespie 		     wchar_t ** __restrict);
13938311d31Sespie size_t	wcsxfrm(wchar_t *, const wchar_t *, size_t);
140bc92a556Sespie wchar_t	*wcswcs(const wchar_t *, const wchar_t *);
141bc92a556Sespie wchar_t	*wmemchr(const wchar_t *, wchar_t, size_t);
142bc92a556Sespie int	wmemcmp(const wchar_t *, const wchar_t *, size_t);
143bc92a556Sespie wchar_t	*wmemcpy(wchar_t * __restrict, const wchar_t * __restrict,
1440ad9e877Smartynas 	    size_t)
1450ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,3)))
1460ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,2,3)));
1470ad9e877Smartynas wchar_t	*wmemmove(wchar_t *, const wchar_t *, size_t)
1480ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,3)))
1490ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,2,3)));
1500ad9e877Smartynas wchar_t	*wmemset(wchar_t *, wchar_t, size_t)
1510ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,3)));
152bc92a556Sespie 
15338311d31Sespie int	wcswidth(const wchar_t *, size_t);
154561d433dSespie int	wctob(wint_t);
15538311d31Sespie int	wcwidth(wchar_t);
15638311d31Sespie 
15738311d31Sespie double wcstod(const wchar_t * __restrict, wchar_t ** __restrict);
15838311d31Sespie long int wcstol(const wchar_t * __restrict, wchar_t ** __restrict, int base);
15938311d31Sespie unsigned long int wcstoul(const wchar_t * __restrict, wchar_t ** __restrict,
16038311d31Sespie 		int base);
16138311d31Sespie 
162e4bf39f1Smillert #if __POSIX_VISIBLE >= 200809
163236998c6Seric FILE *open_wmemstream(wchar_t **, size_t *);
164236998c6Seric 
165*3a628b46Sschwarze int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
1662dcf140dSnicm wchar_t	*wcsdup(const wchar_t *);
16742569c7dSespie int wcscasecmp(const wchar_t *, const wchar_t *);
168*3a628b46Sschwarze int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
16942569c7dSespie int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
170*3a628b46Sschwarze int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
171*3a628b46Sschwarze size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t);
1725a08728eSmatthew 
1735a08728eSmatthew size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
1740ad9e877Smartynas     size_t, mbstate_t * __restrict)
1750ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,4)));
1765a08728eSmatthew size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
1770ad9e877Smartynas     size_t, mbstate_t * __restrict)
1780ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,4)));
17942569c7dSespie #endif
18042569c7dSespie 
181416b788cSkettenis #if __ISO_C_VISIBLE >= 1999
182416b788cSkettenis float	wcstof(const wchar_t * __restrict, wchar_t ** __restrict);
183416b788cSkettenis long double wcstold(const wchar_t * __restrict, wchar_t ** __restrict);
1849bfcd176Sguenther 
1859bfcd176Sguenther struct tm;
1860b5b2ca2Sstsp size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t *__restrict,
1870b5b2ca2Sstsp 	const struct tm *__restrict);
188416b788cSkettenis #endif
189416b788cSkettenis 
190fd7ad13fSguenther #if !defined(__STRICT_ANSI__) || __ISO_C_VISIBLE >= 1999
19138311d31Sespie long long int wcstoll(const wchar_t * __restrict,
19238311d31Sespie 	wchar_t ** __restrict, int base);
19338311d31Sespie unsigned long long int wcstoull(const wchar_t * __restrict,
19438311d31Sespie 	wchar_t ** __restrict, int base);
19538311d31Sespie #endif
196c2fb3212Sespie 
197c2fb3212Sespie wint_t ungetwc(wint_t, FILE *);
198c2fb3212Sespie wint_t fgetwc(FILE *);
1990ad9e877Smartynas wchar_t *fgetws(wchar_t * __restrict, int, FILE * __restrict)
2000ad9e877Smartynas 		__attribute__ ((__bounded__(__wcstring__,1,2)));
201c2fb3212Sespie wint_t getwc(FILE *);
202c2fb3212Sespie wint_t getwchar(void);
203c2fb3212Sespie wint_t fputwc(wchar_t, FILE *);
204c2fb3212Sespie int fputws(const wchar_t * __restrict, FILE * __restrict);
205c2fb3212Sespie wint_t putwc(wchar_t, FILE *);
206c2fb3212Sespie wint_t putwchar(wchar_t);
207c2fb3212Sespie 
208c2fb3212Sespie int fwide(FILE *, int);
209c2fb3212Sespie 
21025963022Sstsp int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
21125963022Sstsp int swprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict, ...);
21225963022Sstsp int vfwprintf(FILE * __restrict, const wchar_t * __restrict, __va_list);
21325963022Sstsp int vswprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict,
21425963022Sstsp 	__va_list);
21525963022Sstsp int vwprintf(const wchar_t * __restrict, __va_list);
21625963022Sstsp int wprintf(const wchar_t * __restrict, ...);
21725963022Sstsp 
2182d31a56bSstsp int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
2192d31a56bSstsp int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...);
2202d31a56bSstsp int vfwscanf(FILE * __restrict, const wchar_t * __restrict, __va_list);
2212d31a56bSstsp int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict, __va_list);
2222d31a56bSstsp int vwscanf(const wchar_t * __restrict, __va_list);
2232d31a56bSstsp int wscanf(const wchar_t * __restrict, ...);
2242d31a56bSstsp 
2253a41feedSmillert #if __BSD_VISIBLE
2263a41feedSmillert wchar_t *fgetwln(FILE * __restrict, size_t * __restrict);
2273a41feedSmillert size_t	wcslcat(wchar_t *, const wchar_t *, size_t)
2283a41feedSmillert 		__attribute__ ((__bounded__(__wcstring__,1,3)));
2293a41feedSmillert size_t	wcslcpy(wchar_t *, const wchar_t *, size_t)
2303a41feedSmillert 		__attribute__ ((__bounded__(__wcstring__,1,3)));
2313a41feedSmillert #endif
2323a41feedSmillert 
233c2fb3212Sespie #define getwc(f) fgetwc(f)
234c2fb3212Sespie #define getwchar() getwc(stdin)
235c2fb3212Sespie #define putwc(wc, f) fputwc((wc), (f))
236c2fb3212Sespie #define putwchar(wc) putwc((wc), stdout)
237bc92a556Sespie __END_DECLS
238bc92a556Sespie 
239bc92a556Sespie #endif /* !_WCHAR_H_ */
240