Updated userspace

This commit is contained in:
Alex
2022-12-24 09:18:45 +02:00
parent 0ce6433311
commit 40410cba41
25 changed files with 472 additions and 36 deletions

View File

@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include "../mem/liballoc_1_1.h"
@@ -37,10 +38,20 @@ int atoi(const char *nptr)
return OutBuffer;
}
char **environ = NULL;
char *getenv(const char *name)
{
static char *env = "PATH=/bin";
return env;
char **env = environ;
if (env == NULL)
return NULL;
size_t len = strlen(name);
while (*env != NULL)
{
if ((strncmp(*env, name, len) == 0) && ((*env)[len] == '='))
return &(*env)[len + 1];
++env;
}
}
void *malloc(size_t Size) { return PREFIX(malloc)(Size); }

14
libc/src/string.c Normal file
View File

@@ -0,0 +1,14 @@
#include <string.h>
int strncmp(const char *s1, const char *s2, size_t n)
{
for (size_t i = 0; i < n; i++)
{
char c1 = s1[i], c2 = s2[i];
if (c1 != c2)
return c1 - c2;
if (!c1)
return 0;
}
return 0;
}