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
Functions
utils.h File Reference
#include "arg_parse.h"
#include "server_handler.h"
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int write_error_msg (const char *str)
 ! WRITTER !!
 
int write_to_client (const int fd, const char *str)
 Write any message to a specific file descriptor.
 
void * find_value_by_param (const struct arg_s **arguments, char *param)
 ! FINDER !!
 
int find_index_by_param (const struct arg_s **arguments, char *param)
 Find the index where a parameter is in the arg_s structure by his parameter.
 
size_t get_array_len (char **array)
 ! GETTER !!
 
void free_array (void *to_free)
 ! FREE !!
 
void free_args (struct arg_s **args, const size_t size)
 Free struct args_s of lenght size.
 
void refill_map (game_data_t *game_data)
 Refill the map with ressources (use in runtime)
 
void fill_map (server_handler_t *server)
 Fill the map with ressources (use in initialization)
 
void free_array_size_n (void *to_free, const size_t n)
 Free any ** array up to n.
 
char ** str_to_word_array (const char *str, const char delim)
 Turn string to char **.
 
char * array_to_str (int ac, const char **av)
 Turn an array of string into a simple string.
 

Function Documentation

◆ array_to_str()

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

Turn an array of string into a simple string.

Parameters
acnumber of element in the array
avArray of string
Returns
concanated string or NULL on error

Definition at line 38 of file array_to_str.c.

◆ fill_map()

void fill_map ( server_handler_t * server)

Fill the map with ressources (use in initialization)

Parameters
serverThe general server structure

Definition at line 68 of file fill.c.

◆ find_index_by_param()

int find_index_by_param ( const struct arg_s ** arguments,
char * param )

Find the index where a parameter is in the arg_s structure by his parameter.

Parameters
argumentsThe structure where parameters and parameters value are stored
paramThe parameter we want to search
Returns
The index where the parameter is in

◆ find_value_by_param()

void * find_value_by_param ( const struct arg_s ** arguments,
char * param )

! FINDER !!

Find the value of a parameter in the arg_s structure by his parameter

Parameters
argumentsThe structure where parameters and parameters value are stored
paramThe parameter we want to search
Returns
The value of the parameter

◆ free_args()

void free_args ( struct arg_s ** args,
const size_t size )

Free struct args_s of lenght size.

Parameters
argsstructure to free
sizesize of structure

Definition at line 35 of file free.c.

◆ free_array()

void free_array ( void * to_free)

! FREE !!

Free any ** array

Parameters
to_free

Definition at line 13 of file free.c.

◆ free_array_size_n()

void free_array_size_n ( void * to_free,
const size_t n )

Free any ** array up to n.

Attention
if n is superior to the array size the behaviour is undefined
Parameters
to_free
n

Definition at line 26 of file free.c.

◆ get_array_len()

size_t get_array_len ( char ** array)

! GETTER !!

Get array len

Parameters
array
Returns
lenght of array or UNDEFINED if array not NULL terminated

Definition at line 13 of file array_utils.c.

◆ refill_map()

void refill_map ( game_data_t * game_data)

Refill the map with ressources (use in runtime)

Parameters
game_dataThe structure where game data are stored

Definition at line 63 of file fill.c.

◆ str_to_word_array()

char ** str_to_word_array ( const char * str,
const char delim )

Turn string to char **.

Parameters
str
delim
Returns
splited string

Definition at line 62 of file array_utils.c.

◆ write_error_msg()

int write_error_msg ( const char * str)

! WRITTER !!

Write any message in the error output

Parameters
strThe string we want to write
Returns
(-1)

Definition at line 11 of file writer.c.

◆ write_to_client()

int write_to_client ( const int fd,
const char * str )

Write any message to a specific file descriptor.

Parameters
fdThe file descriptor where we want to write
strThe string we want to write
Returns
(0)

Definition at line 17 of file writer.c.