aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_get_res.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_get_res.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/ft_get_res.c b/src/ft_get_res.c
index 26853be..4447c1d 100644
--- a/src/ft_get_res.c
+++ b/src/ft_get_res.c
@@ -24,8 +24,7 @@ static int8_t
i++;
if (i != ft_strlen(word))
{
- ft_strlcpy(clist->errmsg, FT_ERR_RES_ALPHA,
- ft_strlen(FT_ERR_RES_ALPHA) + 1);
+ ft_sprintf(clist->errmsg, FT_ERR_RES_ALPHA);
return (-1);
}
return (0);
@@ -40,28 +39,37 @@ static void
wl->y_size -= 1;
}
-int8_t
- ft_get_res(char **words, t_cub *clist)
+static int8_t
+ ft_check_res_args(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);
+ ft_sprintf(clist->errmsg, FT_ERR_ARGS);
return (-1);
}
+ return (0);
+}
+
+int8_t
+ ft_get_res(char **words, t_cub *clist)
+{
+ t_win *wlist;
+
+ wlist = &clist->wlist;
+ if (clist->currlvl > 0)
+ return (0);
+ if (ft_check_res_args(words, clist) < 0)
+ 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 <= 10
- || wlist->y_size <= 10)
+ if (wlist->x_size <= 50 ||
+ wlist->y_size <= 50)
{
- ft_strlcpy(clist->errmsg, FT_ERR_RES_SMALL,
- ft_strlen(FT_ERR_RES_SMALL) + 1);
+ ft_sprintf(clist->errmsg, FT_ERR_RES_SMALL);
return (-1);
}
if (ft_get_screen_size(wlist) < 0)