Beispiel #1
0
char		*get_next_line(int fd)
{
  static char	keep[READ_SIZE + 1];
  char		buff[READ_SIZE + 1];
  t_strs	strs;
  int		len;

  strs.line = NULL;
  if (READ_SIZE <= 0)
    return (NULL);
  if (keep[0] != 0)
    {
      if ((put_in_line(&strs, keep)) == 1)
	return (NULL);
      if (is_backslash_n(keep, keep) == 1)
	return (strs.line);
    }
  while ((len = read(fd, buff, READ_SIZE)) > 0)
    {
      buff[len] = '\0';
      if ((put_in_line(&strs, buff)) == 1)
	return (NULL);
      if (is_backslash_n(buff, keep) == 1 || len < READ_SIZE)
	return (strs.line);
    }
  return (strs.line);
}
Beispiel #2
0
int					get_next_line(int fd, char **line)
{
	static char		*tmp[256];
	char			*buff;
	int				ret;
	int				value;

	if ((ret = 2) && (fd < 0 || line == NULL))
		return (-1);
	while (ft_strchr(tmp[fd], '\n') == NULL && ret > 0)
	{
		if ((buff = ft_strnew(BUFF_SIZE)) == NULL)
			return (-1);
		ret = read(fd, buff, BUFF_SIZE);
		if ((tmp[fd] = join_in_temp(&tmp[fd], &buff)) == NULL)
			return (-1);
		free(buff);
	}
	if (ret == 0 || ret == -1)
	{
		if (tmp[fd] && *tmp[fd])
			put_in_line(line, &tmp[fd]);
		if (tmp[fd] && *tmp[fd])
			return (1);
		return (ret);
	}
	return (value = put_in_line(line, &tmp[fd]));
}
Beispiel #3
0
void bfs_matriz(int current_size,int node_number,int line_pos){
		int j;		
		int next_node;

		//printf("BFS:%d\n",node_number);
		//printf("SIZE:%d\n",current_size);

		for(j = 0;j < vertices; j++){
				if(matriz[node_number][j] == 1 ){
						if(put_in_line(j)){
								dist[j] = current_size + 1;
								//printf("%d:%d %d\n",node_number,j,dist[j]);
						}
				}	
		}

		line_pos++;

		if(global_line[line_pos] != -1){
				next_node = global_line[line_pos];
				bfs_matriz(dist[next_node],next_node,line_pos);
		}
}