git.cappig.dev / apheleiaOS.git master

1
#include "ctype.h"
2
3
4
int isalnum(int c) {
5
    if (isdigit(c) || isalpha(c)) {
6
        return 1;
7
    }
8
9
    return 0;
10
}
11
12
int isalpha(int c) {
13
    if (c >= 'a' && c <= 'z') {
14
        return 1;
15
    }
16
17
    if (c >= 'A' && c <= 'Z') {
18
        return 1;
19
    }
20
21
    return 0;
22
}
23
24
int isblank(int c) {
25
    if (c == ' ' || c == '\t') {
26
        return 1;
27
    }
28
29
    return 0;
30
}
31
32
int iscntrl(int c) {
33
    if (c == 0x7f) {
34
        return 1;
35
    }
36
37
    if (c >= 0x00 && c <= 0x1f) {
38
        return 1;
39
    }
40
41
    return 0;
42
}
43
44
int isdigit(int c) {
45
    if (c >= '0' && c <= '9') {
46
        return 1;
47
    }
48
49
    return 0;
50
}
51
52
int isgraph(int c) {
53
    if (c >= 0x21 && c <= 0x7e) {
54
        return 1;
55
    }
56
57
    return 0;
58
}
59
60
int islower(int c) {
61
    if (c >= 'a' && c <= 'z') {
62
        return 1;
63
    }
64
65
    return 0;
66
}
67
68
int isprint(int c) {
69
    if (c >= 0x20 && c <= 0x7e) {
70
        return 1;
71
    }
72
73
    return 0;
74
}
75
76
int ispunct(int c) {
77
    if (isgraph(c) && !isalnum(c)) {
78
        return 1;
79
    }
80
81
    return 0;
82
}
83
84
int isspace(int c) {
85
    if (c == ' ') {
86
        return 1;
87
    }
88
89
    if (c >= 0x9 && c <= 0xd) {
90
        return 1;
91
    }
92
93
    return 0;
94
}
95
96
int isupper(int c) {
97
    if (c >= 'A' && c <= 'Z') {
98
        return 1;
99
    }
100
101
    return 0;
102
}
103
104
int isxdigit(int c) {
105
    if (isdigit(c)) {
106
        return 1;
107
    }
108
109
    if (c >= 'a' && c <= 'f') {
110
        return 1;
111
    }
112
113
    if (c >= 'A' && c <= 'F') {
114
        return 1;
115
    }
116
117
    return 0;
118
}
119
120
int tolower(int c) {
121
    if (isupper(c)) {
122
        return c - ('A' - 'a');
123
    }
124
125
    return c;
126
}
127
128
int toupper(int c) {
129
    if (islower(c)) {
130
        return c - ('a' - 'A');
131
    }
132
133
    return c;
134
}