#ifndef _CTYPE_H
#define _CTYPE_H

#define _U 0x01 /* upper */	// ñλڴдַ[A-Z]
#define _L 0x02 /* lower */	// ñλСдַ[a-z]
#define _D 0x04 /* digit */	// ñλ[0-9]
#define _C 0x08 /* cntrl */	// ñλڿַ
#define _P 0x10 /* punct */	// ñλڱַ
#define _S 0x20 /* white space (space/lf/tab) */	// ڿհַո\t\n ȡ
#define _X 0x40 /* hex digit */	// ñλʮ֡
#define _SP 0x80 /* hard space (0x20) */	// ñλڿոַ(0x20)

extern unsigned char _ctype[];	// ַ()˸ַӦԡ
extern char _ctmp;		// һʱַ(fs/ctype.c ж)

// һЩȷַ͵ĺꡣ
#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D))	// ַ[A-Z][a-z][0-9]
#define isalpha(c) ((_ctype+1)[c]&(_U|_L))	// ַ
#define iscntrl(c) ((_ctype+1)[c]&(_C))	// ǿַ
#define isdigit(c) ((_ctype+1)[c]&(_D))	// ֡
#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D))	// ͼַ
#define islower(c) ((_ctype+1)[c]&(_L))	// Сдַ
#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP))	// ǿɴӡַ
#define ispunct(c) ((_ctype+1)[c]&(_P))	// Ǳš
#define isspace(c) ((_ctype+1)[c]&(_S))	// ǿհַո,\f,\n,\r,\t,\v
#define isupper(c) ((_ctype+1)[c]&(_U))	// Ǵдַ
#define isxdigit(c) ((_ctype+1)[c]&(_D|_X))	// ʮ֡

#define isascii(c) (((unsigned) c)<=0x7f)	// ASCII ַ
#define toascii(c) (((unsigned) c)&0x7f)	// תASCII ַ

#define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-( 'A'- 'a'):_ctmp)	// תɶӦСдַ
#define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-( 'a'- 'A'):_ctmp)	// תɶӦдַ

#endif
