blob: 8b83c9f5008ee0fd8bf6de1d2395bda267d664c2 (
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
|
#include <lib/strings.h>
unsigned long strlen(string_t s)
{
unsigned long len = 0;
while (s[len] != 0) {
len += 1;
}
return len;
}
unsigned char strcmp(string_t a, string_t b)
{
unsigned long idx = 0;
while (a[idx] != 0 && b[idx] != 0) {
if (a[idx] != b[idx]) {
return 0;
}
idx += 1;
}
return a[idx] == b[idx];
}
unsigned char strcmpn(string_t a, string_t b, unsigned int n)
{
unsigned long idx = 0;
while (a[idx] != 0 && b[idx] != 0 && idx+1 < n) {
if (a[idx] != b[idx]) {
return 0;
}
idx += 1;
}
return a[idx] == b[idx];
}
|