debut ecritures fonctions clean et error
This commit is contained in:
22
srcs/error.c
Normal file
22
srcs/error.c
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
#include "pushswap.h"
|
||||
|
||||
void ps_clean(t_stack *stack, int err)
|
||||
{
|
||||
(void)stack;
|
||||
ps_error(err);
|
||||
}
|
||||
|
||||
void ps_usage(void)
|
||||
{
|
||||
ft_printf("usage\n");
|
||||
}
|
||||
|
||||
void ps_error(int err)
|
||||
{
|
||||
if (err == 1)
|
||||
ps_usage();
|
||||
if (err == 2)
|
||||
ft_printf("error\n");
|
||||
exit(0);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
#include "pushswap.h"
|
||||
|
||||
void is_valid(int ac, char **av)
|
||||
{
|
||||
if (ac < 2)
|
||||
ps_error(1);
|
||||
(void)av;
|
||||
}
|
||||
|
||||
t_stack *init_stack(int ac, char **av)
|
||||
{
|
||||
(void)ac;
|
||||
(void)av;
|
||||
t_stack *start;
|
||||
|
||||
if (!(start = ft_calloc(1, sizeof(t_stack))))
|
||||
ps_clean(start, 2);
|
||||
return (start);
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
t_stack *stack;
|
||||
//t_list *result;
|
||||
|
||||
is_valid(ac, av); // check if usage and list are correct
|
||||
stack = init_stack(ac, av);
|
||||
// result = sort_algo(stack);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user