diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-09-02 08:45:47 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-09-02 08:45:47 +0300 |
| commit | 6a36d7e889fb3b683c03607428ad88cd5fadaceb (patch) | |
| tree | dbad26ce67228334603c808ca5ed6e062fda1e23 /src/commandRouter.c | |
| parent | 124e07eb3d22e3964f1fcd2580d7f2954621c596 (diff) | |
| download | you86-6a36d7e889fb3b683c03607428ad88cd5fadaceb.tar you86-6a36d7e889fb3b683c03607428ad88cd5fadaceb.tar.gz you86-6a36d7e889fb3b683c03607428ad88cd5fadaceb.zip | |
(1) Moved code files to src folder
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; +} |
