-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_param.c
68 lines (64 loc) · 1.67 KB
/
check_param.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_param.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rlechapt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/02/03 12:01:34 by rlechapt #+# #+# */
/* Updated: 2015/03/11 06:00:14 by rlechapt ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void check_param(t_flags *f, char **av)
{
int i;
i = 0;
f->v = 0;
f->t = 0;
f->d = 0;
if (av[1][0] == '-')
{
i = 1;
while (av[1][i])
{
if (av[1][i] == 'v')
f->v = 1;
if (av[1][i] == 't')
f->t = 5;
if (av[1][i] == 'v' || av[1][i] == 't')
f->d = 1;
if ((av[1][i] >= 48 && av[1][i] <= 57) ||
av[1][i] == 'v' || av[1][i] == 't')
;
else
ft_puterror("Error\n");
i++;
}
}
}
void settings(t_env *e, t_flags *f, int ac, char **av)
{
if (ac < 2)
exit(0);
check_param(f, av);
if (f->d == 1)
{
e->len_a = ac - 2;
e->len_max = e->len_a;
e->len_b = 0;
e->count = 0;
e->i = 2;
e->j = 0;
}
else
{
e->len_a = ac - 1;
e->len_max = e->len_a;
e->len_b = 0;
e->count = 0;
e->i = 1;
e->j = 0;
}
check_error(e, av);
}