From 8e0c4dc52871e720f793db0b21e1b4f504cefcf9 Mon Sep 17 00:00:00 2001 From: marvinborner Date: Wed, 18 Sep 2019 11:02:15 +0200 Subject: Added basic command support --- src/commands/command.c | 17 +++++++++++++++++ src/commands/command.h | 6 ++++++ 2 files changed, 23 insertions(+) create mode 100644 src/commands/command.c create mode 100644 src/commands/command.h (limited to 'src/commands') diff --git a/src/commands/command.c b/src/commands/command.c new file mode 100644 index 0000000..ee53c90 --- /dev/null +++ b/src/commands/command.c @@ -0,0 +1,17 @@ +#include "../graphics/graphics.h" +#include "../lib/lib.h" + +int32_t starts_with(const char *a, const char *b) { + if (strcmp(a, b, strlen(b)) == 0) + return 1 + return 0 +} + +void exec_command(char *command) { + if (starts_with(command, "ls")) + terminal_write_string("// listing files"); + else if (starts_with(command, "help")) + terminal_write_string("I can't help you write now"); + else if (starts_with(command, "ping")) + terminal_write_string("pong!") +} diff --git a/src/commands/command.h b/src/commands/command.h new file mode 100644 index 0000000..2a43416 --- /dev/null +++ b/src/commands/command.h @@ -0,0 +1,6 @@ +#ifndef MELVIX_COMMAND_H +#define MELVIX_COMMAND_H + +void exec_command(char *command); + +#endif -- cgit v1.2.3