xref: /illumos-gate/usr/src/head/wctype.h (revision 61a52ead)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	wctype.h	1.13 89/11/02 SMI; JLE	*/
237c478bd9Sstevel@tonic-gate /*	from AT&T JAE 2.1			*/
247c478bd9Sstevel@tonic-gate /*	definitions for international functions	*/
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27*61a52eadSGarrett D'Amore  * Copyright 2015 Garrett D'Amore <garrett@damore.org>
28ba3594baSGarrett D'Amore  *
297c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
307c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef	_WCTYPE_H
347c478bd9Sstevel@tonic-gate #define	_WCTYPE_H
357c478bd9Sstevel@tonic-gate 
362d08521bSGarrett D'Amore #include <sys/feature_tests.h>
377c478bd9Sstevel@tonic-gate #include <iso/wctype_iso.h>
382d08521bSGarrett D'Amore #ifndef _STRICT_SYMBOLS
397c478bd9Sstevel@tonic-gate #include <ctype.h>
407c478bd9Sstevel@tonic-gate #include <wchar.h>
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate  * Allow global visibility for symbols defined in
457c478bd9Sstevel@tonic-gate  * C++ "std" namespace in <iso/wctype_iso.h>.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
487c478bd9Sstevel@tonic-gate using std::wint_t;
497c478bd9Sstevel@tonic-gate using std::wctrans_t;
507c478bd9Sstevel@tonic-gate using std::iswalnum;
517c478bd9Sstevel@tonic-gate using std::iswalpha;
527c478bd9Sstevel@tonic-gate using std::iswcntrl;
537c478bd9Sstevel@tonic-gate using std::iswdigit;
547c478bd9Sstevel@tonic-gate using std::iswgraph;
557c478bd9Sstevel@tonic-gate using std::iswlower;
567c478bd9Sstevel@tonic-gate using std::iswprint;
577c478bd9Sstevel@tonic-gate using std::iswpunct;
587c478bd9Sstevel@tonic-gate using std::iswspace;
597c478bd9Sstevel@tonic-gate using std::iswupper;
607c478bd9Sstevel@tonic-gate using std::iswxdigit;
617c478bd9Sstevel@tonic-gate using std::towlower;
627c478bd9Sstevel@tonic-gate using std::towupper;
637c478bd9Sstevel@tonic-gate using std::wctrans;
647c478bd9Sstevel@tonic-gate using std::towctrans;
657c478bd9Sstevel@tonic-gate using std::iswctype;
667c478bd9Sstevel@tonic-gate using std::wctype;
670934fbd7SGarrett D'Amore #if (__cplusplus >= 201103L) || defined(_STDC_C99) || defined(_XPG6) || \
680934fbd7SGarrett D'Amore 	!defined(_STRICT_SYMBOLS)
692d08521bSGarrett D'Amore using std::iswblank;
702d08521bSGarrett D'Amore #endif
717c478bd9Sstevel@tonic-gate #endif
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
747c478bd9Sstevel@tonic-gate extern "C" {
757c478bd9Sstevel@tonic-gate #endif
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /* do not allow any of the following in a strictly conforming application */
782d08521bSGarrett D'Amore #ifndef _STRICT_SYMBOLS
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*
817c478bd9Sstevel@tonic-gate  * data structure for supplementary code set
827c478bd9Sstevel@tonic-gate  * for character class and conversion
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate struct	_wctype {
857c478bd9Sstevel@tonic-gate 	wchar_t	tmin;		/* minimum code for wctype */
867c478bd9Sstevel@tonic-gate 	wchar_t	tmax;		/* maximum code for wctype */
877c478bd9Sstevel@tonic-gate 	unsigned char  *index;	/* class index */
887c478bd9Sstevel@tonic-gate 	unsigned int   *type;	/* class type */
897c478bd9Sstevel@tonic-gate 	wchar_t	cmin;		/* minimum code for conversion */
907c478bd9Sstevel@tonic-gate 	wchar_t	cmax;		/* maximum code for conversion */
917c478bd9Sstevel@tonic-gate 	wchar_t *code;		/* conversion code */
927c478bd9Sstevel@tonic-gate };
937c478bd9Sstevel@tonic-gate 
94163bd69bSGarrett D'Amore 
95163bd69bSGarrett D'Amore #ifdef	_ILLUMOS_PRIVATE
96163bd69bSGarrett D'Amore extern	int __iswrune(wint_t);
97163bd69bSGarrett D'Amore extern	wint_t __nextwctype(wint_t, wctype_t);
98163bd69bSGarrett D'Amore #define	iswrune(c)		__iswrune(c)
99163bd69bSGarrett D'Amore #define	nextwctype(c, t)	__nextwctype(c, t)
100163bd69bSGarrett D'Amore #endif
101163bd69bSGarrett D'Amore 
1027c478bd9Sstevel@tonic-gate /* character classification functions */
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /* iswascii is still a macro */
1057c478bd9Sstevel@tonic-gate #define	iswascii(c)	isascii(c)
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate /* isw*, except iswascii(), are not macros any more.  They become functions */
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate /* is* also become functions */
1107c478bd9Sstevel@tonic-gate extern	int isphonogram(wint_t);
1117c478bd9Sstevel@tonic-gate extern	int isideogram(wint_t);
1127c478bd9Sstevel@tonic-gate extern	int isenglish(wint_t);
1137c478bd9Sstevel@tonic-gate extern	int isnumber(wint_t);
1147c478bd9Sstevel@tonic-gate extern	int isspecial(wint_t);
1152d08521bSGarrett D'Amore /* From BSD/MacOS */
1162d08521bSGarrett D'Amore extern	int iswideogram(wint_t);
1172d08521bSGarrett D'Amore extern	int iswphonogram(wint_t);
1182d08521bSGarrett D'Amore extern	int iswnumber(wint_t);
1192d08521bSGarrett D'Amore extern	int iswhexnumber(wint_t);
1202d08521bSGarrett D'Amore extern	int iswspecial(wint_t);
1212d08521bSGarrett D'Amore 
1227c478bd9Sstevel@tonic-gate #define	iscodeset0(c)	isascii(c)
1237c478bd9Sstevel@tonic-gate #define	iscodeset1(c)	(((c) & WCHAR_CSMASK) == WCHAR_CS1)
1247c478bd9Sstevel@tonic-gate #define	iscodeset2(c)	(((c) & WCHAR_CSMASK) == WCHAR_CS2)
1257c478bd9Sstevel@tonic-gate #define	iscodeset3(c)	(((c) & WCHAR_CSMASK) == WCHAR_CS3)
1267c478bd9Sstevel@tonic-gate 
1272d08521bSGarrett D'Amore #endif /* !defined(_STRICT_SYMBOLS)... */
1282d08521bSGarrett D'Amore 
1292d08521bSGarrett D'Amore 
1302d08521bSGarrett D'Amore /* XPG7 extended locale support */
1312d08521bSGarrett D'Amore #if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
1322d08521bSGarrett D'Amore 
1332d08521bSGarrett D'Amore #ifndef	_LOCALE_T
1342d08521bSGarrett D'Amore #define	_LOCALE_T
135732efd55SDan McDonald typedef struct _locale *locale_t;
1362d08521bSGarrett D'Amore #endif
1372d08521bSGarrett D'Amore 
1382d08521bSGarrett D'Amore extern wint_t towlower_l(wint_t, locale_t);
1392d08521bSGarrett D'Amore extern wint_t towupper_l(wint_t, locale_t);
1402d08521bSGarrett D'Amore extern wint_t towctrans_l(wint_t, wctrans_t, locale_t);
1412d08521bSGarrett D'Amore extern int iswctype_l(wint_t, wctype_t, locale_t);
1422d08521bSGarrett D'Amore extern int iswalnum_l(wint_t, locale_t);
1432d08521bSGarrett D'Amore extern int iswalpha_l(wint_t, locale_t);
144*61a52eadSGarrett D'Amore extern int iswblank_l(wint_t, locale_t);
1452d08521bSGarrett D'Amore extern int iswcntrl_l(wint_t, locale_t);
1462d08521bSGarrett D'Amore extern int iswdigit_l(wint_t, locale_t);
1472d08521bSGarrett D'Amore extern int iswgraph_l(wint_t, locale_t);
1482d08521bSGarrett D'Amore extern int iswlower_l(wint_t, locale_t);
1492d08521bSGarrett D'Amore extern int iswprint_l(wint_t, locale_t);
1502d08521bSGarrett D'Amore extern int iswpunct_l(wint_t, locale_t);
1512d08521bSGarrett D'Amore extern int iswspace_l(wint_t, locale_t);
1522d08521bSGarrett D'Amore extern int iswupper_l(wint_t, locale_t);
1532d08521bSGarrett D'Amore extern int iswxdigit_l(wint_t, locale_t);
1542d08521bSGarrett D'Amore extern wctrans_t wctrans_l(const char *, locale_t);
1552d08521bSGarrett D'Amore extern wctype_t wctype_l(const char *, locale_t);
1562d08521bSGarrett D'Amore #endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1597c478bd9Sstevel@tonic-gate }
1607c478bd9Sstevel@tonic-gate #endif
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate #endif	/* _WCTYPE_H */
163