working on reading elf from initrd, and getting it launched with the new scheduler

This commit is contained in:
2026-06-30 19:26:31 -05:00
parent ce81d4eb31
commit af6c1c94cf
21 changed files with 253 additions and 151 deletions

49
kernel/lib/strtok.c Normal file
View File

@@ -0,0 +1,49 @@
#include <lib/string.h>
#include <stddef.h>
static int is_delim(char c, const char* delim) {
while (*delim) {
if (c == *delim) {
return 1;
}
delim++;
}
return 0;
}
char* strtok_r(char* str, const char* delim, char** saveptr) {
if (saveptr == NULL) {
return NULL;
}
char* next_token = (str != NULL) ? str : *saveptr;
if (next_token == NULL || *next_token == '\0') {
*saveptr = NULL;
return NULL;
}
while (*next_token && is_delim(*next_token, delim)) {
next_token++;
}
if (*next_token == '\0') {
*saveptr = next_token;
return NULL;
}
char* token_start = next_token;
while (*next_token) {
if (is_delim(*next_token, delim)) {
*next_token = '\0'; // Destructively null-terminate the token
*saveptr = next_token + 1; // Save the position right after the null-terminator
return token_start;
}
next_token++;
}
*saveptr = next_token;
return token_start;
}