/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cchauvet env, infile, outfile); if (cmds == NULL) { close(outfile); close(infile); ft_lstclear(cmds, ft_cmddel); free(cmds); free(line_clean); return (1); } code = ft_cmds_executor(data, cmds); ft_lstclear(cmds, ft_cmddel); free(cmds); free(line_clean); return (code); } #if DEBUG int main(int ac, char **av, char **env) { t_data data; if (ac == 1) return (1); data.env = init_env(env); if (data.env == NULL) return (1); if (ft_minishell(data.env, av[1]) == 1) { ft_lstclear(data.env, env_del); free(data.env); return (1); } ft_lstclear(data.env, env_del); free(data.env); return (0); } #else int main(int ac, char **av, char **env) { t_data data; char *line; data.env = init_env(env); if (data.env == NULL) return (1); if (create_value_by_key_dup("", "$", data.env) == 1 || create_value_by_key_dup("?", "0", data.env) == 1) { ft_lstclear(data.env, env_del); free(data.env); return (1); } line = ft_get_user_input(data.env); if (line == NULL) { ft_lstclear(data.env, env_del); free(data.env); return (1); } while (line != NULL) { if (ft_minishell(&data, line) == -1) break ; free(line); line = ft_get_user_input(data.env); if (line == NULL) { ft_lstclear(data.env, env_del); free(data.env); return (1); } } ft_lstclear(data.env, env_del); free(data.env); return (data.exit_code); } #endif