Exemplo n.º 1
0
int			ft_getnextline(int const fd, t_str **line)
{
	static t_str	*buff = NULL;
	t_str			*read_buff;

	if (line == NULL || 1 > BUFF_SIZE)
		return (-1);
	if ((read_buff = ft_t_strnew(NULL, 0)) == NULL)
		return (-1);
	while ((buff == NULL) || (*line = ft_t_strcutchr(buff, '\n')) == NULL)
	{
		read_buff = ft_t_strnew(NULL, BUFF_SIZE);
		if ((read_buff->l = read(fd, read_buff->s, BUFF_SIZE)) <= 0)
			return (gnl_dried_file(&read_buff, &buff, line));
		if ((gnl_filled_file(&buff, &read_buff)) == -1)
			return (-1);
	}
	return (1);
}
Exemplo n.º 2
0
t_str	*ft_strtot_str(char *str)
{
	return (ft_t_strnew(str, ft_strlen(str)));
}