-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.c
59 lines (54 loc) · 1.7 KB
/
start.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* start.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: djames <djames@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 15:38:41 by djames #+# #+# */
/* Updated: 2023/07/18 12:25:45 by djames ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void ft_start3(char *prom_line)
{
if (prom_line == NULL)
{
printf("\033[1A");
printf("\033[11C");
printf("exit\n");
if (prom_line)
free(prom_line);
exit(0);
}
ft_history(prom_line);
}
void disable_rawmode(void)
{
tcgetattr(STDIN_FILENO, &(g_data.term));
g_data.term.c_lflag |= ECHOCTL;
tcsetattr(STDIN_FILENO, TCSANOW, &(g_data.term));
}
int start_main(t_token *token, t_command *command)
{
int i;
char *prom_line;
i = 1;
command = NULL;
token = NULL;
g_data.flag2 = 0;
enable_rawmode();
signal(SIGQUIT, SIG_IGN);
signal(SIGINT, handle_signal);
prom_line = readline("MINISHELL$ ");
ft_start3(prom_line);
if (g_data.flag2 != 1)
{
if (!count_quotes(prom_line))
token = tokenizer(prom_line);
i = check_built3(token, command);
}
if (prom_line)
free(prom_line);
return (i);
}