Ejemplo n.º 1
0
static int	facto_main(char **av, t_list **list)
{
	int		fd;
	char	*line;

	fd = 0;
	if ((fd = open(av[1], O_RDONLY)) == -1)
	{
		ft_error(1);
		return (FALSE);
	}
	while (get_next_line(fd, &line) > 0)
	{
		if (line[0] != '\0' && line[0] != '#')
		{
			if (line[0] == ' ' || line[0] == '\t')
				ft_list_push(delete_tab_or_spaces(line), list);
			else
				ft_list_push(line, list);
		}
	}
	if (line[0])
		ft_strdel(&line);
	close(fd);
	return (TRUE);
}
Ejemplo n.º 2
0
void		ft_define_way(t_map *map, int index, int i)
{
	t_elem		*elem;

	map->ants[i]->way = ft_list_init(map->ants[i]->way);
	elem = map->roads->first;
	while (index-- > 0)
		elem = elem->next;
	elem = ((t_list *)elem->value)->first;
	while (elem != NULL)
	{
		ft_list_push(map->ants[i]->way
					, ft_list_new(elem->value, sizeof(t_room *)));
		elem = elem->next;
	}
	map->ants[i]->room = map->ants[i]->way->first;
}
Ejemplo n.º 3
0
void	ft_sorted_list_insert(t_list **begin_list, void *data, int (*cmp)())
{
	t_list	*tmp1;
	t_list	*tmp2;
	int		i;

	i = 1;
	if (*begin_list == NULL)
	{
		*begin_list = ft_create_elem(data);
		return ;
	}
	tmp1 = *begin_list;
	tmp2 = tmp1->next;
	while (tmp2)
	{
		if (ft_list_push(&tmp1, &tmp2, data, cmp))
			return ;
		tmp1 = tmp1->next;
		tmp2 = tmp2->next;
	}
	tmp1->next = ft_create_elem(data);
}