/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: wctype.h 1.3 90/06/22 $"

#ifndef _WCTYPE_H_

/*	definitions for international function		*/

	extern	unsigned _iswctype();
	extern	wchar_t _trwctype();
	extern	wchar_t	_ctmp_;

/*	bit definition for character class	*/

#define	_E1	0x00000100	/* phonogram (international use) */
#define	_E2	0x00000200	/* ideogram (international use) */
#define	_E3	0x00000400	/* English (international use) */
#define	_E4	0x00000800	/* number (international use) */
#define	_E5	0x00001000	/* special (international use) */
#define	_E6	0x00002000	/* other characters (international use) */
#define	_E7	0x00004000	/* reserved (international use) */
#define	_E8	0x00008000	/* reserved (international use) */

#define	_E9	0x00010000
#define	_E10	0x00020000
#define	_E11	0x00040000
#define	_E12	0x00080000
#define	_E13	0x00100000
#define	_E14	0x00200000
#define	_E15	0x00400000
#define	_E16	0x00800000
#define	_E17	0x01000000
#define	_E18	0x02000000
#define	_E19	0x04000000
#define	_E20	0x08000000
#define	_E21	0x10000000
#define	_E22	0x20000000
#define	_E23	0x40000000
#define	_E24	0x80000000

/*	data structure for supplementary code set
		for character class and conversion	*/

	struct	_wctype{
		wchar_t	tmin;		/* minimum code for wctype */
		wchar_t	tmax;		/* maximum code for wctype */
		unsigned char  *index;	/* class index */
		unsigned int   *type;	/* class type */
		wchar_t	cmin;		/* minimum code for conversion */
		wchar_t	cmax;		/* maximum code for conversion */
		wchar_t *code;		/* conversion code */
	};

/*	character classification functions	*/

#define	iswalpha(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_U|_L)	\
				 	    : isalpha(_ctmp_))
#define	iswupper(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_U)	\
					    : isupper(_ctmp_))
#define	iswlower(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_L)	\
					    : islower(_ctmp_))
#define	iswdigit(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_N)	\
					    : isdigit(_ctmp_))
#define	iswxdigit(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_X)	\
					    : isxdigit(_ctmp_))
#define	iswalnum(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_U|_L|_N) \
					    : isalnum(_ctmp_))
#define	iswspace(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_S)	\
					    : isspace(_ctmp_))
#define	iswpunct(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_P)	\
					    : ispunct(_ctmp_))
#define	iswprint(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_P|_U|_L|_N|_B|_E1|_E2|_E5|_E6)\
					    : isprint(_ctmp_))
#define	iswgraph(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_P|_U|_L|_N|_E1|_E2|_E5|_E6)\
					    : isgraph(_ctmp_))
#define	iswcntrl(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_C)	\
					    : iscntrl(_ctmp_))
#define	iswascii(c)	isascii(c)
#define	isphonogram(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_E1) : 0)
#define	isideogram(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_E2) : 0)
#define	isenglish(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_E3) : 0)
#define	isnumber(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_E4) : 0)
#define	isspecial(c)	((_ctmp_=(c)) > 127 ? _iswctype(_ctmp_,_E5) : 0)
#define	towupper(c)	((_ctmp_=(c)) > 127 ? _trwctype(_ctmp_,_L)	\
					    : toupper(_ctmp_))
#define	towlower(c)	((_ctmp_=(c)) > 127 ? _trwctype(_ctmp_,_U)	\
					    : tolower(_ctmp_))

#define	iscodeset0(c)	isascii(c)
#ifndef EUCMASK
#define EUCMASK  0x8080 	/* mask bit   for 2 bytes code */
#define P11	 0x8080 	/* code set 1 for 2 bytes code */
#define P01	 0x0080 	/* code set 2 for 2 bytes code */
#define P10	 0x8000		/* code set 3 for 2 bytes code */
#define F_EUCMASK  0x30000000 	/* mask bit   for 4 bytes code */
#define F_P11	   0x30000000 	/* code set 1 for 4 bytes code */
#define F_P01	   0x10000000 	/* code set 2 for 4 bytes code */
#define F_P10	   0x20000000	/* code set 3 for 4 bytes code */
#endif	/* EUCMASK */
#define	_iscodeset1(c)	(((c) & F_EUCMASK) == F_P11)
#define	_iscodeset2(c)	(((c) & F_EUCMASK) == F_P01)
#define	_iscodeset3(c)	(((c) & F_EUCMASK) == F_P10)
/*
 *	get the process code width
 */
#define 	_getpcw (_ctype[514] > sizeof(unsigned short)	|| \
		         _ctype[515] > sizeof(unsigned short)	|| \
		         _ctype[516] > sizeof(unsigned short))	 ? \
			sizeof(unsigned long)			 : \
			sizeof(unsigned short)

#define	iscodeset1(c)	(( _getpcw ) > sizeof(unsigned short)? _iscodeset1(c) \
						:((c) & EUCMASK) == P11)
#define	iscodeset2(c)	(( _getpcw ) > sizeof(unsigned short)? _iscodeset2(c) \
						:((c) & EUCMASK) == P01)
#define	iscodeset3(c)	(( _getpcw ) > sizeof(unsigned short)? _iscodeset3(c) \
						:((c) & EUCMASK) == P10)
/*#define	iscodeset1(c)	(sizeof(wchar_t) > sizeof(unsigned short)? _iscodeset1(c) \ */
/*						:((c) & EUCMASK) == P11) */
/*#define	iscodeset2(c)	(sizeof(wchar_t) > sizeof(unsigned short)? _iscodeset2(c) \ */
/*						:((c) & EUCMASK) == P01) */
/*#define	iscodeset3(c)	(sizeof(wchar_t) > sizeof(unsigned short)? _iscodeset3(c) \ */
/*						:((c) & EUCMASK) == P10) */
/* #define	iscodeset1(c)	(((c) & 0x8080) == 0x8080) */
/* #define	iscodeset2(c)	(((c) & 0x8080) == 0x0080) */
/* #define	iscodeset3(c)	(((c) & 0x8080) == 0x8000) */

/*	include header for native language function	*/

#include <xctype.h>

 
#define _WCTYPE_H_
#endif  /* _WCTYPE_H_ */
