From 6becbff5724d79cb3a958db297b5c3310200daea Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 23 Jul 2020 21:06:44 +0200 Subject: Added *very* simple ide and ext2 support --- src/lib/str.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/lib/str.c') 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) { -- cgit v1.2.3