xref: /freebsd/include/wctype.h (revision 42b388439bd3795e09258c57a74ce9eec3651c7b)
195a4049aSTakuya SHIOZAKI /*-
2*e58eb3c4SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause
3*e58eb3c4SPedro F. Giffuni  *
495a4049aSTakuya SHIOZAKI  * Copyright (c)1999 Citrus Project,
595a4049aSTakuya SHIOZAKI  * All rights reserved.
695a4049aSTakuya SHIOZAKI  *
795a4049aSTakuya SHIOZAKI  * Redistribution and use in source and binary forms, with or without
895a4049aSTakuya SHIOZAKI  * modification, are permitted provided that the following conditions
995a4049aSTakuya SHIOZAKI  * are met:
1095a4049aSTakuya SHIOZAKI  * 1. Redistributions of source code must retain the above copyright
1195a4049aSTakuya SHIOZAKI  *    notice, this list of conditions and the following disclaimer.
1295a4049aSTakuya SHIOZAKI  * 2. Redistributions in binary form must reproduce the above copyright
1395a4049aSTakuya SHIOZAKI  *    notice, this list of conditions and the following disclaimer in the
1495a4049aSTakuya SHIOZAKI  *    documentation and/or other materials provided with the distribution.
1595a4049aSTakuya SHIOZAKI  *
1695a4049aSTakuya SHIOZAKI  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1795a4049aSTakuya SHIOZAKI  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1895a4049aSTakuya SHIOZAKI  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1995a4049aSTakuya SHIOZAKI  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2095a4049aSTakuya SHIOZAKI  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2195a4049aSTakuya SHIOZAKI  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2295a4049aSTakuya SHIOZAKI  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2395a4049aSTakuya SHIOZAKI  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2495a4049aSTakuya SHIOZAKI  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2595a4049aSTakuya SHIOZAKI  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2695a4049aSTakuya SHIOZAKI  * SUCH DAMAGE.
2795a4049aSTakuya SHIOZAKI  *
2895a4049aSTakuya SHIOZAKI  *	citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp
29115fef56SDavid E. O'Brien  *	$NetBSD: wctype.h,v 1.3 2000/12/22 14:16:16 itojun Exp $
3095a4049aSTakuya SHIOZAKI  */
3195a4049aSTakuya SHIOZAKI 
3295a4049aSTakuya SHIOZAKI #ifndef _WCTYPE_H_
3395a4049aSTakuya SHIOZAKI #define	_WCTYPE_H_
3495a4049aSTakuya SHIOZAKI 
3595a4049aSTakuya SHIOZAKI #include <sys/cdefs.h>
36abbd8902SMike Barcroft #include <sys/_types.h>
3795a4049aSTakuya SHIOZAKI 
38c92997c2STim J. Robbins #include <_ctype.h>
395b32667cSTim J. Robbins 
4046450799STim J. Robbins #ifndef _WCTRANS_T
4146450799STim J. Robbins typedef	int	wctrans_t;
4246450799STim J. Robbins #define	_WCTRANS_T
4346450799STim J. Robbins #endif
4446450799STim J. Robbins 
455b32667cSTim J. Robbins #ifndef _WCTYPE_T
464bd5585fSTim J. Robbins typedef	unsigned long	wctype_t;
475b32667cSTim J. Robbins #define	_WCTYPE_T
485b32667cSTim J. Robbins #endif
495b32667cSTim J. Robbins 
50abbd8902SMike Barcroft #ifndef _WINT_T_DECLARED
51abbd8902SMike Barcroft typedef	__wint_t	wint_t;
52abbd8902SMike Barcroft #define	_WINT_T_DECLARED
539a1a7924STim J. Robbins #endif
549a1a7924STim J. Robbins 
5595a4049aSTakuya SHIOZAKI #ifndef WEOF
5695a4049aSTakuya SHIOZAKI #define	WEOF	((wint_t)-1)
5795a4049aSTakuya SHIOZAKI #endif
5895a4049aSTakuya SHIOZAKI 
5995a4049aSTakuya SHIOZAKI __BEGIN_DECLS
60bb28f3c2SWarner Losh int	iswalnum(wint_t);
61bb28f3c2SWarner Losh int	iswalpha(wint_t);
62bb28f3c2SWarner Losh int	iswblank(wint_t);
63bb28f3c2SWarner Losh int	iswcntrl(wint_t);
646b44a04dSTim J. Robbins int	iswctype(wint_t, wctype_t);
65bb28f3c2SWarner Losh int	iswdigit(wint_t);
66bb28f3c2SWarner Losh int	iswgraph(wint_t);
67bb28f3c2SWarner Losh int	iswlower(wint_t);
68bb28f3c2SWarner Losh int	iswprint(wint_t);
69bb28f3c2SWarner Losh int	iswpunct(wint_t);
70bb28f3c2SWarner Losh int	iswspace(wint_t);
71bb28f3c2SWarner Losh int	iswupper(wint_t);
72bb28f3c2SWarner Losh int	iswxdigit(wint_t);
736b44a04dSTim J. Robbins wint_t	towctrans(wint_t, wctrans_t);
74bb28f3c2SWarner Losh wint_t	towlower(wint_t);
75bb28f3c2SWarner Losh wint_t	towupper(wint_t);
769a1a7924STim J. Robbins wctrans_t
779a1a7924STim J. Robbins 	wctrans(const char *);
789a1a7924STim J. Robbins wctype_t
799a1a7924STim J. Robbins 	wctype(const char *);
806b44a04dSTim J. Robbins 
816b44a04dSTim J. Robbins #if __BSD_VISIBLE
826b44a04dSTim J. Robbins wint_t	iswascii(wint_t);
836b44a04dSTim J. Robbins wint_t	iswhexnumber(wint_t);
846b44a04dSTim J. Robbins wint_t	iswideogram(wint_t);
856b44a04dSTim J. Robbins wint_t	iswnumber(wint_t);
866b44a04dSTim J. Robbins wint_t	iswphonogram(wint_t);
876b44a04dSTim J. Robbins wint_t	iswrune(wint_t);
886b44a04dSTim J. Robbins wint_t	iswspecial(wint_t);
89ee446de0STim J. Robbins wint_t	nextwctype(wint_t, wctype_t);
905b32667cSTim J. Robbins #endif
91a8ed63bbSDavid Chisnall 
92a8ed63bbSDavid Chisnall #if __POSIX_VISIBLE >= 200809
93a8ed63bbSDavid Chisnall #define _XLOCALE_WCTYPES 1
94a8ed63bbSDavid Chisnall #include <xlocale/_ctype.h>
95a8ed63bbSDavid Chisnall #endif /* __POSIX_VISIBLE >= 200809 */
9695a4049aSTakuya SHIOZAKI __END_DECLS
9795a4049aSTakuya SHIOZAKI 
9822e24cfdSDavid Chisnall #ifndef __cplusplus
99f5dde016SBaptiste Daroussin #define	iswalnum(wc)		__istype((wc), _CTYPE_A|_CTYPE_D|_CTYPE_N)
1006b44a04dSTim J. Robbins #define	iswalpha(wc)		__istype((wc), _CTYPE_A)
1016b44a04dSTim J. Robbins #define	iswblank(wc)		__istype((wc), _CTYPE_B)
1026b44a04dSTim J. Robbins #define	iswcntrl(wc)		__istype((wc), _CTYPE_C)
1035b32667cSTim J. Robbins #define	iswctype(wc, charclass)	__istype((wc), (charclass))
104f5dde016SBaptiste Daroussin #define	iswdigit(wc)		__istype((wc), _CTYPE_D)
1056b44a04dSTim J. Robbins #define	iswgraph(wc)		__istype((wc), _CTYPE_G)
1066b44a04dSTim J. Robbins #define	iswlower(wc)		__istype((wc), _CTYPE_L)
1076b44a04dSTim J. Robbins #define	iswprint(wc)		__istype((wc), _CTYPE_R)
1086b44a04dSTim J. Robbins #define	iswpunct(wc)		__istype((wc), _CTYPE_P)
1096b44a04dSTim J. Robbins #define	iswspace(wc)		__istype((wc), _CTYPE_S)
1106b44a04dSTim J. Robbins #define	iswupper(wc)		__istype((wc), _CTYPE_U)
111f5dde016SBaptiste Daroussin #define	iswxdigit(wc)		__istype((wc), _CTYPE_X)
1126b44a04dSTim J. Robbins #define	towlower(wc)		__tolower(wc)
1136b44a04dSTim J. Robbins #define	towupper(wc)		__toupper(wc)
1146b44a04dSTim J. Robbins 
1156b44a04dSTim J. Robbins #if __BSD_VISIBLE
116ce0d9ca3SAndrey A. Chernov #define	iswascii(wc)		(((wc) & ~0x7F) == 0)
117f5dde016SBaptiste Daroussin #define	iswhexnumber(wc)	__istype((wc), _CTYPE_X) /* alias of iswxdigit */
1186b44a04dSTim J. Robbins #define	iswideogram(wc)		__istype((wc), _CTYPE_I)
119f5dde016SBaptiste Daroussin #define	iswnumber(wc)		__istype((wc), _CTYPE_D|_CTYPE_N)
1206b44a04dSTim J. Robbins #define	iswphonogram(wc)	__istype((wc), _CTYPE_Q)
1216b44a04dSTim J. Robbins #define	iswrune(wc)		__istype((wc), 0xFFFFFF00L)
1226b44a04dSTim J. Robbins #define	iswspecial(wc)		__istype((wc), _CTYPE_T)
12322e24cfdSDavid Chisnall #endif /* __BSD_VISIBLE */
12422e24cfdSDavid Chisnall #endif /* __cplusplus */
1255b32667cSTim J. Robbins 
12695a4049aSTakuya SHIOZAKI #endif		/* _WCTYPE_H_ */
127