13static int number_checker(
const struct arg_s **arguments,
const int index)
16 char *num_str = (
char *)arguments[index]->value;
18 if (strcmp(arguments[index]->name,
"-n") == 0)
20 if (strlen(num_str) == 1 && strcmp(num_str,
"0") == 0) {
21 strcpy(str,
"Error: The number of the parameter '");
22 strcat(str, arguments[index]->name);
23 strcat(str,
"' must be greater than 0.\n");
26 for (
int i = 0; num_str[i] !=
'\0'; i++) {
27 if (num_str[i] <
'0' || num_str[i] >
'9') {
28 strcpy(str,
"Error: The parameter '");
29 strcat(str, arguments[index]->name);
30 strcat(str,
"' must be a number.\n");
37static int compare_name_2(
char **array,
const char *name,
const size_t x)
41 for (
size_t i = 0; i < x; i++) {
42 if (array[i] == NULL) {
45 if (strcmp(name, array[i]) == 0) {
46 strcpy(str,
"Error: The team name '");
48 strcat(str,
"' is repeated. A team name must be unique.\n");
55static int compare_name_1(
const struct arg_s **arguments,
const size_t index)
61 name = arguments[index]->
value;
62 tmp = malloc(
sizeof(
char *) * arguments[index]->nb_value + 1);
63 for (
size_t i = 0; i < arguments[index]->
nb_value; i++) {
64 if (compare_name_2(tmp, *name, x) == -1) {
76static int name_checker(
const struct arg_s **arguments,
const size_t index)
78 if (strcmp(arguments[index]->name,
"-n") != 0) {
81 if (arguments[index]->nb_value > 1) {
82 if (compare_name_1(arguments, index) == -1) {
89static int map_size_checker(
const struct arg_s **arguments)
108 for (
size_t i = 0; i < size; i++) {
109 if (number_checker(arguments, i) == -1) {
112 if (name_checker(arguments, i) == -1) {
116 return map_size_checker(arguments);
int check_values_validity(const struct arg_s **arguments, const size_t size)
Check if the values of the parameters are correct.
void * find_value_by_param(const struct arg_s **arguments, char *param)
! FINDER !!
int write_error_msg(const char *str)
! WRITTER !!