-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
43 lines (40 loc) · 1.4 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rhallste <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/10/27 14:32:01 by rhallste #+# #+# */
/* Updated: 2017/11/18 14:50:21 by rhallste ### ########.fr */
/* */
/* ************************************************************************** */
#include <fcntl.h>
#include <stdlib.h>
#include "libft/inc/libft.h"
#include "fillit.h"
int main(int argc, char **argv)
{
int fd;
t_piece **pieces;
char *map;
t_piece *tmp;
if (argc != 2)
ERROR_RETURN(ARG_ISSUE);
if ((fd = open(argv[1], O_RDONLY)) == -1)
ERROR_RETURN(ARG_ISSUE);
if (!(pieces = get_pieces(fd)))
ERROR_RETURN(INPUT_ISSUE);
if (!(map = solve(pieces)))
ERROR_RETURN(SOLVE_ISSUE);
ft_putstr(map);
free(map);
while (*pieces)
{
tmp = *pieces;
pieces++;
free(tmp);
}
free(pieces);
return (PASS);
}