📚 Documentation & Build Update
📝 Documentation Overhaul: - 🚚 Function docs have been migrated from implementation files (.c) to their header files (.h) across the following modules: - char - convert - list - memory - All documentation is now in Doxygen-style comments, making headers self-documented and turning the API into an easier-to-navigate codex. ## 🛠️ Build System Tweaks: - 🔗 Added str/ft_strncpy.c to the SRC list in the Makefile, ensuring it’s properly compiled and linked into the arsenal. ## ⚡ Impact - Clearer and more maintainable API documentation. - Stronger build consistency with all sources included. - A polished codebase with up-to-date metadata.
This commit is contained in:
commit
63a1b2abdf
56 changed files with 472 additions and 427 deletions
7
Makefile
7
Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: rparodi <marvin@42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2025/09/05 15:10:23 by rparodi ### ########.fr #
|
||||
# Updated: 2025/09/05 16:21:13 by rparodi ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -30,10 +30,10 @@ CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP
|
|||
OBJDIRNAME = ./build
|
||||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
|
||||
|
||||
SRC = char/ft_isdigit.c \
|
||||
char/ft_isalnum.c \
|
||||
SRC = char/ft_isalnum.c \
|
||||
char/ft_isalpha.c \
|
||||
char/ft_isascii.c \
|
||||
char/ft_isdigit.c \
|
||||
char/ft_isprint.c \
|
||||
char/ft_tolower.c \
|
||||
char/ft_toupper.c \
|
||||
|
|
@ -74,6 +74,7 @@ SRC = char/ft_isdigit.c \
|
|||
str/ft_strlen.c \
|
||||
str/ft_strmapi.c \
|
||||
str/ft_strncmp.c \
|
||||
str/ft_strncpy.c \
|
||||
str/ft_strnstr.c \
|
||||
str/ft_strrchr.c \
|
||||
str/ft_strtrim.c \
|
||||
|
|
|
|||
|
|
@ -6,18 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/06 12:47:28 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/04 18:12:52 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:01:38 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "char.h"
|
||||
|
||||
/**
|
||||
* @brief Check if the character is alpha-numeric
|
||||
*
|
||||
* @param c the character
|
||||
* @return the character if alphanumeric or 0 if not
|
||||
*/
|
||||
int ft_isalnum(int c)
|
||||
{
|
||||
if (ft_isalpha(c) || ft_isdigit(c))
|
||||
|
|
|
|||
|
|
@ -6,16 +6,10 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/06 11:58:37 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/04 18:13:06 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:03:14 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/**
|
||||
* @brief Check if the character is alpha
|
||||
*
|
||||
* @param c the character
|
||||
* @return the character if alpha or 0 if not
|
||||
*/
|
||||
int ft_isalpha(int c)
|
||||
{
|
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
||||
|
|
|
|||
|
|
@ -6,16 +6,10 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/06 14:04:26 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/05 10:40:03 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:01:13 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/**
|
||||
* @brief Check if the character is in the ascii table
|
||||
*
|
||||
* @param c the character
|
||||
* @return the character if in the ascii table or 0 if not
|
||||
*/
|
||||
int ft_isascii(int c)
|
||||
{
|
||||
if (c == 0)
|
||||
|
|
|
|||
|
|
@ -6,16 +6,10 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/06 12:44:28 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/04 18:13:17 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:00:16 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/**
|
||||
* @brief Check if the character is alpha numeric
|
||||
*
|
||||
* @param c the character
|
||||
* @return the character if numeric or 0 if not
|
||||
*/
|
||||
int ft_isdigit(int c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
|
|
|
|||
|
|
@ -6,16 +6,10 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/06 14:06:53 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/05 10:44:13 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:03:14 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/**
|
||||
* @brief Check if the character is printable
|
||||
*
|
||||
* @param c the character
|
||||
* @return the character if can be print or 0 if not
|
||||
*/
|
||||
int ft_isprint(int c)
|
||||
{
|
||||
if (c >= 32 && c <= 126)
|
||||
|
|
|
|||
|
|
@ -6,16 +6,10 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 10:38:54 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/04 11:42:13 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:00:45 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/**
|
||||
* @brief convert the upper case to lower case
|
||||
*
|
||||
* @param c the character
|
||||
* @return the character to lower case if is on upper
|
||||
*/
|
||||
int ft_tolower(int c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
|
|
|
|||
|
|
@ -6,16 +6,10 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 10:44:26 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/04 11:41:57 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:00:45 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/**
|
||||
* @brief convert the lower case to upper case
|
||||
*
|
||||
* @param c the character
|
||||
* @return the character to upper case if is on lower
|
||||
*/
|
||||
int ft_toupper(int c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 17:22:41 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/05 14:34:51 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:08:14 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -31,12 +31,6 @@ static int ft_check_sign(const char *nptr, int *i)
|
|||
return (1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts string to integer
|
||||
*
|
||||
* @param nptr the string that will be converted
|
||||
* @return The integer on the string
|
||||
*/
|
||||
int ft_atoi(const char *nptr)
|
||||
{
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:12:07 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/05 14:54:50 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:08:14 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -33,12 +33,6 @@ static int ft_check_sign(const char *nptr, size_t *i)
|
|||
return (1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts string to long long integer
|
||||
*
|
||||
* @param nptr the string that will be converted
|
||||
* @return The long long int on the string
|
||||
*/
|
||||
long long int ft_atoll(const char *nptr)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:56:30 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:30:01 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:08:14 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,12 +26,6 @@ static size_t ft_check_sign(char *str, long *nb)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts integer to string
|
||||
*
|
||||
* @param n the integer that will be converted
|
||||
* @return The string with this integer
|
||||
*/
|
||||
char *ft_itoa(int n)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,67 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 14:54:04 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 18:26:44 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:06:07 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CHAR_H
|
||||
# define CHAR_H
|
||||
|
||||
/**
|
||||
* @brief Check if the character is alpha-numeric
|
||||
*
|
||||
* @param c the character
|
||||
* @return 1 if the char is alpha-numeric overwise 0
|
||||
*/
|
||||
int ft_isalnum(int c);
|
||||
|
||||
/**
|
||||
* @brief Check if the character is alpha
|
||||
*
|
||||
* @param c the character
|
||||
* @return 1 if the char is alphabetic overwise 0
|
||||
*/
|
||||
int ft_isalpha(int c);
|
||||
|
||||
/**
|
||||
* @brief Check if the character is in the ascii table
|
||||
*
|
||||
* @param c the character
|
||||
* @return 1 if the char is ascii overwise 0
|
||||
*/
|
||||
int ft_isascii(int c);
|
||||
|
||||
/**
|
||||
* @brief Check if the character is numeric
|
||||
*
|
||||
* @param c the character
|
||||
* @return 1 if the char is numeric overwise 0
|
||||
*/
|
||||
int ft_isdigit(int c);
|
||||
|
||||
/**
|
||||
* @brief Check if the character is printable
|
||||
*
|
||||
* @param c the character
|
||||
* @return 1 if the char is printable 0
|
||||
*/
|
||||
int ft_isprint(int c);
|
||||
|
||||
/**
|
||||
* @brief convert the upper case to lower case
|
||||
*
|
||||
* @param c the character
|
||||
* @return the character to lower case if is on upper
|
||||
*/
|
||||
int ft_tolower(int c);
|
||||
|
||||
/**
|
||||
* @brief convert the lower case to upper case
|
||||
*
|
||||
* @param c the character
|
||||
* @return the character to upper case if is on lower
|
||||
*/
|
||||
int ft_toupper(int c);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,15 +6,35 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 14:57:24 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:55:58 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:07:54 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CONVERT_H
|
||||
# define CONVERT_H
|
||||
|
||||
/**
|
||||
* @brief Converts integer to string
|
||||
*
|
||||
* @param n the integer that will be converted
|
||||
* @return The string with this integer
|
||||
*/
|
||||
char *ft_itoa(int n);
|
||||
|
||||
/**
|
||||
* @brief Converts string to integer
|
||||
*
|
||||
* @param nptr the string that will be converted
|
||||
* @return The integer on the string
|
||||
*/
|
||||
int ft_atoi(const char *nptr);
|
||||
|
||||
/**
|
||||
* @brief Converts string to long long integer
|
||||
*
|
||||
* @param nptr the string that will be converted
|
||||
* @return The long long int on the string
|
||||
*/
|
||||
long long int ft_atoll(const char *nptr);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:00:12 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:34:41 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:24:23 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,14 +19,78 @@ typedef struct s_list
|
|||
struct s_list *next;
|
||||
} t_list;
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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 The list edited by the function given by f
|
||||
*/
|
||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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 *));
|
||||
|
||||
/**
|
||||
* @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 *));
|
||||
|
||||
/**
|
||||
* @brief Apply the fstunction 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 *));
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:18:17 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/04 11:51:05 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:26:36 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,12 +15,79 @@
|
|||
|
||||
# include <stddef.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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,18 +6,60 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:07:30 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:36:18 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:23:42 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PRINT_H
|
||||
# define PRINT_H
|
||||
|
||||
/**
|
||||
* @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, ...);
|
||||
|
||||
/**
|
||||
* @brief Print on the standard output
|
||||
*
|
||||
* @param s the string
|
||||
* @return the number of character printable
|
||||
*/
|
||||
int ft_printf(const char *s, ...);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
173
includes/str.h
173
includes/str.h
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:04:59 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/04 11:53:11 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:19:06 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,21 +15,192 @@
|
|||
|
||||
# include <stddef.h>
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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));
|
||||
|
||||
/**
|
||||
* @brief Copies a string.
|
||||
*
|
||||
* @param dst The destination buffer.
|
||||
* @param src The source string.
|
||||
* @param size The size to copy
|
||||
*
|
||||
* @return A pointer to `dst`.
|
||||
*/
|
||||
char *ft_strncpy(char *dst, const char *src, size_t size);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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 *dst, const char *src, size_t size);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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*));
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:39:56 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:35:17 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:14:04 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "list.h"
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:40:16 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:35:45 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "list.h"
|
||||
#include <unistd.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)
|
||||
|
|
|
|||
|
|
@ -6,18 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:40:37 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:33:31 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "list.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;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:42:11 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:36:07 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "list.h"
|
||||
#include <stdlib.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);
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:42:24 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:35:17 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "list.h"
|
||||
#include <unistd.h>
|
||||
|
||||
/**
|
||||
* @brief Apply the fstunction 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)
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:42:54 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:36:47 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:14:04 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "list.h"
|
||||
#include <unistd.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)
|
||||
|
|
|
|||
|
|
@ -6,21 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:43:28 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:37:46 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "list.h"
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:44:02 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:39:00 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "list.h"
|
||||
#include <stdlib.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;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:44:24 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:39:28 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:14:04 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "list.h"
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:43:13 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:39:50 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "memory.h"
|
||||
#include <unistd.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);
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 18:28:34 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:25:35 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "memory.h"
|
||||
#include <stdlib.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;
|
||||
|
|
|
|||
|
|
@ -6,23 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:48:30 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:40:36 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:26:04 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "memory.h"
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,24 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:49:04 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:40:58 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:26:04 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,21 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:49:46 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:41:32 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:26:04 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:51:35 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/04 11:56:02 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -37,15 +37,6 @@ static 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;
|
||||
|
|
|
|||
|
|
@ -6,21 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:50:29 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 16:42:01 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/14 17:27:44 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/04 11:56:27 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -44,13 +44,6 @@ static int _check_args(int fd, char c, va_list args, int *ret)
|
|||
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;
|
||||
|
|
@ -77,12 +70,6 @@ int ft_dprintf(int fd, const char *s, ...)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
|
|
|||
|
|
@ -6,18 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:58:22 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:46:44 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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);
|
||||
|
|
|
|||
|
|
@ -6,18 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:59:01 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:46:30 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "print.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);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:59:18 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:47:41 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -41,12 +41,6 @@ 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;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:58:46 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:48:07 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "str.h"
|
||||
#include <unistd.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));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:56:02 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:49:19 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -74,15 +74,6 @@ 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;
|
||||
|
|
|
|||
|
|
@ -6,22 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:32:19 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:49:27 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "str.h"
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,23 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:50:06 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:21:46 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,20 +6,12 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 16:14:10 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:36:18 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,21 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:53:59 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:58:58 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "str.h"
|
||||
#include <stdlib.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;
|
||||
|
|
|
|||
|
|
@ -6,20 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:57:34 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:50:26 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,22 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:55:15 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:58:58 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "str.h"
|
||||
#include <stdlib.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;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 22:28:26 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:52:29 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,15 +23,6 @@ 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;
|
||||
|
|
|
|||
|
|
@ -6,22 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:55:25 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:52:00 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "str.h"
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:24 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 18:34:21 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:56:57 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 18:28:51 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,15 +14,6 @@
|
|||
#include "str.h"
|
||||
#include <stdlib.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;
|
||||
|
|
|
|||
|
|
@ -6,21 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:54:01 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,21 +6,12 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 16:14:10 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 18:46:55 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* @brief Copies a string.
|
||||
*
|
||||
* @param dst The destination buffer.
|
||||
* @param src The source string.
|
||||
* @param size The size to copy
|
||||
*
|
||||
* @return A pointer to `dst`.
|
||||
*/
|
||||
char *ft_strcpy(char *dst, const char *src, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,26 +6,12 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:57:44 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:54:58 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,22 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:58:22 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 17:49:39 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "str.h"
|
||||
#include <unistd.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;
|
||||
|
|
|
|||
|
|
@ -6,21 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:55:44 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 18:26:20 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:16:46 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "str.h"
|
||||
#include <stdlib.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;
|
||||
|
|
|
|||
|
|
@ -6,22 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:54:42 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/01 18:26:29 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "str.h"
|
||||
#include <stdlib.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;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/04 16:54:42 by rparodi #+# #+# */
|
||||
/* Updated: 2025/09/05 15:08:52 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/05 16:10:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue