generalized pixel format handling in 3d pipeline
[bootcensus] / src / libc / ctype.c
1 /*
2 pcboot - bootable PC demo/game kernel
3 Copyright (C) 2018  John Tsiombikas <nuclear@member.fsf.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY, without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18 #include "ctype.h"
19
20 int isalnum(int c)
21 {
22         return isalpha(c) || isdigit(c);
23 }
24
25 int isalpha(int c)
26 {
27         return isupper(c) || islower(c);
28 }
29
30 int isblank(int c)
31 {
32         return c == ' ' || c == '\t';
33 }
34
35 int isdigit(int c)
36 {
37         return c >= '0' && c <= '9';
38 }
39
40 int isupper(int c)
41 {
42         return c >= 'A' && c <= 'Z';
43 }
44
45 int islower(int c)
46 {
47         return c >= 'a' && c <= 'z';
48 }
49
50 int isgraph(int c)
51 {
52         return c > ' ' && c <= '~';
53 }
54
55 int isprint(int c)
56 {
57         return isgraph(c) || c == ' ';
58 }
59
60 int isspace(int c)
61 {
62         return isblank(c) || c == '\f' || c == '\n' || c == '\r' || c == '\v';
63 }
64
65 int toupper(int c)
66 {
67         return islower(c) ? (c + ('A' - 'a')) : c;
68 }
69
70 int tolower(int c)
71 {
72         return isupper(c) ? (c - ('A' - 'a')) : c;
73 }