blob: 337d3d7d48fa72905fb98e1d397c36d7dd02ed74 (
plain)
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
|
#include <libft.h>
#include <cub3d.h>
static void
ft_checkdigit(const char *word, t_win *wlist)
{
size_t i;
i = 0;
while (ft_isdigit(word[i]))
i++;
if (i != ft_strlen(word))
ft_map_error(1, wlist);
}
int
ft_get_res(int fd, t_win *wlist)
{
char *line;
char **words;
if (get_next_line(fd, &line) <= 0 || !(words = ft_split(line, ' ')))
{
ft_memdel(line);
return (ft_map_error(1, wlist));
}
if (!(*words) || ft_strcmp(*words, "R") || !(*(words + 1))
|| !(*(words + 2)) || (*(words + 3)))
{
ft_free_words(words, line);
return (ft_map_error(1, wlist));
}
ft_checkdigit(words[1], wlist);
ft_checkdigit(words[2], wlist);
wlist->x_size = ft_atoi(words[1]);
wlist->y_size = ft_atoi(words[2]);
ft_free_words(words, line);
return (0);
}
|