aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorMarvin Borner2019-09-19 18:58:02 +0200
committerMarvin Borner2019-09-19 18:58:02 +0200
commit2a3620453de91e08b668ef21049058239c82d0a4 (patch)
tree8f64cce5d28c7f205dd1db8a9faa915db88a2280 /src/commands
parent68838789574c9a39b7382c67e8cc984a8c928fe6 (diff)
parentc33bc6864a3291dc72b2da071e52e481573f5459 (diff)
Fixed commands and added some more
Diffstat (limited to 'src/commands')
-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!");
}