-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
50 lines (47 loc) · 755 Bytes
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "header.h"
/**
* main - entry point
*
* Return: 0 to success
*/
int main(void)
{
char w_env[4] = "env";
char w_exit[5] = "exit";
char w_slash[1] = "/";
char *line = NULL;
char **arg = NULL;
char **path = NULL;
int flag = 0;
signal(SIGINT, salto_linea);
while (flag != EOF)
{
line = read_line();
arg = parsing_arg(line);
if (_strcmp(w_env, arg[0]) == 0)
{
free(line);
free(arg);
_enviro();
continue;
}
else if (_strcmp(w_exit, arg[0]) == 0)
{
free(line);
free(arg);
exit(0);
continue;
}
else if (_strcmp(w_slash, arg[0]) == 0)
{
exec_process(arg, line);
free(line);
free(arg);
}
path = path_av(arg);
exec_process(path, line);
free(line);
free(arg);
}
return (0);
}