-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
37 lines (30 loc) · 1.14 KB
/
main.c
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
#include "global.h"
int main(int argc, char *argv[]) {
/* holds the commands entered as single string */
char command_buffer[MAX_COMMAND_SIZE];
/* the name of the current working directory */
char current_working_dir[MAX_DIR_LENGHT];
/* initialize the iron shell control block */
init_shell_control_block(&iscb);
/* main loop for the iron-shell prompt */
while(1) {
/* shell prompt being logged on screen with every command */
getcwd(current_working_dir, 512);
PRINT_PROMPT(current_working_dir);
if(read_command(command_buffer, MAX_COMMAND_SIZE) != EOF) {
/* check if its build in shell command */
if(check_builtin_command(command_buffer)) {
execute_shell_builtin_command(command_buffer);
}
/* if not build in shell command */
else {
/* command handler handles the execution of the user commmand */
command_handler(command_buffer);
}
} else {
/* exit as user pressed control-D */
break;
}
}
return 0;
}