forked from dbenshachar/mini-os
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.c
More file actions
Latest commit
48 lines (42 loc) · 883 Bytes
/
Copy pathkernel.c
File metadata and controls
48 lines (42 loc) · 883 Bytes
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
39
40
41
42
43
44
45
46
47
48
#include<stdint.h>
#include"commands.h"
intdone=0;
charcmdbuf[256];
uint8_tcmdlen=0;
voidnew_line() {
cmdbuf[0] ='\0';
cmdlen=0;
}
voidbackspace() {
cmdbuf[cmdlen] ='\0';
cmdlen= (cmdlen>0) ? cmdlen-1 : 0;
}
/*Execute by running:
chmod +x run.bash && ./run.bash
*/
voidkmain(void){
fs_init();
fs_return();
puts("\n> ");
while (1)
{
intc=getc();
if (c=='\n'||c=='\r') {
cmdbuf[cmdlen] ='\0';
cmdlen++;
done= !execute(cmdbuf);
if (done) {puts("\nTried to quit!");}
new_line();
puts("\n> ");
continue;
}
if (c==0x7F||c=='\b') {
backspace();
puts("\b \b");
continue;
}
cmdbuf[cmdlen] =c;
cmdlen++;
putc((char)c);
}
}