diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_map_redo.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/ft_get_map_redo.c b/src/ft_get_map_redo.c index 9b7793b..004dd3d 100644 --- a/src/ft_get_map_redo.c +++ b/src/ft_get_map_redo.c @@ -3,10 +3,58 @@ #include <stddef.h> #include <stdlib.h> +static int8_t +ft_check_line(char *line, uint8_t l, t_cub *clist) +{ + size_t i; + + i = 0; + while (line[i]) + { + if (l != 1) + { + if (!ft_ischarset("012NSEW ", line[i])) + return (-1); + if (ft_ischarset("NSEW", line[i])) + clist->nsew += 1; + if (clist->nsew > 1) + return (-1); + } + else + { + if (!ft_ischarset("1 ", line[i])) + return (-1); + } + i++; + } + if (line[0] != '1' || line[i - 1] != '1') + return (-1); + return (0); +} + +int +ft_get_first_line(char *line, t_cub *clist) +{ + if (!line[0]) + { + ft_memdel(line); + return (-1); + } + if (ft_check_line(line, 1, clist) < 0) + { + ft_memdel(line); + return (-1); + } + return (1); +} + int ft_get_map(int fd, t_cub *clist) { + int ret; + (void)fd; + (void)ret; (void)clist; return (0); } |