From 6a36d7e889fb3b683c03607428ad88cd5fadaceb Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 2 Sep 2021 08:45:47 +0300 Subject: (1) Moved code files to src folder --- src/commandRouter.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/commandRouter.c (limited to 'src/commandRouter.c') diff --git a/src/commandRouter.c b/src/commandRouter.c new file mode 100644 index 0000000..3d41ddd --- /dev/null +++ b/src/commandRouter.c @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include "commandHandler.h" + +extern struct CommandHandler handlers[MAX_HANDLERS]; +extern int handlerCount; + +bool route(char *command) { + command = strtok(command, " "); + + for (int i = 0; i < handlerCount; i++) { + if (strcasecmp(handlers[i].p_name, command) == 0) { + handlers[i].p_executor(command); + return true; + } + } + return false; +} -- cgit v1.2.3