#include "libftx/libftx.h" #include "minishell.h" #include /* int main(int ac, char **av) */ /* { */ /* char *line; */ /* int fd; */ /* */ /* if (ac != 2) */ /* return (1); */ /* fd = open(av[1], O_RDONLY); */ /* line = get_next_line(fd); */ /* while (line != NULL) */ /* { */ /* ft_printf(line); */ /* line = get_next_line(fd); */ /* free(line); */ /* } */ /* free(line); */ /* return (0); */ /* } */ int main(int ac, char **av, char **env) { t_list **cmds; char *line; t_data data; if (ac == 1) return (1); line = ft_normalizer(av[1]); if (line == NULL) return (1); if (ft_syntatic_verif(line) == 1) { free(line); return (1); } data.env = init_env(env); if (data.env == NULL) return (1); cmds = ft_parse_cmds(line); if (cmds == NULL) return (1); if (ft_cmds_executor(cmds, env) == 1) { ft_lstclear(data.env, env_del); ft_lstclear(cmds, ft_cmddel); return (1); } ft_lstclear(data.env, env_del); ft_lstclear(cmds, ft_cmddel); free(cmds); free(data.env); free(line); return (0); }