aboutsummaryrefslogtreecommitdiff
path: root/src/commands/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/command.c')
-rw-r--r--src/commands/command.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/commands/command.c b/src/commands/command.c
index ee53c90..eeac08e 100644
--- a/src/commands/command.c
+++ b/src/commands/command.c
@@ -1,17 +1,24 @@
#include "../graphics/graphics.h"
#include "../lib/lib.h"
+#include "../io/io.h"
int32_t starts_with(const char *a, const char *b) {
- if (strcmp(a, b, strlen(b)) == 0)
- return 1
- return 0
+ size_t length_pre = strlen(b);
+ size_t length_main = strlen(a);
+ return length_main < length_pre ? 0 : memory_compare(b, a, length_pre) == 0;
}
+extern void shutdown();
+
void exec_command(char *command) {
if (starts_with(command, "ls"))
- terminal_write_string("// listing files");
+ terminal_write_line("Listing files");
else if (starts_with(command, "help"))
- terminal_write_string("I can't help you write now");
+ terminal_write_line("I can't help you write now");
else if (starts_with(command, "ping"))
- terminal_write_string("pong!")
+ terminal_write_line("pong!");
+ else if (starts_with(command, "shutdown"))
+ shutdown();
+ else
+ terminal_write_line("Command not found!");
}