Adding the starting of cub

This commit is contained in:
Raphael 2024-10-30 17:35:35 +01:00
parent 3c74145832
commit 9415f843e7
7 changed files with 230 additions and 0 deletions

32
parsing/arguments.c Normal file
View file

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* arguments.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/30 16:41:32 by rparodi #+# #+# */
/* Updated: 2024/10/30 17:26:17 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
#include <string.h>
/**
* @brief checking if the args given to the executable is valid
*
* @param argc the arguments count
* @param argv the arguments value
* @return false if an error / true if no error
*/
bool ft_parse_args(int argc, char *argv[])
{
if (argc != 2)
return (write(2, ERR_ARGS_COUNT, strlen(ERR_ARGS_COUNT)), false);
if (strlen(argv[1]) < 4 || \
strcmp((argv[1] + (strlen(argv[1]) - 4)), ".cub") != 0)
return (write(2, "PB\n", 3), false);
return (true);
}