-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
68 lines (61 loc) · 1.73 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
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
66
67
68
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmakboub <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/02 21:16:47 by mmakboub #+# #+# */
/* Updated: 2023/01/08 23:26:35 by mmakboub ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_global g_global;
void init_var(int *fd, char **str, int ac)
{
(void)ac;
(void)str;
*fd = dup(1);
g_global.end = NULL;
g_global.temp = NULL;
g_global.sig = 0;
}
void main_utils(char **env, t_env *envr, int fd_1, char *line)
{
t_element *element;
while (1)
{
handling_sig();
g_global.exit_heredoc = 0;
line = readline("minishell> ");
lineisempty(line);
if (*line)
{
add_history(line);
element = parser(line, env);
if (element)
{
if (!envr)
{
printf("sadly ! there is no env\n");
continue ;
}
check_cmd(element, &envr);
free_memory(1);
}
}
dup2(fd_1, 1);
}
}
int main(int ac, char **str, char **env)
{
t_env *envr;
int fd_1;
char *line;
line = NULL;
init_var(&fd_1, str, ac);
envr = build_env(env);
env_initialisation(&envr);
main_utils(env, envr, fd_1, line);
return (0);
}