diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_init_lists.c | 2 | ||||
-rw-r--r-- | src/ft_parse_map.c | 31 | ||||
-rw-r--r-- | src/ft_select_get.c | 7 |
3 files changed, 34 insertions, 6 deletions
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index 5c14731..1b4ab59 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -38,6 +38,6 @@ t_cub return (NULL); clist->map[1] = 0; clist->map_w = 0; - clist->line_chk = 0; + clist->line_chk = 1; return (clist); } diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 1911e5c..c94a91b 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -31,7 +31,7 @@ ft_check_cub(const char *map_path, t_cub *clist) } static void -ft_check_last_line(t_cub *clist) +ft_check_map_last_line(t_cub *clist) { size_t i; size_t j; @@ -48,9 +48,30 @@ ft_check_last_line(t_cub *clist) } } -/* -** I can't close fd -*/ +static int +ft_parse_it(int fd, t_cub *clist) +{ + char *line; + char **words; + + if (get_next_line(fd, &line) <= 0) + { + ft_memdel(line); + return (ft_map_error(clist->line_chk, clist)); + } + if (!line[0]) + { + ft_memdel(line); + return (ft_parse_it(fd, clist)); + } + if (!(words = ft_split(line, ' '))) + { + ft_memdel(line); + return (ft_map_error(clist->line_chk, clist)); + } + ft_memdel(line); + return (ft_select_get(words, clist)); +} void ft_parse_map(const char *map_path, t_cub *clist) @@ -75,7 +96,7 @@ ft_parse_map(const char *map_path, t_cub *clist) ft_check_empty_line(fd, 10, clist); if (ft_get_map(fd, clist) < 0) ft_map_error(11, clist); - ft_check_last_line(clist); + ft_check_map_last_line(clist); ft_print_list(clist); close(fd); } diff --git a/src/ft_select_get.c b/src/ft_select_get.c new file mode 100644 index 0000000..0ddc80a --- /dev/null +++ b/src/ft_select_get.c @@ -0,0 +1,7 @@ +int +ft_select_get(char **words, t_cub *clist) +{ + (void)words; + (void)clist; + return (0); +} |