Fixed ZDE build - missing header file
[ZeXOS.git] / kernel / include / ctype.h
blob0671e6304c50d956afad2d411016cd97144fb8bf
1 /*
2 * ZeX/OS
3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef __TL_CTYPE_H
22 #define __TL_CTYPE_H
24 extern char _ctype[];
26 #define CT_UP 0x01 /* upper case */
27 #define CT_LOW 0x02 /* lower case */
28 #define CT_DIG 0x04 /* digit */
29 #define CT_CTL 0x08 /* control */
30 #define CT_PUN 0x10 /* punctuation */
31 #define CT_WHT 0x20 /* white space (space/cr/lf/tab) */
32 #define CT_HEX 0x40 /* hex digit */
33 #define CT_SP 0x80 /* hard space (0x20) */
35 /* without the cast to unsigned, DJGPP complains (using -Wall) */
36 #define isalnum(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG))
37 #define isalpha(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW))
38 #define iscntrl(c) ((_ctype + 1)[(unsigned)(c)] & (CT_CTL))
39 #define isdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG))
40 #define isgraph(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG))
41 #define islower(c) ((_ctype + 1)[(unsigned)(c)] & (CT_LOW))
42 #define isprint(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP))
43 #define ispunct(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN))
44 #define isspace(c) ((_ctype + 1)[(unsigned)(c)] & (CT_WHT))
45 #define isupper(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP))
46 #define isxdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG | CT_HEX))
47 #define isascii(c) ((unsigned)(c) <= 0x7F)
48 #define toascii(c) ((unsigned)(c) & 0x7F)
50 #define tolower(c) (isupper(c) ? c + 'a' - 'A' : c)
51 #define toupper(c) (islower(c) ? c + 'A' - 'a' : c)
53 #endif