aboutsummaryrefslogtreecommitdiff
path: root/parser.c
blob: 1c127cd1f111e8f27e446f37e05220fc0c65e82d (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
#include "db.h"


uint16_t len(const char *s){
	uint16_t l = -1;
	while(s[++l]);
	return l;
}

bool sameStr(const char* s1, const char *s2){
	uint16_t i1 = 0, i2 = 0;
	while(s1[i1] && s2[i2] && s1[i1] == s2[i2])
		++i1, ++i2;
	return !s1[i1] && !s2[i2];
}

int handleMetaCommand(inputBuffer *in){
	if(sameStr(in->buffer, ".exit")){
		freeInputBuffer(in);
		printf("EXIT M'NIGGA\n");
		exit(EXIT_SUCCESS);
	}else{
		return META_COMMAND_FAIL;
	}
}

int handleInput(inputBuffer *in){
	if(in->buffer[0] == '.'){
		return handleMetaCommand(in);
	}else{
		printf("normal command\n");
	}
}