-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.c
48 lines (39 loc) · 809 Bytes
/
util.c
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
#include <kernel/util.h>
int memset(void *dst, byte c, int count) {
int i;
for (i = 0; i < count; i++)
*(byte*)(dst+i) = c;
return i;
}
int memcpy(void *dst, void *src, int count) {
int i;
for (i = 0; i <count; i++)
*(byte*)(dst+i) = *(byte*)(src+i);
return i;
}
void* memmove (void *dst, const void *src, dword count) {
int i;
for (i = 0; i < count; i++)
*(byte*)(dst+i) = *(byte*)(src+i);
return dst;
}
int strlen(char *s) {
int len = 0;
while (*s++) len++;
return len;
}
int isalpha(char c) {
return (c >= 'a' && c < 'z') || (c >= 'A' && c <= 'Z');
}
int islower(char c) {
return c >= 'a' && c < 'z';
}
int isupper(char c) {
return c >= 'A' && c < 'Z';
}
char tolower(char c) {
return isupper(c)? (c-'A'+'a'):c;
}
char toupper(char c) {
return islower(c)? (c-'a'+'A'):c;
}