-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
83 lines (76 loc) · 2.09 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
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
75
76
77
78
79
80
81
82
83
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mdos-san <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/07/27 19:49:24 by mdos-san #+# #+# */
/* Updated: 2015/07/30 08:44:05 by mdos-san ### ########.fr */
/* */
/* ************************************************************************** */
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include "ft.h"
#include "ft_get_grid.h"
#include "ft_error.h"
#include "ft_find_square.h"
void ft_read_stdin(int fd)
{
int length;
int line;
int nb_char;
char *str;
char ref[4];
line = 0;
nb_char = 0;
length = 0;
ft_get_stdin(&length);
fd = open("menu_maxi_best_of_+.txt", O_RDONLY);
str = ft_allocate_str(length);
ft_assign_str(&str, length, fd);
close(fd);
ft_check_info(&str);
ft_get_info(&str, &line, ref);
nb_char = ft_check_grid(str, ref, line);
ft_resolve(str, ref, nb_char, line);
free(str);
}
void ft_read_params(char **av, int i, int fd)
{
int length;
int line;
int nb_char;
char *str;
char ref[4];
line = 0;
nb_char = 0;
fd = open(av[i - 1], O_RDONLY);
length = ft_get_length(&fd, av[i - 1]);
str = ft_allocate_str(length);
ft_assign_str(&str, length, fd);
close(fd);
ft_check_info(&str);
ft_get_info(&str, &line, ref);
nb_char = ft_check_grid(str, ref, line);
ft_resolve(str, ref, nb_char, line);
free(str);
}
int main(int ac, char **av)
{
int i;
int fd;
i = 2;
fd = 0;
if (ac == 1)
ft_read_stdin(fd);
while (i <= ac)
{
ft_read_params(av, i, fd);
i++;
}
return (0);
}