-
Notifications
You must be signed in to change notification settings - Fork 0
/
File_Executing.c
executable file
·65 lines (56 loc) · 1.72 KB
/
File_Executing.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
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
63
64
65
#include"file.h"
void Executing(char* line)
{
int NbCmd;
char *parsedArgs[LineLength];
if(CheckNext(line) == 0)
{
if(CheckOr(line) == 0)
{
if(CheckAnd(line) == 0)
{
if(CheckPipe(line) == 0)
{
if(CheckRedirectFile(line) == 0)
{
NbCmd =ParseSimple(strdup(line),parsedArgs," ");
int DetectPathHandler = PathHandler(parsedArgs);
if (DetectPathHandler==0)
{
ExecuteOneCommand(parsedArgs);
}
else if (DetectPathHandler == -1)
{
printf("Wrong Path \n");
}
}
else
{
NbCmd=ParseSimple(strdup(line),parsedArgs,">");
ExecuteRedirected(parsedArgs,NbCmd);
}
}
else
{
NbCmd=ParseSimple(strdup(line),parsedArgs,"|");
ExecutePiped(parsedArgs,NbCmd);
}
}
else
{
NbCmd=ParseSimple(strdup(line),parsedArgs,"&&");
ExecuteAndCommands(parsedArgs,NbCmd);
}
}
else
{
NbCmd=ParseSimple(strdup(line),parsedArgs,"||");
ExecuteOrCommands(parsedArgs,NbCmd);
}
}
else
{
NbCmd=ParseSimple(strdup(line),parsedArgs,";");
ExecuteAllCommand(parsedArgs,NbCmd);
}
}