From 2fd013d7583e0388d50ff9895c5e474e2d76f79f Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Mon, 17 Feb 2020 15:31:11 +0100 Subject: Better parse for textures and colors --- src/ft_get_tex.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/ft_get_tex.c') diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c index 1965e72..ad093ed 100644 --- a/src/ft_get_tex.c +++ b/src/ft_get_tex.c @@ -18,10 +18,23 @@ int8_t ft_get_tex_no(char **words, t_cub *clist) { if (!(*words) || !(*(words + 1)) || (*(words + 2))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1); return (-1); + } + if (ft_check_ext(*(words + 1), ".xpm") < 0) + { + ft_strlcpy(clist->errmsg, FT_ERR_NOT_A_XPM, + ft_strlen(FT_ERR_NOT_A_XPM) + 1); + return (-1); + } ft_memdel((void**)&clist->mlist->no_tex_path); if (!(clist->mlist->no_tex_path = ft_strdup(*(words + 1)))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE, + ft_strlen(FT_ERR_ALLOCATE) + 1); return (-1); + } return (0); } @@ -29,10 +42,23 @@ int8_t ft_get_tex_so(char **words, t_cub *clist) { if (!(*words) || !(*(words + 1)) || (*(words + 2))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1); + return (-1); + } + if (ft_check_ext(*(words + 1), ".xpm") < 0) + { + ft_strlcpy(clist->errmsg, FT_ERR_NOT_A_XPM, + ft_strlen(FT_ERR_NOT_A_XPM) + 1); return (-1); + } ft_memdel((void**)&clist->mlist->so_tex_path); if (!(clist->mlist->so_tex_path = ft_strdup(*(words + 1)))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE, + ft_strlen(FT_ERR_ALLOCATE) + 1); return (-1); + } return (0); } @@ -40,10 +66,23 @@ int8_t ft_get_tex_ea(char **words, t_cub *clist) { if (!(*words) || !(*(words + 1)) || (*(words + 2))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1); return (-1); + } + if (ft_check_ext(*(words + 1), ".xpm") < 0) + { + ft_strlcpy(clist->errmsg, FT_ERR_NOT_A_XPM, + ft_strlen(FT_ERR_NOT_A_XPM) + 1); + return (-1); + } ft_memdel((void**)&clist->mlist->ea_tex_path); if (!(clist->mlist->ea_tex_path = ft_strdup(*(words + 1)))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE, + ft_strlen(FT_ERR_ALLOCATE) + 1); return (-1); + } return (0); } @@ -51,9 +90,22 @@ int8_t ft_get_tex_we(char **words, t_cub *clist) { if (!(*words) || !(*(words + 1)) || (*(words + 2))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1); + return (-1); + } + if (ft_check_ext(*(words + 1), ".xpm") < 0) + { + ft_strlcpy(clist->errmsg, FT_ERR_NOT_A_XPM, + ft_strlen(FT_ERR_NOT_A_XPM) + 1); return (-1); + } ft_memdel((void**)&clist->mlist->we_tex_path); if (!(clist->mlist->we_tex_path = ft_strdup(*(words + 1)))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE, + ft_strlen(FT_ERR_ALLOCATE) + 1); return (-1); + } return (0); } -- cgit v1.2.3