diff options
author | Marvin Borner | 2020-07-23 21:06:44 +0200 |
---|---|---|
committer | Marvin Borner | 2020-07-23 21:06:44 +0200 |
commit | 6becbff5724d79cb3a958db297b5c3310200daea (patch) | |
tree | 295a5b4bf7ee2234fdc56c24fec28f936927de21 /src/lib | |
parent | a0b8c61b09200aa3f9e27878cb866648a7d26502 (diff) |
Added *very* simple ide and ext2 support
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/inc/str.h | 1 | ||||
-rw-r--r-- | src/lib/str.c | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/inc/str.h b/src/lib/inc/str.h index 0e00e75..f4c63b1 100644 --- a/src/lib/inc/str.h +++ b/src/lib/inc/str.h @@ -10,6 +10,7 @@ char *strcpy(char *dst, const char *src); char *strchr(const char *s, int c); char *strcat(char *dst, const char *src); int strcmp(const char *s1, const char *s2); +int strncmp(const char *s1, const char *s2, u32 n); char *strinv(char *s); char *strdup(const char *s); diff --git a/src/lib/str.c b/src/lib/str.c index 24f95e5..d1ee325 100644 --- a/src/lib/str.c +++ b/src/lib/str.c @@ -40,6 +40,22 @@ int strcmp(const char *s1, const char *s2) return d; } +int strncmp(const char *s1, const char *s2, u32 n) +{ + const u8 *c1 = (const u8 *)s1; + const u8 *c2 = (const u8 *)s2; + u8 ch; + int d = 0; + + while (n--) { + d = (int)(ch = *c1++) - (int)*c2++; + if (d || !ch) + break; + } + + return d; +} + char *strchr(const char *s, int c) { while (*s != (char)c) { |