-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker.c
39 lines (36 loc) · 1.48 KB
/
checker.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
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* checker.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jjacobso <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/27 18:29:17 by jjacobso #+# #+# */
/* Updated: 2019/02/08 17:58:33 by jjacobso ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int main(int argc, char const *argv[])
{
t_stacks_state arg;
char *filename;
int mod;
arg_init(&arg);
filename = 0;
if ((mod = parse_arg(argc, argv, &arg.a, &filename)) == 0)
error(&arg, &filename);
if (check_options(mod, USAGE))
return (ft_int_free((void**)&filename, 1) && arg_destroy(&arg));
if (arg.a)
{
if (!(try_sort(&arg, mod, filename)))
error(&arg, &filename);
if (check_options(mod, PRINTRES))
print(&arg);
if (sorted(&arg))
ft_printf("OK\n");
else
ft_printf("KO\n");
}
return (ft_int_free((void**)&filename, 1) && arg_destroy(&arg));
}