2024-04-25 11:46:41 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* main.c :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
2024-05-22 14:51:52 +02:00
|
|
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
2024-04-25 11:46:41 +02:00
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
2024-07-09 14:42:28 +02:00
|
|
|
/* Updated: 2024/07/09 14:40:50 by mmoussou ### ########.fr */
|
2024-04-25 11:46:41 +02:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2024-04-30 12:36:16 +02:00
|
|
|
#include "minishell.h"
|
2024-04-25 11:46:41 +02:00
|
|
|
|
2024-07-04 17:15:08 +02:00
|
|
|
void sig_c(int code)
|
2024-06-25 17:54:33 +02:00
|
|
|
{
|
|
|
|
(void)code;
|
|
|
|
ft_putchar_fd('\n', STDOUT_FILENO);
|
|
|
|
rl_on_new_line();
|
|
|
|
rl_replace_line("", 0);
|
|
|
|
rl_redisplay();
|
|
|
|
}
|
|
|
|
|
2024-07-09 11:25:22 +02:00
|
|
|
bool run_checks(char *rl)
|
|
|
|
{
|
|
|
|
if (!*rl)
|
|
|
|
return (true);
|
|
|
|
if (check_syntax(rl))
|
|
|
|
return (true);
|
|
|
|
if (check_quote(rl))
|
|
|
|
return (true);
|
|
|
|
if (check_pipe(rl))
|
|
|
|
return (true);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
|
2024-07-09 14:42:28 +02:00
|
|
|
/*int main(int ac, char **av, char **env)
|
2024-04-25 11:46:41 +02:00
|
|
|
{
|
2024-07-04 17:15:08 +02:00
|
|
|
char *rl;
|
2024-05-02 15:50:58 +02:00
|
|
|
char *prompt;
|
2024-05-28 14:21:41 +02:00
|
|
|
t_env env_l;
|
2024-05-31 19:26:09 +02:00
|
|
|
t_list *cmd_list;
|
2024-07-04 17:15:08 +02:00
|
|
|
t_list *piped;
|
2024-04-25 11:46:41 +02:00
|
|
|
|
|
|
|
(void)ac;
|
2024-06-30 18:03:58 +02:00
|
|
|
get_program_name(av[0]);
|
2024-05-30 17:59:49 +02:00
|
|
|
if (env_init(env, &env_l))
|
|
|
|
return (EXIT_FAILURE);
|
2024-07-04 17:15:08 +02:00
|
|
|
signal(SIGINT, &sig_c);
|
2024-04-25 11:46:41 +02:00
|
|
|
while (1)
|
|
|
|
{
|
2024-05-28 14:21:41 +02:00
|
|
|
prompt = get_prompt(env_l);
|
2024-07-04 17:15:08 +02:00
|
|
|
rl = readline(prompt);
|
2024-05-02 15:54:16 +02:00
|
|
|
free(prompt);
|
2024-07-04 17:15:08 +02:00
|
|
|
if (!rl)
|
|
|
|
exit(727);
|
2024-07-09 11:25:22 +02:00
|
|
|
if (run_checks(rl))
|
2024-06-30 18:03:58 +02:00
|
|
|
continue ;
|
2024-07-04 17:15:08 +02:00
|
|
|
piped = tokenizer(rl);
|
|
|
|
if (check_argv(piped))
|
2024-06-30 18:03:58 +02:00
|
|
|
continue ;
|
2024-07-04 17:15:08 +02:00
|
|
|
add_history(rl);
|
2024-07-06 18:08:04 +02:00
|
|
|
cmd_list = get_cmd_list(piped, &env_l);
|
2024-07-04 17:15:08 +02:00
|
|
|
ft_lstclear(&piped, &free_token);
|
2024-07-04 11:45:37 +02:00
|
|
|
format_quotes(cmd_list);
|
2024-06-21 09:59:31 +02:00
|
|
|
exec_split_cmd(cmd_list, &env_l);
|
2024-07-04 17:15:08 +02:00
|
|
|
ft_lstclear(&cmd_list, &free_cmd);
|
|
|
|
free(rl);
|
2024-04-25 11:46:41 +02:00
|
|
|
}
|
|
|
|
return (0);
|
2024-07-09 14:42:28 +02:00
|
|
|
}*/
|
|
|
|
|
|
|
|
int main(int ac, char **av, char **e)
|
|
|
|
{
|
|
|
|
t_env *env;
|
|
|
|
|
|
|
|
(void) ac;
|
|
|
|
(void) av;
|
|
|
|
env = env_init(e);
|
|
|
|
ft_envprint(env);
|
|
|
|
ft_envclear(&env, free);
|
2024-04-25 11:46:41 +02:00
|
|
|
}
|