Archived
1
0

wip_parsing

This commit is contained in:
Maelys
2024-09-10 16:27:06 +02:00
commit c671539661
62 changed files with 1863 additions and 0 deletions

44
src/main.c Normal file
View File

@ -0,0 +1,44 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/04 16:58:27 by madumerg #+# #+# */
/* Updated: 2024/09/07 19:12:04 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "../include/cub3d.h"
char **ft_parse_map(char *map)
{
int fd;
char **parse_map;
char *save;
char *join;
fd = open(map, O_RDONLY);
save = get_next_line(fd);
join = ft_calloc(1, 1);
if (!join)
return (NULL);
while (save != NULL)
{
join = ft_strjoin(join, save);
free(save);
save = get_next_line(fd);
}
parse_map = ft_split(join, '\n');
free(join);
close(fd);
return (parse_map);
}
int main(int ac, char **av)
{
if (check_err_arg(ac, av) == 1)
return (1);
return (0);
}

46
src/parsing/check_arg.c Normal file
View File

@ -0,0 +1,46 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_arg.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/04 21:33:35 by madumerg #+# #+# */
/* Updated: 2024/09/07 17:57:29 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../include/cub3d.h"
int check_err_arg(int ac, char **av)
{
int fd;
int rd;
char buf[10];
if (ac != 2)
return (err_mess(ERR_ARGS));
if (check_format_file(av[1]) == 0)
return (err_mess(ERR_TYPE));
fd = open(av[1], O_RDONLY);
if (fd == -1)
{
close(fd);
return (err_mess(EMPTY));
}
rd = read(fd, buf, 10);
close(fd);
return (rd);
}
int check_format_file(char *file)
{
int len;
len = ft_strlen(file) - 1;
if (file[len] == 'b' && file[len - 1] == 'u' && \
file[len - 2] == 'c' && file[len - 3] == '.')
return (1);
return (0);
}

View File

0
src/parsing/check_map.c Normal file
View File

0
src/parsing/check_rgb.c Normal file
View File

18
src/parsing/memo_parsing Normal file
View File

@ -0,0 +1,18 @@
char **map = ft_parse_map(av[1]);
int i = 0;
while (map[i])
{
ft_putchar_fd('*', 2);
ft_putstr_fd(map[i], 2);
ft_putchar_fd('*', 2);
ft_putchar_fd('\n', 2);
i++;
}
//envoyer de 0 a 3 inclus dans check id texture
//envoyer de 4 a 5 inclus dans check rgb format
//envoyer de 6 a jusqu a la fin dans check map
struct typedef s_pars
{
} t_pars;

20
src/utils/mess_error.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mess_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/07 17:35:14 by madumerg #+# #+# */
/* Updated: 2024/09/07 17:40:57 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../include/cub3d.h"
int err_mess(char *str)
{
ft_putendl_fd("Error\n", 2);
ft_putendl_fd(str, 2);
return (1);
}