int get_next_line(int const fd, char **line) { static t_list_fd *list = NULL; char *buf; int len; char *chr; if (fd < 0 || !line || !(list = ft_search_fd(list, fd)) || BUFF_SIZE <= 0) return (-1); if (!(buf = malloc(sizeof(char) * (BUFF_SIZE + 1)))) return (-1); ft_bzero(buf, BUFF_SIZE + 1); if (check_buf(list, line, buf)) return (1); *line = ft_strdup(list->content); while ((len = read(fd, buf, BUFF_SIZE))) { if (len == -1) return (-1); buf[len] = '\0'; if (check_buf(list, line, buf)) return (1); chr = *line; *line = ft_strjoin(*line, buf); free(chr); } return (0); }
int get_next_line(int const fd, char **line) { static t_list *next = NULL; t_list *begin; char buf[BUFF_SIZE]; int nbr; char *d; d = NULL; if (fd < 0 || !line || read(fd, buf, 0) < 0) return (-1); if (next) begin = next; else begin = NULL; next = ft_search_fd(&begin, fd); while ((nbr = read(fd, buf, BUFF_SIZE)) > 0 && !(ft_strchr(buf, '\n'))) next->content = ft_passkip((next->content), buf, nbr); next->content = ft_passkip((next->content), buf, nbr); *line = ft_get_line(next->content, *line); if (!*((char *)next->content) && (next = begin)) return (0); d = next->content; next->content = ft_strdup(ft_skype_n(next->content)); free(d); next = begin; return (1); }
int ft_get_next_line(int const fd, char **line) { static t_list *lst; char buf[BUFF_SIZE + 1]; int retour_read; t_file *file; if (fd == -1 || !line || BUFF_SIZE <= 0 || !(file = ft_search_fd(&lst, fd))) return (-1); if (!(retour_read = ft_save_line(file, line))) { while ((retour_read = read(fd, buf, BUFF_SIZE))) { if (retour_read < 0) return (-1); buf[retour_read] = '\0'; if ((retour_read = ft_readnextline(buf, line, file))) return (retour_read); } if (**line) return (1); return (0); } return (retour_read); }