Joel Kitching | 393c71c | 2019-06-16 16:09:42 +0800 | [diff] [blame] | 1 | #ifndef CTYPE_H |
| 2 | #define CTYPE_H |
| 3 | |
| 4 | static 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 | |
| 15 | static inline int isprint(int c) |
| 16 | { |
| 17 | return c >= ' ' && c <= '~'; |
| 18 | } |
| 19 | |
| 20 | static inline int isdigit(int c) |
| 21 | { |
| 22 | return (c >= '0' && c <= '9'); |
| 23 | } |
| 24 | |
| 25 | static inline int isxdigit(int c) |
| 26 | { |
| 27 | return ((c >= '0' && c <= '9') || |
| 28 | (c >= 'a' && c <= 'f') || |
| 29 | (c >= 'A' && c <= 'F')); |
| 30 | } |
| 31 | |
| 32 | static inline int isupper(int c) |
| 33 | { |
| 34 | return (c >= 'A' && c <= 'Z'); |
| 35 | } |
| 36 | |
| 37 | static inline int islower(int c) |
| 38 | { |
| 39 | return (c >= 'a' && c <= 'z'); |
| 40 | } |
| 41 | |
| 42 | static inline int toupper(int c) |
| 43 | { |
| 44 | if (islower(c)) |
| 45 | c -= 'a'-'A'; |
| 46 | return c; |
| 47 | } |
| 48 | |
| 49 | static inline int tolower(int c) |
| 50 | { |
| 51 | if (isupper(c)) |
| 52 | c -= 'A'-'a'; |
| 53 | return c; |
| 54 | } |
| 55 | |
| 56 | #endif /* CTYPE_H */ |