diff options
Diffstat (limited to 'bsq/srcs')
| -rw-r--r-- | bsq/srcs/helper.c | 62 | ||||
| -rw-r--r-- | bsq/srcs/main.c | 20 | ||||
| -rw-r--r-- | bsq/srcs/parse.c | 42 |
3 files changed, 124 insertions, 0 deletions
diff --git a/bsq/srcs/helper.c b/bsq/srcs/helper.c new file mode 100644 index 0000000..d1fe8bc --- /dev/null +++ b/bsq/srcs/helper.c @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* helper.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/19 15:19:53 by cacharle #+# #+# */ +/* Updated: 2019/07/19 15:19:56 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include <unistd.h> +#include <stdlib.h> +#include <fcntl.h> +#include "include.h" + +int read_file(int fildes, char **file) +{ + char buf[BUF_SIZE]; + int file_size; + int read_size; + + file_size = 0; + while ((read_size = read(fildes, buf, BUF_SIZE))) + { + if (read_size < 0) + return (-1); + *file = ft_memcat(*file, buf, file_size, read_size); + file_size += read_size; + } + return (file_size); +} + +char *ft_memcat(char *file, char buf[BUF_SIZE], int file_size, + int read_size) +{ + int i; + char *file_clone; + + if ((file_clone = malloc(sizeof(char) * (file_size + 1))) == NULL) + return (NULL); + i = -1; + while (++i < file_size) + file_clone[i] = file[i]; + free(file); + if ((file = malloc(sizeof(char) * (file_size + read_size + 1))) == NULL) + return (NULL); + i = 0; + while (i < file_size) + { + file[i] = file_clone[i]; + i++; + } + free(file_clone); + while (i < file_size + read_size) + { + file[i] = buf[i - file_size]; + i++; + } + return (file); +} diff --git a/bsq/srcs/main.c b/bsq/srcs/main.c new file mode 100644 index 0000000..637ac13 --- /dev/null +++ b/bsq/srcs/main.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/19 11:01:32 by cacharle #+# #+# */ +/* Updated: 2019/07/19 13:35:23 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "include.h" + +int main(int argc, char **argv) +{ + + + return (0); +} diff --git a/bsq/srcs/parse.c b/bsq/srcs/parse.c new file mode 100644 index 0000000..8c4af3a --- /dev/null +++ b/bsq/srcs/parse.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/19 15:23:43 by cacharle #+# #+# */ +/* Updated: 2019/07/19 15:55:31 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "include.h" + +t_bool check_input(char *input) +{ + char *line; + int i; + + i = 0; + while (input[i] != '\n') + i++; + if (i < 4) + return (FALSE); + parsed.fill = input[i--]; + parsed.obstacle = input[i--]; + parsed.empty = input[i--]; + // parsed.size = // atoi smth + while (*input != '\n') + input++; + i = 0; + while (input[i]) + { + while (input[i] != '\n') + { + + } + if (i != parsed.size + + + } +} |
