/
grab_command.c
executable file
·74 lines (67 loc) · 1.72 KB
/
grab_command.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
69
70
71
72
73
74
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* grab_command.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jadawson <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/09/05 16:27:08 by jadawson #+# #+# */
/* Updated: 2018/11/13 14:28:35 by jadawson ### ########.fr */
/* */
/* ************************************************************************** */
#include "check_header.h"
void dup_check_ps(t_nums *head, int nbr, t_nums **a)
{
int i;
i = 0;
while (head)
{
if (head->num == nbr)
i++;
head = head->next;
}
if (i >= 2)
{
ft_putstr("\33[31mError\033[0m\n");
free_here(a);
exit(1);
}
}
void dup_check_c(t_nums *head, int nbr, t_nums **a)
{
int i;
i = 0;
while (head)
{
if (head->num == nbr)
i++;
head = head->next;
}
if (i >= 2)
{
ft_putstr("\33[31mError\033[0m\n");
free_here(a);
exit(1);
}
}
int grab_command(t_nums **a, t_nums **b)
{
char *line;
while (get_next_line(0, &line) > 0)
{
apply_command(line, a, b);
free(line);
}
if (*b != NULL)
{
ft_putstr("\33[31mKO\033[0m\n");
free_here(a);
free_here(b);
exit(1);
}
if (final_confirmed_ordered(*a, *b) == 0)
ft_putstr("\033[32mOK\033[0m\n");
else
ft_putstr("\033[31mKO\033[0m\n");
return (0);
}