diff options
Diffstat (limited to 'src/commandRouter.c')
| -rw-r--r-- | src/commandRouter.c | 20 |
1 files changed, 20 insertions, 0 deletions
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 <stdio.h> +#include <string.h> +#include <stdbool.h> +#include <strings.h> +#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; +} |
