1 /*
2  * Copyright (c) 2008 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #include <ctype.h>
9 
isblank(int c)10 int isblank(int c) {
11     return (c == ' ' || c == '\t');
12 }
13 
isspace(int c)14 int isspace(int c) {
15     return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v');
16 }
17 
islower(int c)18 int islower(int c) {
19     return ((c >= 'a') && (c <= 'z'));
20 }
21 
isupper(int c)22 int isupper(int c) {
23     return ((c >= 'A') && (c <= 'Z'));
24 }
25 
isdigit(int c)26 int isdigit(int c) {
27     return ((c >= '0') && (c <= '9'));
28 }
29 
isalpha(int c)30 int isalpha(int c) {
31     return isupper(c) || islower(c);
32 }
33 
isalnum(int c)34 int isalnum(int c) {
35     return isalpha(c) || isdigit(c);
36 }
37 
isxdigit(int c)38 int isxdigit(int c) {
39     return isdigit(c) || ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F'));
40 }
41 
isgraph(int c)42 int isgraph(int c) {
43     return ((c > ' ') && (c < 0x7f));
44 }
45 
iscntrl(int c)46 int iscntrl(int c) {
47     return ((c < ' ') || (c == 0x7f));
48 }
49 
isprint(int c)50 int isprint(int c) {
51     return ((c >= 0x20) && (c < 0x7f));
52 }
53 
ispunct(int c)54 int ispunct(int c) {
55     return isgraph(c) && (!isalnum(c));
56 }
57 
tolower(int c)58 int tolower(int c) {
59     if ((c >= 'A') && (c <= 'Z'))
60         return c + ('a' - 'A');
61     return c;
62 }
63 
toupper(int c)64 int toupper(int c) {
65     if ((c >= 'a') && (c <= 'z'))
66         return c + ('A' - 'a');
67     return c;
68 }
69 
70