#include "push_swap.h"

void	ps_usage(void)
{
	ft_printf("usage :\n");
	ft_printf("launch executable : ./push_swap [flag -p] nb nb nb nb nb ...\n");
}

void	ps_error(int err)
{
	if (err == 1)
		ps_usage();
	if (err == 2)
		ft_printf("error\n");
	exit(0);
}

void	ps_stop(t_stack *stack, t_list *lst, int err)
{
	t_stack	**a;
	t_stack	**b;

	if (stack)
		ft_lstclear((t_list **)&stack, NULL);
	if (lst)
	{
		a = lst->content;
		b = lst->next->content;
		ft_lstclear((t_list **)a, NULL);
		ft_lstclear((t_list **)b, NULL);
		lst->content = NULL;
		lst->next->content = NULL;
		ft_lstclear(&lst, free);
	}
	if (err < 0)
		return ;
	else if (err > 0)
		ps_error(err);
}
