From b7de684a63b150712c722147bd407e700c2314a5 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Sat, 9 Dec 2023 13:43:15 +0100 Subject: [PATCH] Change file structure of this library Separate source files (functions) to folders by topic. Create separate header file each folder. Adjust Makefile and libft.h accordingly. --- Makefile | 132 +++++++++--------- ft_check/ft_check.h | 25 ++++ ft_isalnum.c => ft_check/ft_isalnum.c | 0 ft_isalpha.c => ft_check/ft_isalpha.c | 0 ft_isascii.c => ft_check/ft_isascii.c | 0 ft_isdigit.c => ft_check/ft_isdigit.c | 0 ft_islower.c => ft_check/ft_islower.c | 0 ft_isprint.c => ft_check/ft_isprint.c | 0 ft_isspace.c => ft_check/ft_isspace.c | 0 ft_isupper.c => ft_check/ft_isupper.c | 0 ft_atoi.c => ft_conv/ft_atoi.c | 0 ft_conv/ft_conv.h | 29 ++++ ft_ctoa.c => ft_conv/ft_ctoa.c | 0 ft_itoa.c => ft_conv/ft_itoa.c | 0 ft_itoa_base.c => ft_conv/ft_itoa_base.c | 0 ft_tolower.c => ft_conv/ft_tolower.c | 0 ft_toupper.c => ft_conv/ft_toupper.c | 0 ft_uitoa_base.c => ft_conv/ft_uitoa_base.c | 0 ft_gen/ft_gen.h | 18 +++ ft_swap.c => ft_gen/ft_swap.c | 0 ft_io/ft_io.h | 23 +++ {ft_printf => ft_io/ft_printf}/conversion.c | 0 {ft_printf => ft_io/ft_printf}/formatting.c | 0 {ft_printf => ft_io/ft_printf}/ft_printf.c | 0 {ft_printf => ft_io/ft_printf}/ft_printf.h | 0 {ft_printf => ft_io/ft_printf}/padding.c | 0 {ft_printf => ft_io/ft_printf}/parsing.c | 0 ft_putchar_fd.c => ft_io/ft_putchar_fd.c | 0 ft_putendl_fd.c => ft_io/ft_putendl_fd.c | 0 ft_putnbr_fd.c => ft_io/ft_putnbr_fd.c | 0 ft_putstr_fd.c => ft_io/ft_putstr_fd.c | 0 get_next_line.c => ft_io/get_next_line.c | 0 get_next_line.h => ft_io/get_next_line.h | 2 - ft_lst/ft_lst.h | 43 ++++++ ft_abs.c => ft_math/ft_abs.c | 0 ft_math/ft_math.h | 18 +++ ft_bzero.c => ft_mem/ft_bzero.c | 0 ft_calloc.c => ft_mem/ft_calloc.c | 0 ft_mem/ft_mem.h | 26 ++++ ft_memchr.c => ft_mem/ft_memchr.c | 0 ft_memcmp.c => ft_mem/ft_memcmp.c | 0 ft_memcpy.c => ft_mem/ft_memcpy.c | 0 ft_memmove.c => ft_mem/ft_memmove.c | 0 ft_memset.c => ft_mem/ft_memset.c | 0 ft_split.c => ft_str/ft_split.c | 0 ft_str/ft_str.h | 35 +++++ ft_strchr.c => ft_str/ft_strchr.c | 0 ft_strdup.c => ft_str/ft_strdup.c | 0 ft_striteri.c => ft_str/ft_striteri.c | 0 ft_strjoin.c => ft_str/ft_strjoin.c | 0 ft_strlcat.c => ft_str/ft_strlcat.c | 0 ft_strlcpy.c => ft_str/ft_strlcpy.c | 0 ft_strlen.c => ft_str/ft_strlen.c | 0 ft_strmapi.c => ft_str/ft_strmapi.c | 0 .../ft_strncat_alloc.c | 0 ft_strncmp.c => ft_str/ft_strncmp.c | 0 ft_strndup.c => ft_str/ft_strndup.c | 0 ft_strnstr.c => ft_str/ft_strnstr.c | 0 ft_strrchr.c => ft_str/ft_strrchr.c | 0 ft_strtrim.c => ft_str/ft_strtrim.c | 0 ft_substr.c => ft_str/ft_substr.c | 0 libft.h | 99 ++----------- 62 files changed, 295 insertions(+), 155 deletions(-) create mode 100644 ft_check/ft_check.h rename ft_isalnum.c => ft_check/ft_isalnum.c (100%) rename ft_isalpha.c => ft_check/ft_isalpha.c (100%) rename ft_isascii.c => ft_check/ft_isascii.c (100%) rename ft_isdigit.c => ft_check/ft_isdigit.c (100%) rename ft_islower.c => ft_check/ft_islower.c (100%) rename ft_isprint.c => ft_check/ft_isprint.c (100%) rename ft_isspace.c => ft_check/ft_isspace.c (100%) rename ft_isupper.c => ft_check/ft_isupper.c (100%) rename ft_atoi.c => ft_conv/ft_atoi.c (100%) create mode 100644 ft_conv/ft_conv.h rename ft_ctoa.c => ft_conv/ft_ctoa.c (100%) rename ft_itoa.c => ft_conv/ft_itoa.c (100%) rename ft_itoa_base.c => ft_conv/ft_itoa_base.c (100%) rename ft_tolower.c => ft_conv/ft_tolower.c (100%) rename ft_toupper.c => ft_conv/ft_toupper.c (100%) rename ft_uitoa_base.c => ft_conv/ft_uitoa_base.c (100%) create mode 100644 ft_gen/ft_gen.h rename ft_swap.c => ft_gen/ft_swap.c (100%) create mode 100644 ft_io/ft_io.h rename {ft_printf => ft_io/ft_printf}/conversion.c (100%) rename {ft_printf => ft_io/ft_printf}/formatting.c (100%) rename {ft_printf => ft_io/ft_printf}/ft_printf.c (100%) rename {ft_printf => ft_io/ft_printf}/ft_printf.h (100%) rename {ft_printf => ft_io/ft_printf}/padding.c (100%) rename {ft_printf => ft_io/ft_printf}/parsing.c (100%) rename ft_putchar_fd.c => ft_io/ft_putchar_fd.c (100%) rename ft_putendl_fd.c => ft_io/ft_putendl_fd.c (100%) rename ft_putnbr_fd.c => ft_io/ft_putnbr_fd.c (100%) rename ft_putstr_fd.c => ft_io/ft_putstr_fd.c (100%) rename get_next_line.c => ft_io/get_next_line.c (100%) rename get_next_line.h => ft_io/get_next_line.h (97%) create mode 100644 ft_lst/ft_lst.h rename ft_abs.c => ft_math/ft_abs.c (100%) create mode 100644 ft_math/ft_math.h rename ft_bzero.c => ft_mem/ft_bzero.c (100%) rename ft_calloc.c => ft_mem/ft_calloc.c (100%) create mode 100644 ft_mem/ft_mem.h rename ft_memchr.c => ft_mem/ft_memchr.c (100%) rename ft_memcmp.c => ft_mem/ft_memcmp.c (100%) rename ft_memcpy.c => ft_mem/ft_memcpy.c (100%) rename ft_memmove.c => ft_mem/ft_memmove.c (100%) rename ft_memset.c => ft_mem/ft_memset.c (100%) rename ft_split.c => ft_str/ft_split.c (100%) create mode 100644 ft_str/ft_str.h rename ft_strchr.c => ft_str/ft_strchr.c (100%) rename ft_strdup.c => ft_str/ft_strdup.c (100%) rename ft_striteri.c => ft_str/ft_striteri.c (100%) rename ft_strjoin.c => ft_str/ft_strjoin.c (100%) rename ft_strlcat.c => ft_str/ft_strlcat.c (100%) rename ft_strlcpy.c => ft_str/ft_strlcpy.c (100%) rename ft_strlen.c => ft_str/ft_strlen.c (100%) rename ft_strmapi.c => ft_str/ft_strmapi.c (100%) rename ft_strncat_alloc.c => ft_str/ft_strncat_alloc.c (100%) rename ft_strncmp.c => ft_str/ft_strncmp.c (100%) rename ft_strndup.c => ft_str/ft_strndup.c (100%) rename ft_strnstr.c => ft_str/ft_strnstr.c (100%) rename ft_strrchr.c => ft_str/ft_strrchr.c (100%) rename ft_strtrim.c => ft_str/ft_strtrim.c (100%) rename ft_substr.c => ft_str/ft_substr.c (100%) diff --git a/Makefile b/Makefile index 3f7e3e8..e92ca75 100644 --- a/Makefile +++ b/Makefile @@ -4,80 +4,86 @@ AR := ar RM := rm -f -SRCDIR := . -INCLUDE := $(addprefix -I, $(SRCDIR)) -SOURCES := ft_strndup.c \ - ft_putstr_fd.c \ - ft_putendl_fd.c \ - ft_atoi.c \ - ft_strtrim.c \ - ft_itoa.c \ - ft_strnstr.c \ - ft_memmove.c \ - ft_putnbr_fd.c \ - ft_memchr.c \ - ft_strrchr.c \ +SRCDIR := ft_gen ft_math ft_str ft_mem ft_io ft_check ft_conv ft_lst +INCLUDE := $(addprefix -I, $(SRCDIR) .) + +SRCgen := ft_swap.c \ + +SRCmath := ft_abs.c \ + +SRCstr := ft_strncat_alloc.c \ + ft_strncmp.c \ + ft_strndup.c \ ft_strchr.c \ - ft_strdup.c \ - ft_memcmp.c \ - ft_substr.c \ - ft_tolower.c \ - ft_isalnum.c \ + ft_strtrim.c \ ft_strlen.c \ - ft_isspace.c \ - ft_isdigit.c \ - ft_calloc.c \ - ft_strjoin.c \ - ft_isprint.c \ + ft_strdup.c \ + ft_strlcpy.c \ + ft_strnstr.c \ + ft_striteri.c \ ft_strmapi.c \ + ft_strjoin.c \ ft_split.c \ - ft_toupper.c \ + ft_substr.c \ ft_strlcat.c \ - ft_strncat_alloc.c \ - ft_bzero.c \ - ft_abs.c \ - ft_isalpha.c \ + ft_strrchr.c \ + +SRCmem := ft_calloc.c \ + ft_memchr.c \ + ft_memcmp.c \ ft_memset.c \ - ft_striteri.c \ - ft_isupper.c \ - ft_isascii.c \ - ft_islower.c \ - ft_strlcpy.c \ + ft_memmove.c \ ft_memcpy.c \ - ft_itoa_base.c \ - ft_putchar_fd.c \ - ft_ctoa.c \ - ft_uitoa_base.c \ - ft_strncmp.c \ - ft_swap.c \ - \ - get_next_line.c \ - \ - ft_lst/ft_lstnew.c \ - ft_lst/ft_lstiter.c \ - ft_lst/ft_lstmap.c \ - ft_lst/ft_lstclear.c \ - ft_lst/ft_lstlast.c \ - ft_lst/ft_lstsize.c \ - ft_lst/ft_lstadd_front.c \ - ft_lst/ft_lstadd_back.c \ - ft_lst/ft_lstdelone.c \ - ft_lst/ft_lst_at.c \ - ft_lst/ft_lst_find.c \ - ft_lst/ft_lst_foreach_if.c \ - ft_lst/ft_lst_merge.c \ - ft_lst/ft_lst_remove_if.c \ - ft_lst/ft_lst_reverse.c \ - ft_lst/ft_lst_sort.c \ - ft_lst/ft_lst_sorted_insert.c \ - ft_lst/ft_lst_sorted_merge.c \ - \ + ft_bzero.c \ + +SRCio := ft_putendl_fd.c \ + ft_putnbr_fd.c \ ft_printf/conversion.c \ - ft_printf/formatting.c \ ft_printf/ft_printf.c \ ft_printf/padding.c \ ft_printf/parsing.c \ - + ft_printf/formatting.c \ + ft_putchar_fd.c \ + get_next_line.c \ + ft_putstr_fd.c \ + +SRCcheck := ft_isalnum.c \ + ft_isspace.c \ + ft_isdigit.c \ + ft_isascii.c \ + ft_isalpha.c \ + ft_islower.c \ + ft_isupper.c \ + ft_isprint.c \ + +SRCconv := ft_itoa_base.c \ + ft_tolower.c \ + ft_toupper.c \ + ft_atoi.c \ + ft_ctoa.c \ + ft_itoa.c \ + ft_uitoa_base.c \ + +SRClst := ft_lst_reverse.c \ + ft_lstdelone.c \ + ft_lst_foreach_if.c \ + ft_lstlast.c \ + ft_lstclear.c \ + ft_lst_at.c \ + ft_lst_sorted_merge.c \ + ft_lst_find.c \ + ft_lstmap.c \ + ft_lst_remove_if.c \ + ft_lstnew.c \ + ft_lst_merge.c \ + ft_lstsize.c \ + ft_lstadd_front.c \ + ft_lstadd_back.c \ + ft_lstiter.c \ + ft_lst_sort.c \ + ft_lst_sorted_insert.c \ + +SOURCES := $(foreach dir, $(SRCDIR), $(addprefix $(dir)/, $($(dir:ft_%=SRC%)))) OBJECTS := $(SOURCES:.c=.o) NAME = libft.a diff --git a/ft_check/ft_check.h b/ft_check/ft_check.h new file mode 100644 index 0000000..b00f69b --- /dev/null +++ b/ft_check/ft_check.h @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_check.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/09 11:55:15 by ljiriste #+# #+# */ +/* Updated: 2023/12/09 11:56:31 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_CHECK_H +# define FT_CHECK_H + +int ft_isalnum(int c); +int ft_isalpha(int c); +int ft_isdigit(int c); +int ft_islower(int c); +int ft_isprint(int c); +int ft_isspace(int c); +int ft_isupper(int c); +int ft_isascii(int c); + +#endif diff --git a/ft_isalnum.c b/ft_check/ft_isalnum.c similarity index 100% rename from ft_isalnum.c rename to ft_check/ft_isalnum.c diff --git a/ft_isalpha.c b/ft_check/ft_isalpha.c similarity index 100% rename from ft_isalpha.c rename to ft_check/ft_isalpha.c diff --git a/ft_isascii.c b/ft_check/ft_isascii.c similarity index 100% rename from ft_isascii.c rename to ft_check/ft_isascii.c diff --git a/ft_isdigit.c b/ft_check/ft_isdigit.c similarity index 100% rename from ft_isdigit.c rename to ft_check/ft_isdigit.c diff --git a/ft_islower.c b/ft_check/ft_islower.c similarity index 100% rename from ft_islower.c rename to ft_check/ft_islower.c diff --git a/ft_isprint.c b/ft_check/ft_isprint.c similarity index 100% rename from ft_isprint.c rename to ft_check/ft_isprint.c diff --git a/ft_isspace.c b/ft_check/ft_isspace.c similarity index 100% rename from ft_isspace.c rename to ft_check/ft_isspace.c diff --git a/ft_isupper.c b/ft_check/ft_isupper.c similarity index 100% rename from ft_isupper.c rename to ft_check/ft_isupper.c diff --git a/ft_atoi.c b/ft_conv/ft_atoi.c similarity index 100% rename from ft_atoi.c rename to ft_conv/ft_atoi.c diff --git a/ft_conv/ft_conv.h b/ft_conv/ft_conv.h new file mode 100644 index 0000000..bf0dc27 --- /dev/null +++ b/ft_conv/ft_conv.h @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_conv.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/09 11:53:15 by ljiriste #+# #+# */ +/* Updated: 2023/12/09 11:54:31 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_CONV_H +# define FT_CONV_H + +# include + +int ft_toupper(int c); +int ft_tolower(int c); + +int ft_atoi(const char *nptr); +long ft_atol(const char *nptr); +long long ft_atoll(const char *nptr); +char *ft_itoa(int n); +char *ft_itoa_base(intmax_t n, const char *base); +char *ft_uitoa_base(uintmax_t n, const char *base); +char *ft_ctoa(char c); + +#endif diff --git a/ft_ctoa.c b/ft_conv/ft_ctoa.c similarity index 100% rename from ft_ctoa.c rename to ft_conv/ft_ctoa.c diff --git a/ft_itoa.c b/ft_conv/ft_itoa.c similarity index 100% rename from ft_itoa.c rename to ft_conv/ft_itoa.c diff --git a/ft_itoa_base.c b/ft_conv/ft_itoa_base.c similarity index 100% rename from ft_itoa_base.c rename to ft_conv/ft_itoa_base.c diff --git a/ft_tolower.c b/ft_conv/ft_tolower.c similarity index 100% rename from ft_tolower.c rename to ft_conv/ft_tolower.c diff --git a/ft_toupper.c b/ft_conv/ft_toupper.c similarity index 100% rename from ft_toupper.c rename to ft_conv/ft_toupper.c diff --git a/ft_uitoa_base.c b/ft_conv/ft_uitoa_base.c similarity index 100% rename from ft_uitoa_base.c rename to ft_conv/ft_uitoa_base.c diff --git a/ft_gen/ft_gen.h b/ft_gen/ft_gen.h new file mode 100644 index 0000000..8e22787 --- /dev/null +++ b/ft_gen/ft_gen.h @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_gen.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/09 12:21:15 by ljiriste #+# #+# */ +/* Updated: 2023/12/09 11:22:31 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_GEN_H +# define FT_GEN_H + +void ft_swap(void **a, void **b); + +#endif diff --git a/ft_swap.c b/ft_gen/ft_swap.c similarity index 100% rename from ft_swap.c rename to ft_gen/ft_swap.c diff --git a/ft_io/ft_io.h b/ft_io/ft_io.h new file mode 100644 index 0000000..1f69b32 --- /dev/null +++ b/ft_io/ft_io.h @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_io.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/09 11:38:28 by ljiriste #+# #+# */ +/* Updated: 2023/12/09 11:40:06 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_IO_H +# define FT_IO_H + +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); +int ft_printf(const char *format, ...); +char *get_next_line(int fd); + +#endif diff --git a/ft_printf/conversion.c b/ft_io/ft_printf/conversion.c similarity index 100% rename from ft_printf/conversion.c rename to ft_io/ft_printf/conversion.c diff --git a/ft_printf/formatting.c b/ft_io/ft_printf/formatting.c similarity index 100% rename from ft_printf/formatting.c rename to ft_io/ft_printf/formatting.c diff --git a/ft_printf/ft_printf.c b/ft_io/ft_printf/ft_printf.c similarity index 100% rename from ft_printf/ft_printf.c rename to ft_io/ft_printf/ft_printf.c diff --git a/ft_printf/ft_printf.h b/ft_io/ft_printf/ft_printf.h similarity index 100% rename from ft_printf/ft_printf.h rename to ft_io/ft_printf/ft_printf.h diff --git a/ft_printf/padding.c b/ft_io/ft_printf/padding.c similarity index 100% rename from ft_printf/padding.c rename to ft_io/ft_printf/padding.c diff --git a/ft_printf/parsing.c b/ft_io/ft_printf/parsing.c similarity index 100% rename from ft_printf/parsing.c rename to ft_io/ft_printf/parsing.c diff --git a/ft_putchar_fd.c b/ft_io/ft_putchar_fd.c similarity index 100% rename from ft_putchar_fd.c rename to ft_io/ft_putchar_fd.c diff --git a/ft_putendl_fd.c b/ft_io/ft_putendl_fd.c similarity index 100% rename from ft_putendl_fd.c rename to ft_io/ft_putendl_fd.c diff --git a/ft_putnbr_fd.c b/ft_io/ft_putnbr_fd.c similarity index 100% rename from ft_putnbr_fd.c rename to ft_io/ft_putnbr_fd.c diff --git a/ft_putstr_fd.c b/ft_io/ft_putstr_fd.c similarity index 100% rename from ft_putstr_fd.c rename to ft_io/ft_putstr_fd.c diff --git a/get_next_line.c b/ft_io/get_next_line.c similarity index 100% rename from get_next_line.c rename to ft_io/get_next_line.c diff --git a/get_next_line.h b/ft_io/get_next_line.h similarity index 97% rename from get_next_line.h rename to ft_io/get_next_line.h index 0b0f615..5a1063c 100644 --- a/get_next_line.h +++ b/ft_io/get_next_line.h @@ -25,6 +25,4 @@ typedef struct s_file_thread char *buffer; } t_ft; -char *get_next_line(int fd); - #endif diff --git a/ft_lst/ft_lst.h b/ft_lst/ft_lst.h new file mode 100644 index 0000000..ad1294c --- /dev/null +++ b/ft_lst/ft_lst.h @@ -0,0 +1,43 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lst.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/09 11:42:15 by ljiriste #+# #+# */ +/* Updated: 2023/11/03 11:43:31 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_LST_H +# define FT_LST_H + +typedef struct s_list +{ + struct s_list *next; + void *content; +} 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 *)); +t_list *ft_lst_at(t_list *lst, unsigned int i); +t_list *ft_lst_find(t_list *lst, void *content_red, int (*cmp)()); +void ft_lst_foreach_if(t_list *lst, void (*f)(void *), + void *content_ref, int (*cmp)()); +void ft_lst_merge(t_list **lst1, t_list *lst2); +void ft_lst_remove_if(t_list **lst, void *content_ref, + int (*cmp)(), void (*free_fct)(void *)); +void ft_lst_reverse(t_list **lst); +void ft_lst_sort(t_list **lst, int (*cmp)()); +void ft_lst_sorted_insert(t_list **lst, t_list *new, int (*cmp)()); +void ft_lst_sorted_merge(t_list **lst1, t_list *lst2, int (*cmp)()); + +#endif diff --git a/ft_abs.c b/ft_math/ft_abs.c similarity index 100% rename from ft_abs.c rename to ft_math/ft_abs.c diff --git a/ft_math/ft_math.h b/ft_math/ft_math.h new file mode 100644 index 0000000..a3e29e2 --- /dev/null +++ b/ft_math/ft_math.h @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_math.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/09 12:19:15 by ljiriste #+# #+# */ +/* Updated: 2023/12/09 12:20:31 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_MATH_H +# define FT_MATH_H + +int ft_abs(int n); + +#endif diff --git a/ft_bzero.c b/ft_mem/ft_bzero.c similarity index 100% rename from ft_bzero.c rename to ft_mem/ft_bzero.c diff --git a/ft_calloc.c b/ft_mem/ft_calloc.c similarity index 100% rename from ft_calloc.c rename to ft_mem/ft_calloc.c diff --git a/ft_mem/ft_mem.h b/ft_mem/ft_mem.h new file mode 100644 index 0000000..fe2d8cf --- /dev/null +++ b/ft_mem/ft_mem.h @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_mem.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/09 12:45:15 by ljiriste #+# #+# */ +/* Updated: 2023/12/09 12:46:31 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_MEM_H +# define FT_MEM_H + +# include + +void *ft_memset(void *s, int c, 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); +void *ft_calloc(size_t nmemb, size_t size); +void ft_bzero(void *s, size_t n); +int ft_memcmp(const void *s1, const void *s2, size_t n); + +#endif diff --git a/ft_memchr.c b/ft_mem/ft_memchr.c similarity index 100% rename from ft_memchr.c rename to ft_mem/ft_memchr.c diff --git a/ft_memcmp.c b/ft_mem/ft_memcmp.c similarity index 100% rename from ft_memcmp.c rename to ft_mem/ft_memcmp.c diff --git a/ft_memcpy.c b/ft_mem/ft_memcpy.c similarity index 100% rename from ft_memcpy.c rename to ft_mem/ft_memcpy.c diff --git a/ft_memmove.c b/ft_mem/ft_memmove.c similarity index 100% rename from ft_memmove.c rename to ft_mem/ft_memmove.c diff --git a/ft_memset.c b/ft_mem/ft_memset.c similarity index 100% rename from ft_memset.c rename to ft_mem/ft_memset.c diff --git a/ft_split.c b/ft_str/ft_split.c similarity index 100% rename from ft_split.c rename to ft_str/ft_split.c diff --git a/ft_str/ft_str.h b/ft_str/ft_str.h new file mode 100644 index 0000000..6ea0807 --- /dev/null +++ b/ft_str/ft_str.h @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/09 11:50:15 by ljiriste #+# #+# */ +/* Updated: 2023/12/09 11:51:31 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_STR_H +# define FT_STR_H + +# include + +size_t ft_strlen(const char *s); +size_t ft_strlcpy(char *dst, const char *src, size_t size); +size_t ft_strlcat(char *dst, const char *src, size_t size); +char *ft_strncat_alloc(char **dest, const char *src, size_t n); +int ft_strncmp(const char *s1, const char *s2, size_t n); +char *ft_strchr(const char *s, int c); +char *ft_strrchr(const char *s, int c); +char *ft_strnstr(const char *big, const char *little, size_t len); +char *ft_strdup(const char *s); +char *ft_strndup(const char *s, size_t n); +char *ft_substr(const char *s, unsigned int start, size_t len); +char *ft_strjoin(const char *s1, const char *s2); +char *ft_strtrim(const char *s1, const char *set); +char **ft_split(const char *s, char c); +char *ft_strmapi(const char *s, char (*f)(unsigned int, char)); +void ft_striteri(char *s, void (*f)(unsigned int, char *)); + +#endif diff --git a/ft_strchr.c b/ft_str/ft_strchr.c similarity index 100% rename from ft_strchr.c rename to ft_str/ft_strchr.c diff --git a/ft_strdup.c b/ft_str/ft_strdup.c similarity index 100% rename from ft_strdup.c rename to ft_str/ft_strdup.c diff --git a/ft_striteri.c b/ft_str/ft_striteri.c similarity index 100% rename from ft_striteri.c rename to ft_str/ft_striteri.c diff --git a/ft_strjoin.c b/ft_str/ft_strjoin.c similarity index 100% rename from ft_strjoin.c rename to ft_str/ft_strjoin.c diff --git a/ft_strlcat.c b/ft_str/ft_strlcat.c similarity index 100% rename from ft_strlcat.c rename to ft_str/ft_strlcat.c diff --git a/ft_strlcpy.c b/ft_str/ft_strlcpy.c similarity index 100% rename from ft_strlcpy.c rename to ft_str/ft_strlcpy.c diff --git a/ft_strlen.c b/ft_str/ft_strlen.c similarity index 100% rename from ft_strlen.c rename to ft_str/ft_strlen.c diff --git a/ft_strmapi.c b/ft_str/ft_strmapi.c similarity index 100% rename from ft_strmapi.c rename to ft_str/ft_strmapi.c diff --git a/ft_strncat_alloc.c b/ft_str/ft_strncat_alloc.c similarity index 100% rename from ft_strncat_alloc.c rename to ft_str/ft_strncat_alloc.c diff --git a/ft_strncmp.c b/ft_str/ft_strncmp.c similarity index 100% rename from ft_strncmp.c rename to ft_str/ft_strncmp.c diff --git a/ft_strndup.c b/ft_str/ft_strndup.c similarity index 100% rename from ft_strndup.c rename to ft_str/ft_strndup.c diff --git a/ft_strnstr.c b/ft_str/ft_strnstr.c similarity index 100% rename from ft_strnstr.c rename to ft_str/ft_strnstr.c diff --git a/ft_strrchr.c b/ft_str/ft_strrchr.c similarity index 100% rename from ft_strrchr.c rename to ft_str/ft_strrchr.c diff --git a/ft_strtrim.c b/ft_str/ft_strtrim.c similarity index 100% rename from ft_strtrim.c rename to ft_str/ft_strtrim.c diff --git a/ft_substr.c b/ft_str/ft_substr.c similarity index 100% rename from ft_substr.c rename to ft_str/ft_substr.c diff --git a/libft.h b/libft.h index bc40688..3e18641 100644 --- a/libft.h +++ b/libft.h @@ -6,101 +6,20 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/08/15 12:58:15 by ljiriste #+# #+# */ -/* Updated: 2023/11/03 16:57:31 by ljiriste ### ########.fr */ +/* Updated: 2023/12/09 12:23:31 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef LIBFT_H # define LIBFT_H -# include -# include - -int ft_isalnum(int c); -int ft_isalpha(int c); -int ft_isdigit(int c); -int ft_islower(int c); -int ft_isprint(int c); -int ft_isspace(int c); -int ft_isupper(int c); -int ft_isascii(int c); - -int ft_abs(int n); - -void *ft_memset(void *s, int c, 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); -void *ft_calloc(size_t nmemb, size_t size); -void ft_bzero(void *s, size_t n); -int ft_memcmp(const void *s1, const void *s2, size_t n); - -size_t ft_strlen(const char *s); -size_t ft_strlcpy(char *dst, const char *src, size_t size); -size_t ft_strlcat(char *dst, const char *src, size_t size); -char *ft_strncat_alloc(char **dest, const char *src, size_t n); -int ft_strncmp(const char *s1, const char *s2, size_t n); -char *ft_strchr(const char *s, int c); -char *ft_strrchr(const char *s, int c); -char *ft_strnstr(const char *big, const char *little, size_t len); -char *ft_strdup(const char *s); -char *ft_strndup(const char *s, size_t n); - -int ft_toupper(int c); -int ft_tolower(int c); - -int ft_atoi(const char *nptr); -long ft_atol(const char *nptr); -long long ft_atoll(const char *nptr); - -char *ft_substr(const char *s, unsigned int start, size_t len); -char *ft_strjoin(const char *s1, const char *s2); -char *ft_strtrim(const char *s1, const char *set); -char **ft_split(const char *s, char c); - -char *ft_itoa(int n); -char *ft_itoa_base(intmax_t n, const char *base); -char *ft_uitoa_base(uintmax_t n, const char *base); -char *ft_ctoa(char c); - -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); -int ft_printf(const char *format, ...); - -void ft_swap(void **a, void **b); - -char *get_next_line(int fd); - -typedef struct s_list -{ - struct s_list *next; - void *content; -} 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 *)); -t_list *ft_lst_at(t_list *lst, unsigned int i); -t_list *ft_lst_find(t_list *lst, void *content_red, int (*cmp)()); -void ft_lst_foreach_if(t_list *lst, void (*f)(void *), - void *content_ref, int (*cmp)()); -void ft_lst_merge(t_list **lst1, t_list *lst2); -void ft_lst_remove_if(t_list **lst, void *content_ref, - int (*cmp)(), void (*free_fct)(void *)); -void ft_lst_reverse(t_list **lst); -void ft_lst_sort(t_list **lst, int (*cmp)()); -void ft_lst_sorted_insert(t_list **lst, t_list *new, int (*cmp)()); -void ft_lst_sorted_merge(t_list **lst1, t_list *lst2, int (*cmp)()); +# include "ft_gen.h" +# include "ft_math.h" +# include "ft_check.h" +# include "ft_conv.h" +# include "ft_str.h" +# include "ft_mem.h" +# include "ft_io.h" +# include "ft_lst.h" #endif -- 2.30.2