-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
38 lines (35 loc) · 1.47 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yel-hadd <yel-hadd@mail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/06 22:54:06 by yel-hadd #+# #+# */
/* Updated: 2023/03/11 23:31:18 by yel-hadd ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int main(int argc, char **argv)
{
t_stack *stack_a;
t_stack *stack_b;
char **args;
stack_a = NULL;
stack_b = NULL;
if (argc == 1)
return (0);
if (empty_arg(argv))
return (write(1, "Error\n", 6), 0);
args = parse(--argc, ++argv, 0);
if (has_errors(args) || !args)
return (free_2d(args), write(1, "Error\n", 6), 0);
if (has_duplicates(args))
return (free_2d(args), write(1, "Error\n", 6), 0);
if (is_sorted(args))
return (free_2d(args), 0);
add_to_stack(&stack_a, args);
master_filter(&stack_a, &stack_b, ft_lstsize(stack_a));
ft_lstclear(&stack_a);
free_2d(args);
}