#include "libftx/libftx.h" #include "minishell.h" static int ft_quote_verif(const char *str) { if (ft_is_in_quote(str, ft_strlen(str))) { ft_eprintf("minishell: Quote is note closed"); return (1); } else return (0); } static int ft_multipipe(const char *str) { size_t i; size_t y; i = 0; while (str[i] != '\0') { y = 0; while (str[i + y] == '|' && !ft_is_in_quote(str, i)) { if (y > 0) { ft_eprintf("minishell: Multiple pipes is not supported\n"); return (1); } y++; } i++; } return (0); } static int ft_pipe_is_alone(const char *str) { size_t i; i = ft_strlen(str) - 1; while (str[i] != '|' && i > 0) { if (str[i] != ' ') return (0); i--; } if (i == 0) return (0); ft_eprintf("minishell: Pipe must be followed by a command or redirection\n"); return (1); } int ft_syntatic_verif(const char *str) { return (ft_quote_verif(str) || ft_multipipe(str) || ft_pipe_is_alone(str)); }