Welcome to The Fiwix Project
A UNIX-like kernel for the i386 architecture
1 /* 2 * fiwix/include/fiwix/ctype.h 3 * 4 * Copyright 2018, Jordi Sanfeliu. All rights reserved. 5 * Distributed under the terms of the Fiwix License. 6 */ 7 8 #ifndef _FIWIX_CTYPE_H 9 #define _FIWIX_CTYPE_H 10 11 #define _U 0x01 /* upper case */ 12 #define _L 0x02 /* lower case */ 13 #define _N 0x04 /* numeral (digit) */ 14 #define _S 0x08 /* spacing character */ 15 #define _P 0x10 /* punctuation */ 16 #define _C 0x20 /* control character */ 17 #define _X 0x40 /* hexadecimal */ 18 #define _B 0x80 /* blank */ 19 20 extern unsigned char _ctype[]; 21 22 #define ISALPHA(ch) ((_ctype + 1)[ch] & (_U | _L)) 23 #define ISUPPER(ch) ((_ctype + 1)[ch] & _U) 24 #define ISLOWER(ch) ((_ctype + 1)[ch] & _L) 25 #define ISDIGIT(ch) ((_ctype + 1)[ch] & _N) 26 #define ISALNUM(ch) ((_ctype + 1)[ch] & (_U | _L | _N)) 27 #define ISSPACE(ch) ((_ctype + 1)[ch] & _S) 28 #define ISPUNCT(ch) ((_ctype + 1)[ch] & _P) 29 #define ISCNTRL(ch) ((_ctype + 1)[ch] & _C) 30 #define ISXDIGIT(ch) ((_ctype + 1)[ch] & (_N | _X)) 31 32 #define ISASCII(ch) ((unsigned) ch <= 0x7F) 33 #define TOASCII(ch) ((unsigned) ch & 0x7F) 34 35 #define TOUPPER(ch) ((ch) & ~32) 36 #define TOLOWER(ch) ((ch) | 32) 37 38 #endif /* _FIWIX_CTYPE_H */