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