int get_next_line(int const fd, char **line) { static char *buff; int rd; char *ret; *line = NULL; rd = 0; if (BUFF_SIZE <= 0 || fd < 0) return (-1); if (!buff) { buff = (char *)malloc(sizeof(char) * BUFF_SIZE + 1); buff[0] = 0; } if (ft_strchr((buff), '\n') || buff[0]) { ret = ft_putline(&buff, &(*line)); if (ret) rd = 1; } if (rd == 0) rd = ft_read(fd, &buff, &(*line)); if (*line) rd = 1; return (rd); }
t_list *rush03(int x, int y) { int length; t_list *list; list = 0; if (x <= 0 || y <= 0) return (0); length = y; while (length >= 1) { if (length == y) ft_list_push_front(&list, ft_putline('A', 'C', 'B', x)); else if (length == 1) ft_list_push_front(&list, ft_putline('A', 'C', 'B', x)); else ft_list_push_front(&list, ft_putline('B', 'B', ' ', x)); length -= 1; } return (list); }
int ft_read(int const fd, char **buff, char **line) { char *pos; int rd; rd = 1; pos = NULL; while (rd != 0) { rd = read(fd, *buff, BUFF_SIZE); if (rd < 0) return (-1); if (rd == 0) return (0); (*buff)[rd] = 0; pos = ft_putline(buff, &(*line)); if (pos) return (1); } return (0); }