void ft_checkwidth(int fd, int w, int w1, t_bresen *var) { if (ft_get_next_line(fd, &(var->line))) { ft_checkline(var->line); if ((var->coord = ft_strsplit(var->line, ' ')) == NULL || !*var->coord) ft_error("Error: content"); if (!(w = ft_findw(var->coord))) ft_error("Error: width"); free(var->coord); free(var->line); } else ft_error("Empty File"); while (ft_get_next_line(fd, &var->line)) { ft_checkline(var->line); if ((var->coord = ft_strsplit(var->line, ' ')) == NULL || !*var->coord) ft_error("Error: content"); w1 = ft_findw(var->coord); if (w != w1) ft_error("Error: Width uneven"); free(var->coord); free(var->line); } }
int parsing_start_end(t_shell *shell, char *buff) { if (ft_checkline(buff, shell->type, shell->head) == 3) return (3); if (ft_checkline(buff, shell->type, shell->head) != ROOMS) return (2); if ((shell->start == 1 && shell->ret == START) || (shell->end == 1 && shell->ret == END)) return (2); return (1); }
t_box *check_format(char *argv) { int fd; int ret; char buf[BUF_SIZE + 1]; int count; t_box *box; count = 0; fd = open(argv, O_RDONLY); if (!fd) return (0); while ((ret = read(fd, buf, BUF_SIZE))) { buf[ret] = '\0'; if (!ft_checkline(buf)) return (0); count++; } if (count == 0 || count > 26) return (0); if (!(box = ft_main(argv, fd, count))) return (0); close(fd); return (box); }
t_shell *parse_lines(t_shell *shell, char *buff) { while (get_next_line(0, &buff)) { ft_putendl(buff); if ((shell->ret == START || shell->ret == END) && shell->type != ANTS) { if (parsing_start_end(shell, buff) == 3) continue ; else if (parsing_start_end(shell, buff) == 2) break ; shell->head = fill_room(shell->head, buff, shell); shell->ret = 0; free(buff); continue; } shell->ret = ft_checkline(buff, shell->type, shell->head); if (shell->ret == ERROR) break ; shell = fill_shell(shell, buff); free(buff); } return (shell); }