diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_res.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/ft_get_res.c b/src/ft_get_res.c index 66eb1df..42b3f19 100644 --- a/src/ft_get_res.c +++ b/src/ft_get_res.c @@ -10,30 +10,22 @@ ft_checkdigit(const char *word, t_cub *clist) while (ft_isdigit(word[i])) i++; if (i != ft_strlen(word)) - ft_map_error(1, clist); + ft_map_error(clist); } int -ft_get_res(int fd, t_cub *clist) +ft_get_res(char **words, t_cub *clist) { - char *line; - char **words; - - if (get_next_line(fd, &line) <= 0 || !(words = ft_split(line, ' '))) - { - ft_memdel(line); - return (ft_map_error(1, clist)); - } - if (!(*words) || ft_strcmp(*words, "R") || !(*(words + 1)) + if (!(*words + 0) || !(*(words + 1)) || !(*(words + 2)) || (*(words + 3))) { - ft_free_words(words, line); - return (ft_map_error(1, clist)); + ft_free_words(words); + return (ft_map_error(clist)); } ft_checkdigit(words[1], clist); ft_checkdigit(words[2], clist); clist->wlist->x_size = ft_atoi(words[1]); clist->wlist->y_size = ft_atoi(words[2]); - ft_free_words(words, line); + ft_free_words(words); return (0); } |