aboutsummaryrefslogtreecommitdiff
path: root/src/commandRouter.c
blob: baf04c2930e76437c2400ced94c6538f1d8ef892 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 *p_command) {
	p_command = strtok(p_command, " ");

	for (int i = 0; i < handlerCount; i++) {
		if (strcasecmp(handlers[i].p_name, p_command) == 0) {
			handlers[i].p_executor(p_command);
			return true;
		}
	}
	return false;
}