/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* simple_cmd.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/21 12:30:07 by khais #+# #+# */ /* Updated: 2025/04/15 14:47:13 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include "simple_cmd.h" #include "libft.h" #include "../../treedrawing.h" #include "../redirect/redirect_debug.h" #include "../cmd/cmd_destroy.h" /* ** parse a wordlist and yield a simple command. ** ** takes ownership of words */ t_simple_cmd *simple_cmd_from_wordlist(t_wordlist *words) { t_simple_cmd *cmd; cmd = ft_calloc(1, sizeof(t_simple_cmd)); if (cmd == NULL) return (NULL); cmd->words = words; return (cmd); } void simple_cmd_destroy(t_simple_cmd *cmd) { if (cmd == NULL) return ; wordlist_destroy(cmd->words); redirect_destroy(cmd->redirections); free(cmd); } void simple_cmd_debug(t_simple_cmd *cmd, t_buffer *leader, bool is_last) { if (cmd == NULL) return ; indent(leader, is_last); ft_printf("%s\n", "t_simple_cmd"); indent(leader, false); ft_printf("line = %d\n", cmd->line); dedent(leader, false); wordlist_debug(cmd->words, leader, false); redirect_debug(cmd->redirections, leader, true); dedent(leader, is_last); }