2022-06-19 19:54:09 +02:00
|
|
|
#include "shell.h"
|
|
|
|
#include "lib/stdio.h"
|
|
|
|
#include "lib/string.h"
|
2022-06-20 16:52:25 +02:00
|
|
|
#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-20 18:06:05 +02:00
|
|
|
if(!strcmp(cmd, "hello")){
|
2022-06-19 19:54:09 +02:00
|
|
|
printf("Hello!\n");
|
|
|
|
}
|
2022-06-20 18:06:05 +02:00
|
|
|
else if(!strcmp(cmd, "version")){
|
2022-06-20 14:17:13 +02:00
|
|
|
printf("%s\n", OS_VERSION);
|
|
|
|
}
|
2022-06-20 18:06:05 +02:00
|
|
|
else if(!strcmp(cmd, "malloc")){
|
2022-06-20 16:52:25 +02:00
|
|
|
printf("Allocated 10 bytes:\n%x\n", kmalloc(10));
|
|
|
|
}
|
2022-06-20 18:06:05 +02:00
|
|
|
else if(!strcmp(cmd, "calloc")){
|
2022-06-20 16:52:25 +02:00
|
|
|
printf("Allocated and zeroed 10 chars:\n%x\n", kcalloc(10, sizeof(char)));
|
|
|
|
}
|
2022-06-20 18:06:05 +02:00
|
|
|
else if(!strcmp(cmd, "clear")){
|
2022-06-20 16:54:00 +02:00
|
|
|
clear_screen();
|
|
|
|
}
|
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
|
|
|
}
|