aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
blob: 303efeac732afe8fd83bc7c485b4200bfc90df7f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/posix2_lim.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>

#define SHELL_STRING "> "

extern void initFiles();
extern void registerDefaultHandlers();

extern bool route(char *command);
void printDefault();

int main() {
	initFiles();
	registerDefaultHandlers();

	char buffer[LINE_MAX];
	buffer[0] = 0;

	printf("Welcome!\n\n");
	do {
		// Removes the Line Feed character at the "end", if it exists
		char *toChange = strchr(buffer, 0x0A);
		if (toChange != NULL)
			toChange[0] = 0;

		if (buffer[0] > 0)
			if (route(buffer))
				printf("\n");
		
		printf(SHELL_STRING);
	} while (fgets(buffer, LINE_MAX, stdin));

	return 0;
}