aboutsummaryrefslogtreecommitdiff
path: root/src/commandRouter.c
blob: 3d41ddd2fb446a509036efe25a8ef328cbcd312a (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 *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;
}