blob: b4684af7689be1f2f6fb226c32221d3794c6d7a9 [file] [log] [blame]
Joel Kitching393c71c2019-06-16 16:09:42 +08001#ifndef CTYPE_H
2#define CTYPE_H
3
4static inline int isspace(int c)
5{
6 switch (c) {
7 case ' ': case '\f': case '\n':
8 case '\r': case '\t': case '\v':
9 return 1;
10 default:
11 return 0;
12 }
13}
14
15static inline int isprint(int c)
16{
17 return c >= ' ' && c <= '~';
18}
19
20static inline int isdigit(int c)
21{
22 return (c >= '0' && c <= '9');
23}
24
25static inline int isxdigit(int c)
26{
27 return ((c >= '0' && c <= '9') ||
28 (c >= 'a' && c <= 'f') ||
29 (c >= 'A' && c <= 'F'));
30}
31
32static inline int isupper(int c)
33{
34 return (c >= 'A' && c <= 'Z');
35}
36
37static inline int islower(int c)
38{
39 return (c >= 'a' && c <= 'z');
40}
41
42static inline int toupper(int c)
43{
44 if (islower(c))
45 c -= 'a'-'A';
46 return c;
47}
48
49static inline int tolower(int c)
50{
51 if (isupper(c))
52 c -= 'A'-'a';
53 return c;
54}
55
56#endif /* CTYPE_H */