42sh 1.0.0
Create a shell in C
Loading...
Searching...
No Matches
my.h File Reference

The header file of the libmy. More...

#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <dirent.h>
#include <signal.h>
#include <glob.h>

Go to the source code of this file.

Data Structures

struct  info_param
 
struct  number_settings_s
 

Macros

#define MAX_INT   2147483647
 
#define MIN_INT   -2147483648
 
#define MAX_LONG   9223372036854775807
 
#define MIN_LONG   -9223372036854775808
 
#define MAX_SHORT   32767
 
#define MIN_SHORT   -32768
 
#define MAX_SHORT_SHORT   127
 
#define MIN_SHORT_SHORT   -128
 
#define MAX_SIZE_T   18446744073709551615
 
#define ABS(value)   ((value < 0) ? - value : value)
 
#define MAX(a, b)   ((a > b) ? a : b)
 
#define MIN(a, b)   ((a < b) ? a : b)
 
#define STR_CONTAINS(str, find)   (my_strstr(str, find) != NULL) ? 1 : 0
 
#define NB   number_settings_t
 
#define STR2ARRAY(str)   my_str_to_word_array(str)
 
#define STR2ARRAY_SEP(str, sep)   my_str_to_word_array_select(str, sep)
 
#define STR2ARRAY_STR(str, sep)   my_str_to_word_array_string(str, sep)
 
#define FREE(ptr)   ptr = my_free_ptr(ptr)
 
#define FREE_WORD_ARRAY(ptr)   my_free_array((void **)ptr)
 
#define NB   number_settings_t
 

Typedefs

typedef enum my_bool my_bool_t
 
typedef struct number_settings_s number_settings_t
 

Enumerations

enum  my_bool { FALSE = 0 , TRUE = 1 }
 

Functions

void my_putchar (char c)
 Prints a char (c) in the stdout.
 
void my_isneg (int nb)
 Prints 'P' if the number (n) is positive or 'N' if the number (n) is negative.
 
void my_putnbr (int nb)
 Prints a number (nb) in stdout.
 
int my_putstr (char const *str)
 Writes a string (str) in stdout and returns the length of the printed string.
 
void my_showstr (char const *str)
 Prints a string (str) but replaces non-printable characters with their hexadecimal number.
 
void my_showmem (char const *str, int size)
 Prints a memory dump of a string (str) with a defined size.
 
void my_print_combn (int n)
 Prints all the numbers composed by (n) different digits numbers All digits in the number are different and only the smallest number composed by those digits are display.
 
void my_putnbr_base (int nbr, char const *base)
 Prints a number (nb) in the requested base (base) in stdout.
 
void my_show_word_array (char *const *tab)
 Prints all word in an array (tab)
 
void my_print_params (int argc, char **argv)
 Prints all the parameters of the program.
 
int my_putstr_error (char const *str)
 Prints a string (str) in stderr.
 
int my_putstr_sized (char const *str, int size)
 Prints a string (str) in stdout with a defined size (size) and returns the length of the printed string.
 
int my_putstr_fd (char const *str, int fd)
 Writes a string (str) in a file descriptor (fd) and returns the length of the printed string.
 
int my_putstr_fd_free (char *str, int fd)
 Writes a string (str) in a file descriptor (fd), free it and returns the length of the printed string.
 
int my_printf (char const *format,...)
 Prints a string (format) with possible flags and format in stdout and returns the length the printed string.
 
int my_fprintf (int fd, char const *format,...)
 Writes a string (format) with possible flags and format in a file descriptor (fd) and returns the length the printed string.
 
int my_char_is_alpha (char const c)
 Checks if a char (c) is a letter.
 
int my_char_is_num (char const c)
 Checks if a char (c) is a number.
 
int my_char_is_printable (char const c)
 Checks if a char (c) is printable.
 
int my_char_is (char c, const char *char_list)
 Checks if a char (c) is in a list of chars (char_list)
 
char * my_add_chr (char *str, char chr)
 Adds a char (chr) at the end of a string (str)
 
char my_get_last_char (char *str)
 Returns the last char of a string (str)
 
int my_str_isalpha (char const *str)
 Checks if a string (str) is alphabetical.
 
int my_str_isnum (char const *str)
 Checks if a string (str) is a number.
 
int my_str_islower (char const *str)
 Checks if a string (str) is lowercase.
 
int my_str_isupper (char const *str)
 Checks if a string (str) is uppercase.
 
int my_str_isprintable (char const *str)
 Checks if a string (str) is printable.
 
int my_str_is (char *str, const char *char_list)
 Checks if a string (str) is composed of characters in the characters list (char_list) or 0 if not.
 
int my_str_contains (char *str, char *char_list)
 Checks if a string (str) contains a character in a list of characters (char_list)
 
int my_strlen (char const *str)
 Returns the length of a string (str)
 
char * my_strcpy (char *dest, char const *src)
 Copies a string (src) and paste it on another string (dest)
 
char * my_strncpy (char *dest, char const *src, int n)
 Copies a string (src) and paste it on another string (dest) with a defined size (n)
 
char * my_revstr (char *str)
 Reverses the characters in a string (str) and returns the string (str)
 
char * my_strstr (char *str, char const *to_find)
 Search a string (to_find) on another (str) and returns the address of the first occurrence.
 
int my_strcmp (char const *s1, char const *s2)
 Compares two strings (s1) and (s2)
 
int my_strncmp (char const *s1, char const *s2, int n)
 Compares two strings (s1) and (s2) with a defined size (n)
 
char * my_strupcase (char *str)
 Replaces lowcase by upcase of a string (str)
 
char * my_strlowcase (char *str)
 Replaces upcase by lowcase of a string (str)
 
char * my_strcapitalize (char *str)
 Capitalizes the first letter of each word in a string (str) and lowercase the other letters.
 
char * my_strcat (char *dest, char const *src)
 Concatenates two strings (dest) and (src)
 
char * my_strncat (char *dest, char const *src, int nb)
 Concatenates two strings (dest) and (src) with a defined size (nb)
 
char * my_strdup (const char *src)
 Duplicates a string (src) and returns the new string.
 
char * my_strndup (const char *src, int n)
 Duplicates a string (src) with a defined size (n) and returns the new string.
 
char ** my_strdup_word_array (char **array)
 Duplicates a word array (array) and returns the new array.
 
const char * my_strerror (int error)
 Returns the error message of the error number (error)
 
int my_count_letter (char const *str, char c)
 Counts the number of times a letter (c) is in a string (str)
 
int my_get_char_index (char *str, char c, int occurrence)
 Get the index of a char in a str according to its occurrence.
 
void my_replace_char (char *str, char to_replace, char replace_by)
 Replace a char in a string by another char.
 
int my_nbrlen (int nb)
 Returns the length of a number (nb)
 
void my_swap (int *a, int *b)
 Swaps two integers (a) and (b)
 
void my_sort_int_array (int *tab, int size)
 Sorts an array (array) with a defined size (size) of integers in ascending order.
 
char * my_convert_base (char const *nbr, char const *base_from, char const *base_to)
 Returns the result of the conversion of a number (nbr) in a specific base (base_from) to another base (base_to)
 
char * my_convert_base_unsigned (char const *nbr, char const *base_from, char const *base_to)
 Returns the result of the conversion of a unsigned number (nbr) in a specific base (base_from) to another base (base_to)
 
char * my_convert_base_size_t (char const *nbr, char const *base_from, char const *base_to)
 Returns the result of the conversion of a size_t number (nbr) in a specific base (base_from) to another base (base_to)
 
void my_round_float_str (char *float_nb, char last_char, int i, int enable)
 Modify a string (float) and round it.
 
int my_array_len (void **array)
 Returns the length of an array (array)
 
char ** my_str_to_word_array (char const *str)
 Returns an array of words from a string (str)
 
char ** my_str_to_word_array_select (char const *str, char const *separator)
 Returns an array of words delimited by a list of separator (separator) from a string (str)
 
char ** my_str_to_word_array_string (char const *str, char const *separator)
 Returns an array of words delimited by a separator (separator) from a string (str)
 
char ** my_super_array (char *str, char *sep)
 Returns an array of words delimited by a list of separator (separator) from a string (str)
 
void my_free_array (void **array)
 Frees an array (array)
 
void * my_free_ptr (void *ptr)
 Frees a pointer (ptr)
 
int my_getnbr (char const *str)
 Returns an int number starting from a string number (str)
 
int my_find_nbr (char const *str)
 Find the first number (number) found in a string.
 
float my_getnbr_float (char const *str)
 Returns a float number starting from a string number (str)
 
int my_getnbr_base (char const *str, char const *base)
 Returns a number starting from a string number (str) in the requested base (base)
 
int my_strict_getnbr (char const *str)
 Returns an int number starting from a string number (str)
 
float my_strict_getnbr_float (char const *str)
 Returns a float number starting from a string number (str)
 
int my_strict_find_nbr (char const *str)
 Find the first number (number) found in a string.
 
int my_super_number (char *number, number_settings_t settings)
 Returns an int number starting from a string number (number) and change my_errno if an error occurs depending on the settings (settings)
 
int my_compute_power_rec (int nb, int power)
 Returns the power (p) of the number (nb)
 
size_t my_compute_power_rec_size_t (int nb, int p)
 Returns the power (p) of the number (nb)
 
int my_compute_square_root (int nb)
 Returns the square root of a number (nb)
 
int my_compute_factorial_rec (int nb)
 Returns the factorial of a number (nb)
 
int my_is_prime (int nb)
 Returns 1 if the number (nb) is prime and 0 otherwise.
 
int my_find_prime_sup (int nb)
 Returns the next prime number after a number (nb)
 
int my_find_prime_inf (int nb)
 Returns the previous prime number before a number (nb)
 
struct info_parammy_params_to_array (int ac, char **av)
 Returns a info_params struct of the argc (ac) and the argv (av)
 
void my_show_param_array (struct info_param const *par)
 Prints the information of a parameter array (par)
 
void my_rev_params (int argc, char **argv)
 Prints all the arguments (argc and argv) in reverse order.
 
void my_sort_params (int argc, char **argv)
 Sorts the parameters (argc and argv) in ascending order.
 
char * my_concat_params (int argc, char **argv)
 Returns a string with all the arguments (argc and argv) concatenated.
 
char * my_str_nbr (int nb)
 Returns the string conversion of a number (nb)
 
char * my_str_nbr_short (short int nb)
 Returns the string conversion of a short number (nb)
 
char * my_str_nbr_short_short (signed char nb)
 Returns the string conversion of a short short number (nb)
 
char * my_str_nbr_base_unsigned (unsigned int nbr, char const *base)
 Returns the string conversion of an unsigned number (nbr) in specific base (base)
 
char * my_str_nbr_base_unsigned_short (unsigned short nbr, char const *base)
 Returns the string conversion of an unsigned short number (nbr) in specific base (base)
 
char * my_str_nbr_base_unsigned_short_short (unsigned char nbr, char const *base)
 Returns the string conversion of an unsigned short short number (nbr) in specific base (base)
 
char * my_str_nbr_base_unsigned_size_t (size_t nbr, char const *base)
 Returns the string conversion of an size_t number (nbr) in specific base (base)
 
char * my_str_nbr_base_unsigned_long (unsigned long nbr, char const *base)
 Returns the string conversion of an unsigned long number (nbr) in specific base (base)
 
char * my_str_nbr_base_long_long_int (long long int nbr, char const *base)
 Returns the string conversion of an long long number (nbr) in specific base (base)
 
char * my_str_nbr_unsigned (unsigned int nb)
 Returns the string conversion of an unsigned number (nb)
 
char * my_str_nbr_unsigned_long (unsigned long int nb)
 Returns the string conversion of an unsigned long number (nb)
 
char * my_str_nbr_long_long (long long nb)
 Returns the string conversion of an long long number (nb)
 
char * my_str_nbr_size_t (size_t nb)
 Returns the string conversion of an size_t number (nb)
 

Variables

int my_errno
 

Detailed Description

The header file of the libmy.

Author
Nicolas TORO

Function Documentation

◆ my_add_chr()

char * my_add_chr ( char * str,
char chr )

Adds a char (chr) at the end of a string (str)

Note
The string must be allocated and have enough space
Parameters
strThe string to modify
chrThe char to add
Returns
char * The modified string
Author
Nicolas TORO

◆ my_array_len()

int my_array_len ( void ** array)

Returns the length of an array (array)

Parameters
arrayThe array to check
Returns
int The length of the array
Author
Nicolas TORO

◆ my_char_is()

int my_char_is ( char c,
const char * char_list )

Checks if a char (c) is in a list of chars (char_list)

Parameters
cThe char to check
char_listThe list of chars to check
Returns
int 1 if the char is in the list, 0 otherwise
Author
Nicolas TORO

◆ my_char_is_alpha()

int my_char_is_alpha ( char const c)

Checks if a char (c) is a letter.

Parameters
cThe char to check
Returns
int 1 if the char is a letter, 0 otherwise
Author
Nicolas TORO

◆ my_char_is_num()

int my_char_is_num ( char const c)

Checks if a char (c) is a number.

Parameters
cThe char to check
Returns
int 1 if the char is a number, 0 otherwise
Author
Nicolas TORO

◆ my_char_is_printable()

int my_char_is_printable ( char const c)

Checks if a char (c) is printable.

Parameters
cThe char to check
Returns
int 1 if the char is printable, 0 otherwise
Author
Nicolas TORO

◆ my_compute_factorial_rec()

int my_compute_factorial_rec ( int nb)

Returns the factorial of a number (nb)

Note
Returns 0 if the number is negative or greater than 12
Parameters
nbThe number to calculate
Returns
int The factorial of the number
Author
Nicolas TORO

◆ my_compute_power_rec()

int my_compute_power_rec ( int nb,
int power )

Returns the power (p) of the number (nb)

Note
Returns 0 if the power is negative
Parameters
nbThe number to calculate
powerThe power of the number
Author
Nicolas TORO

◆ my_compute_power_rec_size_t()

size_t my_compute_power_rec_size_t ( int nb,
int p )

Returns the power (p) of the number (nb)

Note
Returns 0 if the power is negative
Parameters
nbThe number to calculate
powerThe power of the number
Returns
size_t The result of the power
Author
Nicolas TORO

◆ my_compute_square_root()

int my_compute_square_root ( int nb)

Returns the square root of a number (nb)

Parameters
nbThe number to calculate
Returns
int The square root of the number
Author
Nicolas TORO

◆ my_concat_params()

char * my_concat_params ( int argc,
char ** argv )

Returns a string with all the arguments (argc and argv) concatenated.

Parameters
argcThe number of parameters
argvThe array of parameters
Returns
char* The concatenated string of the parameters
Author
Nicolas TORO

◆ my_convert_base()

char * my_convert_base ( char const * nbr,
char const * base_from,
char const * base_to )

Returns the result of the conversion of a number (nbr) in a specific base (base_from) to another base (base_to)

Parameters
nbrThe number to convert
base_fromThe base of the number
base_toThe base to convert the number
Returns
char* The converted number in the new base
Author
Nicolas TORO

◆ my_convert_base_size_t()

char * my_convert_base_size_t ( char const * nbr,
char const * base_from,
char const * base_to )

Returns the result of the conversion of a size_t number (nbr) in a specific base (base_from) to another base (base_to)

Parameters
nbrThe number to convert
base_fromThe base of the number
base_toThe base to convert the number
Returns
char* The converted number in the new base
Author
Nicolas TORO

◆ my_convert_base_unsigned()

char * my_convert_base_unsigned ( char const * nbr,
char const * base_from,
char const * base_to )

Returns the result of the conversion of a unsigned number (nbr) in a specific base (base_from) to another base (base_to)

Parameters
nbrThe number to convert
base_fromThe base of the number
base_toThe base to convert the number
Returns
char* The converted number in the new base
Author
Nicolas TORO

◆ my_count_letter()

int my_count_letter ( char const * str,
char c )

Counts the number of times a letter (c) is in a string (str)

Parameters
strThe string to check
cThe letter to count
Returns
int The number of times the letter is in the string
Author
Nicolas TORO

◆ my_find_nbr()

int my_find_nbr ( char const * str)

Find the first number (number) found in a string.

Note
Returns -1 if the string does not contain a number
The program function overflow
Parameters
strThe string to convert
Returns
int The number found in the string
Author
Nicolas TORO

◆ my_find_prime_inf()

int my_find_prime_inf ( int nb)

Returns the previous prime number before a number (nb)

Parameters
nbThe number to check
Returns
int The previous prime number before the number or the number if it is prime
Author
Nicolas TORO

◆ my_find_prime_sup()

int my_find_prime_sup ( int nb)

Returns the next prime number after a number (nb)

Parameters
nbThe number to check
Returns
int The next prime number after the number or the number if it is prime
Author
Nicolas TORO

◆ my_fprintf()

int my_fprintf ( int fd,
char const * format,
... )

Writes a string (format) with possible flags and format in a file descriptor (fd) and returns the length the printed string.

Parameters
formatThe string to print
...The arguments to use with flags and format
Returns
int The number of printed characters
Author
Nicolas TORO and Gianni TUERO

◆ my_free_array()

void my_free_array ( void ** array)

Frees an array (array)

Parameters
arrayThe array to free
Returns
void
Author
Nicolas TORO

◆ my_free_ptr()

void * my_free_ptr ( void * ptr)

Frees a pointer (ptr)

Parameters
ptrThe pointer to free
Returns
void * Always NULL
Author
Nicolas TORO

◆ my_get_char_index()

int my_get_char_index ( char * str,
char c,
int occurrence )

Get the index of a char in a str according to its occurrence.

Parameters
strThe string to check
cThe letter to find
occurrenceThe occurrence of the letter to find
Returns
int -1 if the letter is not found, otherwise the index of the letter in the string

◆ my_get_last_char()

char my_get_last_char ( char * str)

Returns the last char of a string (str)

Parameters
strThe string to check
Returns
char The last char of the string
Author
Nicolas TORO

◆ my_getnbr()

int my_getnbr ( char const * str)

Returns an int number starting from a string number (str)

Note
Returns 0 if the string is not a number or if the number overflow
The function accept only -0123456789
Parameters
strThe string to convert
Returns
int The number found in the string
Author
Nicolas TORO

◆ my_getnbr_base()

int my_getnbr_base ( char const * str,
char const * base )

Returns a number starting from a string number (str) in the requested base (base)

Note
Returns 0 if the string is not a number
The function accept multiple signes in the string
Parameters
strThe string to convert
baseThe base of the number
Returns
int The number found in the string
Author
Nicolas TORO

◆ my_getnbr_float()

float my_getnbr_float ( char const * str)

Returns a float number starting from a string number (str)

Note
Returns 0 if the string is not a number
The function accept only -0123456789.
The function accept only one point in the string
Parameters
strThe string to convert
Returns
float The number found in the string
Author
Nicolas TORO

◆ my_is_prime()

int my_is_prime ( int nb)

Returns 1 if the number (nb) is prime and 0 otherwise.

Parameters
nbThe number to check
Returns
int 1 if the number is prime, 0 otherwise
Author
Nicolas TORO

◆ my_isneg()

void my_isneg ( int nb)

Prints 'P' if the number (n) is positive or 'N' if the number (n) is negative.

Parameters
nbThe number to check
Returns
void
Author
Nicolas TORO

◆ my_nbrlen()

int my_nbrlen ( int nb)

Returns the length of a number (nb)

Parameters
nbThe number to check
Returns
int The length of the number
Author
Nicolas TORO

◆ my_params_to_array()

struct info_param * my_params_to_array ( int ac,
char ** av )

Returns a info_params struct of the argc (ac) and the argv (av)

Parameters
acThe number of parameters
avThe array of parameters
Returns
struct info_param* The information of the parameters
Author
Nicolas TORO

◆ my_print_combn()

void my_print_combn ( int n)

Prints all the numbers composed by (n) different digits numbers All digits in the number are different and only the smallest number composed by those digits are display.

Parameters
nThe number of digits in the number
Returns
void
Author
Nicolas TORO

◆ my_print_params()

void my_print_params ( int argc,
char ** argv )

Prints all the parameters of the program.

Parameters
argcThe number of parameters
argvThe array of parameters
Returns
void
Author
Nicolas TORO

◆ my_printf()

int my_printf ( char const * format,
... )

Prints a string (format) with possible flags and format in stdout and returns the length the printed string.

Parameters
formatThe string to print
...The arguments to use with flags and format
Returns
int The number of printed characters
Author
Nicolas TORO and Gianni TUERO

◆ my_putchar()

void my_putchar ( char c)

Prints a char (c) in the stdout.

Parameters
cThe char to print
Returns
void
Author
Nicolas TORO

◆ my_putnbr()

void my_putnbr ( int nb)

Prints a number (nb) in stdout.

Parameters
nbThe number to print
Returns
void
Author
Nicolas TORO

◆ my_putnbr_base()

void my_putnbr_base ( int nbr,
char const * base )

Prints a number (nb) in the requested base (base) in stdout.

Parameters
nbrThe number to print
baseThe base to use
Returns
void
Author
Nicolas TORO

◆ my_putstr()

int my_putstr ( char const * str)

Writes a string (str) in stdout and returns the length of the printed string.

Parameters
strThe string to print
Returns
int The length of the printed string
Author
Nicolas TORO

◆ my_putstr_error()

int my_putstr_error ( char const * str)

Prints a string (str) in stderr.

Parameters
strThe string to print
Returns
int 84
Author
Nicolas TORO

◆ my_putstr_fd()

int my_putstr_fd ( char const * str,
int fd )

Writes a string (str) in a file descriptor (fd) and returns the length of the printed string.

Parameters
strThe string to print
fdThe file descriptor to write in
Returns
int The number of printed characters
Author
Nicolas TORO

◆ my_putstr_fd_free()

int my_putstr_fd_free ( char * str,
int fd )

Writes a string (str) in a file descriptor (fd), free it and returns the length of the printed string.

Parameters
strThe string to print
fdThe file descriptor to write in
Returns
int The number of printed characters
Author
Nicolas TORO

◆ my_putstr_sized()

int my_putstr_sized ( char const * str,
int size )

Prints a string (str) in stdout with a defined size (size) and returns the length of the printed string.

Parameters
strThe string to print
sizeThe size of the string
Returns
int The length of the printed string
Author
Nicolas TORO

◆ my_replace_char()

void my_replace_char ( char * str,
char to_replace,
char replace_by )

Replace a char in a string by another char.

Parameters
strThe string to modify
to_replaceThe char to replace
replace_byThe char to replace by
Returns
void

◆ my_rev_params()

void my_rev_params ( int argc,
char ** argv )

Prints all the arguments (argc and argv) in reverse order.

Parameters
parThe information of the parameters
Returns
void
Author
Nicolas TORO

◆ my_revstr()

char * my_revstr ( char * str)

Reverses the characters in a string (str) and returns the string (str)

Parameters
strThe string to reverse
Returns
char* The reversed string
Author
Nicolas TORO

◆ my_round_float_str()

void my_round_float_str ( char * float_nb,
char last_char,
int i,
int enable )

Modify a string (float) and round it.

Parameters
float_nbThe float number to round
last_charThe last character of the float number
iThe index of the float number
enableThe enable of the round
Returns
void

◆ my_show_param_array()

void my_show_param_array ( struct info_param const * par)

Prints the information of a parameter array (par)

Parameters
parThe information of the parameters
Returns
void
Author
Nicolas TORO

◆ my_show_word_array()

void my_show_word_array ( char *const * tab)

Prints all word in an array (tab)

Parameters
tabThe array of words to print
Returns
void
Author
Nicolas TORO

◆ my_showmem()

void my_showmem ( char const * str,
int size )

Prints a memory dump of a string (str) with a defined size.

Parameters
strThe string to print
sizeThe size of the string
Returns
void
Author
Nicolas TORO

◆ my_showstr()

void my_showstr ( char const * str)

Prints a string (str) but replaces non-printable characters with their hexadecimal number.

Parameters
strThe string to print
Returns
void
Author
Nicolas TORO

◆ my_sort_int_array()

void my_sort_int_array ( int * tab,
int size )

Sorts an array (array) with a defined size (size) of integers in ascending order.

Parameters
tabThe array to sort
sizeThe size of the tab
Author
Nicolas TORO

◆ my_sort_params()

void my_sort_params ( int argc,
char ** argv )

Sorts the parameters (argc and argv) in ascending order.

Parameters
argcThe number of parameters
argvThe array of parameters
Returns
void
Author
Nicolas TORO

◆ my_str_contains()

int my_str_contains ( char * str,
char * char_list )

Checks if a string (str) contains a character in a list of characters (char_list)

Parameters
strThe string to check
char_listThe list of characters to check
Returns
int 1 if the string contains a character in the list, 0 otherwise
Author
Nicolas TORO

◆ my_str_is()

int my_str_is ( char * str,
const char * char_list )

Checks if a string (str) is composed of characters in the characters list (char_list) or 0 if not.

Parameters
strThe string to check
Returns
int 1 if the string is composed of characters in the characters list (char_list), 0 otherwise
Author
Nicolas TORO

◆ my_str_isalpha()

int my_str_isalpha ( char const * str)

Checks if a string (str) is alphabetical.

Parameters
strThe string to check
Returns
int 1 if the string is alphabetical, 0 otherwise
Author
Nicolas TORO

◆ my_str_islower()

int my_str_islower ( char const * str)

Checks if a string (str) is lowercase.

Parameters
strThe string to check
Returns
int 1 if the string is lowercase, 0 otherwise
Author
Nicolas TORO

◆ my_str_isnum()

int my_str_isnum ( char const * str)

Checks if a string (str) is a number.

Parameters
strThe string to check
Returns
int 1 if the string is a number, 0 otherwise
Author
Nicolas TORO

◆ my_str_isprintable()

int my_str_isprintable ( char const * str)

Checks if a string (str) is printable.

Parameters
strThe string to check
Returns
int 1 if the string is printable, 0 otherwise
Author
Nicolas TORO

◆ my_str_isupper()

int my_str_isupper ( char const * str)

Checks if a string (str) is uppercase.

Parameters
strThe string to check
Returns
int 1 if the string is uppercase, 0 otherwise
Author
Nicolas TORO

◆ my_str_nbr()

char * my_str_nbr ( int nb)

Returns the string conversion of a number (nb)

Parameters
nbThe number to convert
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_base_long_long_int()

char * my_str_nbr_base_long_long_int ( long long int nbr,
char const * base )

Returns the string conversion of an long long number (nbr) in specific base (base)

Parameters
nbThe number to convert
baseThe base to use
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_base_unsigned()

char * my_str_nbr_base_unsigned ( unsigned int nbr,
char const * base )

Returns the string conversion of an unsigned number (nbr) in specific base (base)

Parameters
nbrThe number to convert
baseThe base to use
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_base_unsigned_long()

char * my_str_nbr_base_unsigned_long ( unsigned long nbr,
char const * base )

Returns the string conversion of an unsigned long number (nbr) in specific base (base)

Parameters
nbThe number to convert
baseThe base to use
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_base_unsigned_short()

char * my_str_nbr_base_unsigned_short ( unsigned short nbr,
char const * base )

Returns the string conversion of an unsigned short number (nbr) in specific base (base)

Parameters
nbThe number to convert
baseThe base to use
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_base_unsigned_short_short()

char * my_str_nbr_base_unsigned_short_short ( unsigned char nbr,
char const * base )

Returns the string conversion of an unsigned short short number (nbr) in specific base (base)

Parameters
nbThe number to convert
baseThe base to use
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_base_unsigned_size_t()

char * my_str_nbr_base_unsigned_size_t ( size_t nbr,
char const * base )

Returns the string conversion of an size_t number (nbr) in specific base (base)

Parameters
nbThe number to convert
baseThe base to use
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_long_long()

char * my_str_nbr_long_long ( long long nb)

Returns the string conversion of an long long number (nb)

Parameters
nbThe number to convert
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_short()

char * my_str_nbr_short ( short int nb)

Returns the string conversion of a short number (nb)

Parameters
nbThe number to convert
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_short_short()

char * my_str_nbr_short_short ( signed char nb)

Returns the string conversion of a short short number (nb)

Parameters
nbThe number to convert
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_size_t()

char * my_str_nbr_size_t ( size_t nb)

Returns the string conversion of an size_t number (nb)

Parameters
nbThe number to convert
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_unsigned()

char * my_str_nbr_unsigned ( unsigned int nb)

Returns the string conversion of an unsigned number (nb)

Parameters
nbThe number to convert
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_nbr_unsigned_long()

char * my_str_nbr_unsigned_long ( unsigned long int nb)

Returns the string conversion of an unsigned long number (nb)

Parameters
nbThe number to convert
Returns
char* The string conversion of the number
Author
Nicolas TORO

◆ my_str_to_word_array()

char ** my_str_to_word_array ( char const * str)

Returns an array of words from a string (str)

Parameters
strThe string to convert
Returns
char** The array of words
Author
Nicolas TORO

◆ my_str_to_word_array_select()

char ** my_str_to_word_array_select ( char const * str,
char const * separator )

Returns an array of words delimited by a list of separator (separator) from a string (str)

Parameters
strThe string to convert
separatorThe separator to use
Returns
char** The array of words
Author
Nicolas TORO

◆ my_str_to_word_array_string()

char ** my_str_to_word_array_string ( char const * str,
char const * separator )

Returns an array of words delimited by a separator (separator) from a string (str)

Parameters
strThe string to convert
separatorThe separator to use
Returns
char** The array of words
Author
Nicolas TORO

◆ my_strcapitalize()

char * my_strcapitalize ( char * str)

Capitalizes the first letter of each word in a string (str) and lowercase the other letters.

Parameters
strThe string to modify
Returns
char* The modified string
Author
Nicolas TORO

◆ my_strcat()

char * my_strcat ( char * dest,
char const * src )

Concatenates two strings (dest) and (src)

Note
The destination string must be allocated and have enough space
Parameters
destThe destination string
srcThe source string
Returns
char* The destination string
Author
Nicolas TORO

◆ my_strcmp()

int my_strcmp ( char const * s1,
char const * s2 )

Compares two strings (s1) and (s2)

Parameters
s1The first string to compare
s2The second string to compare
Returns
int 0 if the strings are identical, otherwise the difference between the first different characters in the strings
Author
Nicolas TORO

◆ my_strcpy()

char * my_strcpy ( char * dest,
char const * src )

Copies a string (src) and paste it on another string (dest)

Note
The destination string must be allocated
Parameters
destThe destination string
srcThe source string
nThe size of the string
Returns
char* The destination string
Author
Nicolas TORO

◆ my_strdup()

char * my_strdup ( const char * src)

Duplicates a string (src) and returns the new string.

Parameters
srcThe string to duplicate
Returns
char* The duplicated string
Author
Nicolas TORO

◆ my_strdup_word_array()

char ** my_strdup_word_array ( char ** array)

Duplicates a word array (array) and returns the new array.

Parameters
arrayThe word array to duplicate
Returns
char** The duplicated word array
Author
Nicolas TORO

◆ my_strerror()

const char * my_strerror ( int error)

Returns the error message of the error number (error)

Parameters
errorThe error number (errno)
Returns
char** The error message of the error number
Author
Nicolas TORO

◆ my_strict_find_nbr()

int my_strict_find_nbr ( char const * str)

Find the first number (number) found in a string.

Note
The function does not accept signes in the string and overflow
Returns -1 if the string does not contain a number
Parameters
strThe string to convert
Returns
int The number found in the string
Author
Nicolas TORO

◆ my_strict_getnbr()

int my_strict_getnbr ( char const * str)

Returns an int number starting from a string number (str)

Note
The function does not accept signes in the string and overflow
Returns -1 if the string is invalid
Parameters
strThe string to convert
Returns
int The number found in the string
Author
Nicolas TORO

◆ my_strict_getnbr_float()

float my_strict_getnbr_float ( char const * str)

Returns a float number starting from a string number (str)

Note
The function does not accept signes in the string and overflow
Returns -1 if the string is invalid
Parameters
strThe string to convert
Returns
float The number found in the string
Author
Nicolas TORO

◆ my_strlen()

int my_strlen ( char const * str)

Returns the length of a string (str)

Parameters
strThe string to check
Returns
int The length of the string
Author
Nicolas TORO

◆ my_strlowcase()

char * my_strlowcase ( char * str)

Replaces upcase by lowcase of a string (str)

Parameters
strThe string to modify
Returns
char* The modified string
Author
Nicolas TORO

◆ my_strncat()

char * my_strncat ( char * dest,
char const * src,
int nb )

Concatenates two strings (dest) and (src) with a defined size (nb)

Note
The destination string must be allocated and have enough space
Parameters
destThe destination string
srcThe source string
nbThe size of the string
Returns
char* The destination string
Author
Nicolas TORO

◆ my_strncmp()

int my_strncmp ( char const * s1,
char const * s2,
int n )

Compares two strings (s1) and (s2) with a defined size (n)

Parameters
s1The first string to compare
s2The second string to compare
nThe size of the strings to compare
Returns
int 0 if the strings are identical, otherwise the difference between the first different characters in the strings
Author
Nicolas TORO

◆ my_strncpy()

char * my_strncpy ( char * dest,
char const * src,
int n )

Copies a string (src) and paste it on another string (dest) with a defined size (n)

Note
The destination string must be allocated
Parameters
destThe destination string
srcThe source string
nThe size of the string
Returns
char* The destination string
Author
Nicolas TORO

◆ my_strndup()

char * my_strndup ( const char * src,
int n )

Duplicates a string (src) with a defined size (n) and returns the new string.

Parameters
srcThe string to duplicate
nThe size of the string
Returns
char* The duplicated string
Author
Nicolas TORO

◆ my_strstr()

char * my_strstr ( char * str,
char const * to_find )

Search a string (to_find) on another (str) and returns the address of the first occurrence.

Parameters
strThe string to be scanned
to_findThe string to search in
Returns
char* The address of the first occurrence of the string to_find in the string str, NULL otherwise
Author
Nicolas TORO

◆ my_strupcase()

char * my_strupcase ( char * str)

Replaces lowcase by upcase of a string (str)

Parameters
strThe string to modify
Returns
char* The modified string
Author
Nicolas TORO

◆ my_super_array()

char ** my_super_array ( char * str,
char * sep )

Returns an array of words delimited by a list of separator (separator) from a string (str)

Parameters
strThe string to convert
sepThe separator to use
Returns
char** The array of words
Author
Gianni TUERO

◆ my_super_number()

int my_super_number ( char * number,
number_settings_t settings )

Returns an int number starting from a string number (number) and change my_errno if an error occurs depending on the settings (settings)

Note
The function will change my_errno by 1 if an error occurs depending on the settings you choose with the settings parameter
Parameters
numberThe string to convert
settingsThe settings of the function
Returns
int The number found in the string
Author
Nicolas TORO

◆ my_swap()

void my_swap ( int * a,
int * b )

Swaps two integers (a) and (b)

Parameters
aThe first integer
bThe second integer
Returns
void
Author
Nicolas TORO