]> Untitled Git - axy/ft/ft_printf.git/commitdiff
initial commit (+libft)
author= <=>
Wed, 29 Oct 2025 13:14:26 +0000 (14:14 +0100)
committer= <=>
Wed, 29 Oct 2025 13:14:26 +0000 (14:14 +0100)
45 files changed:
libft/Makefile [new file with mode: 0644]
libft/ft_atoi.c [new file with mode: 0644]
libft/ft_bzero.c [new file with mode: 0644]
libft/ft_calloc.c [new file with mode: 0644]
libft/ft_isalnum.c [new file with mode: 0644]
libft/ft_isalpha.c [new file with mode: 0644]
libft/ft_isascii.c [new file with mode: 0644]
libft/ft_isdigit.c [new file with mode: 0644]
libft/ft_isprint.c [new file with mode: 0644]
libft/ft_itoa.c [new file with mode: 0644]
libft/ft_lstadd_back.c [new file with mode: 0644]
libft/ft_lstadd_front.c [new file with mode: 0644]
libft/ft_lstclear.c [new file with mode: 0644]
libft/ft_lstdelone.c [new file with mode: 0644]
libft/ft_lstiter.c [new file with mode: 0644]
libft/ft_lstlast.c [new file with mode: 0644]
libft/ft_lstmap.c [new file with mode: 0644]
libft/ft_lstnew.c [new file with mode: 0644]
libft/ft_lstsize.c [new file with mode: 0644]
libft/ft_memchr.c [new file with mode: 0644]
libft/ft_memcmp.c [new file with mode: 0644]
libft/ft_memcpy.c [new file with mode: 0644]
libft/ft_memmove.c [new file with mode: 0644]
libft/ft_memset.c [new file with mode: 0644]
libft/ft_putchar_fd.c [new file with mode: 0644]
libft/ft_putendl_fd.c [new file with mode: 0644]
libft/ft_putnbr_fd.c [new file with mode: 0644]
libft/ft_putstr_fd.c [new file with mode: 0644]
libft/ft_split.c [new file with mode: 0644]
libft/ft_strchr.c [new file with mode: 0644]
libft/ft_strdup.c [new file with mode: 0644]
libft/ft_striteri.c [new file with mode: 0644]
libft/ft_strjoin.c [new file with mode: 0644]
libft/ft_strlcat.c [new file with mode: 0644]
libft/ft_strlcpy.c [new file with mode: 0644]
libft/ft_strlen.c [new file with mode: 0644]
libft/ft_strmapi.c [new file with mode: 0644]
libft/ft_strncmp.c [new file with mode: 0644]
libft/ft_strnstr.c [new file with mode: 0644]
libft/ft_strrchr.c [new file with mode: 0644]
libft/ft_strtrim.c [new file with mode: 0644]
libft/ft_substr.c [new file with mode: 0644]
libft/ft_tolower.c [new file with mode: 0644]
libft/ft_toupper.c [new file with mode: 0644]
libft/libft.h [new file with mode: 0644]

diff --git a/libft/Makefile b/libft/Makefile
new file mode 100644 (file)
index 0000000..a423fba
--- /dev/null
@@ -0,0 +1,34 @@
+NAME=libft.a
+
+SRCS=ft_calloc.c ft_strnstr.c ft_isdigit.c ft_strrchr.c ft_strncmp.c ft_strjoin.c ft_toupper.c ft_tolower.c ft_strlcat.c ft_strchr.c ft_strdup.c ft_atoi.c ft_strtrim.c ft_substr.c ft_split.c ft_isalpha.c ft_isascii.c ft_isprint.c ft_isalnum.c ft_memset.c ft_bzero.c ft_memcpy.c ft_memmove.c ft_memchr.c ft_strlen.c ft_strlcpy.c ft_memcmp.c ft_itoa.c ft_strmapi.c ft_striteri.c ft_putchar_fd.c ft_putstr_fd.c ft_putendl_fd.c ft_putnbr_fd.c
+
+BONUS_SRCS=ft_lstnew.c ft_lstadd_front.c ft_lstsize.c ft_lstlast.c ft_lstadd_back.c ft_lstdelone.c ft_lstclear.c ft_lstiter.c ft_lstmap.c
+
+OBJS=${SRCS:.c=.o}
+
+BONUS_OBJS=${BONUS_SRCS:.c=.o}
+
+CFLAGS=-Wall -Wextra -Werror
+
+CC=cc
+
+all : ${NAME}
+
+%.o : %.c
+       ${CC} ${CFLAGS} -c -o $@ -- $<
+
+${NAME} : ${OBJS}
+       ar -rcs $@ $^
+
+bonus : ${BONUS_OBJS}
+       ar -rcs ${NAME} $^
+
+clean : 
+       rm -f ${OBJS} ${BONUS_OBJS}
+
+fclean : clean
+       rm -f ${NAME}
+
+re : fclean all
+
+.PHONY : all clean fclean re
diff --git a/libft/ft_atoi.c b/libft/ft_atoi.c
new file mode 100644 (file)
index 0000000..b31be33
--- /dev/null
@@ -0,0 +1,38 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_atoi.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:05:22 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:13:14 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdbool.h>
+#include "libft.h"
+
+static bool    ft_isspace(char c)
+{
+       return (c == ' ' || (c >= '\t' && c <= '\r'));
+}
+
+int    ft_atoi(const char *nptr)
+{
+       int     sign;
+       int     res;
+
+       sign = 1;
+       res = 0;
+       while (ft_isspace(*nptr))
+               nptr++;
+       if (*nptr == '-')
+               sign = -1;
+       else if (*nptr != '+')
+               nptr--;
+       nptr++;
+       while (ft_isdigit(*nptr))
+               res = res * 10 + sign * (*(nptr++) - '0');
+       return (res);
+}
diff --git a/libft/ft_bzero.c b/libft/ft_bzero.c
new file mode 100644 (file)
index 0000000..29aafa1
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_bzero.c                                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:47:42 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:47:59 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void   *ft_bzero(void *s, size_t n)
+{
+       return (ft_memset(s, '\0', n));
+}
diff --git a/libft/ft_calloc.c b/libft/ft_calloc.c
new file mode 100644 (file)
index 0000000..5b6d5ce
--- /dev/null
@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_calloc.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:52:41 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:55:36 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "libft.h"
+
+void   *ft_calloc(size_t nmemb, size_t size)
+{
+       void    *res;
+       size_t  alloc;
+
+       if (__builtin_mul_overflow(nmemb, size, &alloc))
+               return (NULL);
+       res = malloc(alloc);
+       if (res)
+               ft_bzero(res, alloc);
+       return (res);
+}
diff --git a/libft/ft_isalnum.c b/libft/ft_isalnum.c
new file mode 100644 (file)
index 0000000..3fbaba8
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isalnum.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:42:58 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:43:50 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int    ft_isalnum(int c)
+{
+       return (ft_isalpha(c) || ft_isdigit(c));
+}
diff --git a/libft/ft_isalpha.c b/libft/ft_isalpha.c
new file mode 100644 (file)
index 0000000..b4c95db
--- /dev/null
@@ -0,0 +1,16 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isalpha.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:42:17 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:42:31 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_isalpha(int c)
+{
+       return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
+}
diff --git a/libft/ft_isascii.c b/libft/ft_isascii.c
new file mode 100644 (file)
index 0000000..ca4fb05
--- /dev/null
@@ -0,0 +1,16 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isascii.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:43:14 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:43:17 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_isascii(int c)
+{
+       return (c >= '\0' && c <= '\x7F');
+}
diff --git a/libft/ft_isdigit.c b/libft/ft_isdigit.c
new file mode 100644 (file)
index 0000000..417eb36
--- /dev/null
@@ -0,0 +1,16 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isdigit.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:42:38 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:42:45 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_isdigit(int c)
+{
+       return (c >= '0' && c <= '9');
+}
diff --git a/libft/ft_isprint.c b/libft/ft_isprint.c
new file mode 100644 (file)
index 0000000..dcd2df9
--- /dev/null
@@ -0,0 +1,16 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isprint.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:43:29 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:43:32 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_isprint(int c)
+{
+       return (c >= ' ' && c <= '~');
+}
diff --git a/libft/ft_itoa.c b/libft/ft_itoa.c
new file mode 100644 (file)
index 0000000..2ea2653
--- /dev/null
@@ -0,0 +1,54 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_itoa.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:19:15 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:34:53 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+#include <stdlib.h>
+
+static void    ft_itoa_visit(long n, void (*f)(void *, char), void *f_dat)
+{
+       if (n < 0)
+       {
+               f(f_dat, '-');
+               return (ft_itoa_visit(-n, f, f_dat));
+       }
+       if (n > 9)
+               ft_itoa_visit(n / 10, f, f_dat);
+       f(f_dat, '0' + n % 10);
+}
+
+static void    ft_itoa_count(size_t *count, char _c)
+{
+       (void) _c;
+       (*count)++;
+}
+
+static void    ft_itoa_write(char **buf, char c)
+{
+       *((*buf)++) = c;
+}
+
+char   *ft_itoa(int n)
+{
+       size_t  len;
+       char    *res;
+       char    *dat;
+
+       len = 1;
+       ft_itoa_visit(n, (void (*)(void *, char))ft_itoa_count, &len);
+       res = malloc(len);
+       if (!res)
+               return (res);
+       dat = res;
+       ft_itoa_visit(n, (void (*)(void *, char)) ft_itoa_write, &dat);
+       *dat = '\0';
+       return (res);
+}
diff --git a/libft/ft_lstadd_back.c b/libft/ft_lstadd_back.c
new file mode 100644 (file)
index 0000000..d0881fc
--- /dev/null
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstadd_back.c                                   :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 12:55:01 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 12:57:51 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void   ft_lstadd_back(t_list **lst, t_list *new)
+{
+       if (!(*lst))
+               *lst = new;
+       else
+               ft_lstadd_back(&(*lst)->next, new);
+}
diff --git a/libft/ft_lstadd_front.c b/libft/ft_lstadd_front.c
new file mode 100644 (file)
index 0000000..36e03c1
--- /dev/null
@@ -0,0 +1,19 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstadd_front.c                                  :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 12:09:55 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 12:14:27 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void   ft_lstadd_front(t_list **lst, t_list *new)
+{
+       new->next = *lst;
+       *lst = new;
+}
diff --git a/libft/ft_lstclear.c b/libft/ft_lstclear.c
new file mode 100644 (file)
index 0000000..caeb50b
--- /dev/null
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstclear.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 13:03:33 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 13:10:12 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include "libft.h"
+
+void   ft_lstclear(t_list **lst, void (*del)(void *))
+{
+       t_list  *lst_next;
+
+       if (!*lst)
+               return ;
+       lst_next = (*lst)->next;
+       ft_lstdelone(*lst, del);
+       *lst = lst_next;
+       ft_lstclear(lst, del);
+}
diff --git a/libft/ft_lstdelone.c b/libft/ft_lstdelone.c
new file mode 100644 (file)
index 0000000..9bb8d7f
--- /dev/null
@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstdelone.c                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 12:58:54 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 13:00:44 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+void   ft_lstdelone(t_list *lst, void (*del)(void *))
+{
+       del(lst->content);
+       free(lst);
+}
diff --git a/libft/ft_lstiter.c b/libft/ft_lstiter.c
new file mode 100644 (file)
index 0000000..55a154d
--- /dev/null
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstiter.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 13:10:47 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 13:13:22 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void   ft_lstiter(t_list *lst, void (*f)(void *))
+{
+       if (!lst)
+               return ;
+       f(lst->content);
+       ft_lstiter(lst->next, f);
+}
diff --git a/libft/ft_lstlast.c b/libft/ft_lstlast.c
new file mode 100644 (file)
index 0000000..8c14481
--- /dev/null
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstlast.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 12:18:37 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 12:21:34 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+t_list *ft_lstlast(t_list *lst)
+{
+       if (!lst || !lst->next)
+               return (lst);
+       else
+               return (ft_lstlast(lst->next));
+}
diff --git a/libft/ft_lstmap.c b/libft/ft_lstmap.c
new file mode 100644 (file)
index 0000000..5ead31d
--- /dev/null
@@ -0,0 +1,35 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstmap.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 13:13:59 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 13:32:14 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include "libft.h"
+
+t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
+{
+       t_list  *res;
+       void    *content;
+
+       if (!lst)
+               return (NULL);
+       content = f(lst->content);
+       res = ft_lstnew(content);
+       if (!res)
+               return (del(content), NULL);
+       if (!lst->next)
+               return (res);
+       res->next = ft_lstmap(lst->next, f, del);
+       if (res->next)
+               return (res);
+       del(res->content);
+       free(res);
+       return (NULL);
+}
diff --git a/libft/ft_lstnew.c b/libft/ft_lstnew.c
new file mode 100644 (file)
index 0000000..0b6da10
--- /dev/null
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstnew.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 12:05:45 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 12:07:12 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+t_list *ft_lstnew(void *content)
+{
+       t_list  *res;
+
+       res = malloc(sizeof(t_list));
+       if (!res)
+               return (res);
+       res->next = 0;
+       res->content = content;
+       return (res);
+}
diff --git a/libft/ft_lstsize.c b/libft/ft_lstsize.c
new file mode 100644 (file)
index 0000000..869a15e
--- /dev/null
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstsize.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 12:15:01 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 12:16:55 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int    ft_lstsize(t_list *lst)
+{
+       if (lst)
+               return (ft_lstsize(lst->next) + 1);
+       else
+               return (0);
+}
diff --git a/libft/ft_memchr.c b/libft/ft_memchr.c
new file mode 100644 (file)
index 0000000..b8e1820
--- /dev/null
@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memchr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:48:41 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:14:45 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+void   *ft_memchr(const void *s, int c, size_t n)
+{
+       size_t  i;
+
+       i = 0;
+       while (i < n)
+       {
+               if (((unsigned char *)s)[i] == (unsigned char)c)
+                       return ((void *)&((unsigned char *)s)[i]);
+               i++;
+       }
+       return (NULL);
+}
diff --git a/libft/ft_memcmp.c b/libft/ft_memcmp.c
new file mode 100644 (file)
index 0000000..2327d56
--- /dev/null
@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memcmp.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:51:58 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:15:40 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+int    ft_memcmp(const void *s1, const void *s2, size_t n)
+{
+       size_t  i;
+       int             res;
+
+       i = 0;
+       res = 0;
+       while (res == 0 && i < n)
+       {
+               res = ((unsigned char *) s1)[i] - ((unsigned char *) s2)[i];
+               i++;
+       }
+       return (res);
+}
diff --git a/libft/ft_memcpy.c b/libft/ft_memcpy.c
new file mode 100644 (file)
index 0000000..99619a2
--- /dev/null
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memcpy.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:48:05 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:13:48 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+void   *ft_memcpy(void *restrict dest, const void *src, size_t n)
+{
+       size_t  i;
+
+       i = 0;
+       while (i < n)
+       {
+               ((unsigned char *)dest)[i] = ((unsigned char *)src)[i];
+               i++;
+       }
+       return (dest);
+}
diff --git a/libft/ft_memmove.c b/libft/ft_memmove.c
new file mode 100644 (file)
index 0000000..a9bb4e8
--- /dev/null
@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memmove.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:48:19 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:14:18 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+void   *ft_memmove(void *dest, const void *src, size_t n)
+{
+       size_t  i;
+
+       if (dest < src)
+       {
+               i = 0;
+               while (i < n)
+               {
+                       ((unsigned char *)dest)[i] = ((unsigned char *)src)[i];
+                       i++;
+               }
+       }
+       else
+               while (n--)
+                       ((unsigned char *)dest)[n] = ((unsigned char *)src)[n];
+       return (dest);
+}
diff --git a/libft/ft_memset.c b/libft/ft_memset.c
new file mode 100644 (file)
index 0000000..f0815fa
--- /dev/null
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memset.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:47:17 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:13:36 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+void   *ft_memset(void *s, int c, size_t n)
+{
+       size_t  i;
+
+       i = 0;
+       while (i < n)
+               ((unsigned char *) s)[i++] = c;
+       return (s);
+}
diff --git a/libft/ft_putchar_fd.c b/libft/ft_putchar_fd.c
new file mode 100644 (file)
index 0000000..7805cf3
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putchar_fd.c                                    :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:52:35 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:54:15 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <unistd.h>
+
+void   ft_putchar_fd(char c, int fd)
+{
+       write(fd, &c, 1);
+}
diff --git a/libft/ft_putendl_fd.c b/libft/ft_putendl_fd.c
new file mode 100644 (file)
index 0000000..7f5cdee
--- /dev/null
@@ -0,0 +1,19 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putendl_fd.c                                    :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:57:18 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:58:07 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void   ft_putendl_fd(char *s, int fd)
+{
+       ft_putstr_fd(s, fd);
+       ft_putchar_fd('\n', fd);
+}
diff --git a/libft/ft_putnbr_fd.c b/libft/ft_putnbr_fd.c
new file mode 100644 (file)
index 0000000..2599618
--- /dev/null
@@ -0,0 +1,35 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putnbr_fd.c                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:59:59 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 11:12:16 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+static void    ft_itoa_visit(long n, void (*f)(void *, char), void *f_dat)
+{
+       if (n < 0)
+       {
+               f(f_dat, '-');
+               return (ft_itoa_visit(-n, f, f_dat));
+       }
+       if (n > 9)
+               ft_itoa_visit(n / 10, f, f_dat);
+       f(f_dat, '0' + n % 10);
+}
+
+void   ft_putnbr_fd_write(int *fd, char c)
+{
+       ft_putchar_fd(c, *fd);
+}
+
+void   ft_putnbr_fd(int n, int fd)
+{
+       ft_itoa_visit(n, (void (*)(void *, char))ft_putnbr_fd_write, &fd);
+}
diff --git a/libft/ft_putstr_fd.c b/libft/ft_putstr_fd.c
new file mode 100644 (file)
index 0000000..90e5b5f
--- /dev/null
@@ -0,0 +1,19 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putstr_fd.c                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:55:24 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:56:44 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void   ft_putstr_fd(char *s, int fd)
+{
+       while (*s)
+               ft_putchar_fd(*(s++), fd);
+}
diff --git a/libft/ft_split.c b/libft/ft_split.c
new file mode 100644 (file)
index 0000000..765d7c7
--- /dev/null
@@ -0,0 +1,82 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_split.c                                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/28 12:08:04 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:37:49 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+static size_t  ft_strlen_term(const char *s, char c)
+{
+       size_t  i;
+
+       i = 0;
+       while (s[i] && s[i] != c)
+               i++;
+       return (i);
+}
+
+static char    **ft_split_cleanup(char **res, size_t len)
+{
+       size_t  i;
+
+       i = 0;
+       while (i < len)
+               free(res[i++]);
+       free(res);
+       return (NULL);
+}
+
+/*
+       Weird Formatting from norminette on that else, for some reason
+*/
+static char    **ft_split_with(char **res, const char *s, char c)
+{
+       size_t  i;
+
+       if (!res)
+               return (res);
+       i = 0;
+       while (*s)
+       {
+               if (ft_strlen_term(s, c) == 0)
+                       s++;
+               else
+               {
+                       res[i] = ft_substr(s, 0, ft_strlen_term(s, c));
+                       if (!res[i])
+                               return (ft_split_cleanup(res, i));
+                       i++;
+                       s += ft_strlen_term(s, c);
+               }
+       }
+       res[i] = NULL;
+       return (res);
+}
+
+char   **ft_split(const char *s, char c)
+{
+       size_t  i;
+       size_t  len;
+
+       i = 0;
+       len = 1;
+       while (s[i])
+       {
+               if (ft_strlen_term(&s[i], c) == 0)
+                       i++;
+               else
+               {
+                       i += ft_strlen_term(&s[i], c);
+                       len++;
+               }
+       }
+       return (ft_split_with(malloc(sizeof(char *) * len), s, c));
+}
diff --git a/libft/ft_strchr.c b/libft/ft_strchr.c
new file mode 100644 (file)
index 0000000..5db2152
--- /dev/null
@@ -0,0 +1,22 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strchr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:50:12 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:51:18 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+char   *ft_strchr(const char *s, int c)
+{
+       while (*s != (char)c && *s != '\0')
+               s++;
+       if (*s == (char)c)
+               return ((char *) s);
+       return (NULL);
+}
diff --git a/libft/ft_strdup.c b/libft/ft_strdup.c
new file mode 100644 (file)
index 0000000..3901588
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strdup.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:01:04 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:12:32 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char   *ft_strdup(char *src)
+{
+       return (ft_substr(src, 0, ft_strlen(src)));
+}
diff --git a/libft/ft_striteri.c b/libft/ft_striteri.c
new file mode 100644 (file)
index 0000000..c335ce9
--- /dev/null
@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_striteri.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:48:45 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:51:20 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+void   ft_striteri(char *s, void (*f)(unsigned int, char*))
+{
+       size_t  i;
+
+       i = 0;
+       while (s[i])
+       {
+               f(i, &s[i]);
+               i++;
+       }
+}
diff --git a/libft/ft_strjoin.c b/libft/ft_strjoin.c
new file mode 100644 (file)
index 0000000..0bb0d59
--- /dev/null
@@ -0,0 +1,31 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strjoin.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:08:19 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:08:40 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+char   *ft_strjoin(const char *s1, const char *s2)
+{
+       size_t  l1;
+       size_t  l2;
+       char    *res;
+
+       l1 = ft_strlen(s1);
+       l2 = ft_strlen(s2);
+       res = malloc(l1 + l2 + 1);
+       if (!res)
+               return (res);
+       ft_memcpy(res, s1, l1);
+       ft_memcpy(&res[l1], s2, l2);
+       res[l1 + l2] = '\0';
+       return (res);
+}
diff --git a/libft/ft_strlcat.c b/libft/ft_strlcat.c
new file mode 100644 (file)
index 0000000..621b347
--- /dev/null
@@ -0,0 +1,36 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strlcat.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:49:32 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:12:16 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+size_t ft_strlcat(char *dest, const char *src, size_t size)
+{
+       size_t  src_len;
+       size_t  dest_len;
+       size_t  i;
+
+       src_len = 0;
+       while (src[src_len])
+               src_len++;
+       dest_len = 0;
+       while (dest_len < size && dest[dest_len])
+               dest_len++;
+       i = 0;
+       while (dest_len + i + 1 < size && i < src_len)
+       {
+               dest[dest_len + i] = src[i];
+               i++;
+       }
+       if (dest_len != size)
+               dest[dest_len + i] = '\0';
+       return (src_len + dest_len);
+}
diff --git a/libft/ft_strlcpy.c b/libft/ft_strlcpy.c
new file mode 100644 (file)
index 0000000..e46eeea
--- /dev/null
@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strlcpy.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:49:19 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:15:19 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+size_t ft_strlcpy(char *dest, const char *src, size_t size)
+{
+       size_t  len;
+       size_t  i;
+
+       len = 0;
+       while (src[len] != '\0')
+               len++;
+       if (size == 0)
+               return (len);
+       i = 0;
+       while (i < len && i < size - 1)
+               *dest++ = src[i++];
+       *dest = '\0';
+       return (len);
+}
diff --git a/libft/ft_strlen.c b/libft/ft_strlen.c
new file mode 100644 (file)
index 0000000..81b77be
--- /dev/null
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strlen.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:48:58 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:14:59 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+size_t ft_strlen(const char *s)
+{
+       size_t  i;
+
+       i = 0;
+       while (s[i] != '\0')
+               i++;
+       return (i);
+}
diff --git a/libft/ft_strmapi.c b/libft/ft_strmapi.c
new file mode 100644 (file)
index 0000000..436f395
--- /dev/null
@@ -0,0 +1,34 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strmapi.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:39:05 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:46:55 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include "libft.h"
+
+char   *ft_strmapi(const char *s, char (*f)(unsigned int, char))
+{
+       size_t  len;
+       char    *res;
+       size_t  i;
+
+       len = ft_strlen(s);
+       res = malloc(len + 1);
+       if (!res)
+               return (res);
+       i = 0;
+       while (i < len)
+       {
+               res[i] = f(i, s[i]);
+               i++;
+       }
+       res[i] = '\0';
+       return (res);
+}
diff --git a/libft/ft_strncmp.c b/libft/ft_strncmp.c
new file mode 100644 (file)
index 0000000..f53ddbc
--- /dev/null
@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strncmp.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:03:01 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:04:21 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+int    ft_strncmp(const char *s1, const char *s2, size_t n)
+{
+       size_t  idx;
+
+       if (n == 0)
+               return (0);
+       idx = 0;
+       while (s1[idx] != '\0' && s1[idx] == s2[idx] && idx < n - 1)
+               idx++;
+       return ((unsigned char) s1[idx] - (unsigned char) s2[idx]);
+}
diff --git a/libft/ft_strnstr.c b/libft/ft_strnstr.c
new file mode 100644 (file)
index 0000000..80ed25d
--- /dev/null
@@ -0,0 +1,35 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strnstr.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:04:47 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:05:14 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+
+char   *ft_strnstr(const char *big, const char *little, size_t len)
+{
+       size_t  i;
+       size_t  j;
+
+       i = 0;
+       j = 0;
+       while (little[i] && i + j < len && big[i + j])
+       {
+               if (big[i + j] != little[i])
+               {
+                       i = 0;
+                       j++;
+               }
+               else
+                       i++;
+       }
+       if (little[i])
+               return (NULL);
+       return ((char *)&big[j]);
+}
diff --git a/libft/ft_strrchr.c b/libft/ft_strrchr.c
new file mode 100644 (file)
index 0000000..c54f1d8
--- /dev/null
@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strrchr.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:51:22 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:37:33 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stddef.h>
+#include <stdbool.h>
+
+char   *ft_strrchr(const char *s, int c)
+{
+       char    *res;
+
+       res = (char *) s;
+       while (true)
+       {
+               if (*s == (char)c)
+                       res = (char *) s;
+               if (!*s)
+                       break ;
+               s++;
+       }
+       if (*res == (char)c)
+               return (res);
+       return (NULL);
+}
diff --git a/libft/ft_strtrim.c b/libft/ft_strtrim.c
new file mode 100644 (file)
index 0000000..0a17515
--- /dev/null
@@ -0,0 +1,36 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strtrim.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:08:47 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:13:24 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdbool.h>
+#include "libft.h"
+
+static bool    ft_char_in_set(char c, const char *set)
+{
+       while (*set && *set != c)
+               set++;
+       return (*set == c);
+}
+
+char   *ft_strtrim(const char *s1, const char *set)
+{
+       size_t  i;
+       size_t  len;
+
+       while (*s1 && ft_char_in_set(*s1, set))
+               s1++;
+       i = 0;
+       len = 0;
+       while (s1[i])
+               if (!ft_char_in_set(s1[i++], set))
+                       len = i;
+       return (ft_substr(s1, 0, len));
+}
diff --git a/libft/ft_substr.c b/libft/ft_substr.c
new file mode 100644 (file)
index 0000000..bd41643
--- /dev/null
@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_substr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 10:07:38 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 10:08:13 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include "libft.h"
+
+char   *ft_substr(const char *s, unsigned int start, size_t len)
+{
+       size_t  s_len;
+       char    *res;
+
+       s_len = ft_strlen(s);
+       if (start > s_len)
+               start = s_len;
+       if (len > s_len - start)
+               len = s_len - start;
+       res = malloc(len + 1);
+       if (!res)
+               return (res);
+       ft_memcpy(res, s + start, len);
+       res[len] = '\0';
+       return (res);
+}
diff --git a/libft/ft_tolower.c b/libft/ft_tolower.c
new file mode 100644 (file)
index 0000000..1797e5d
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_tolower.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:44:28 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:44:39 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_tolower(int c)
+{
+       if (c >= 'A' && c <= 'Z')
+               c = c - 'A' + 'a';
+       return (c);
+}
diff --git a/libft/ft_toupper.c b/libft/ft_toupper.c
new file mode 100644 (file)
index 0000000..570fbe7
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_toupper.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/29 09:44:12 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 09:44:20 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_toupper(int c)
+{
+       if (c >= 'a' && c <= 'z')
+               c = c - 'a' + 'A';
+       return (c);
+}
diff --git a/libft/libft.h b/libft/libft.h
new file mode 100644 (file)
index 0000000..7d32994
--- /dev/null
@@ -0,0 +1,69 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   libft.h                                            :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/10/27 11:27:06 by agilliar          #+#    #+#             */
+/*   Updated: 2025/10/29 13:31:51 by agilliar         ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef LIBFT_H
+# define LIBFT_H
+
+# include <stddef.h>
+
+int            ft_memcmp(const void *s1, const void *s2, size_t n);
+void   *ft_calloc(size_t nmemb, size_t size);
+char   *ft_strdup(char *src);
+int            ft_strncmp(const char *s1, const char *s2, size_t n);
+char   *ft_strnstr(const char *big, const char *little, size_t len);
+int            ft_atoi(const char *nptr);
+char   *ft_substr(const char *s, unsigned int start, size_t len);
+void   *ft_memset(void *s, int c, size_t n);
+void   *ft_bzero(void *s, size_t n);
+void   *ft_memcpy(void *dest, const void *src, size_t n);
+void   *ft_memmove(void *dest, const void *src, size_t n);
+void   *ft_memchr(const void *s, int c, size_t n);
+size_t ft_strlen(const char *s);
+size_t ft_strlcpy(char *dest, const char *src, size_t size);
+size_t ft_strlcat(char *dest, const char *src, size_t size);
+char   *ft_strchr(const char *s, int c);
+char   *ft_strrchr(const char *s, int c);
+int            ft_isalpha(int c);
+int            ft_isdigit(int c);
+int            ft_isalnum(int c);
+int            ft_isascii(int c);
+int            ft_isprint(int c);
+char   *ft_strjoin(const char *s1, const char *s2);
+char   *ft_strtrim(const char *s1, const char *set);
+int            ft_toupper(int c);
+int            ft_tolower(int c);
+char   **ft_split(const char *s, char c);
+char   *ft_itoa(int n);
+char   *ft_strmapi(const char *s, char (*f)(unsigned int, char));
+void   ft_striteri(char *s, void (*f)(unsigned int, char*));
+void   ft_putchar_fd(char c, int fd);
+void   ft_putstr_fd(char *s, int fd);
+void   ft_putendl_fd(char *s, int fd);
+void   ft_putnbr_fd(int n, int fd);
+
+typedef struct s_list
+{
+       void                    *content;
+       struct s_list   *next;
+}                                      t_list;
+
+t_list *ft_lstnew(void *content);
+void   ft_lstadd_front(t_list **lst, t_list *new);
+int            ft_lstsize(t_list *lst);
+t_list *ft_lstlast(t_list *lst);
+void   ft_lstadd_back(t_list **lst, t_list *new);
+void   ft_lstdelone(t_list *lst, void (*del)(void *));
+void   ft_lstclear(t_list **lst, void (*del)(void *));
+void   ft_lstiter(t_list *lst, void (*f)(void *));
+t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
+
+#endif