Пример #1
0
void	ft_lstdelcmp(t_list **begin, void (*del)(void *, size_t),
		int (cmp)(void *))
{
	t_list *tmp;
	t_list *prev;

	tmp = *begin;
	prev = tmp;
	while (tmp)
	{
		if ((tmp == *begin) && !cmp(tmp->content))
		{
			*begin = tmp->next;
			ft_lstdelone(&tmp, del);
			tmp = *begin;
		}
		else if (!cmp(tmp->content))
		{
			prev->next = tmp->next;
			ft_lstdelone(&tmp, del);
			tmp = prev->next;
		}
		else
		{
			prev = tmp;
			tmp = tmp->next;
		}
	}
}
Пример #2
0
static void		print_fakelist(t_list **list)
{
	t_list	*cur;
	t_list	*prev;

	prev = *list;
	while (prev != NULL && ((t_file *)prev->content)->error != 0)
	{
		print_error(((t_file *)prev->content)->name,
					((t_file *)prev->content)->error);
		*list = (*list)->next;
		ft_lstdelone(&prev, free_list);
		prev = *list;
	}
	while (prev != NULL && prev->next != NULL)
	{
		cur = prev->next;
		if (((t_file *)cur->content)->error != 0)
		{
			prev->next = cur->next;
			print_error(((t_file *)cur->content)->name,
						((t_file *)cur->content)->error);
			ft_lstdelone(&cur, free_list);
		}
		else
			prev = prev->next;
	}
}
Пример #3
0
void	ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	if ((*alst)->next == NULL)
		ft_lstdelone(&(*alst), del);
	else
	{
		ft_lstdel(&(*alst)->next, del);
		ft_lstdelone(&(*alst), del);
	}
}
Пример #4
0
void	ft_lstdel(t_list **alst, void (*del)(void*, size_t))
{
	if (*alst != NULL && del != NULL)
	{
		while ((*alst)->next != NULL)
		{
			ft_lstdelone(alst, del);
			(*alst)->next = *alst;
		}
		ft_lstdelone(alst, del);
	}
}
Пример #5
0
void	ft_lstdel(t_list_libft **alst, void (*del)(void*, size_t))
{
	if (!alst || !*alst)
		return ;
	ft_lstdel(&((*alst)->next), del);
	ft_lstdelone(alst, del);
}
Пример #6
0
void			ls_list_dir_cont(char *name, t_lst *dcontent, t_lst *subdirs,
							t_lsargs *args)
{
	t_lst	*el;
	t_uint	sub_count;

	if ((name[0] != '.' || HCK2 || args->ndirs) || HCK)
	{
		if (args->flags & FLAG_l && dcontent)
			ls_l_tblock(dcontent);
		ls_display_cont(dcontent, args);
	}
	if (args->flags & FLAG_R)
	{
		if (subdirs && ((name[0] != '.' || !ft_strcmp(name, ".")) || HCK))
			ft_putchar('\n');
		if (args->flags & FLAG_r)
			ft_lstrev(&subdirs);
		while ((el = ft_lstpop(&subdirs)) != NULL)
		{
			if (((t_lsentry*)el->data)->name[0] != '.' || HCK)
				HCKLOL;
			sub_count = ls_list_dir((t_lsentry*)el->data, args);
			if ((el->next || (el->next && sub_count)) && FTDODO)
				ft_putchar('\n');
			ft_lstdelone(&el, ls_del_ent);
		}
	}
}
Пример #7
0
Файл: main.c Проект: z0mbie42/42
void	ls_process_files(t_lsargs *args)
{
	t_lst		*elem;
	t_l_form	forml;

	ls_l_form_init(&forml);
	if (args->flags & FLAG_l)
		ls_l_count(args->files, &forml, NULL);
	while ((elem = ft_lstpop(&(args->files))) != NULL)
	{
		if (((t_lsentry*)elem->data)->name[0] == '.' && !(args->flags & FLAG_a))
			continue ;
		if (args->flags & FLAG_l)
			ls_pinfos((t_lsentry*)elem->data, &forml);
		if (ft_strcountc(((t_lsentry*)elem->data)->path, '/') >= 1)
			ls_ppath((t_lsentry*)elem->data);
		else
			ls_pname((t_lsentry*)elem->data);
		if (S_ISLNK(((t_lsentry*)elem->data)->infos.st_mode)
			&& args->flags & FLAG_l)
			ls_l_plink(((t_lsentry*)elem->data)->path);
		ft_putchar('\n');
		ft_lstdelone(&elem, ls_del_ent);
	}
}
Пример #8
0
void	ft_lstdel(t_list **alst, void (*del)(void*, size_t))
{
	if (*alst == NULL || !del)
		return ;
	ft_lstdel(&((*alst)->next), del);
	ft_lstdelone(alst, del);
}
Пример #9
0
static t_list		*get_lstdir(t_list *lst, t_list *start, t_list *prev,
	t_list *tmp, char *flags)
{
	int		val;

	while (lst)
	{
		val = is_valid(flags, lst->content);
		if (val == 1 || val == -1)
		{
			tmp = lst;
			lst = lst->next;
			if (prev == NULL)
				start = lst;
			else
				prev->next = lst;
			ft_lstdelone(&tmp, del);
			if (val == 1 && ft_strchr(flags, 'l') == NULL && lst != NULL)
				if (lst->next != NULL || ft_strcmp(lst->content,
						start->content) == 0)
					ft_putchar(' ');
		}
		else
		{
			prev = lst;
			lst = lst->next;
		}
	}
	return (start);
}
Пример #10
0
static void	aux_lstdel(t_list *alst, void (*del)(void *, size_t))
{
	if (alst)
	{
		aux_lstdel(alst->next, del);
		ft_lstdelone(&alst, del);
	}
}
Пример #11
0
void	ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	if ((*alst)->next != NULL)
	{
		ft_lstdel(&(*alst)->next, del);
	}
	ft_lstdelone(alst, del);
}
Пример #12
0
void	ft_lstdel(t_list **link, void (*del)(void *, size_t))
{
	if (*link && del)
	{
		ft_lstdel(&(*link)->next, (*del));
		ft_lstdelone(link, del);
	}
}
Пример #13
0
void	my_lstdel(t_list **alst, void (*del)(void *, size_t))
{
  if (*alst && del)
    {
      ft_lstdel(&(*alst)->next, del);
      ft_lstdelone(alst, del);
    }
}
Пример #14
0
void	ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	if (*alst)
	{
		ft_lstdel(&((*alst)->next), del);
		ft_lstdelone(alst, del);
	}
}
Пример #15
0
void		ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	t_list	*node;

	node = (*alst)->next;
	if (node != NULL)
		ft_lstdel(&node, del);
	ft_lstdelone(alst, del);
}
Пример #16
0
void	ft_lstdel(t_list **lst, void (*del)(void *, size_t))
{
	if (!lst)
		return ;
	if (!*lst)
		return ;
	ft_lstdel(&(*lst)->next, del);
	ft_lstdelone(lst, del);
}
Пример #17
0
void	ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	t_list *temp;

	if (alst && del && alst[0])
	{
		temp = alst[0];
		while (alst[0]->next)
		{
			temp = alst[0]->next;
			ft_lstdelone(alst, del);
			alst[0] = temp;
		}
		ft_lstdelone(alst, del);
	}
	alst = NULL;
	temp = NULL;
}
Пример #18
0
void	ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	t_list	*tmp;

	if (alst && *alst)
	{
		while ((*alst)->next)
		{
			tmp = *alst;
			*alst = (*alst)->next;
			ft_lstdelone(&tmp, del);
			free(tmp);
		}
		ft_lstdelone(&*alst, del);
		free(*alst);
		*alst = NULL;
	}
}
Пример #19
0
void			ft_lstrmdel(t_list **list, void *ct, size_t len,
		int (*cmp)(void*, size_t, void*, size_t))
{
	t_list	*elem;

	elem = ft_lstremove(list, ct, len, cmp);
	if (elem)
		ft_lstdelone(&elem, &ft_delelem);
}
Пример #20
0
t_list			*ft_lstpop_front(t_list **lst, void (*deleter)(void *, size_t))
{
	t_list		**ret;

	ret = &(*lst)->next;
	ft_lstdelone(lst, deleter);
	*lst = *ret;
	return (*ret);
}
Пример #21
0
void	ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	t_list	*cpy;
	t_list	*tmp;

	if (!alst || !del)
		return ;
	cpy = *alst;
	while (cpy->next)
	{
		tmp = cpy->next;
		ft_lstdelone(&cpy, del);
		cpy = tmp;
	}
	ft_lstdelone(&cpy, del);
	free(*alst);
	*alst = NULL;
}
Пример #22
0
int		gnl_get_str(t_list *cur, char **line)
{
	t_list	*tmp;

	if (!(cur->next))
		return (0);
	if (!ft_strchr((char *)(cur->next)->content, '\n'))
	{
		*line = ft_strdup((cur->next)->content);
		ft_lstdelone(&(cur->next), ft_lstdelcontent);
		return (0);
	}
	tmp = cur->next;
	*line = ft_strdup(tmp->content);
	cur->next = (cur->next)->next;
	ft_lstdelone(&tmp, ft_lstdelcontent);
	return (2);
}
Пример #23
0
void	ft_lstdelcmp(t_list **root, void *ct, int (*cmpf)(void*, void*),
			void (*del)(void*, size_t))
{
	if (!*root)
		;
	else if (cmpf((*root)->content, ct) != 0)
		ft_lstdelcmp(&((*root)->next), ct, cmpf, del);
	else
		ft_lstdelone(root, del);
}
Пример #24
0
void	ft_lstdel(t_list **alst, void (*del)(void*, size_t))
{
	t_list	*buf;
	t_list	*next;

	if (alst != NULL && *alst && del != NULL)
	{
		buf = *alst;
		next = buf->next;
		while (buf->next != NULL)
		{
			ft_lstdelone(&buf, del);
			buf = next;
			next = buf->next;
		}
		ft_lstdelone(&buf, del);
		*alst = NULL;
	}
}
Пример #25
0
void		ft_lstpopone(t_list **lst, void (*del)(void *, size_t))
{
	t_list	*prev;
	t_list	*next;

	prev = (*lst)->prev;
	next = (*lst)->next;
	if (prev || !del)
	{
		prev->next = next;
		ft_lstdelone(lst, del);
	}
	else
	{
		ft_lstdelone(lst, del);
		*lst = next;
		(*lst)->prev = NULL;
	}
}
Пример #26
0
void	ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	if (alst && del)
	{
		if ((*alst)->next != NULL)
			ft_lstdel(&((*alst)->next), del);
		ft_lstdelone(alst, del);
		(*alst) = NULL;
	}
}
Пример #27
0
void		ft_lstdequeue(t_list **alst)
{
	t_list	*tmp;

	if (!alst || !*alst)
		return ;
	tmp = *alst;
	*alst = tmp->next;
	ft_lstdelone(&tmp, &del);
}
Пример #28
0
void		ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	t_list	*temp;

	if (alst && del && *alst)
	{
		temp = (*alst)->next;
		if (temp == NULL)
			ft_lstdelone(alst, del);
		else
		{
			while (temp)
			{
				temp = (*alst)->next;
				ft_lstdelone(alst, del);
				*alst = temp;
			}
		}
	}
}
Пример #29
0
void			ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	t_list		*tmp;

	while (*alst)
	{
		tmp = *alst;
		ft_lstdelone(&tmp, del);
		*alst = (*alst)->next;
	}
}
Пример #30
0
void	ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
	t_list		*next;

	while (*alst)
	{
		next = (*alst)->next;
		ft_lstdelone(alst, del);
		*alst = next;
	}
}