-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcub3d.c
54 lines (49 loc) · 1.75 KB
/
cub3d.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ael-bekk <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/21 13:13:39 by mel-hada #+# #+# */
/* Updated: 2022/08/12 11:30:12 by ael-bekk ### ########.fr */
/* */
/* ************************************************************************** */
#include "inc/cub3d.h"
int arg_check(int ac, char **av)
{
char *error;
error = NULL;
if(ac != 2)
error = "Error: too many arguments\n";
else
if(ft_strncmp(av[1] + ft_strlen(av[1]) - 4, ".cub", 4) != 0)
error = "Error: invalid file extension\n";
if (error)
{
write(2, error, ft_strlen(error));
return (0);
}
return (1);
}
int main(int ac, char **av)
{
t_map *map;
char *buff;
int fd;
init_args(&map);
buff = NULL;
if (arg_check(ac, av) != 1)
return (0);
fd = open(av[1], O_RDONLY);
buff = get_next_line(fd);
while(buff)
{
if (ft_strlen(buff) > 0 && buff[ft_strlen(buff) - 1] == '\n')
buff[ft_strlen(buff) - 1] = '\0';
ft_lst_add_back(&map, ft_lst_new(buff));
buff = get_next_line(fd);
}
parsing(map);
set_minimap();
}