diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4e0df54 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +NAME = codexion + +SRCS = $(wildcard coders/*.c) +INCLUDES = coders/codexion.h + +OBJS = $(SRCS:.c=.o) + +CC = cc +CFLAGS = -Wall -Wextra -Werror + +all: $(NAME) + +$(NAME): $(OBJS) + $(CC) $(CFLAGS) -o $@ $^ + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +test: $(NAME) + ./$(NAME) 0 1 2 3 4 5 6 7 + +clean: + rm -f $(OBJS) + +fclean: clean + rm -f $(NAME) + +re: fclean all + +.PHONY: all clean fclean re diff --git a/coders/codexion.h b/coders/codexion.h new file mode 100644 index 0000000..28cee84 --- /dev/null +++ b/coders/codexion.h @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* codexion.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: semebrah +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/22 18:07:06 by semebrah #+# #+# */ +/* Updated: 2026/03/22 18:07:31 by semebrah ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef CODEXION_H +# define CODEXION_H + +typedef struct s_data +{ + int number_of_coders; + int time_to_burnout; + int time_to_compile; + int time_to_debug; + int time_to_refactor; + int number_of_compiles_required; + int dongle_cooldown; + int scheduler; +} t_data; + +// utils.h +t_data *parse_arguments(int count, char **args); + +#endif diff --git a/coders/main.c b/coders/main.c new file mode 100644 index 0000000..959508b --- /dev/null +++ b/coders/main.c @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: semebrah +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/22 18:07:14 by semebrah #+# #+# */ +/* Updated: 2026/03/22 18:07:31 by semebrah ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "codexion.h" +#include +#include + +int main(int argc, char **argv) +{ + t_data *data; + + data = parse_arguments(argc - 1, &argv[1]); + if (!data) + return (0); + printf("d = [%d]\n", data->number_of_coders); + printf("d = [%d]\n", data->time_to_burnout); + printf("d = [%d]\n", data->time_to_compile); + printf("d = [%d]\n", data->time_to_debug); + printf("d = [%d]\n", data->time_to_refactor); + printf("d = [%d]\n", data->number_of_compiles_required); + printf("d = [%d]\n", data->dongle_cooldown); + printf("d = [%d]\n", data->scheduler); + if (data) + free(data); + data = NULL; +} diff --git a/coders/utils.c b/coders/utils.c new file mode 100644 index 0000000..c2b2a81 --- /dev/null +++ b/coders/utils.c @@ -0,0 +1,56 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: semebrah +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/22 18:07:24 by semebrah #+# #+# */ +/* Updated: 2026/03/22 18:07:31 by semebrah ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "codexion.h" +#include +#include +#include + +int isnumeric(char *str) +{ + size_t i; + + i = -1; + while (++i < strlen(str)) + if (str[i] < '0' || str[i] > '9') + return (0); + return (1); +} + +t_data *parse_arguments(int count, char **args) +{ + int args_int[8]; + t_data *data; + int i; + + if (count != 8) + return (NULL); + data = malloc(sizeof(t_data)); + if (!data) + return (NULL); + i = -1; + while (++i < 8) + { + if (!isnumeric(args[i])) + return (NULL); + args_int[i] = atoi(args[i]); + } + data->number_of_coders = args_int[0]; + data->time_to_burnout = args_int[1]; + data->time_to_compile = args_int[2]; + data->time_to_debug = args_int[3]; + data->time_to_refactor = args_int[4]; + data->number_of_compiles_required = args_int[5]; + data->dongle_cooldown = args_int[6]; + data->scheduler = args_int[7]; + return (data); +}