commit fcbe35befd2156063e07ceb1304d2c3d28826874 Author: Camille Chauvet Date: Thu Jan 19 17:33:26 2023 +0100 kekw diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7474655 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +OBJ = ${SRC:.c=.o} + +NAME = libftx.a + +LIBS = libft/libft.a gnl/get_next_line.a printf/ft_printf.a extra/extra.a + +CC = clang + +FLAG = -Wall -Wextra -Werror + +all: ${NAME} + +${NAME}: ${OBJ} + make -C extra + make -C libft + make -C gnl + make -C printf + ar -rcT $(NAME) $(LIBS) + +clean: + make -C extra clean + make -C libft clean + make -C gnl clean + make -C printf clean + +fclean: clean + rm -f ${NAME} + make -C extra fclean + make -C libft fclean + make -C printf fclean + make -C gnl fclean + +re: fclean all + +.PHONY: all clean fclean re diff --git a/extra/Makefile b/extra/Makefile new file mode 100644 index 0000000..269a370 --- /dev/null +++ b/extra/Makefile @@ -0,0 +1,39 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cchauvet +# include +# include +# include +# include "../libft/libft.h" + +char *ft_ultoa_base(unsigned long long n, char *base); +char *get_next_line(int fd); +size_t ft_random_generator(size_t start, size_t stop); +void ft_freer_tab_ultimate(size_t len, ...); +void ft_freer_ultimate(size_t len, ...); +char *ft_strgen(char c, size_t len); +char *ft_strfjoin(char *s1, char *s2); +char *ft_strmerger(size_t arg_len, ...); +int ft_is_in(char *str, char c); +char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size); +char *ft_strndup(char *src, size_t n); +ssize_t ft_strchri(char *str, char c); +int ft_contain_only_str(char *str, char *to_find); +int ft_contain_only(char *str, char c); +int ft_strcmp(char *s1, char *s2); +#endif diff --git a/extra/ft_contain_only.c b/extra/ft_contain_only.c new file mode 100644 index 0000000..4844e79 --- /dev/null +++ b/extra/ft_contain_only.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_contain_only.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet 2) + { + temp = ft_strjoin(out, va_arg(va, char *)); + free(out); + if (temp == NULL) + return (NULL); + out = temp; + arg_len--; + } + return (out); +} diff --git a/extra/ft_strndup.c b/extra/ft_strndup.c new file mode 100644 index 0000000..c0fc2aa --- /dev/null +++ b/extra/ft_strndup.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strndup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet +# include +# ifndef BUFFER_SIZE +# define BUFFER_SIZE 42 +# endif +# include "../libft/libft.h" +# include "../extra/extra.h" + +char *get_next_line(int fd); + +#endif diff --git a/gnl/get_next_line_utils.o b/gnl/get_next_line_utils.o new file mode 100644 index 0000000..fccc944 Binary files /dev/null and b/gnl/get_next_line_utils.o differ diff --git a/libft/Makefile b/libft/Makefile new file mode 100644 index 0000000..9a2c3b1 --- /dev/null +++ b/libft/Makefile @@ -0,0 +1,87 @@ +:# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cchauvet = c && c >= '0') + || ('z' >= c && c >= 'a') + || ('Z' >= c && c >= 'A')) + return (1); + return (0); +} diff --git a/libft/ft_isalpha.c b/libft/ft_isalpha.c new file mode 100644 index 0000000..9573931 --- /dev/null +++ b/libft/ft_isalpha.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet = c && c >= 'a') || ('Z' >= c && c >= 'A')) + return (1); + return (0); +} diff --git a/libft/ft_isascii.c b/libft/ft_isascii.c new file mode 100644 index 0000000..5706106 --- /dev/null +++ b/libft/ft_isascii.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isascii.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet = 0 && 127 >= c) + return (1); + return (0); +} diff --git a/libft/ft_isdigit.c b/libft/ft_isdigit.c new file mode 100644 index 0000000..0db99f6 --- /dev/null +++ b/libft/ft_isdigit.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isdigit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet = c && c >= '0') + return (1); + return (0); +} diff --git a/libft/ft_isprint.c b/libft/ft_isprint.c new file mode 100644 index 0000000..fd6d523 --- /dev/null +++ b/libft/ft_isprint.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isprint.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet next = new; +} diff --git a/libft/ft_lstadd_front.c b/libft/ft_lstadd_front.c new file mode 100644 index 0000000..b17cc46 --- /dev/null +++ b/libft/ft_lstadd_front.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_front.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet next = *lst; + *lst = new; +} diff --git a/libft/ft_lstclear.c b/libft/ft_lstclear.c new file mode 100644 index 0000000..e29060a --- /dev/null +++ b/libft/ft_lstclear.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstclear.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet next; + ft_lstdelone(*lst, del); + *lst = next; + } +} diff --git a/libft/ft_lstdelone.c b/libft/ft_lstdelone.c new file mode 100644 index 0000000..73ac454 --- /dev/null +++ b/libft/ft_lstdelone.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstdelone.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet content != NULL) + del(lst->content); + free(lst); + } +} diff --git a/libft/ft_lstiter.c b/libft/ft_lstiter.c new file mode 100644 index 0000000..1baa94d --- /dev/null +++ b/libft/ft_lstiter.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstiter.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet content); + lst = lst->next; + } +} diff --git a/libft/ft_lstlast.c b/libft/ft_lstlast.c new file mode 100644 index 0000000..ba0d9d7 --- /dev/null +++ b/libft/ft_lstlast.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstlast.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet next != NULL) + lst = lst->next; + return (lst); +} diff --git a/libft/ft_lstmap.c b/libft/ft_lstmap.c new file mode 100644 index 0000000..ed99c7c --- /dev/null +++ b/libft/ft_lstmap.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstmap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet content)); + if (root == NULL) + return (NULL); + last = root; + lst = lst->next; + while (lst != NULL) + { + last->next = ft_lstnew(f(lst->content)); + if (last->next == NULL) + { + ft_lstclear(&root, del); + return (NULL); + } + lst = lst->next; + last = last->next; + } + return (root); +} diff --git a/libft/ft_lstnew.c b/libft/ft_lstnew.c new file mode 100644 index 0000000..705733e --- /dev/null +++ b/libft/ft_lstnew.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet next = NULL; + new->content = content; + return (new); +} diff --git a/libft/ft_lstsize.c b/libft/ft_lstsize.c new file mode 100644 index 0000000..fa39de9 --- /dev/null +++ b/libft/ft_lstsize.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstsize.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet next; + } + return (count); +} diff --git a/libft/ft_memchr.c b/libft/ft_memchr.c new file mode 100644 index 0000000..28f3775 --- /dev/null +++ b/libft/ft_memchr.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet 9) + { + ft_putnbr_fd(n / 10, fd); + ft_putnbr_fd(n % 10, fd); + } + else + ft_putchar_fd(n + 48, fd); +} diff --git a/libft/ft_putstr_fd.c b/libft/ft_putstr_fd.c new file mode 100644 index 0000000..d8c87d2 --- /dev/null +++ b/libft/ft_putstr_fd.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet = size) + return (ft_strlen(src) + (size)); + return (len_dest + ft_strlcpy(dest + len_dest, src, size - len_dest)); +} diff --git a/libft/ft_strlcpy.c b/libft/ft_strlcpy.c new file mode 100644 index 0000000..677264b --- /dev/null +++ b/libft/ft_strlcpy.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet 0) + if (s[i] == (char) c) + return ((char *) s + i); + return (NULL); +} diff --git a/libft/ft_strtrim.c b/libft/ft_strtrim.c new file mode 100644 index 0000000..229cb81 --- /dev/null +++ b/libft/ft_strtrim.c @@ -0,0 +1,44 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strtrim.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet len) + size = len; + ptr = malloc((size + 1) * sizeof(char)); + if (ptr == NULL) + return (NULL); + ptr[size] = '\0'; + while (size-- > 0) + ptr[size] = s[start + size]; + return (ptr); +} diff --git a/libft/ft_tolower.c b/libft/ft_tolower.c new file mode 100644 index 0000000..14d83da --- /dev/null +++ b/libft/ft_tolower.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_tolower.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet = 'A' && 'Z' >= c)); +} diff --git a/libft/ft_toupper.c b/libft/ft_toupper.c new file mode 100644 index 0000000..3775f6d --- /dev/null +++ b/libft/ft_toupper.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_toupper.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet = 'a' && 'z' >= c)); +} diff --git a/libft/libft.h b/libft/libft.h new file mode 100644 index 0000000..3c98b38 --- /dev/null +++ b/libft/libft.h @@ -0,0 +1,71 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet +# include + +void *ft_cancel(char **tab, size_t len); +int ft_atoi(const char *nptr); +void ft_bzero(void *s, size_t n); +void *ft_calloc(size_t nmemb, size_t size); +int ft_isalnum(int c); +int ft_isalpha(int c); +int ft_isascii(int c); +int ft_isdigit(int c); +int ft_isprint(int c); +void *ft_memchr(const void *s, int c, size_t n); +int ft_memcmp(const void *s1, const void *s2, 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_memset(void *s, int c, size_t n); +char *ft_strchr(const char *s, int c); +char *ft_strdup(const char *s); +size_t ft_strlcat(char *dst, const char *src, size_t size); +size_t ft_strlcpy(char *dst, const char *src, size_t size); +size_t ft_strlen(const char *s); +int ft_strncmp(const char *s1, const char *s2, size_t n); +char *ft_strnstr(const char *big, const char *little, size_t len); +char *ft_strrchr(const char *s, int c); +int ft_tolower(int c); +int ft_toupper(int c); + +char *ft_substr(char const *s, unsigned int start, size_t len); +char *ft_strjoin(char const *s1, char const *s2); +char *ft_strtrim(char const *s1, char const *set); +char **ft_split(char const *s, char c); +char *ft_itoa(int n); +char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); +void ft_striteri(char *s, void (*f)(unsigned int, char*)); +void ft_putchar_fd(int fd, char c); +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 *nouveau); +int ft_lstsize(t_list *lst); +t_list *ft_lstlast(t_list *lst); +void ft_lstadd_back(t_list **lst, t_list *nouveau); +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 diff --git a/libftx.h b/libftx.h new file mode 100644 index 0000000..e9d6a7a --- /dev/null +++ b/libftx.h @@ -0,0 +1,89 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libftx.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet +# include +# include + +char *ft_ultoa_base(unsigned long long n, char *base); +int ft_printf(const char *format, ...); +char *get_next_line(int fd); +size_t ft_random_generator(size_t start, size_t stop); +void ft_freer_tab_ultimate(size_t len, ...); +void ft_freer_ultimate(size_t len, ...); +char *ft_strgen(char c, size_t len); +int ft_is_in(char *str, char c); +char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size); +int ft_contain_only_str(char *str, char *to_find); +int ft_contain_only(char *str, char c); +char *ft_strfjoin(char *s1, char *s2); +char *ft_strmerger(size_t arg_len, ...); +int ft_strcmp(char *s1, char *s2); +ssize_t ft_strchri(char *str, char c); +char *ft_strndup(char *src, size_t n); + +void *ft_cancel(char **tab, size_t len); +int ft_atoi(const char *nptr); +void ft_bzero(void *s, size_t n); +void *ft_calloc(size_t nmemb, size_t size); +int ft_isalnum(int c); +int ft_isalpha(int c); +int ft_isascii(int c); +int ft_isdigit(int c); +int ft_isprint(int c); +void *ft_memchr(const void *s, int c, size_t n); +int ft_memcmp(const void *s1, const void *s2, 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_memset(void *s, int c, size_t n); +char *ft_strchr(const char *s, int c); +char *ft_strdup(const char *s); +size_t ft_strlcat(char *dst, const char *src, size_t size); +size_t ft_strlcpy(char *dst, const char *src, size_t size); +size_t ft_strlen(const char *s); +int ft_strncmp(const char *s1, const char *s2, size_t n); +char *ft_strnstr(const char *big, const char *little, size_t len); +char *ft_strrchr(const char *s, int c); +int ft_tolower(int c); +int ft_toupper(int c); + +char *ft_substr(char const *s, unsigned int start, size_t len); +char *ft_strjoin(char const *s1, char const *s2); +char *ft_strtrim(char const *s1, char const *set); +char **ft_split(char const *s, char c); +char *ft_itoa(int n); +char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); +void ft_striteri(char *s, void (*f)(unsigned int, char*)); +void ft_putchar_fd(int fd, char c); +void ft_putstr_fd(int fd, char *s); +void ft_putendl_fd(int fd, char *s); +void ft_putnbr_fd(int fd, int n); + +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 *nouveau); +int ft_lstsize(t_list *lst); +t_list *ft_lstlast(t_list *lst); +void ft_lstadd_back(t_list **lst, t_list *nouveau); +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 diff --git a/printf/Makefile b/printf/Makefile new file mode 100644 index 0000000..7be75df --- /dev/null +++ b/printf/Makefile @@ -0,0 +1,39 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cchauvet base_size - 1) + { + ft_dprintul_base(fd, n / base_size, base); + ft_putchar_fd(fd, base[n % base_size]); + } + else + ft_putchar_fd(fd, base[n]); + return (str_size - 1); +} diff --git a/printf/ft_dprintx.c b/printf/ft_dprintx.c new file mode 100644 index 0000000..6d6de6e --- /dev/null +++ b/printf/ft_dprintx.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_dprintx.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet = '0') + return (1); + return (0); +} diff --git a/printf/ft_printf.c b/printf/ft_printf.c new file mode 100644 index 0000000..80cedbe --- /dev/null +++ b/printf/ft_printf.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet +# include + +size_t ft_strlen(const char *s); +char *ft_strchr(const char *s, int c); +int ft_isdigit(int c); +int ft_skipflag(const char *str); +int ft_isarg(int c); + +int ft_dprintptr(int fd, void *ptr); +int ft_dprintl_base(int fd, long long n, char *base); +int ft_dprintul_base(int fd, unsigned long long n, char *base); +int ft_dprintul(int fd, unsigned long long n); +int ft_dprintx(int fd, unsigned int n); +int ft_dprint_upperx(int fd, unsigned int n); +int ft_dprintflag(int fd, const char *flag, va_list va); +int ft_dprintarg(int fd, int c, va_list va); +int ft_dprintstrtab(int fd, char **tab); + +int ft_printf(const char *format, ...); + +int ft_vdprintf(int fd, const char *format, va_list va); + +int ft_putchar_fd(int fd, char c); +int ft_putstr_fd(int fd, char *str); + +#endif diff --git a/printf/ft_putchar_fd.c b/printf/ft_putchar_fd.c new file mode 100644 index 0000000..d509e9c --- /dev/null +++ b/printf/ft_putchar_fd.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet