blob: ed6833df38ebef66a3969bb20ea8541b880b6fef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#ifndef _CTYPE_H
#define _CTYPE_H
#include <stdc_common.h>
int islower(int c) {
return c >= 'a' && c <= 'z';
}
int isupper(int c) {
return c >= 'A' && c <= 'Z';
}
int isalpha(int c) {
return isupper(c) || islower(c);
}
int isalnum(int c) {
return isalpha(c) || isdigit(c);
}
int isprint(int c) {
if (isalnum(c)) return 1;
switch (c) {
case '!': return 1;
case '@': return 1;
case '#': return 1;
case '$': return 1;
case '%': return 1;
case '^': return 1;
case '&': return 1;
case '*': return 1;
case '(': return 1;
case ')': return 1;
case '-': return 1;
case '=': return 1;
case '_': return 1;
case '+': return 1;
case '`': return 1;
case '~': return 1;
case '[': return 1;
case '{': return 1;
case ']': return 1;
case '}': return 1;
case '\\': return 1;
case '|': return 1;
case ';': return 1;
case ':': return 1;
case '\'': return 1;
case '"': return 1;
case ',': return 1;
case '<': return 1;
case '.': return 1;
case '>': return 1;
case '/': return 1;
case '?': return 1;
}
return 0;
}
int iscntrl(int c) {
return !isprint(c);
}
int isgraph(int c) {
return isprint(c) && c != ' ';
}
int ispunct(int c) {
return isprint(c) && c != ' ' && !isalnum(c);
}
int isxdigit(int c) {
if (isdigit(c)) return 1;
if (c >= 'a' && c <= 'f') return 1;
if (c >= 'A' && c <= 'F') return 1;
return 0;
}
int tolower(int c) {
if (c >= 'A' && c <= 'Z')
return c - 'A' + 'a';
return c;
}
int toupper(int c) {
if (c >= 'a' && c <= 'z')
return c - 'a' + 'A';
return c;
}
#endif // _CTYPE_H
|