quark/src/kernel/shell.c

30 líneas
664 B
C
Original Vista normal Històric

2022-06-19 19:54:09 +02:00
#include "shell.h"
#include "lib/stdio.h"
#include "lib/string.h"
#include "lib/memory.h"
2022-06-19 19:54:09 +02:00
int shell_run(char *cmd){
2022-06-20 14:17:13 +02:00
int ret = 0;
puts("\x1b[32m");
2022-06-19 19:54:09 +02:00
if(!strcmp(cmd, "HELLO")){
printf("Hello!\n");
}
2022-06-20 14:17:13 +02:00
else if(!strcmp(cmd, "VERSION")){
printf("%s\n", OS_VERSION);
}
else if(!strcmp(cmd, "MALLOC")){
printf("Allocated 10 bytes:\n%x\n", kmalloc(10));
}
else if(!strcmp(cmd, "CALLOC")){
printf("Allocated and zeroed 10 chars:\n%x\n", kcalloc(10, sizeof(char)));
}
2022-06-19 19:54:09 +02:00
else{
printf("SHELL: Unknown command \"%s\"\n", cmd);
2022-06-20 14:17:13 +02:00
ret = 127;
2022-06-19 19:54:09 +02:00
}
2022-06-20 14:17:13 +02:00
puts("\x1b[0m");
return ret;
2022-06-19 19:54:09 +02:00
}