Zappy - Year end project 2
This is a project that Epitech asked us to create in order to allow us to reveiw the notions of the current year.
Loading...
Searching...
No Matches
Data Structures | Functions
arg_parse.h File Reference
#include <stdlib.h>
#include <stdbool.h>
#include "constants.h"
Include dependency graph for arg_parse.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  arg_s
 
struct  option_s
 
struct  option_list_s
 

Functions

int get_nb_mandatory_option (const struct option_list_s *opt_list)
 Get the number of mandatory options needed for the server.
 
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 is_param (const char *str, const struct option_list_s *opt_list)
 Check if a string is a parameter.
 
int get_nb_parameter (int ac, const char **av)
 Get the number of parameter passed to the program.
 
int get_arg_value (int ac, const char **av, const struct option_s *param, struct arg_s **arg)
 Get the variables of a parameter and store it in arg_s structure.
 
struct arg_s ** get_zappy_args (int ac, const char **av, const struct option_list_s *opt_l)
 The principal function to get every arguments.
 
int check_values_validity (const struct arg_s **arguments, const size_t size)
 Check if the values of the parameters are correct.
 

Function Documentation

◆ check_mandatory_set()

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.

Parameters
acNumber of arguments
avVariables passed as parameter to the program
nb_paramNumber of parameter
opt_listThe constant defined with every known command
Returns
(0) if there's enough parameter, (-1) if not

Definition at line 54 of file check_arg_mandatory.c.

◆ check_values_validity()

int check_values_validity ( const struct arg_s ** arguments,
const size_t size )

Check if the values of the parameters are correct.

Parameters
argumentsThe structure where parameters and parameters value are stored
sizeThe size of the structure
Returns
(0) if every values are correct, (-1) if not

Definition at line 106 of file check_values_validity.c.

◆ get_arg_value()

int get_arg_value ( int ac,
const char ** av,
const struct option_s * param,
struct arg_s ** arg )

Get the variables of a parameter and store it in arg_s structure.

Parameters
acNumber of arguments
avVariables passed as parameter to the program
paramA intermediaire structure (option_s) before store it in arg_s structure
argThe structure where parameters and parameters value are stored
Returns
(0) if values are stored successfully, (-1) if not

Definition at line 50 of file arg_parse.c.

◆ get_nb_mandatory_option()

int get_nb_mandatory_option ( const struct option_list_s * opt_list)

Get the number of mandatory options needed for the server.

Parameters
opt_listThe constant defined with every known command
Returns
5 because the zappy server has 5 mandatory function

Definition at line 14 of file check_arg_mandatory.c.

◆ get_nb_parameter()

int get_nb_parameter ( int ac,
const char ** av )

Get the number of parameter passed to the program.

Parameters
acNumber of arguments
avVariables passed as parameter to the program
Returns
The number of parameter passed to the program

Definition at line 38 of file parameter_utils.c.

◆ get_zappy_args()

struct arg_s ** get_zappy_args ( int ac,
const char ** av,
const struct option_list_s * opt_l )

The principal function to get every arguments.

Parameters
acNumber of arguments
avVariables passed as parameter to the program
paramA intermediaire structure (option_s) before store it in arg_s structure
Returns
arg_s the structure where parameters and parameters value are stored

Definition at line 89 of file arg_parse.c.

◆ is_param()

int is_param ( const char * str,
const struct option_list_s * opt_list )

Check if a string is a parameter.

Parameters
strThe string to check
opt_listThe constant defined with every known command
Returns
The index of the parameter in the constants, (-1) if not found

Definition at line 12 of file parameter_utils.c.