xref: /plan9/sys/include/ape/ctype.h (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1 #ifndef __CTYPE
2 #define __CTYPE
3 #pragma lib "/$M/lib/ape/libap.a"
4 
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8 
9 extern int isalnum(int);
10 extern int isalpha(int);
11 extern int iscntrl(int);
12 extern int isdigit(int);
13 extern int isgraph(int);
14 extern int islower(int);
15 extern int isprint(int);
16 extern int ispunct(int);
17 extern int isspace(int);
18 extern int isupper(int);
19 extern int isxdigit(int);
20 extern int tolower(int);
21 extern int toupper(int);
22 
23 #ifdef __cplusplus
24 }
25 #endif
26 enum
27 {
28   _ISupper = 01,	/* UPPERCASE.  */
29   _ISlower = 02,	/* lowercase.  */
30   _ISdigit = 04,	/* Numeric.  */
31   _ISspace = 010,	/* Whitespace.  */
32   _ISpunct = 020,	/* Punctuation.  */
33   _IScntrl = 040,	/* Control character.  */
34   _ISblank = 0100,	/* Blank (usually SPC and TAB).  */
35   _ISxdigit = 0200,	/* Hexadecimal numeric.  */
36 };
37 
38 extern unsigned char _ctype[];
39 #define	isalnum(c)	(_ctype[(unsigned char)(c)]&(_ISupper|_ISlower|_ISdigit))
40 #define	isalpha(c)	(_ctype[(unsigned char)(c)]&(_ISupper|_ISlower))
41 #define	iscntrl(c)	(_ctype[(unsigned char)(c)]&_IScntrl)
42 #define	isdigit(c)	(_ctype[(unsigned char)(c)]&_ISdigit)
43 #define	isgraph(c)	(_ctype[(unsigned char)(c)]&(_ISpunct|_ISupper|_ISlower|_ISdigit))
44 #define	islower(c)	(_ctype[(unsigned char)(c)]&_ISlower)
45 #define	isprint(c)	(_ctype[(unsigned char)(c)]&(_ISpunct|_ISupper|_ISlower|_ISdigit|_ISblank))
46 #define	ispunct(c)	(_ctype[(unsigned char)(c)]&_ISpunct)
47 #define	isspace(c)	(_ctype[(unsigned char)(c)]&_ISspace)
48 #define	isupper(c)	(_ctype[(unsigned char)(c)]&_ISupper)
49 #define	isxdigit(c)	(_ctype[(unsigned char)(c)]&_ISxdigit)
50 
51 #ifdef _BSD_EXTENSION
52 #define	isascii(c) (((unsigned int)(c))<0x80)
53 #endif
54 
55 #endif /* __CTYPE */
56