aboutsummaryrefslogtreecommitdiff
path: root/src/common/libc/ctype.c
blob: e54a24c3f60f4a5b509cb9cf3f50eb6048362bdd (plain) (blame)
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
#include <ctype.h>


int isalnum(int c) {
	return isalpha(c) || isdigit(c);
}
int isalpha(int c) {
	return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
}
int isdigit(int c) {
	return (c >= '0' && c <= '9');
}
int isxdigit(int c) {
	return isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
int isspace(int c) {
	return c == ' ' || c == '\t' || c == '\r' || c == '\n';
}
int isprint(int c) {
	return (c >= ' ' && c < 256) || isspace(c);
}
int isupper(int c) {
	return c >= 'A' && c <= 'Z';
}
int islower(int c) {
	return c >= 'a' && c <= 'z';
}
int ispunct(int c) {
	return isprint(c) && !isspace(c);
}
int isgraph(int c) {
	return c > ' ' && c < 256;
}
int iscntrl(int c) {
	return c > 0 && c < ' ';
}

int toupper(int c) {
	if (islower(c))
		return c + 'A' - 'a';
	else
		return c;
}
int tolower(int c) {
	if (isupper(c))
		return c + 'a' - 'A';
	else
		return c;
}

/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/