docs: Adding the doxygen on all my function

This commit is contained in:
Raphael 2024-10-31 18:16:00 +01:00
parent 707e9a4177
commit f5bcbeac3c
38 changed files with 342 additions and 43 deletions

View file

@ -6,7 +6,7 @@
# By: rparodi <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
# Updated: 2024/10/31 17:22:49 by rparodi ### ########.fr #
# Updated: 2024/10/31 17:26:05 by rparodi ### ########.fr #
# #
# **************************************************************************** #
@ -32,6 +32,10 @@ LDLIBS = -lft
INCLUDES = ./includes/libft/
# Objects
OBJDIRNAME = ./build
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
SRC = char/ft_isdigit.c \
char/ft_isalnum.c \
char/ft_isalpha.c \
@ -81,10 +85,6 @@ SRC = char/ft_isdigit.c \
str/ft_strtrim.c \
str/ft_substr.c
# Objects
OBJDIRNAME = ./build
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
# Colors
GREEN = \033[32m
GREY = \033[0;90m

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:39:56 by rparodi #+# #+# */
/* Updated: 2023/11/12 17:11:53 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:29:37 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Add the list new to the back of chained list of lst
*
* @param lst first element of the list
* @param new The element to add at the end
*/
void ft_lstadd_back(t_list **lst, t_list *new)
{
t_list *tempo;

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:40:16 by rparodi #+# #+# */
/* Updated: 2023/11/12 17:14:33 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:30:01 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Add the list new to the front of chained list of lst
*
* @param lst first element of the list
* @param new The element to add at the start
*/
void ft_lstadd_front(t_list **lst, t_list *new)
{
if (*lst == NULL)

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:40:37 by rparodi #+# #+# */
/* Updated: 2023/11/12 19:34:19 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:32:23 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Clear the all list with the function
*
* @param lst the start of the chained list
* @param del the function to clear the list
*/
void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *tempo;

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:42:11 by rparodi #+# #+# */
/* Updated: 2023/11/12 18:10:40 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:46:00 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Clear the element of the list with the function
*
* @param lst the element of the list to be clear
* @param del the function to clear the list
*/
void ft_lstdelone(t_list *lst, void (*del)(void *))
{
del(lst->content);

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:42:24 by rparodi #+# #+# */
/* Updated: 2023/11/12 18:07:02 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:46:55 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Apply the function given in arguments at all the element of the list
*
* @param lst the chained list
* @param f the pointer to function
*/
void ft_lstiter(t_list *lst, void (*f)(void *))
{
while (lst != NULL)

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:42:54 by rparodi #+# #+# */
/* Updated: 2023/11/12 17:25:48 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:48:08 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Found the last element of the chained list
*
* @param lst the chained list
* @return the last element of the chained list
*/
t_list *ft_lstlast(t_list *lst)
{
if (lst == NULL)

View file

@ -6,12 +6,20 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:43:28 by rparodi #+# #+# */
/* Updated: 2023/11/12 19:28:02 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:51:38 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Create an other list from an old one with a function on all element
*
* @param lst the chained list
* @param f the function to function to iterate
* @param del The function to delete the old list
* @return
*/
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
{
t_list *tempo;

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:44:02 by rparodi #+# #+# */
/* Updated: 2023/11/12 14:25:12 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:52:24 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Allocate a new list with the first element
*
* @param content the element to give on first element
* @return the new list
*/
t_list *ft_lstnew(void *content)
{
t_list *to_return;

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:44:24 by rparodi #+# #+# */
/* Updated: 2023/11/13 12:22:02 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:53:11 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Give the size of the chained list
*
* @param lst the chained list
* @return the size of the list
*/
int ft_lstsize(t_list *lst)
{
int count;

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:43:13 by rparodi #+# #+# */
/* Updated: 2023/11/07 17:25:28 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:54:25 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Sets a block of memory to zero
*
* @param s Pointer to the memory area to be set at zero
* @param n Number of bytes to set to zero
*/
void ft_bzero(void *s, size_t n)
{
ft_memset(s, 0, n);

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */
/* Updated: 2023/11/13 14:47:17 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:55:30 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Allocates and zeroes memory for an array
*
* @param nmemb Number of elements to allocate
* @param size Size of each element in bytes
*/
void *ft_calloc(size_t nmemb, size_t size)
{
size_t total;

View file

@ -6,12 +6,22 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:48:30 by rparodi #+# #+# */
/* Updated: 2023/11/07 18:45:57 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:59:07 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Scans memory for a byte
*
* @param s Pointer to the memory area to scan
* @param c Byte value to search for
* @param n Number of bytes to scan in s
*
* @return A pointer to the matching byte in memory, or NULL if the byte
is not found within the first n bytes
*/
void *ft_memchr(const void *s, int c, size_t n)
{
size_t i;

View file

@ -6,12 +6,24 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:49:04 by rparodi #+# #+# */
/* Updated: 2023/11/07 18:46:15 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:59:48 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Compares two memory blocks
*
* @param s1 Pointer to the first memory area
* @param s2 Pointer to the second memory area
* @param n Number of bytes to compare
*
* @return An integer indicating the relationship between the two memory areas:
* - `< 0` if `s1` is less than `s2`
* - `0` if `s1` equals `s2`
* - `> 0` if `s1` is greater than `s2`
*/
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;

View file

@ -6,12 +6,21 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:49:46 by rparodi #+# #+# */
/* Updated: 2023/11/13 19:14:23 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:57:31 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Copies memory from source to destination
*
* @param dest Pointer to the destination memory area
* @param src Pointer to the source memory area
* @param n Number of bytes to copy from src to dest
*
* @return A pointer to the destination memory area dest
*/
void *ft_memcpy(void *dest, const void *src, size_t n)
{
char *d;

View file

@ -6,7 +6,7 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:51:35 by rparodi #+# #+# */
/* Updated: 2023/11/13 19:55:40 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:15:19 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -37,6 +37,15 @@ char *ft_checks(char *s, char *d, size_t n)
return (d);
}
/**
* @brief Copies memory with overlap handling
*
* @param dest Pointer to the destination memory area
* @param src Pointer to the source memory area
* @param n Number of bytes to copy from src to dest
*
* @return A pointer to the destination memory area dest
*/
void *ft_memmove(void *dest, const void *src, size_t n)
{
char *d;

View file

@ -6,12 +6,21 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:50:29 by rparodi #+# #+# */
/* Updated: 2023/11/07 18:58:02 by rparodi ### ########.fr */
/* Updated: 2024/10/31 17:56:59 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Fills a block of memory with a specified byte
*
* @param s Pointer to the memory area to fill
* @param c Byte value to be set in the memory
* @param n Number of bytes to be set to the value c
*
* @return A pointer to the memory area s
*/
void *ft_memset(void *s, int c, size_t n)
{
char *str;

View file

@ -6,7 +6,7 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/14 17:27:44 by rparodi #+# #+# */
/* Updated: 2024/10/31 16:12:37 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:01:28 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -43,6 +43,13 @@ int _check_args(int fd, char c, va_list args, int *ret_value)
return (1);
}
/**
* @brief Print on a file descriptor
*
* @param fd the file descriptor
* @param s the string
* @return the number of character printable
*/
int ft_dprintf(int fd, const char *s, ...)
{
size_t i;
@ -69,6 +76,12 @@ int ft_dprintf(int fd, const char *s, ...)
return (ret_value);
}
/**
* @brief Print on the standard output
*
* @param s the string
* @return the number of character printable
*/
int ft_printf(const char *s, ...)
{
size_t i;

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:58:22 by rparodi #+# #+# */
/* Updated: 2023/11/10 15:31:57 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:02:37 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief print an character on a file descriptor
*
* @param c the character to print
* @param fd the file descriptor
*/
void ft_putchar_fd(char c, int fd)
{
write(fd, &c, 1);

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:59:01 by rparodi #+# #+# */
/* Updated: 2023/11/10 15:57:53 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:03:47 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Print a string follow by a new line on a file descriptor
*
* @param s the string to print
* @param fd the file descriptor
*/
void ft_putendl_fd(char *s, int fd)
{
ft_putstr_fd(s, fd);

View file

@ -6,7 +6,7 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:59:18 by rparodi #+# #+# */
/* Updated: 2023/11/13 20:13:20 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:04:17 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -39,6 +39,12 @@ static int ft_check_sign(int n, char *str, size_t *i, int fd)
return (n);
}
/**
* @brief Print a number on a file descriptor
*
* @param n the number to print
* @param fd the file descriptor
*/
void ft_putnbr_fd(int n, int fd)
{
size_t i;

View file

@ -6,12 +6,18 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:58:46 by rparodi #+# #+# */
/* Updated: 2023/11/10 15:57:46 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:05:11 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief print a string on a file descriptor
*
* @param s the string to print
* @param fd the file descriptor
*/
void ft_putstr_fd(char *s, int fd)
{
write(fd, s, ft_strlen(s));

View file

@ -6,7 +6,7 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:56:02 by rparodi #+# #+# */
/* Updated: 2023/11/13 12:14:57 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:13:39 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -74,6 +74,15 @@ static char **ext_w(char **words_array, const char *str, char sep, int size)
return (words_array);
}
/**
* @brief Splits a string into an array of substrings based on a delimiter.
*
* @param s The string to split.
* @param c The delimiter character.
*
* @return A NULL-terminated array of substrings,
* or NULL if memory allocation fails.
*/
char **ft_split(char const *s, char c)
{
int size;

View file

@ -6,12 +6,21 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:32:19 by rparodi #+# #+# */
/* Updated: 2023/11/09 12:08:01 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:13:01 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Locates the first occurrence of a character in a string.
*
* @param s The string to search.
* @param c The character to locate.
*
* @return A pointer to the matched character,
* or NULL if it does not appear in `s`.
*/
char *ft_strchr(const char *s, int c)
{
unsigned int i;

View file

@ -1,17 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* strcmp.c :+: :+: :+: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */
/* Updated: 2024/10/31 17:05:03 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:07:20 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Compares two strings lexicographically.
*
* @param s1 The first string to compare.
* @param s2 The second string to compare.
*
* @return An integer indicating the relationship between the two strings:
* - `< 0` if `s1` is less than `s2`.
* - `0` if `s1` equals `s2`.
* - `> 0` if `s1` is greater than `s2`.
*/
int ft_strcmp(const char *s1, const char *s2)
{
size_t i;

View file

@ -6,12 +6,20 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/31 16:14:10 by rparodi #+# #+# */
/* Updated: 2024/10/31 16:15:46 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:14:03 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Copies a string.
*
* @param dst The destination buffer.
* @param src The source string.
*
* @return A pointer to `dst`.
*/
char *ft_strcpy(char *dst, const char *src)
{
size_t i;

View file

@ -6,12 +6,20 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:53:59 by rparodi #+# #+# */
/* Updated: 2023/11/13 20:02:09 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:14:44 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Duplicates a string.
*
* @param s1 The string to duplicate.
*
* @return A pointer to the duplicated string,
* or NULL if memory allocation fails.
*/
char *ft_strdup(const char *s)
{
size_t len;

View file

@ -6,12 +6,20 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:57:34 by rparodi #+# #+# */
/* Updated: 2023/11/11 17:26:00 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:11:04 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Applies a function to each character of a string.
*
* @param s The string to modify.
* @param f The function to apply to each character.
*
* @return void
*/
void ft_striteri(char *s, void (*f)(unsigned int, char*))
{
size_t i;

View file

@ -6,12 +6,21 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:55:15 by rparodi #+# #+# */
/* Updated: 2023/11/09 17:47:46 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:13:21 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Joins two strings into a new string.
*
* @param s1 The first string.
* @param s2 The second string.
*
* @return A pointer to the new concatenated string,
* or NULL if memory allocation fails.
*/
char *ft_strjoin(char const *s1, char const *s2)
{
size_t i;

View file

@ -6,7 +6,7 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 22:28:26 by rparodi #+# #+# */
/* Updated: 2023/11/12 11:45:52 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:10:19 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,6 +22,15 @@ static size_t ft_strnlen(char *dest, size_t size)
return (i);
}
/**
* @brief Appends a string with size limit.
*
* @param dst The destination buffer.
* @param src The source string.
* @param size The size of the destination buffer.
*
* @return The total length of the string it tried to create.
*/
size_t ft_strlcat(char *dest, const char *src, size_t size)
{
size_t i;

View file

@ -6,12 +6,21 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:55:25 by rparodi #+# #+# */
/* Updated: 2023/11/13 19:16:30 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:12:13 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Copies a string with size limit.
*
* @param dst The destination buffer.
* @param src The source string.
* @param size The maximum number of characters to copy.
*
* @return The total length of `src`.
*/
size_t ft_strlcpy(char *dst, const char *src, size_t size)
{
size_t i;

View file

@ -6,12 +6,19 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:56:24 by rparodi #+# #+# */
/* Updated: 2023/11/08 12:37:09 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:12:19 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Computes the length of a string.
*
* @param s The input string.
*
* @return The number of characters in the string `s`.
*/
size_t ft_strlen(const char *s)
{
size_t i;

View file

@ -6,12 +6,21 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:56:57 by rparodi #+# #+# */
/* Updated: 2023/11/13 19:49:30 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:14:29 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Applies a function to each character of a string.
*
* @param s The input string.
* @param f The function to apply to each character.
*
* @return A pointer to the newly created string,
* or NULL if memory allocation fails.
*/
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
size_t i;

View file

@ -6,12 +6,21 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */
/* Updated: 2023/11/09 13:16:39 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:13:58 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Compares two strings up to a specified number of characters.
*
* @param s1 The first string to compare.
* @param s2 The second string to compare.
* @param n The maximum number of characters to compare.
*
* @return An integer indicating the relationship between the two strings.
*/
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
size_t i;

View file

@ -6,12 +6,26 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:57:44 by rparodi #+# #+# */
/* Updated: 2023/11/13 19:17:49 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:12:05 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Locates a substring within a string, up to a specified length.
*
* The `ft_strnstr` function locates the first occurrence of the null-terminated
* string `needle` within the string `haystack`,
* searching only up to `len` characters.
*
* @param big The string to search.
* @param little The substring to locate.
* @param len The maximum number of characters to search.
*
* @return A pointer to the beginning of the located substring,
* or NULL if `needle` is not found.
*/
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t i;

View file

@ -6,12 +6,21 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:58:22 by rparodi #+# #+# */
/* Updated: 2023/11/11 18:46:54 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:13:53 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Locates the last occurrence of a character in a string.
*
* @param s The string to search.
* @param c The character to locate.
*
* @return A pointer to the matched character,
* or NULL if it does not appear in `s`.
*/
char *ft_strrchr(const char *s, int c)
{
size_t i;

View file

@ -6,12 +6,20 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:55:44 by rparodi #+# #+# */
/* Updated: 2023/11/13 20:08:51 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:09:25 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Trims specified characters from the start and end of a string.
*
* @param s1 The string to trim.
* @param set The set of characters to remove.
*
* @return A pointer to the trimmed string, or NULL if memory allocation fails.
*/
char *ft_strtrim(char const *s1, char const *set)
{
size_t i;

View file

@ -6,12 +6,21 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:54:42 by rparodi #+# #+# */
/* Updated: 2023/11/13 20:08:02 by rparodi ### ########.fr */
/* Updated: 2024/10/31 18:10:59 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Extracts a substring from a string.
*
* @param s The source string.
* @param start The starting index of the substring.
* @param len The maximum length of the substring.
*
* @return A pointer to the substring, or NULL if memory allocation fails.
*/
char *ft_substr(char const *s, unsigned int start, size_t len)
{
char *str;