예제 #1
0
void		ft_add(t_swap **ptr2, int data)
{
	t_swap	*ptr;

	ptr = *ptr2;
	if (!ptr)
	{
		*ptr2 = ft_init_list(ft_itoa(data));
		return ;
	}
	while (ptr->next)
		ptr = ptr->next;
	ptr->next = ft_init_list(ft_itoa(data));
}
예제 #2
0
void	ft_check_coord(t_env *env)
{
	t_coord		**coord;
	int			i;

	i = -1;
	coord = (t_coord**)malloc(sizeof(t_coord*) * 4);
	env->height = 0;
	env->width = 0;
	while (env->map[env->nb_tetri][++i] != '\0')
	{
		if (env->map[env->nb_tetri][i] == '#' && env->height < 5)
		{
			coord[env->height] = (t_coord*)malloc(sizeof(t_coord));
			coord[env->height]->y = env->width;
			coord[env->height]->x = (i - ((4 + 1) * env->width));
			env->height++;
		}
		if (env->map[env->nb_tetri][i] == '\n')
			env->width++;
	}
	ft_save_coord(env, coord);
	if (!env->ltetri)
		ft_init_list(env, coord);
	else
		ft_create_tetri(env, coord);
	env->index++;
}
예제 #3
0
파일: main.c 프로젝트: Nquere/select
int				main(int ac, char **av)
{
	char			buffer[2048];
	struct termios	t;
	char			read_char[5];
	t_l				*l;

	*read_char = 0;
	l = NULL;
	if (tgetent(buffer, getenv("TERM")) < 1)
		return (-1);
	term_no_canon(t);
	tputs(tgetstr("ti", NULL), 1, ft_int_putchar);
	tputs(tgetstr("vi", NULL), 1, ft_int_putchar);
	if ((l = (t_l *)malloc(sizeof(t_l))) == NULL)
		return (-1);
	ft_init_list(l);
	display_list(l, ac, av);
	tputs(tgetstr("ks", NULL), 1, ft_int_putchar);
	read_keys(read_char);
	tputs(tgetstr("ke", NULL), 1, ft_int_putchar);
	tputs(tgetstr("ve", NULL), 1, ft_int_putchar);
	tputs(tgetstr("te", NULL), 1, ft_int_putchar);
	term_canon(t);
	return (0);
}
예제 #4
0
t_swap		*ft_creat_list(int max, char **av)
{
    int		i;
    void	*save;
    t_swap	*ptr;

    i = 1;
    if (!ft_strcmp(av[1], "-v"))
        ++i;
    ptr = ft_init_list(av[i++]);
    save = ptr;
    while (i <= max)
    {
        ptr->next = ft_init_list(av[i++]);
        ptr = ptr->next;
    }
    return (save);
}
예제 #5
0
t_list_fd					*ft_search_fd(t_list_fd *list, int fd)
{
	void					*tmp;
	t_list_fd				*ltmp;

	if (!list)
		return (ft_init_list(fd, NULL, -1));
	while (list->i != 0)
		list = list->next;
	tmp = list;
	if (list->fd == fd)
		return (list);
	if (list->next)
		list = list->next;
	ltmp = list;
	while (list->i)
	{
		if (list->fd == fd)
			return (list);
		ltmp = list;
		list = list->next;
	}
	return (ltmp->next = ft_init_list(fd, tmp, ltmp->i));
}