Kernel debug shell

This commit is contained in:
2026-03-21 11:34:46 +01:00
parent db36899152
commit 3ae56bbad5
5 changed files with 87 additions and 8 deletions

View File

@@ -69,4 +69,33 @@ void strncpy(char* dst, const char* src, size_t n)
{
size_t i = 0;
while(i++ != n && (*dst++ = *src++));
}
/*
* strncmp - compare two strings up to n characters
* @s1: first string
* @s2: second string
* @n: number of bytes to compare
*
* Taken from: https://github.com/DevSolar/pdclib/blob/master/functions/string/strncmp.c
*
* Return:
* $0 - @s1 and @s2 are equal
* $<0 - @s1 is less than @s2
* $>0 - @s1 is greater than @s2
*/
int strncmp(const char* s1, const char* s2, size_t n)
{
while ( n && *s1 && ( *s1 == *s2 ) ) {
++s1;
++s2;
--n;
}
if ( n == 0 ) {
return 0;
}
else {
return ( *(unsigned char *)s1 - *(unsigned char *)s2 );
}
}