├── README.md ├── ft_bzero.c ├── ft_isascii.c ├── ft_isdigit.c ├── ft_isprint.c ├── ft_putchar_fd.c ├── ft_isalnum.c ├── ft_putstr_fd.c ├── ft_isalpha.c ├── ft_tolower.c ├── ft_toupper.c ├── ft_strlen.c ├── ft_putendl_fd.c ├── ft_lstlast.c ├── ft_lstadd_front.c ├── ft_lstdelone.c ├── ft_memset.c ├── ft_striteri.c ├── ft_calloc.c ├── ft_lstsize.c ├── ft_lstiter.c ├── ft_memchr.c ├── ft_strrchr.c ├── ft_strchr.c ├── ft_lstnew.c ├── ft_lstclear.c ├── ft_memcmp.c ├── ft_putnbr_fd.c ├── ft_lstadd_back.c ├── ft_memcpy.c ├── ft_strlcpy.c ├── ft_strncmp.c ├── ft_memmove.c ├── ft_strdup.c ├── ft_strmapi.c ├── ft_strtrim.c ├── ft_atoi.c ├── ft_substr.c ├── ft_strjoin.c ├── ft_lstmap.c ├── ft_strnstr.c ├── ft_strlcat.c ├── ft_itoa.c ├── ft_split.c ├── Makefile └── libft.h /README.md: -------------------------------------------------------------------------------- 1 | # libft 2 | -------------------------------------------------------------------------------- /ft_bzero.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_bzero.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/07 19:08:48 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 15:56:31 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_bzero(void *s, size_t n) 16 | { 17 | ft_memset(s, 0, n); 18 | } 19 | -------------------------------------------------------------------------------- /ft_isascii.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isascii.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 13:56:01 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/20 22:41:04 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isascii(int c) 16 | { 17 | return (c >= 0x00 && c <= 0x7f); 18 | } 19 | -------------------------------------------------------------------------------- /ft_isdigit.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isdigit.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 13:52:59 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 15:55:57 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isdigit(int c) 16 | { 17 | return (c >= 0x30 && c <= 0x39); 18 | } 19 | -------------------------------------------------------------------------------- /ft_isprint.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isprint.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 13:57:02 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 15:56:12 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isprint(int c) 16 | { 17 | return (c >= 0x20 && c <= 0x7e); 18 | } 19 | -------------------------------------------------------------------------------- /ft_putchar_fd.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putchar_fd.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/21 09:05:53 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:16:21 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_putchar_fd(char c, int fd) 16 | { 17 | write(fd, &c, 1); 18 | } 19 | -------------------------------------------------------------------------------- /ft_isalnum.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isalnum.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 13:53:49 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/20 22:41:00 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isalnum(int c) 16 | { 17 | return (ft_isalpha(c) || ft_isdigit(c)); 18 | } 19 | -------------------------------------------------------------------------------- /ft_putstr_fd.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr_fd.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/21 09:08:16 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:18:24 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_putstr_fd(char *s, int fd) 16 | { 17 | if (s) 18 | write(fd, s, ft_strlen(s)); 19 | } 20 | -------------------------------------------------------------------------------- /ft_isalpha.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isalpha.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/07 18:54:47 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/20 22:40:56 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_isalpha(int c) 16 | { 17 | return ((c >= 0x41 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a)); 18 | } 19 | -------------------------------------------------------------------------------- /ft_tolower.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_tolower.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 14:44:44 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 15:59:37 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_tolower(int c) 16 | { 17 | if (c >= 0x41 && c <= 0x5a) 18 | return (c + 0x20); 19 | return (c); 20 | } 21 | -------------------------------------------------------------------------------- /ft_toupper.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_toupper.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 14:05:03 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 15:59:08 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_toupper(int c) 16 | { 17 | if (c >= 0x61 && c <= 0x7a) 18 | return (c - 0x20); 19 | return (c); 20 | } 21 | -------------------------------------------------------------------------------- /ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 13:58:05 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/25 11:45:35 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | size_t ft_strlen(const char *s) 16 | { 17 | const char *c; 18 | 19 | c = s; 20 | while (*c) 21 | c++; 22 | return ((c - s)); 23 | } 24 | -------------------------------------------------------------------------------- /ft_putendl_fd.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putendl_fd.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/21 09:15:02 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/27 02:11:14 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_putendl_fd(char *s, int fd) 16 | { 17 | if (!s) 18 | return ; 19 | write(fd, s, ft_strlen(s)); 20 | write(fd, "\n", 1); 21 | } 22 | -------------------------------------------------------------------------------- /ft_lstlast.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lstlast.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/22 06:29:29 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:21:18 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | t_list *ft_lstlast(t_list *lst) 16 | { 17 | if (lst) 18 | { 19 | while (lst->next) 20 | lst = lst->next; 21 | } 22 | return (lst); 23 | } 24 | -------------------------------------------------------------------------------- /ft_lstadd_front.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lstadd_front.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/22 03:10:03 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/28 16:02:49 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_lstadd_front(t_list **lst, t_list *new) 16 | { 17 | if (new && lst) 18 | { 19 | new->next = *lst; 20 | *lst = new; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ft_lstdelone.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lstdelone.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/22 08:37:37 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:22:17 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_lstdelone(t_list *lst, void (*del)(void*)) 16 | { 17 | if (!lst || !del) 18 | return ; 19 | del(lst->content); 20 | free (lst); 21 | } 22 | -------------------------------------------------------------------------------- /ft_memset.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memset.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/07 18:56:23 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/25 22:51:17 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_memset(void *b, int c, size_t len) 16 | { 17 | while (len) 18 | *(unsigned char *)(b + --len) = (unsigned char)c; 19 | return (b); 20 | } 21 | -------------------------------------------------------------------------------- /ft_striteri.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_striteri.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/21 08:48:00 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/27 02:23:37 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_striteri(char *s, void (*f)(unsigned int, char*)) 16 | { 17 | unsigned int i; 18 | 19 | i = 0; 20 | if (s && f) 21 | while (*s) 22 | f(i++, s++); 23 | } 24 | -------------------------------------------------------------------------------- /ft_calloc.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_calloc.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/10 16:00:04 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/30 01:33:30 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_calloc(size_t count, size_t size) 16 | { 17 | void *p; 18 | 19 | p = malloc(count * size); 20 | if (p) 21 | ft_bzero(p, count * size); 22 | return (p); 23 | } 24 | -------------------------------------------------------------------------------- /ft_lstsize.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lstsize.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/22 06:26:19 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/28 04:30:34 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_lstsize(t_list *lst) 16 | { 17 | int count; 18 | 19 | count = 0; 20 | while (lst) 21 | { 22 | lst = lst->next; 23 | count++; 24 | } 25 | return (count); 26 | } 27 | -------------------------------------------------------------------------------- /ft_lstiter.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lstiter.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/22 12:09:03 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/22 12:15:50 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_lstiter(t_list *lst, void (*f)(void *)) 16 | { 17 | if (!lst || !f) 18 | return ; 19 | while (lst) 20 | { 21 | f(lst->content); 22 | lst = lst->next; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ft_memchr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memchr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/09 18:04:59 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 10:58:55 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_memchr(const void *s, int c, size_t n) 16 | { 17 | while (n--) 18 | if (*(unsigned char *)(s++) == (unsigned char)c) 19 | return ((void *)(s - 1)); 20 | return (NULL); 21 | } 22 | -------------------------------------------------------------------------------- /ft_strrchr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strrchr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 15:58:48 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/28 04:24:29 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strrchr(const char *s, int c) 16 | { 17 | int n; 18 | 19 | n = ft_strlen(s) + 1; 20 | while (--n > -1) 21 | if (*(s + n) == (char)c) 22 | return ((char *)(s + n)); 23 | return (NULL); 24 | } 25 | -------------------------------------------------------------------------------- /ft_strchr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strchr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 15:28:57 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 18:25:02 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strchr(const char *s, int c) 16 | { 17 | while (*(s++)) 18 | if (*(s - 1) == (char)c) 19 | return ((char *)(s - 1)); 20 | if (*(s - 1) == (char)c) 21 | return ((char *)(s - 1)); 22 | return (NULL); 23 | } 24 | -------------------------------------------------------------------------------- /ft_lstnew.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lstnew.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/22 02:58:35 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/28 04:30:39 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | t_list *ft_lstnew(void *content) 16 | { 17 | t_list *node; 18 | 19 | node = (t_list *)malloc(sizeof(t_list)); 20 | if (node) 21 | { 22 | node->content = content; 23 | node->next = NULL; 24 | } 25 | return (node); 26 | } 27 | -------------------------------------------------------------------------------- /ft_lstclear.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lstclear.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/22 10:04:52 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/27 02:14:15 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_lstclear(t_list **lst, void (*del)(void*)) 16 | { 17 | t_list *tmp; 18 | 19 | if (!lst || !del) 20 | return ; 21 | while (*lst) 22 | { 23 | tmp = (*lst)->next; 24 | ft_lstdelone(*lst, del); 25 | *lst = tmp; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ft_memcmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memcmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/09 18:18:39 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 11:01:21 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_memcmp(const void *s1, const void *s2, size_t n) 16 | { 17 | while (n-- > 0) 18 | if (*(unsigned char *)(s1++) != *(unsigned char *)(s2++)) 19 | return (*(unsigned char *)(s1 - 1) - *(unsigned char *)(s2 - 1)); 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /ft_putnbr_fd.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putnbr_fd.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/21 09:18:43 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/27 01:48:06 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_putnbr_fd(int n, int fd) 16 | { 17 | long long b; 18 | 19 | b = n; 20 | if (b < 0) 21 | { 22 | write(fd, "-", 1); 23 | b = -b; 24 | } 25 | if (b > 9) 26 | ft_putnbr_fd(b / 10, fd); 27 | ft_putchar_fd((b % 10) + 0x30, fd); 28 | } 29 | -------------------------------------------------------------------------------- /ft_lstadd_back.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lstadd_back.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/22 08:05:10 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:21:54 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void ft_lstadd_back(t_list **lst, t_list *new) 16 | { 17 | t_list *tmp; 18 | 19 | tmp = NULL; 20 | if (!new || !lst) 21 | return ; 22 | if (!*lst) 23 | *lst = new; 24 | else 25 | { 26 | tmp = ft_lstlast(*lst); 27 | tmp->next = new; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ft_memcpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memcpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 09:26:56 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/28 04:28:05 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_memcpy(void *dst, const void *src, size_t n) 16 | { 17 | size_t i; 18 | 19 | i = -1; 20 | if (dst == src || !n) 21 | return (dst); 22 | while (++i < n) 23 | *((unsigned char *)(dst + i)) = *((unsigned char *)(src + i)); 24 | return (dst); 25 | } 26 | -------------------------------------------------------------------------------- /ft_strlcpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlcpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/20 02:48:25 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 18:23:39 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | size_t ft_strlcpy(char *dst, const char *src, size_t dstsize) 16 | { 17 | size_t ls; 18 | 19 | ls = ft_strlen(src); 20 | if (dstsize == 0) 21 | return (ls); 22 | while (*src && --dstsize) 23 | *(dst++) = *(src++); 24 | *dst = '\0'; 25 | return (ls); 26 | } 27 | -------------------------------------------------------------------------------- /ft_strncmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 16:16:15 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/28 04:26:07 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_strncmp(const char *s1, const char *s2, size_t n) 16 | { 17 | if (!n) 18 | return (0); 19 | while (n--) 20 | { 21 | if (*s1 != *s2) 22 | return ((unsigned char)*s1 - (unsigned char)*s2); 23 | if (!*s1 && !*s2) 24 | return (0); 25 | s1++; 26 | s2++; 27 | } 28 | return (0); 29 | } 30 | -------------------------------------------------------------------------------- /ft_memmove.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_memmove.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/08 14:25:08 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:46:36 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | void *ft_memmove(void *dst, const void *src, size_t len) 16 | { 17 | if (!src && !dst) 18 | return (NULL); 19 | if (src < dst) 20 | while (len-- > 0) 21 | *((unsigned char *)(dst + len)) = *((unsigned char *)(src + len)); 22 | else 23 | return (ft_memcpy(dst, src, len)); 24 | return (dst); 25 | } 26 | -------------------------------------------------------------------------------- /ft_strdup.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strdup.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/10 17:13:32 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:05:41 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strdup(const char *s1) 16 | { 17 | char *dst; 18 | int count; 19 | 20 | count = -1; 21 | dst = (char *)ft_calloc((ft_strlen(s1) + 1), sizeof(char)); 22 | if (!dst) 23 | return (NULL); 24 | while (*(char *)(s1 + ++count)) 25 | *(dst + count) = *(char *)(s1 + count); 26 | return (dst); 27 | } 28 | -------------------------------------------------------------------------------- /ft_strmapi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strmapi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/19 05:26:24 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/27 01:39:36 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) 16 | { 17 | unsigned int i; 18 | char *str; 19 | 20 | if (!s || !f) 21 | return (NULL); 22 | i = -1; 23 | str = (char *)ft_calloc(ft_strlen(s) + 1, sizeof(char)); 24 | if (str) 25 | while (*(s + ++i)) 26 | *(str + i) = f(i, *(s + i)); 27 | return (str); 28 | } 29 | -------------------------------------------------------------------------------- /ft_strtrim.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strtrim.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/13 11:26:46 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/27 15:56:42 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strtrim(char const *s1, char const *set) 16 | { 17 | int n; 18 | 19 | if (!s1) 20 | return (NULL); 21 | if (!set || !*set) 22 | return (ft_strdup(s1)); 23 | while (*s1 && ft_strchr(set, *s1)) 24 | s1++; 25 | n = ft_strlen(s1); 26 | while (n && ft_strchr(set, *(s1 + n - 1))) 27 | n--; 28 | return (ft_substr(s1, 0, n)); 29 | } 30 | -------------------------------------------------------------------------------- /ft_atoi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atoi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/09 21:15:00 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:04:02 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | int ft_atoi(const char *str) 16 | { 17 | int sign; 18 | long res; 19 | 20 | sign = 1; 21 | res = 0; 22 | while (*str == 0x20 || (*str >= 0x09 && *str <= 0x0d)) 23 | str++; 24 | if (*str == 0x2D || *str == 0x2B) 25 | if (*(str++) == 0x2D) 26 | sign = -1; 27 | while (*str && ft_isdigit(*str)) 28 | res = (res * 10) + *(str++) - 0x30; 29 | return ((int)(res * sign)); 30 | } 31 | -------------------------------------------------------------------------------- /ft_substr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_substr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/10 18:03:02 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:06:58 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_substr(const char *s, unsigned int start, size_t len) 16 | { 17 | char *dest; 18 | size_t s_len; 19 | 20 | if (!s) 21 | return (NULL); 22 | if (start >= ft_strlen(s)) 23 | return (ft_strdup("")); 24 | s_len = ft_strlen(s + start); 25 | if (len > s_len) 26 | len = s_len; 27 | dest = ft_calloc(len + 1, sizeof(char)); 28 | if (dest) 29 | ft_memcpy(dest, (s + start), len); 30 | return (dest); 31 | } 32 | -------------------------------------------------------------------------------- /ft_strjoin.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strjoin.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/13 09:03:03 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/27 00:43:58 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strjoin(char const *s1, char const *s2) 16 | { 17 | char *str; 18 | size_t s1_len; 19 | size_t s2_len; 20 | 21 | if (!s1 || !s2) 22 | return (NULL); 23 | s1_len = ft_strlen(s1); 24 | s2_len = ft_strlen(s2); 25 | str = (char *)ft_calloc((s1_len + s2_len + 1), sizeof(char)); 26 | if (!str) 27 | return (NULL); 28 | ft_memcpy(str, s1, s1_len); 29 | ft_memcpy(str + s1_len, s2, s2_len); 30 | return (str); 31 | } 32 | -------------------------------------------------------------------------------- /ft_lstmap.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lstmap.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/22 13:12:43 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/30 01:33:10 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) 16 | { 17 | t_list *node; 18 | t_list *tmp; 19 | 20 | if (!lst || !f || !del) 21 | return (NULL); 22 | node = NULL; 23 | while (lst) 24 | { 25 | tmp = ft_lstnew(f(lst->content)); 26 | if (!tmp) 27 | { 28 | ft_lstclear(&node, del); 29 | return (NULL); 30 | } 31 | ft_lstadd_back(&node, tmp); 32 | lst = lst->next; 33 | } 34 | return (node); 35 | } 36 | -------------------------------------------------------------------------------- /ft_strnstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strnstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/26 16:02:50 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/28 16:15:27 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | char *ft_strnstr(const char *haystack, const char *needle, size_t len) 16 | { 17 | int i; 18 | 19 | if (!*needle || (haystack == needle && ft_strlen(needle) == len)) 20 | return ((char *)haystack); 21 | while (len && *haystack) 22 | { 23 | i = 0; 24 | while (*(needle + i) == *(haystack + i) && *(needle + i) && len--) 25 | if (!*(needle + ++i)) 26 | return ((char *)(haystack)); 27 | len += --i; 28 | haystack++; 29 | } 30 | return (NULL); 31 | } 32 | -------------------------------------------------------------------------------- /ft_strlcat.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlcat.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/10 03:03:40 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 18:23:42 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | size_t ft_strlcat(char *dst, const char *src, size_t dstsize) 16 | { 17 | size_t dstlen; 18 | size_t returnlen; 19 | size_t i; 20 | 21 | i = -1; 22 | returnlen = ft_strlen(src); 23 | if (!dstsize) 24 | return (returnlen); 25 | dstlen = ft_strlen(dst); 26 | if (dstlen > dstsize) 27 | return (returnlen + dstsize); 28 | returnlen += dstlen; 29 | while (*src && dstlen < dstsize - 1) 30 | *(dst + dstlen++) = *(src++); 31 | *(dst + dstlen) = '\0'; 32 | return (returnlen); 33 | } 34 | -------------------------------------------------------------------------------- /ft_itoa.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_itoa.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/18 01:47:51 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/28 04:31:31 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | static size_t chars_nbr(int n); 16 | 17 | char *ft_itoa(int n) 18 | { 19 | char *nbr; 20 | int chr_count; 21 | long long tmp; 22 | 23 | if (!n) 24 | return (ft_strdup("0")); 25 | chr_count = chars_nbr(n); 26 | nbr = (char *)ft_calloc(chr_count + 1, sizeof(char)); 27 | if (!nbr) 28 | return (NULL); 29 | tmp = n; 30 | if (tmp < 0) 31 | tmp = -tmp; 32 | while (chr_count && tmp) 33 | { 34 | *(nbr + --chr_count) = tmp % 10 + 0x30; 35 | tmp /= 10; 36 | } 37 | if (chr_count) 38 | *nbr = 0x2D; 39 | return (nbr); 40 | } 41 | 42 | static size_t chars_nbr(int n) 43 | { 44 | size_t s; 45 | 46 | s = 0; 47 | if (n < 0) 48 | s++; 49 | while (n != 0 && ++s) 50 | n /= 10; 51 | return (s); 52 | } 53 | -------------------------------------------------------------------------------- /ft_split.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_split.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/13 22:57:13 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/27 00:47:31 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "libft.h" 14 | 15 | static int word_count(char *s, char c); 16 | static int alloc_fill_strs(char **splited, char *s, char c, int wc); 17 | 18 | char **ft_split(char const *s, char c) 19 | { 20 | char **splited; 21 | int wc; 22 | 23 | if (!s) 24 | return (NULL); 25 | wc = word_count((char *)s, c); 26 | splited = malloc((wc + 1) * sizeof(char *)); 27 | if (!splited) 28 | return (NULL); 29 | if (alloc_fill_strs(splited, (char *)s, c, wc)) 30 | { 31 | while (*splited) 32 | free(*splited++); 33 | free(splited); 34 | } 35 | return (splited); 36 | } 37 | 38 | static int alloc_fill_strs(char **splited, char *s, char c, int wc) 39 | { 40 | int tmp_count; 41 | 42 | while (wc--) 43 | { 44 | tmp_count = 0; 45 | while (*s == c) 46 | s++; 47 | while (*(s + tmp_count) != c && *(s + tmp_count)) 48 | tmp_count++; 49 | if (!tmp_count) 50 | break ; 51 | *splited = ft_substr(s, 0, tmp_count); 52 | if (!splited) 53 | return (1); 54 | s += tmp_count; 55 | splited++; 56 | } 57 | *splited = NULL; 58 | return (0); 59 | } 60 | 61 | static int word_count(char *s, char c) 62 | { 63 | int i; 64 | 65 | i = 0; 66 | while (*(s++)) 67 | if (*(s - 1) != c && (*s == c || !*s)) 68 | i++; 69 | return (i); 70 | } 71 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # Makefile :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: aahlyel +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2022/10/25 13:21:42 by aahlyel #+# #+# # 9 | # Updated: 2022/10/30 01:34:03 by aahlyel ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | 14 | OBJS = ft_atoi.o\ 15 | ft_bzero.o\ 16 | ft_calloc.o\ 17 | ft_isalnum.o\ 18 | ft_isalpha.o\ 19 | ft_isascii.o\ 20 | ft_isdigit.o\ 21 | ft_isprint.o\ 22 | ft_memchr.o\ 23 | ft_memcmp.o\ 24 | ft_memcpy.o\ 25 | ft_memmove.o\ 26 | ft_memset.o\ 27 | ft_strchr.o\ 28 | ft_strdup.o\ 29 | ft_strlcat.o\ 30 | ft_strlcpy.o\ 31 | ft_strlen.o\ 32 | ft_strncmp.o\ 33 | ft_strnstr.o\ 34 | ft_strrchr.o\ 35 | ft_tolower.o\ 36 | ft_toupper.o\ 37 | ft_substr.o\ 38 | ft_strjoin.o\ 39 | ft_strtrim.o\ 40 | ft_split.o\ 41 | ft_itoa.o\ 42 | ft_strmapi.o\ 43 | ft_striteri.o\ 44 | ft_putchar_fd.o\ 45 | ft_putstr_fd.o\ 46 | ft_putendl_fd.o\ 47 | ft_putnbr_fd.o 48 | 49 | BONUS = ft_lstnew.o\ 50 | ft_lstadd_front.o\ 51 | ft_lstsize.o\ 52 | ft_lstlast.o\ 53 | ft_lstadd_back.o\ 54 | ft_lstdelone.o\ 55 | ft_lstclear.o\ 56 | ft_lstiter.o\ 57 | ft_lstmap.o 58 | 59 | CC = cc 60 | 61 | CFLAGS = -Wall -Wextra -Werror 62 | 63 | RM = rm -f 64 | 65 | AR = ar -rcs 66 | 67 | NAME = libft.a 68 | 69 | all : ${NAME} 70 | 71 | ${NAME} : ${OBJS} 72 | ${AR} ${NAME} $^ 73 | 74 | %.o : %.c libft.h 75 | ${CC} ${CFLAGS} -c -o $@ $< 76 | 77 | bonus : ${NAME} ${BONUS} 78 | ${AR} ${NAME} $^ 79 | 80 | clean : 81 | ${RM} ${OBJS} ${BONUS} 82 | 83 | fclean : clean 84 | ${RM} ${NAME} 85 | 86 | re : fclean all bonus 87 | 88 | .PHONY : bonus fclean clean re 89 | -------------------------------------------------------------------------------- /libft.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* libft.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/10/26 16:24:21 by aahlyel #+# #+# */ 9 | /* Updated: 2022/10/26 16:26:12 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef LIBFT_H 14 | # define LIBFT_H 15 | 16 | # include 17 | # include 18 | # include 19 | # include 20 | # include 21 | 22 | typedef struct s_list 23 | { 24 | void *content; 25 | struct s_list *next; 26 | } t_list; 27 | 28 | int ft_atoi(const char *str); 29 | void ft_bzero(void *s, size_t n); 30 | void *ft_calloc(size_t count, size_t size); 31 | int ft_isalnum(int c); 32 | int ft_isalpha(int c); 33 | int ft_isascii(int c); 34 | int ft_isdigit(int c); 35 | int ft_isprint(int c); 36 | void *ft_memchr(const void *s, int c, size_t n); 37 | int ft_memcmp(const void *s1, const void *s2, size_t n); 38 | void *ft_memcpy(void *dst, const void *src, size_t n); 39 | void *ft_memmove(void *dst, const void *src, size_t len); 40 | void *ft_memset(void *b, int c, size_t len); 41 | char *ft_strchr(const char *s, int c); 42 | char *ft_strdup(const char *s1); 43 | size_t ft_strlcat(char *dst, const char *src, size_t dstsize); 44 | size_t ft_strlcpy(char *dst, const char *src, size_t dstsize); 45 | size_t ft_strlen(const char *s); 46 | int ft_strncmp(const char *s1, const char *s2, size_t n); 47 | char *ft_strnstr(const char *haystack, const char *needle, size_t len); 48 | char *ft_strrchr(const char *s, int c); 49 | int ft_tolower(int c); 50 | int ft_toupper(int c); 51 | char *ft_strjoin(char const *s1, char const *s2); 52 | char *ft_substr(char const *s, unsigned int start, size_t len); 53 | char *ft_strtrim(char const *s1, char const *set); 54 | char **ft_split(char const *s, char c); 55 | char *ft_itoa(int n); 56 | char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); 57 | void ft_striteri(char *s, void (*f)(unsigned int, char*)); 58 | void ft_putchar_fd(char c, int fd); 59 | void ft_putstr_fd(char *s, int fd); 60 | void ft_putendl_fd(char *s, int fd); 61 | void ft_putnbr_fd(int n, int fd); 62 | t_list *ft_lstnew(void *content); 63 | void ft_lstadd_front(t_list **lst, t_list *new); 64 | int ft_lstsize(t_list *lst); 65 | t_list *ft_lstlast(t_list *lst); 66 | void ft_lstadd_back(t_list **lst, t_list *new); 67 | void ft_lstdelone(t_list *lst, void (*del)(void*)); 68 | void ft_lstclear(t_list **lst, void (*del)(void*)); 69 | void ft_lstiter(t_list *lst, void (*f)(void *)); 70 | t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)); 71 | 72 | #endif 73 | --------------------------------------------------------------------------------