19 if (opt_list[i].option.mandatory)
22 return (nb_mandatory);
25static void is_mandatory(
int ac,
int *mandatory_present,
const char **av,
28 for (
int j = 1; j < ac - 1; ++j) {
29 if (strcmp(mandatory, av[j]) == 0) {
30 ++(*mandatory_present);
36static char **get_list_mandatory(
const struct option_list_s *opt_list)
39 char **mandatory = malloc(
sizeof(
char *) * (nb_mandatory + 1));
40 int mandatory_idx = 0;
42 if (mandatory == NULL)
45 if (SERVER_OPTION[i].option.mandatory) {
46 mandatory[mandatory_idx] = strdup(SERVER_OPTION[i].option.name);
50 mandatory[nb_mandatory] = NULL;
58 char **mandatory = get_list_mandatory(opt_list);
59 int mandatory_present = 0;
61 if (mandatory == NULL) {
64 if (nb_param < nb_mandatory) {
68 for (
int i = 0; i < nb_mandatory; ++i) {
69 is_mandatory(ac, &mandatory_present, av, mandatory[i]);
71 if (nb_mandatory != mandatory_present) {
int check_mandatory_set(int ac, const char **av, int nb_param, const struct option_list_s *opt_list)
Check if there's every mandatory options in the arguments passed to the program.
int get_nb_mandatory_option(const struct option_list_s *opt_list)
Get the number of mandatory options needed for the server.
#define NB_PARAM
! PARSING CONSTANTS !!
void free_array(void *to_free)
! FREE !!
int write_error_msg(const char *str)
! WRITTER !!