-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdController.c
More file actions
62 lines (36 loc) · 1.72 KB
/
cmdController.c
File metadata and controls
62 lines (36 loc) · 1.72 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "eggshell.h"
//parses through inputted command, understandable through String array "args" calls methods from intrnlCmdController.c or extrnlCmdController.c
void checkCmd(char * args[MAX_ARGS]){
//Recognises internal command as variable assignment command because first argument has an '=', and there's only one argument
if(strstr(args[0], "=") && args[1] == NULL){
parseVrblCmd(args); //calls method for parsing variable declaration commands
}
//Recognises internal command as "print" command since first argument is print
else if(strcmp(args[0],"print") == 0){
parsePrintCmd(args); //calls method for parsing print commands
}
//Recognises internal command as the "chdir" command to change the current working directory
else if(strcmp(args[0],"chdir") == 0){
parseChdirCmd(args); //calls method for parsing chdir commands
}
//Recognises internal command as "all" command therefore it prints all variables
else if(strcmp(args[0],"all") == 0 && args[1] == NULL){
printAllVar(); //prints all variables
}
//Recognises internal command as "source" command
else if(strcmp(args[0],"source") == 0){
parseSourceCmd(args); //parses "source" command
}
//Recognises internal command as "fg" command
else if(strcmp(args[0],"fg" ) == 0 && args[1] == NULL){
resumeSuspended(1); //resumes suspended process to foreground
}
//Recognises internal command as "bg" command
else if(strcmp(args[0],"bg") == 0 && args[1] == NULL){
resumeSuspended(0); //resumes suspended process to background
}
//Doesn't recognise so passes it off as an external command to handle
else{
externalCmd(args);
}
}