Libft
 
Loading...
Searching...
No Matches
libft.h File Reference
#include <stddef.h>
#include <unistd.h>
Include dependency graph for libft.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  s_list
 Structure for linked list. More...
 

Macros

#define FX_VA   0
 Activate the variadic functions 1 is activated, 0 is desactivated.
 

Typedefs

typedef enum e_bool t_bool
 Basic type to mimic stdbool.
 
typedef struct s_list t_list
 Structure for linked list.
 

Enumerations

enum  e_bool { FALSE = 0 , TRUE = 1 }
 Basic type to mimic stdbool. More...
 

Functions

int ft_atoi (const char *nptr)
 Convert string to int, and handle number.
 
int ft_atoi_base (char *str, char *base)
 Atoi with a particular base.
 
char * ft_itoa (int n)
 Return a string representing the integer 'n' received as argument.
 
int ft_isalpha (int character)
 Check if arg is a char alphabetic.
 
int ft_isdigit (int character)
 Check if arg is a digit.
 
int ft_isalnum (int character)
 Check if arg is a char or a digit (alphanumeric)
 
int ft_isascii (int character)
 Check if arg is in ascii table.
 
int ft_isprint (int character)
 Check if arg is in ascii table and printable.
 
int ft_toupper (int character)
 Transform minuscules into majuscules.
 
int ft_tolower (int character)
 Transform majuscules into minuscules.
 
int ft_isspace (int character)
 Check if arg is a whitespace.
 
int ft_iswhitespace (int character)
 Alternative name for ft_isspace.
 
size_t ft_strlen (const char *the_string)
 Len of string without '\0'.
 
size_t ft_strlen_char (const char *the_string, int character)
 Number of occurrence of character in the string.
 
size_t ft_strlcpy (char *dst, const char *src, size_t size)
 
size_t ft_strlcat (char *dst, const char *src, size_t size)
 Concatenate src into dst, up to size bytes.
 
char * ft_strchr (const char *string, int searched_char)
 Find first occurrence of searched_char.
 
char * ft_strrchr (const char *string, int searched_char)
 Find last occurrence of searched_char.
 
int ft_strncmp (const char *first, const char *second, size_t length)
 Find differences between first and second.
 
const char * ft_strnstr (const char *big, const char *little, size_t len)
 Search a substring in a bigger string, up to len position in string.
 
char * ft_strdup (const char *source)
 Create a copy of source into a new pointer NEEDS to be freed.
 
char * ft_strndup (const char *source, size_t len)
 Create a copy of source into a new pointer of size len NEEDS to be freed.
 
char * ft_substr (char const *src, unsigned int start, size_t len)
 Create a copy of source into a new pointer, at start, of size len NEEDS to be freed.
 
char * ft_strjoin (char const *s1, char const *s2)
 Allocates a new string, and returns the result of a concatenation of s1 and s2.
 
char * ft_strjoins (char **str)
 Allocates a new string, and returns the result of a concatenation of all the strings from the array last argument needs to be NULL.
 
char * ft_strtrim (char const *s, char const *set)
 Deletes all characters that exist in s and set, if they are at the beginning of the string or at the end.
 
char ** ft_split (char const *s, char c)
 Allocates with a malloc and returns an array of strings obtained by separating ’s’ using the character ’c’, used as a delimiter. The array must be terminated by NULL.
 
char * ft_strmapi (char const *s, char(*f)(unsigned int, char))
 Apply the function ’f’ to each character of the string ’s’, passing its index as first argument and the character itself as second argument.
 
void ft_striteri (char *s, void(*f)(unsigned int, char *))
 Iterate the function f on string s.
 
void ft_rev_int (int *tab, size_t size)
 Reverse an array of ints.
 
void ft_bzero (void *s, size_t n)
 Set at 0, the n first bytes at the pointer adress.
 
void * ft_memcpy (void *destination, const void *source, size_t size)
 Set a memory zone with a value, count times.
 
void * ft_memset (void *pointer, int value, size_t count)
 Set a memory zone with a value, count times.
 
void * ft_memmove (void *destination, const void *source, size_t size)
 Moves the memory blocks avoiding overlapping, until size blocks.
 
const void * ft_memchr (const void *memory_block, int searched_char, size_t size)
 Research the first occurence of a value typed int, but interpreted as a char in a memory block.
 
int ft_memcmp (const void *src, const void *set, size_t size)
 Compares the first size bytes of the memory areas src and set.
 
void * ft_calloc (size_t element_count, size_t element_size)
 Allocates a new memory zone, and set all bits to zero.
 
void ft_swap_int (int *a, int *b)
 Swap 2 int values.
 
void ft_swap_char (char *a, char *b)
 Swap 2 char values.
 
void ft_swap_str (char **a, char **b)
 Swap 2 string addresses.
 
void ft_swap_mem (void **a, void **b)
 Swap 2 memory adresses.
 
void ft_swap_int_no_temp (int *a, int *b)
 Works similarly as ft_swap_int but doens't use temporary variable SHOULD NOT BE USED IF a and b points at the same adress.
 
void ft_swap_char_no_temp (char *a, char *b)
 Works similarly as ft_swap_char but doens't use temporary variable SHOULD NOT BE USED IF a and b points at the same adress.
 
ssize_t ft_putchar_fd (const char c, int fd)
 Print the character 'c' on the file descriptor.
 
ssize_t ft_putstr_fd (const char *s, int fd)
 Print the string 's' on the file descriptor.
 
ssize_t ft_putnstr_fd (const char *s, size_t len, int fd)
 Print the string 's' on the file descriptor until a given size or the length of s if len is greater.
 
ssize_t ft_putendl_fd (const char *s, int fd)
 Print the string 's' on the file descriptor, followed by a newline.
 
ssize_t ft_putnendl_fd (const char *s, size_t len, int fd)
 Print the string 's' on the file descriptor, followed by a newline until a given size or the length of s if len is greater.
 
ssize_t ft_putnbr_fd (long long n, int fd)
 Write the int 'n' on the given file descriptor.
 
ssize_t ft_putnbr_bin (int nbr)
 Putnbr for binary.
 
ssize_t ft_putnbr_oct (int nbr)
 Putnbr for octal.
 
ssize_t ft_putnbr_hex (int nbr, char height)
 Putnbr for hex or HEX.
 
ssize_t ft_putnbr_hex_fd (unsigned int nbr, char height, int fd)
 Putnbr for hex or HEX.
 
ssize_t ft_putptr_fd (unsigned long nbr, int fd)
 Print pointer adress.
 
ssize_t ft_putnbr_base (int nbr, const char *base)
 Putnbr with a particular base.
 
size_t ft_check_base_atoi (const char *base)
 Check if base is valid for atoi_base.
 
size_t ft_check_base_putnbr (const char *base)
 Check if base is valid for putnbr_base.
 
ssize_t ft_putpointer_fd (const void *ptr)
 Print pointer adress.
 
t_listft_lstnew (void *content)
 Allocate (with malloc(3)) and return a new element. The variable member 'content' is initialized with the value of the parameter 'content'. The variable 'next' is initialized to NULL.
 
void ft_lstadd_front (t_list **lst, t_list *new)
 Adds the element ’new’ at the start of the list.
 
int ft_lstsize (t_list *lst)
 Count the number of elements in a list.
 
t_listft_lstlast (t_list *lst)
 Returns the last element of the list.
 
void ft_lstadd_back (t_list **lst, t_list *new)
 Adds the element ’new’ at the end of the list.
 
void ft_lstdelone (t_list *lst, void(*del)(void *))
 Free the memory of the element passed as a parameter using the function 'del' and free(3). The memory of next must not be freed.
 
void ft_lstclear (t_list **lst, void(*del)(void *))
 Deletes and free the memory of the element passed as a parameter, and all the elements that follow, using 'del' and free(3) Finally, the initial pointer must be set to NULL.
 
void ft_lstiter (t_list *lst, void(*f)(void *))
 Iterate on the linked list 'lst' and apply the function 'f' on the content of each element.
 
t_listft_lstmap (t_list *lst, void *(*f)(void *), void(*del)(void *))
 Iterated on the linked list 'list' and apply the function 'f' on the content of each element. Create a new list resulting from the successive applications of 'f'. The function 'del' is there to destroy the content of an element if necessary.
 
void ft_swap_nodes (t_list **start, t_list *lst1, t_list *lst2)
 Swap two nodes in a linked list (swap nodes, not content)
 
void ft_frees (void **ptr)
 Frees multiple pointers.
 

Macro Definition Documentation

◆ FX_VA

#define FX_VA   0

Activate the variadic functions 1 is activated, 0 is desactivated.

Typedef Documentation

◆ t_bool

typedef enum e_bool t_bool

Basic type to mimic stdbool.

◆ t_list

typedef struct s_list t_list

Structure for linked list.

Enumeration Type Documentation

◆ e_bool

enum e_bool

Basic type to mimic stdbool.

Enumerator
FALSE 
TRUE