blob: 8607f6219599c7a54994fc5e2ef1d321cfa61e9c (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_get_res.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:28:47 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:28:47 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
static int8_t
ft_checkdigit(const char *word, t_cub *clist)
{
size_t i;
i = 0;
while (ft_isdigit(word[i]))
i++;
if (i != ft_strlen(word))
{
ft_strlcpy(clist->errmsg, FT_ERR_RES_ALPHA,
ft_strlen(FT_ERR_RES_ALPHA) + 1);
return (-1);
}
return (0);
}
int8_t
ft_get_res(char **words, t_cub *clist)
{
t_win *wlist;
wlist = clist->wlist;
if (!(*words + 0) || !(*(words + 1)) ||
!(*(words + 2)) || (*(words + 3)))
{
ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1);
return (-1);
}
if ((ft_checkdigit(words[1], clist) < 0) ||
(ft_checkdigit(words[2], clist) < 0))
return (-1);
wlist->x_size = ft_atoi(words[1]);
wlist->y_size = ft_atoi(words[2]);
if (wlist->x_size <= 1
|| wlist->y_size <= 1)
{
ft_strlcpy(clist->errmsg, FT_ERR_RES_SMALL,
ft_strlen(FT_ERR_RES_SMALL) + 1);
return (-1);
}
if (ft_get_screen_size(wlist) < 0)
return (-1);
return (0);
}
|