#include #include #include static void ft_check_empty_line(int fd, unsigned int linum, t_win *wlist) { char *line; get_next_line(fd, &line); if (*line) { ft_memdel(line); ft_map_error(linum, wlist); } ft_memdel(line); } int ft_get_sprite_tex(int fd, t_win *wlist) { char *line; char **words; size_t len; ft_check_empty_line(fd, 6, wlist); get_next_line(fd, &line); if (!(words = ft_split(line, ' '))) return (ft_exit(5, wlist)); if (!(*words) || ft_strcmp(*words, "S") || !(*(words + 1)) || (*(words + 2))) { ft_free_words(words); return (ft_map_error(7, wlist)); } ft_memdel(wlist->clist->sprite_path); len = ft_strlen(*(words + 1)); if (!(wlist->clist->sprite_path = (char*)malloc((len + 1) * sizeof(char)))) return (-1); ft_strlcpy(wlist->clist->sprite_path, *(words + 1), len + 1); ft_free_words(words); ft_memdel(line); return (0); }