style: error message are now in red
This commit is contained in:
parent
66a523d4b5
commit
f48e586896
5 changed files with 38 additions and 8 deletions
3
Makefile
3
Makefile
|
|
@ -6,7 +6,7 @@
|
||||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||||
# Updated: 2024/10/30 16:48:22 by rparodi ### ########.fr #
|
# Updated: 2024/10/31 11:16:34 by rparodi ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
@ -31,6 +31,7 @@ CFLAGS += -g3 -MMD
|
||||||
INCLUDES = ./includes/
|
INCLUDES = ./includes/
|
||||||
|
|
||||||
SRC = sources/main.c \
|
SRC = sources/main.c \
|
||||||
|
sources/error.c \
|
||||||
parsing/arguments.c
|
parsing/arguments.c
|
||||||
|
|
||||||
# Objects
|
# Objects
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */
|
/* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/10/30 17:01:03 by rparodi ### ########.fr */
|
/* Updated: 2024/10/31 11:17:40 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
# define BONUS 0
|
# define BONUS 0
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
void print_error(char *msg);
|
||||||
bool ft_parse_args(int argc, char *argv[]);
|
bool ft_parse_args(int argc, char *argv[]);
|
||||||
int main(int argc, char *argv[]);
|
int main(int argc, char *argv[]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,17 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/30 16:43:20 by rparodi #+# #+# */
|
/* Created: 2024/10/30 16:43:20 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/10/31 10:38:21 by rparodi ### ########.fr */
|
/* Updated: 2024/10/31 11:23:20 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef MESSAGE_ERROR_H
|
#ifndef MESSAGE_ERROR_H
|
||||||
# define MESSAGE_ERROR_H
|
# define MESSAGE_ERROR_H
|
||||||
|
|
||||||
# define ERR_ARGS_COUNT "Error:\nYou have to give only the map on arguments !\n"
|
# define ERR_ARGS_COUNT "You have to give only the map on arguments !\n"
|
||||||
# define INV_NAME_MAP "Error:\nThe name of the map have to finish by `.cub` !\n"
|
# define INV_NAME_MAP "The name of the map have to finish by `.cub` !\n"
|
||||||
|
|
||||||
|
# define RED "\x1b[31m"
|
||||||
|
# define BOLD_RED "\033[1;31m"
|
||||||
|
# define RESET "\x1b[K\x1b[0m"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/30 16:41:32 by rparodi #+# #+# */
|
/* Created: 2024/10/30 16:41:32 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/10/31 10:37:56 by rparodi ### ########.fr */
|
/* Updated: 2024/10/31 11:23:05 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,9 +24,9 @@
|
||||||
bool ft_parse_args(int argc, char *argv[])
|
bool ft_parse_args(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
return (write(2, ERR_ARGS_COUNT, strlen(ERR_ARGS_COUNT)), false);
|
return (print_error(ERR_ARGS_COUNT), false);
|
||||||
if (strlen(argv[1]) < 4 || \
|
if (strlen(argv[1]) < 4 || \
|
||||||
strcmp((argv[1] + (strlen(argv[1]) - 4)), ".cub") != 0)
|
strcmp((argv[1] + (strlen(argv[1]) - 4)), ".cub") != 0)
|
||||||
return (write(2, INV_NAME_MAP, strlen(INV_NAME_MAP)), false);
|
return (print_error(INV_NAME_MAP), false);
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
25
sources/error.c
Normal file
25
sources/error.c
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* error.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/10/31 11:09:00 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/10/31 11:21:59 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "cub3d.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void print_error(char *msg)
|
||||||
|
{
|
||||||
|
write(2, BOLD_RED, strlen(BOLD_RED));
|
||||||
|
write(2, "Error:\n", strlen("Error:\n"));
|
||||||
|
write(2, RESET, strlen(RESET));
|
||||||
|
write(2, RED, strlen(RED));
|
||||||
|
write(2, msg, strlen(msg));
|
||||||
|
write(2, RESET, strlen(RESET));
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue