-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
29 lines (29 loc) · 904 Bytes
/
main.c
File metadata and controls
29 lines (29 loc) · 904 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
#include "./include/headers.h"
struct recordOfCommands* recordHead;
char* shellpath;
int main()
{
// Keep accepting commands
recordHead=(struct recordOfCommands*)malloc(sizeof(struct recordOfCommands));
shellpath=(char*)malloc(sizeof(char)*500);
recordHead->next=recordHead;
recordHead->prev=recordHead;
originalpath();
x();
while (1)
{
// Print appropriate prompt with username, systemname and directory before accepting input
prompt();
char input[4096];
fgets(input, 4096, stdin);
// parse function returns a linkedlist of separate command lines
struct commandnode *result = parse(input);
if(result==NULL)
{
fprintf(stderr,RED"ERROR: Syntax error! Please enter valid command\n"RESET);
continue;
}
commandExtraction(result);
destroylist(&result);
}
}