ps_stop fonctionne
This commit is contained in:
2
Makefile
2
Makefile
@@ -21,6 +21,7 @@ LIBS = $(_LIBS:lib%.a=%)
|
|||||||
|
|
||||||
SRCS = pushswap.c \
|
SRCS = pushswap.c \
|
||||||
algo.c \
|
algo.c \
|
||||||
|
print.c \
|
||||||
stop.c
|
stop.c
|
||||||
|
|
||||||
ODIR = ./builds
|
ODIR = ./builds
|
||||||
@@ -52,7 +53,6 @@ clean:
|
|||||||
/bin/rm -f $(OBJS)
|
/bin/rm -f $(OBJS)
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
make fclean -C $(LDIR)
|
|
||||||
/bin/rm -rf $(ODIR)
|
/bin/rm -rf $(ODIR)
|
||||||
/bin/rm -f $(NAME)
|
/bin/rm -f $(NAME)
|
||||||
/bin/rm -rf a.out a.out.dSYM
|
/bin/rm -rf a.out a.out.dSYM
|
||||||
|
|||||||
BIN
builds/algo.o
BIN
builds/algo.o
Binary file not shown.
BIN
builds/print.o
Normal file
BIN
builds/print.o
Normal file
Binary file not shown.
Binary file not shown.
BIN
builds/stop.o
BIN
builds/stop.o
Binary file not shown.
@@ -15,22 +15,27 @@ typedef struct s_stack
|
|||||||
/*
|
/*
|
||||||
** pushswap.c
|
** pushswap.c
|
||||||
*/
|
*/
|
||||||
void is_valid(int ac, char **av)
|
void is_valid(int ac, char **av);
|
||||||
t_stack *init_stack(int ac, char **av)
|
t_stack *init_stack(int ac, char **av);
|
||||||
void print_stack(t_stack *stack)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** stop.c
|
** stop.c
|
||||||
*/
|
*/
|
||||||
void ps_usage(void);
|
void ps_usage(void);
|
||||||
void ps_error(int err);
|
void ps_error(int err);
|
||||||
void stop(t_stack *stb, t_stack *sta, t_list *lst, int i);
|
void ps_stop(t_stack *stb, t_stack *sta, t_list *lst, int i);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** algo.c
|
** algo.c
|
||||||
*/
|
*/
|
||||||
t_list *sort_algo(t_stack *stack);
|
t_list *sort_algo(t_stack *stack);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** print.c
|
||||||
|
*/
|
||||||
|
void print_stack(t_stack *stack);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** swap
|
** swap
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ t_list *sort_algo(t_stack *stack)
|
|||||||
(void)stack;
|
(void)stack;
|
||||||
t_list *lst;
|
t_list *lst;
|
||||||
|
|
||||||
lst = ft_lstnew("solution");
|
lst = ft_lstnew(ft_strdup("solution"));
|
||||||
return (lst);
|
return (lst);
|
||||||
}
|
}
|
||||||
|
|||||||
16
srcs/print.c
Normal file
16
srcs/print.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
#include "pushswap.h"
|
||||||
|
|
||||||
|
void print_stack(t_stack *stack)
|
||||||
|
{
|
||||||
|
ft_putstr("[");
|
||||||
|
while (stack)
|
||||||
|
{
|
||||||
|
ft_printf("%i", stack->n);
|
||||||
|
stack = stack->next;
|
||||||
|
if (stack)
|
||||||
|
ft_putstr("; ");
|
||||||
|
}
|
||||||
|
ft_putstr("]\n");
|
||||||
|
}
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
void is_valid(int ac, char **av)
|
void is_valid(int ac, char **av)
|
||||||
{
|
{
|
||||||
if (ac < 2)
|
if (ac < 2)
|
||||||
ps_error(1);
|
ps_stop(NULL, NULL, NULL, 1);
|
||||||
(void)av;
|
(void)av;
|
||||||
// check more error
|
// check more error
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ t_stack *init_stack(int ac, char **av)
|
|||||||
while (--ac)
|
while (--ac)
|
||||||
{
|
{
|
||||||
if (!(start = ft_calloc(1, sizeof(t_stack))))
|
if (!(start = ft_calloc(1, sizeof(t_stack))))
|
||||||
ps_clean(start, 2);
|
ps_stop(start, NULL, NULL, 2);
|
||||||
start->n = ft_atoi(av[ac]);
|
start->n = ft_atoi(av[ac]);
|
||||||
start->next = tmp;
|
start->next = tmp;
|
||||||
tmp = start;
|
tmp = start;
|
||||||
@@ -26,19 +26,6 @@ t_stack *init_stack(int ac, char **av)
|
|||||||
return (start);
|
return (start);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_stack(t_stack *stack)
|
|
||||||
{
|
|
||||||
ft_putstr("[");
|
|
||||||
while (stack)
|
|
||||||
{
|
|
||||||
ft_printf("%i", stack->n);
|
|
||||||
stack = stack->next;
|
|
||||||
if (stack)
|
|
||||||
ft_putstr("; ");
|
|
||||||
}
|
|
||||||
ft_putstr("]\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int ac, char **av)
|
int main(int ac, char **av)
|
||||||
{
|
{
|
||||||
t_stack *stack;
|
t_stack *stack;
|
||||||
@@ -49,6 +36,6 @@ int main(int ac, char **av)
|
|||||||
print_stack(stack);
|
print_stack(stack);
|
||||||
result = sort_algo(stack);
|
result = sort_algo(stack);
|
||||||
ft_printf("%s\n", result->content);
|
ft_printf("%s\n", result->content);
|
||||||
ps_clean(stack, 1);
|
ps_stop(stack, NULL, result, 0);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ void ps_error(int err)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop(t_stack *stack_a, t_stack *stack_b, t_list *solution, int err)
|
void ps_stop(t_stack *stack_a, t_stack *stack_b, t_list *solution, int err)
|
||||||
{
|
{
|
||||||
if (stack_a)
|
if (stack_a)
|
||||||
ft_lstclear((t_list)&stack_a, NULL);
|
ft_lstclear((t_list **)&stack_a, NULL);
|
||||||
if (stack_b)
|
if (stack_b)
|
||||||
ft_lstclear((t_list)&stack_b, NULL);
|
ft_lstclear((t_list **)&stack_b, NULL);
|
||||||
if (solution)
|
if (solution)
|
||||||
ft_lstclear(&solution, free);
|
ft_lstclear(&solution, free);
|
||||||
ps_error(err);
|
ps_error(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user