bastien 1 месяц назад
Сommit
557d6e510a
100 измененных файлов с 4121 добавлено и 0 удалено
  1. 153 0
      Makefile
  2. 62 0
      Makefile.example
  3. 1 0
      README.md
  4. 43 0
      includes/ft_defs.h
  5. 116 0
      includes/libft.h
  6. 96 0
      includes/libftprintf.h
  7. 37 0
      srcs/ft_atoi.c
  8. 20 0
      srcs/ft_bzero.c
  9. 27 0
      srcs/ft_charjoin.c
  10. 29 0
      srcs/ft_cptchar.c
  11. 40 0
      srcs/ft_cptchar_glued.c
  12. 25 0
      srcs/ft_cptcmp.c
  13. 42 0
      srcs/ft_dup_first_word.c
  14. 21 0
      srcs/ft_exit.c
  15. 40 0
      srcs/ft_get_file_content.c
  16. 23 0
      srcs/ft_getchar.c
  17. 27 0
      srcs/ft_getenv.c
  18. 52 0
      srcs/ft_htoa.c
  19. 21 0
      srcs/ft_isalnum.c
  20. 20 0
      srcs/ft_isalpha.c
  21. 20 0
      srcs/ft_isascii.c
  22. 20 0
      srcs/ft_isdigit.c
  23. 20 0
      srcs/ft_islower.c
  24. 28 0
      srcs/ft_isnum.c
  25. 20 0
      srcs/ft_isprint.c
  26. 20 0
      srcs/ft_isupper.c
  27. 39 0
      srcs/ft_itoa.c
  28. 72 0
      srcs/ft_itoa_base.c
  29. 63 0
      srcs/ft_itoa_base_depth.c
  30. 37 0
      srcs/ft_itohex.c
  31. 21 0
      srcs/ft_lstadd.c
  32. 33 0
      srcs/ft_lstdel.c
  33. 29 0
      srcs/ft_lstdelone.c
  34. 25 0
      srcs/ft_lstiter.c
  35. 36 0
      srcs/ft_lstnew.c
  36. 24 0
      srcs/ft_memalloc.c
  37. 31 0
      srcs/ft_memccpy.c
  38. 33 0
      srcs/ft_memchr.c
  39. 33 0
      srcs/ft_memcmp.c
  40. 34 0
      srcs/ft_memcpy.c
  41. 21 0
      srcs/ft_memdel.c
  42. 28 0
      srcs/ft_memdel2.c
  43. 32 0
      srcs/ft_memmove.c
  44. 27 0
      srcs/ft_memset.c
  45. 30 0
      srcs/ft_nb_word.c
  46. 43 0
      srcs/ft_nbrlen.c
  47. 26 0
      srcs/ft_pow.c
  48. 56 0
      srcs/ft_print_memory.c
  49. 99 0
      srcs/ft_printf.c
  50. 66 0
      srcs/ft_printf/pf_b.c
  51. 32 0
      srcs/ft_printf/pf_c.c
  52. 60 0
      srcs/ft_printf/pf_c_up.c
  53. 72 0
      srcs/ft_printf/pf_d_up.c
  54. 97 0
      srcs/ft_printf/pf_di.c
  55. 49 0
      srcs/ft_printf/pf_len.c
  56. 142 0
      srcs/ft_printf/pf_more_inf.c
  57. 63 0
      srcs/ft_printf/pf_o.c
  58. 48 0
      srcs/ft_printf/pf_o_up.c
  59. 97 0
      srcs/ft_printf/pf_p.c
  60. 29 0
      srcs/ft_printf/pf_percent.c
  61. 67 0
      srcs/ft_printf/pf_putnbr.c
  62. 65 0
      srcs/ft_printf/pf_putnbrlong.c
  63. 48 0
      srcs/ft_printf/pf_putstr.c
  64. 50 0
      srcs/ft_printf/pf_s.c
  65. 40 0
      srcs/ft_printf/pf_s_up.c
  66. 95 0
      srcs/ft_printf/pf_take_inf.c
  67. 52 0
      srcs/ft_printf/pf_u.c
  68. 46 0
      srcs/ft_printf/pf_u_up.c
  69. 100 0
      srcs/ft_printf/pf_x.c
  70. 97 0
      srcs/ft_printf/pf_x_up.c
  71. 21 0
      srcs/ft_putascii.c
  72. 30 0
      srcs/ft_putchar.c
  73. 26 0
      srcs/ft_putendl.c
  74. 23 0
      srcs/ft_puthex.c
  75. 40 0
      srcs/ft_putnbr.c
  76. 22 0
      srcs/ft_putnbr_base.c
  77. 26 0
      srcs/ft_putstr.c
  78. 24 0
      srcs/ft_puttab.c
  79. 25 0
      srcs/ft_sqrt.c
  80. 23 0
      srcs/ft_str_lower.c
  81. 23 0
      srcs/ft_str_upper.c
  82. 20 0
      srcs/ft_strcat.c
  83. 24 0
      srcs/ft_strchr.c
  84. 28 0
      srcs/ft_strcmp.c
  85. 27 0
      srcs/ft_strcmp_end.c
  86. 32 0
      srcs/ft_strcorr.c
  87. 18 0
      srcs/ft_strcpy.c
  88. 25 0
      srcs/ft_strdup.c
  89. 25 0
      srcs/ft_strequ.c
  90. 31 0
      srcs/ft_strichr.c
  91. 36 0
      srcs/ft_strisdigit.c
  92. 25 0
      srcs/ft_striter.c
  93. 28 0
      srcs/ft_striteri.c
  94. 27 0
      srcs/ft_strjoin.c
  95. 34 0
      srcs/ft_strlcat.c
  96. 24 0
      srcs/ft_strlen.c
  97. 36 0
      srcs/ft_strmap.c
  98. 35 0
      srcs/ft_strmapi.c
  99. 23 0
      srcs/ft_strmerge.c
  100. 30 0
      srcs/ft_strncat.c

+ 153 - 0
Makefile

@@ -0,0 +1,153 @@
+#******************************************************************************#
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2015/11/27 00:02:23 by bchanot           #+#    #+#              #
+#*   Updated: 2018/10/12 22:30:35 by bchanot          ###   ########.fr       *#
+#                                                                              #
+#******************************************************************************#
+
+CC = gcc -Wall -Wextra -Werror -g
+NAME = libft.a
+OBJS_DIR = .objects/
+SRCS_DIR = srcs/
+INC = -I./includes
+FILES = ft_atoi \
+	ft_strrchr \
+	ft_bzero \
+	ft_memalloc \
+	ft_strsplit \
+	ft_isalnum \
+	ft_isnum \
+	ft_memccpy \
+	ft_strjoin \
+	ft_strstr \
+	ft_isalpha \
+	ft_memchr \
+	ft_putstr \
+	ft_strlcat \
+	ft_strsub \
+	ft_isascii \
+	ft_memcmp \
+	ft_strlen \
+	ft_strtrim \
+	ft_isdigit \
+	ft_memcpy \
+	ft_strcat \
+	ft_tolower \
+	ft_isprint \
+	ft_memdel \
+	ft_strchr \
+	ft_toupper \
+	ft_strncat \
+	ft_strcmp \
+	ft_strncmp \
+	ft_memset \
+	ft_strcpy \
+	ft_strncpy \
+	ft_putchar \
+	ft_strnequ \
+	ft_strdup \
+	ft_strnew \
+	ft_putendl \
+	ft_strequ \
+	ft_strnstr \
+	ft_cptchar \
+	ft_puttab \
+	ft_exit \
+	ft_sqrt \
+	ft_unicode \
+	ft_strnjoin \
+	ft_getchar \
+	ft_charjoin \
+	ft_isupper \
+	ft_islower \
+	ft_memdel2 \
+	ft_strisdigit \
+	ft_strcmp_end \
+	ft_tablen \
+	ft_swap \
+	ft_tabnew \
+	ft_printf \
+	ft_strcorr \
+	ft_strichr \
+	ft_strreplace \
+	ft_cptcmp \
+	ft_itoa_base_depth \
+	ft_itoa_base \
+	ft_take_last_chain \
+	ft_nb_word \
+	ft_tabjoin \
+	ft_getenv \
+	ft_tabdup \
+	ft_cptchar_glued \
+	ft_puthex \
+	ft_putascii \
+	ft_system \
+	ft_print_memory \
+	ft_dup_first_word \
+	ft_strndup \
+	ft_strmerge \
+	ft_take_args \
+	ft_take_opts \
+	ft_get_file_content \
+	ft_str_upper \
+	ft_str_lower \
+	ft_pow \
+	ft_nbrlen \
+	ft_putnbr \
+	get_next_line
+PRINTF = pf_b \
+		pf_c \
+		pf_c_up \
+		pf_d_up \
+		pf_di \
+		pf_len \
+		pf_more_inf \
+		pf_o \
+		pf_o_up \
+		pf_p \
+		pf_percent \
+		pf_putnbr \
+		pf_putnbrlong \
+		pf_putstr \
+		pf_s \
+		pf_s_up \
+		pf_take_inf \
+		pf_u \
+		pf_u_up \
+		pf_x \
+		pf_x_up
+SRC_PRINTF = $(addprefix ft_printf/, $(PRINTF))
+SRC = $(FILES) $(SRC_PRINTF)
+OBJS := $(addprefix $(OBJS_DIR), $(addsuffix .o, $(SRC)))
+RED = \033[1;31m
+BLUE = \033[1;34m
+CYAN = \033[0;36m
+GREEN = \033[1;32m
+YELLOW = \033[1;33m
+EOC = \033[0m
+
+all: $(NAME)
+
+$(NAME): $(OBJS)
+	@ar rc $(NAME) $(OBJS)
+	@ranlib $(NAME)
+	@echo -e "$(GREEN)Libft crated.$(EOC)"
+
+$(OBJS_DIR)%.o: $(SRCS_DIR)%.c
+	@mkdir -p $(dir $@)
+	$(CC) -c $< $(INC) -o $@
+
+clean:
+	@/bin/rm -rf $(OBJS_DIR)
+
+fclean: clean
+	@/bin/rm -f $(NAME)
+
+re: fclean all
+
+.PHONY: all clean fclean re

+ 62 - 0
Makefile.example

@@ -0,0 +1,62 @@
+#******************************************************************************#
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#*   Updated: 2018/03/15 13:30:20 by xuser            ###   ########.fr       *#
+#                                                                              #
+#******************************************************************************#
+
+NAME = ft_
+MAKE_LIBS = make --no-print-directory
+SRCS_DIR = srcs/
+OBJS_DIR = .objects/
+LIBS_DIR = ./libs/
+CC = gcc -Wall -Wextra -Werror
+LIB = -L$(LIBS_DIR)/libft/ -lft
+INC = -I./includes -I$(LIBS_DIR)/libft/includes
+SRCS = file1 \
+		file2
+#SUB_DIR_SRCS = sub_dir/
+#SUB_FILES = sub_dir_file1 \
+#			sub_dir_file2
+#SUB_SRCS = $(addprefix SUB_DIR_SRCS, $(SUB_FILES))
+#SRCS += $(SUB_SRC)
+OBJS = $(addprefix $(OBJS_DIR), $(addsuffix .o, $(FILES)))
+RED = \033[1;31m
+BLUE = \033[1;34m
+CYAN = \033[0;36m
+GREEN = \033[1;32m
+YELLOW = \033[1;33m
+EOC = \033[0m
+
+all: libs $(NAME)
+
+libs:
+	@$(MAKE_LIBS) -C $(LIBS_DIR)/libft
+
+$(NAME): $(OBJS)
+	@echo -e "$(GREEN)Objects created.$(EOC)"
+	@$(CC) $(OBJS) $(LIB) $(INC) -o $(NAME)
+	@echo -e "$(GREEN)Compilation complete.$(EOC)"
+
+$(OBJS_DIR)%.o: $(SRCS_DIR)%.c
+	@mkdir -p $(dir $@)
+	$(CC) -c $< $(INC) -o $@
+
+clean:
+	@echo -e "$(RED)Deleting objects.$(EOC)"
+	@/bin/rm -rf $(OBJS_DIR)
+	@$(MAKE_LIBS) clean -C $(LIBS_DIR)/libft
+
+fclean: clean
+	@echo -e "$(RED)Deleting binary.$(EOC)"
+	@/bin/rm -rf $(NAME)
+	@$(MAKE_LIBS) fclean -C $(LIBS_DIR)/libft
+
+re: fclean all
+
+.PHONY: all libs clean fclean re

+ 1 - 0
README.md

@@ -0,0 +1 @@
+My library of C functions.

+ 43 - 0
includes/ft_defs.h

@@ -0,0 +1,43 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_defs.h                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/10/05 22:22:34 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/22 02:46:35 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef FT_DEFS_H
+# define FT_DEFS_H
+
+# include <string.h>
+
+# define NO_FLAGS 0
+
+typedef unsigned char		t_uint8;
+typedef unsigned short		t_uint16;
+typedef unsigned int		t_uint32;
+typedef unsigned long long	t_uint64;
+typedef char				t_int8;
+typedef short				t_int16;
+typedef int					t_int32;
+typedef long long			t_int64;
+
+typedef struct				s_gnl
+{
+	char					*tmp;
+	int						fd;
+	int						eof;
+	struct s_gnl			*next;
+}							t_gnl;
+
+typedef enum				e_bool
+{
+	false,
+	true
+}							t_bool;
+
+#endif

+ 116 - 0
includes/libft.h

@@ -0,0 +1,116 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   libft.h                                            :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/09/09 20:40:59 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:16:55 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef LIBFT_H
+# define LIBFT_H
+# define BUFF_SIZE 8
+
+# include "ft_defs.h"
+# include <wchar.h>
+
+char		*ft_strreplace(const char *src, const char *var, const char *val);
+int			ft_printf(int fd, const char *format, ...);
+int			ft_isalpha(int c);
+int			ft_isdigit(int c);
+int			ft_isnum(const char *s);
+int			ft_isascii(int c);
+int			ft_isprint(int c);
+int			ft_isalnum(int c);
+int			ft_isupper(int c);
+int			ft_isupper(int c);
+
+int			ft_toupper(int c);
+int			ft_tolower(int c);
+char		*ft_strstr(const char *s1, const char *s2);
+char		*ft_strnstr(const char *const s1, const char *const s2, size_t n);
+char		*ft_strchr(const char *s, int c);
+char		*ft_strrchr(const char *s, int c);
+size_t		ft_strichr(const char *const s, int c);
+char		*ft_strcpy(char *dst, const char *src);
+char		*ft_strncpy(char *dst, const char *src, size_t n);
+int			ft_strcmp(const char *const s1, const char *const s2);
+int			ft_strncmp(const char *const s1, const char *const s2, size_t n);
+char		*ft_strcat(char *dest, const char *src);
+char		*ft_strncat(char *s1, const char *const s2, size_t n);
+size_t		ft_strlcat(char *dst, const char *const src, size_t size);
+size_t		ft_strlen(const char *const s);
+size_t		ft_tablen(char **tab);
+char		*ft_strdup(const char *src);
+int			ft_bzero(void *s, size_t n);
+void		*ft_memset(void *b, int c, size_t len);
+void		*ft_memcpy(void *dst, const void *src, size_t n);
+int			ft_memcmp(const void *s1, const void *s2, size_t n);
+void		*ft_memchr(const void *s, int c, size_t n);
+void		*ft_memccpy(void *dst, const void *src, int c, size_t n);
+void		*ft_memalloc(size_t size);
+char		*ft_utoa_base(t_uint64 value, t_uint8 base);
+char		*ft_itoa_base(t_int64 value, t_uint8 base);
+char		*ft_utoa_base_depth(t_uint64 nb, t_uint8 base, size_t depth);
+char		*ft_itoa_base_depth(t_int64 nb, t_uint8 base, size_t depth);
+int			ft_atoi(const char *src);
+void		ft_memdel(void **ap);
+void		ft_memdel2(void ***ap);
+int			ft_putchar(int c);
+int			ft_putchar_fd(int c, int fd);
+void		ft_putendl(const char *const s);
+void		ft_putendl_fd(const char *const s, int fd);
+void		ft_putstr(const char *const s);
+void		ft_putstr_fd(const char *const s, int fd);
+void		ft_putascii(unsigned char c);
+void		ft_puthex(unsigned char c, int maj);
+void		ft_puttab(char **tab);
+int			ft_strequ(const char *const s1, const char *const s2);
+int			ft_strnequ(const char *const s1, const char *const s2, size_t n);
+char		*ft_strnew(size_t size);
+char		**ft_tabnew(size_t len);
+char		*ft_strsub(const char *const src, unsigned int start, size_t len);
+char		*ft_strjoin(const char *s1, const char *s2);
+char		*ft_strnjoin(const char *s1, const char *s2, size_t n);
+char		*ft_strtrim(const char *src);
+char		**ft_strsplit(const char *s, char c);
+size_t		ft_cptchar(const char *src, char c);
+void		ft_exit(const char *const s, int fd);
+size_t		ft_sqrt(size_t nb);
+char		*ft_widechar(wchar_t c);
+char		*ft_widestr(wchar_t *src);
+int			get_next_line(int const fd, char **line);
+int			ft_getchar(int fd);
+char		*ft_charjoin(const char *src, const char c);
+int			ft_strcmp_end(const char *s1, const char *const s2);
+int			ft_strisdigit(const char *src);
+void		ft_swap(int *a, int *b);
+char		*ft_strcorr(const char *const src, const char c);
+size_t		ft_cptcmp(const char *const s1, const char *const s2);
+char		*ft_take_last_chain(char *src);
+size_t		ft_nb_word(const char *src);
+char		**ft_tabjoin(char **tabl, const char *const src);
+char		*ft_getenv(char **env, const char *const src);
+char		**ft_tabdup(char **tabl);
+size_t		ft_cptchar_glued(const char *src, char c);
+void		ft_system(char *src);
+void		ft_print_memory(const void *addr, size_t size);
+char		*ft_dup_first_word(const char *src);
+char		*ft_strmerge(char *s1, char *s2);
+char		*ft_strndup(const char *src, int n);
+char		**ft_take_args_begin(int ac, char **av);
+char		**ft_take_opts_begin(int ac, char **av);
+t_bool		ft_check_opts(char **tab, const char *opt);
+char		*ft_get_file_content(int fd);
+char		*ft_str_upper(char *src);
+char		*ft_str_lower(char *src);
+size_t		ft_pow(int a, int b);
+size_t		ft_nbrlen(t_int64 nb);
+size_t		ft_nbrulen(t_uint64 nb);
+void		ft_putunbr_fd(t_uint64 nb, int fd);
+void		ft_putnbr_fd(t_int64 nb, int fd);
+
+#endif

+ 96 - 0
includes/libftprintf.h

@@ -0,0 +1,96 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   libftprintf.h                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 00:34:04 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:44:53 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef LIBFTPRINTF_H
+# define LIBFTPRINTF_H
+
+# include <stdarg.h>
+# include "libft.h"
+
+# define BLACK "\033[0;30m"
+# define RED "\033[0;31m"
+# define GREEN "\033[0;32m"
+# define YELLOW "\033[0;33m"
+# define BLUE "\033[0;34m"
+# define PURPLE "\033[0;35m"
+# define CYAN "\033[0;36m"
+# define GREY "\033[0;37m"
+# define EOC "\033[0;m"
+
+typedef struct		s_inf
+{
+	int				done;
+	int				fd;
+
+	int				flag;
+	int				di;
+	int				zero;
+	int				min;
+	int				space;
+	int				plus;
+
+	int				h;
+	int				hh;
+	int				l;
+	int				ll;
+	int				j;
+	int				z;
+
+	int				width;
+	int				prec;
+	int				type;
+}					t_inf;
+
+int					ft_printf(int fd, const char *format, ...);
+int					pf_print_part(const char *format, char *s, int fd);
+int					pf_take_color(char **s, const char **format,
+									int *len, int fd);
+void				pf_do_if(t_inf *inf, long long int nb, int min);
+t_inf				pf_take_inf(char **s, va_list ap, int fd);
+void				take_prec(char **s, t_inf *inf, va_list ap, int i);
+int					pf_more_flag(char **s, t_inf *inf);
+int					pf_wrong_conv(char **s, const char **format, t_inf inf,
+								int *len);
+int					pf_width_s(char *s, t_inf inf, int len);
+int					pf_octlen(unsigned int n, t_inf inf);
+int					pf_hexlen(unsigned int n);
+int					pf_octulen(long long unsigned int n, t_inf inf);
+int					pf_hexulen(long long unsigned int n);
+int					pf_putoctal(unsigned int n, int fd);
+int					pf_puthexm(unsigned int n, int fd);
+int					pf_puthex(unsigned int n, int fd);
+int					pf_putuoctal(long long unsigned int n, int fd);
+int					pf_putuhexm(long long unsigned int n, int fd);
+int					pf_putuhex(long long unsigned int n, int fd);
+int					pf_putunbrlong(long long unsigned int n, int fd);
+int					pf_putunbr(unsigned int n, int fd);
+int					pf_putstr(const char *s, int fd);
+int					pf_putnstr(const char *s, int n, int fd);
+int					pf_percent(va_list ap, t_inf inf);
+int					pf_c(va_list ap, t_inf inf);
+int					pf_s(va_list ap, t_inf inf);
+int					pf_di(va_list ap, t_inf inf);
+int					pf_p(va_list ap, t_inf inf);
+int					pf_x(va_list ap, t_inf inf);
+int					pf_xlong2(int len, t_inf *inf, unsigned long long nb);
+int					pf_u(va_list ap, t_inf inf);
+int					pf_o(va_list ap, t_inf inf);
+int					pf_b(va_list ap, t_inf inf);
+int					pf_x_up(va_list ap, t_inf inf);
+int					pf_x_uplong2(int len, t_inf *inf, unsigned long long nb);
+int					pf_s_up(va_list ap, t_inf inf);
+int					pf_d_up(va_list ap, t_inf inf);
+int					pf_o_up(va_list ap, t_inf inf);
+int					pf_u_up(va_list ap, t_inf inf);
+int					pf_c_up(va_list ap, t_inf inf);
+
+#endif

+ 37 - 0
srcs/ft_atoi.c

@@ -0,0 +1,37 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_atoi.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 17:07:30 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/13 19:54:48 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_atoi(const char *src)
+{
+	int		nb;
+	t_bool	neg;
+
+	neg = false;
+	nb = 0;
+	if (!src)
+		return (0);
+	while (*src == ' ' || (*src >= 7 && *src <= 15))
+		src++;
+	if (*src == '-')
+		neg = true;
+	if (*src == '+' || *src == '-')
+		src++;
+	while (*src >= '0' && *src <= '9')
+	{
+		nb *= 10;
+		nb += (*src - 48);
+		src++;
+	}
+	return (neg ? -nb : nb);
+}

+ 20 - 0
srcs/ft_bzero.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_bzero.c                                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/24 15:27:39 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/11 20:18:16 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_bzero(void *s, size_t n)
+{
+	if (s && n)
+		ft_memset(s, 0, n);
+	return (true);
+}

+ 27 - 0
srcs/ft_charjoin.c

@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_charjoin.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/07/23 03:06:18 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/13 19:51:19 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+char	*ft_charjoin(const char *src, const char c)
+{
+	char	*s;
+
+	if (!src || !c)
+		return (NULL);
+	if (!(s = ft_strnew(ft_strlen(src) + 1)))
+		return (NULL);
+	s = ft_strcpy(s, src);
+	*(s + ft_strlen(s)) = c;
+	return (s);
+}

+ 29 - 0
srcs/ft_cptchar.c

@@ -0,0 +1,29 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_cptchar.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/12/23 15:16:22 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/13 20:10:40 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t	ft_cptchar(const char *src, char c)
+{
+	size_t	i;
+
+	i = 0;
+	if (!src || !c)
+		return (0);
+	while (*src)
+	{
+		if (*src == c)
+			i++;
+		src++;
+	}
+	return (i);
+}

+ 40 - 0
srcs/ft_cptchar_glued.c

@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_cptchar_glued.c                                 :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/04/28 00:56:56 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:15:35 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t	ft_cptchar_glued(const char *src, char c)
+{
+	size_t	i;
+	size_t	j;
+
+	j = 0;
+	if (!src || !ft_cptchar(src, c))
+		return (0);
+	while (*src)
+	{
+		if (*src == c)
+		{
+			i = 0;
+			while (*src && *src == c)
+			{
+				src++;
+				i++;
+			}
+			if (i > j)
+				j = i;
+		}
+		else
+			src++;
+	}
+	return (j);
+}

+ 25 - 0
srcs/ft_cptcmp.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_cptcmp.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/01/31 14:14:51 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:15:59 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t	ft_cptcmp(const char *const s1, const char *const s2)
+{
+	size_t	i;
+
+	i = 0;
+	if (!s1 || !s2)
+		return (0);
+	while (s1[i] && s2[i] && s2[i] == s1[i])
+		i++;
+	return (i);
+}

+ 42 - 0
srcs/ft_dup_first_word.c

@@ -0,0 +1,42 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_dup_first_word.c                                :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/12/04 22:56:53 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/13 20:16:50 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_dup_first_word(const char *src)
+{
+	const char	*tmp;
+	size_t		i;
+	char		*ret;
+
+	tmp = src;
+	i = 0;
+	while (*tmp && ((*tmp >= 7 && *tmp <= 13) || *tmp == ' '))
+		tmp++;
+	while (*tmp && ((*tmp < 7 || *tmp > 13) && *tmp != ' '))
+	{
+		tmp++;
+		i++;
+	}
+	if (!(ret = ft_strnew(i)))
+		return (NULL);
+	tmp = src;
+	i = 0;
+	while (*tmp && ((*tmp >= 7 && *tmp <= 13) || *tmp == ' '))
+		tmp++;
+	while (*tmp && ((*tmp < 7 || *tmp > 13) && *tmp != ' '))
+	{
+		ret[i++] = *tmp;
+		tmp++;
+	}
+	return (ret);
+}

+ 21 - 0
srcs/ft_exit.c

@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_exit.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/01/23 20:00:55 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:15:07 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+void	ft_exit(const char *const s, int fd)
+{
+	if (s)
+		ft_putendl_fd(s, fd);
+	exit(fd == 1 ? EXIT_SUCCESS : EXIT_FAILURE);
+}

+ 40 - 0
srcs/ft_get_file_content.c

@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_get_file_content.c                              :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/09/23 19:01:27 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:19:25 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <unistd.h>
+
+char	*ft_get_file_content(int fd)
+{
+	char	*buff;
+	char	*tmp;
+	char	*s;
+
+	buff = (char *)ft_memalloc(sizeof(char) * BUFF_SIZE + 1);
+	ft_bzero(buff, BUFF_SIZE);
+	s = NULL;
+	while (read(fd, buff, BUFF_SIZE) > 0)
+	{
+		if (!s)
+			s = ft_strdup(buff);
+		else
+		{
+			tmp = ft_strjoin(s, buff);
+			ft_memdel((void **)&s);
+			s = tmp;
+			tmp = NULL;
+		}
+		ft_bzero(buff, BUFF_SIZE);
+	}
+	ft_memdel((void **)&buff);
+	return (s);
+}

+ 23 - 0
srcs/ft_getchar.c

@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_getchar.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/06/15 18:46:16 by bchanot           #+#    #+#             */
+/*   Updated: 2017/11/13 15:31:49 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <unistd.h>
+
+int	ft_getchar(int fd)
+{
+	char	c;
+
+	if (read(fd, &c, 1) != 1)
+		return (-1);
+	return ((int)c);
+}

+ 27 - 0
srcs/ft_getenv.c

@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_getenv.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/03/03 02:48:21 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:14:56 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char		*ft_getenv(char **env, const char *const src)
+{
+	if (!env || !ft_tablen(env))
+		return (NULL);
+	while (*env)
+	{
+		if (!ft_strncmp(*env, src, ft_strlen(src)) &&
+			*(*env + ft_strlen(src)) == '=')
+			return ((char *)*env + (ft_strlen(src) + 1));
+		env++;
+	}
+	return (NULL);
+}

+ 52 - 0
srcs/ft_htoa.c

@@ -0,0 +1,52 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_htoa.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/11 19:54:05 by bchanot           #+#    #+#             */
+/*   Updated: 2018/04/17 11:49:39 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+static int	valuehex(int x)
+{
+	if (x >= 0 && x <= 9)
+		return (48 + x);
+	else if (x >= 10 && x <= 15)
+	{
+		x = x - 10;
+		return (97 + x);
+	}
+	return (0);
+}
+
+char		*ft_htoa(long long unsigned int nb)
+{
+	long long unsigned int	x;
+	char					*str;
+	int						cpt;
+
+	x = nb;
+	cpt = 0;
+	while (x > 16)
+	{
+		x /= 16;
+		cpt++;
+	}
+	if ((str = (char *)ft_memalloc(sizeof(char *) * cpt + 1)))
+	{
+		str[cpt + 1] = '\0';
+		while (cpt >= 0)
+		{
+			x = nb % 16;
+			str[cpt] = valuehex(x);
+			nb /= 16;
+			cpt--;
+		}
+	}
+	return (str);
+}

+ 21 - 0
srcs/ft_isalnum.c

@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isalnum.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/12/29 16:18:26 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:33:31 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_isalnum(int c)
+{
+	if ((c >= 48 && c <= 57) || (c >= 65 && c <= 90) ||
+		(c >= 97 && c <= 122))
+		return (true);
+	return (false);
+}

+ 20 - 0
srcs/ft_isalpha.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isalpha.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/27 14:54:35 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:33:40 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_isalpha(int c)
+{
+	if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122))
+		return (true);
+	return (false);
+}

+ 20 - 0
srcs/ft_isascii.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isascii.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 12:46:30 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:33:48 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_isascii(int c)
+{
+	if (c >= 0 && c <= 127)
+		return (true);
+	return (false);
+}

+ 20 - 0
srcs/ft_isdigit.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isdigit.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 12:39:16 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:33:56 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_isdigit(int c)
+{
+	if (c >= 48 && c <= 57)
+		return (true);
+	return (false);
+}

+ 20 - 0
srcs/ft_islower.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_islower.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/11/13 15:40:23 by bchanot           #+#    #+#             */
+/*   Updated: 2017/11/13 15:42:13 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_islower(int c)
+{
+	if (c >= 97 && c <= 122)
+		return (true);
+	return (false);
+}

+ 28 - 0
srcs/ft_isnum.c

@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isnum.c                                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/07/20 14:23:27 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:34:13 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_isnum(const char *s)
+{
+	if (*s == '+' || *s == '-')
+		s++;
+	if (*s == '\0')
+		return (false);
+	while (*s)
+	{
+		if (!ft_isdigit(*s))
+			return (false);
+		s++;
+	}
+	return (true);
+}

+ 20 - 0
srcs/ft_isprint.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isprint.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 12:53:55 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:34:24 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_isprint(int c)
+{
+	if ((c >= 32 && c <= 126))
+		return (true);
+	return (false);
+}

+ 20 - 0
srcs/ft_isupper.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isupper.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/08/09 23:42:37 by bchanot           #+#    #+#             */
+/*   Updated: 2017/11/13 16:11:22 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_isupper(int c)
+{
+	if (c >= 65 && c <= 90)
+		return (true);
+	return (false);
+}

+ 39 - 0
srcs/ft_itoa.c

@@ -0,0 +1,39 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_itoa.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 15:33:13 by bchanot           #+#    #+#             */
+/*   Updated: 2018/04/17 11:49:53 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char			*ft_itoa(long long int n)
+{
+	int				size;
+	char			*str;
+
+	if (n == -2147483648)
+		return (ft_strdup("-2147483648"));
+	size = ft_nbrlen(n);
+	if (!(str = (char *)ft_memalloc(sizeof(char *) * (size + 1))))
+		return (NULL);
+	if (n < 0)
+	{
+		str[0] = '-';
+		n = -n;
+	}
+	str[size] = '\0';
+	while (n >= 10)
+	{
+		str[size - 1] = n % 10 + 48;
+		n = n / 10;
+		size--;
+	}
+	str[size - 1] = n + 48;
+	return (str);
+}

+ 72 - 0
srcs/ft_itoa_base.c

@@ -0,0 +1,72 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_itoa_base.c                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/10/12 03:26:09 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 11:49:37 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+static int	ft_ulen(t_uint64 value, t_uint8 base)
+{
+	int	i;
+
+	i = 0;
+	while (value / base)
+		i++;
+	return (i);
+}
+
+char		*ft_utoa_base(t_uint64 value, t_uint8 base)
+{
+	const char	hex[16] = "0123456789abcdef";
+	char		*s;
+	int			i;
+
+	i = ft_ulen(value, base);
+	s = ft_strnew(i);
+	while (value / base)
+	{
+		s[i] = hex[value % base];
+		value /= base;
+		i--;
+	}
+	return (s);
+}
+
+static int	ft_len(t_int64 value, t_uint8 base)
+{
+	int	i;
+
+	i = 0;
+	while (value / base)
+		i++;
+	return (i);
+}
+
+char		*ft_itoa_base(t_int64 value, t_uint8 base)
+{
+	const char	hex[16] = "0123456789abcdef";
+	char		*s;
+	int			i;
+	int			neg;
+
+	neg = value < 0 && base == 10 ? 1 : 0;
+	value = value < 0 ? -value : value;
+	i = ft_len(value, base) + neg;
+	s = ft_strnew(i);
+	while (value / base)
+	{
+		s[i] = hex[value % base];
+		value /= base;
+		i--;
+	}
+	if (neg)
+		s[i] = '-';
+	return (s);
+}

+ 63 - 0
srcs/ft_itoa_base_depth.c

@@ -0,0 +1,63 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_itoa_base.c                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/02/01 15:26:43 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/13 20:32:40 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+static void	ft_itoa_loop(t_int64 nb, char **s, t_uint8 base, size_t depth)
+{
+	const char	*hex = "0123456789abcdef";
+	t_uint64	index;
+
+	index = nb % base;
+	if (nb / base > 0)
+		ft_itoa_loop(nb / base, s, base, (depth - 1));
+	(*s)[depth] = hex[index];
+}
+
+char		*ft_itoa_base_depth(t_int64 nb, t_uint8 base, size_t depth)
+{
+	char	*s;
+	size_t	i;
+
+	if (!(s = ft_strnew(depth + 1)))
+		return (NULL);
+	i = 0;
+	while (i <= depth)
+		s[i++] = '0';
+	ft_itoa_loop(nb, &s, base, depth);
+	return (s);
+}
+
+static void	ft_utoa_loop(t_uint64 nb, char **s, t_uint8 base, size_t depth)
+{
+	const char	*hex = "0123456789abcdef";
+	t_uint64	index;
+
+	index = nb % base;
+	if (nb / base > 0)
+		ft_utoa_loop(nb / base, s, base, (depth - 1));
+	(*s)[depth] = hex[index];
+}
+
+char		*ft_utoa_base_depth(t_uint64 nb, t_uint8 base, size_t depth)
+{
+	char	*s;
+	size_t	i;
+
+	if (!(s = ft_strnew(depth + 1)))
+		return (NULL);
+	i = 0;
+	while (i <= depth)
+		s[i++] = '0';
+	ft_utoa_loop(nb, &s, base, depth);
+	return (s);
+}

+ 37 - 0
srcs/ft_itohex.c

@@ -0,0 +1,37 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_itohex.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/01/16 00:21:29 by bchanot           #+#    #+#             */
+/*   Updated: 2018/01/16 00:34:09 by xuser            ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+static void	ft_itohex_loop(unsigned long nb, char **str, int depth)
+{
+	const char		*hex = "0123456789abcdef";
+	unsigned long	index;
+
+	index = nb % 16;
+	if (nb / 16 > 0)
+		ft_itohex_loop(nb / 16, str, (depth - 1));
+	(*str)[depth] = hex[index];
+}
+
+char		*ft_itohex(unsigned long nb, int depth)
+{
+	char	*str;
+	int		cpt;
+
+	str = ft_strnew(depth + 1);
+	cpt = 0;
+	while (cpt <= depth)
+		str[cpt++] = '0';
+	ft_itohex_loop(nb, &str, depth);
+	return (str);
+}

+ 21 - 0
srcs/ft_lstadd.c

@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstadd.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/12/05 13:31:14 by bchanot           #+#    #+#             */
+/*   Updated: 2017/12/08 14:21:18 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_lstadd(t_slist **alst, t_slist *new)
+{
+	if (*alst == NULL || new == NULL)
+		return ;
+	new->next = *alst;
+	*alst = new;
+}

+ 33 - 0
srcs/ft_lstdel.c

@@ -0,0 +1,33 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstdel.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/12/08 14:22:40 by bchanot           #+#    #+#             */
+/*   Updated: 2017/12/08 14:28:35 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_lstdel(t_slist **alst, void (*del)(void *, size_t))
+{
+	t_slist	*next;
+	t_slist	*tmp;
+
+	if (alst != NULL)
+	{
+		tmp = *alst;
+		while (tmp != NULL)
+		{
+			if (del != NULL)
+				(*del)(tmp->content, (*tmp).content_size);
+			next = tmp->next;
+			ft_memdel((void **)&tmp);
+			tmp = next;
+		}
+		*alst = NULL;
+	}
+}

+ 29 - 0
srcs/ft_lstdelone.c

@@ -0,0 +1,29 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstdelone.c                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/12/08 14:29:12 by bchanot           #+#    #+#             */
+/*   Updated: 2017/12/08 14:31:19 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_lstdelone(t_slist **alst, void (*del)(void *, size_t))
+{
+	t_slist	*tmp;
+
+	if (alst != NULL)
+	{
+		tmp = *alst;
+		if (tmp != NULL)
+		{
+			(*del)((*tmp).content, (*tmp).content_size);
+			ft_memdel((void **)&tmp);
+		}
+		*alst = NULL;
+	}
+}

+ 25 - 0
srcs/ft_lstiter.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstiter.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/12/08 14:32:03 by bchanot           #+#    #+#             */
+/*   Updated: 2017/12/08 14:33:10 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_lstiter(t_slist *lst, void (*f)(t_slist *elem))
+{
+	t_slist	*tmp;
+
+	tmp = lst;
+	while (tmp != NULL)
+	{
+		(*f)(tmp);
+		tmp = tmp->next;
+	}
+}

+ 36 - 0
srcs/ft_lstnew.c

@@ -0,0 +1,36 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_lstnew.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/12/05 13:29:31 by bchanot           #+#    #+#             */
+/*   Updated: 2018/04/17 11:50:02 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+t_slist	*ft_lstnew(void *content, size_t content_size)
+{
+	t_slist	*list;
+
+	if (!(list = (t_slist *)ft_memalloc(sizeof(*list))))
+		return (NULL);
+	if (content && content_size)
+	{
+		if ((list->content = ft_memalloc(content_size)))
+			ft_memcpy(list->content, content, content_size);
+		else
+			return (NULL);
+		list->content_size = content_size;
+	}
+	else
+	{
+		list->content = NULL;
+		list->content_size = 0;
+	}
+	list->next = NULL;
+	return (list);
+}

+ 24 - 0
srcs/ft_memalloc.c

@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memalloc.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 17:32:00 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/11 22:52:07 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+void	*ft_memalloc(size_t size)
+{
+	void	*mem;
+
+	if (!(mem = (void*)malloc(size)))
+		return (NULL);
+	ft_bzero(mem, size);
+	return (mem);
+}

+ 31 - 0
srcs/ft_memccpy.c

@@ -0,0 +1,31 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memccpy.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/26 17:54:45 by bchanot           #+#    #+#             */
+/*   Updated: 2017/11/13 15:43:43 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	*ft_memccpy(void *dst, const void *src, int c, size_t n)
+{
+	size_t	cpt;
+
+	cpt = 0;
+	if (dst && src && n)
+	{
+		while (cpt < n)
+		{
+			*((char *)dst + cpt) = *((char *)src + cpt);
+			if (*((char *)src + cpt) == (char)c)
+				return ((char *)dst + cpt + 1);
+			cpt++;
+		}
+	}
+	return (NULL);
+}

+ 33 - 0
srcs/ft_memchr.c

@@ -0,0 +1,33 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memchr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/24 19:06:29 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:19:47 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	*ft_memchr(const void *s, int c, size_t n)
+{
+	unsigned char	*str;
+	size_t			cpt;
+
+	cpt = 0;
+	if (s && n)
+	{
+		str = (unsigned char *)s;
+		while (cpt < n)
+		{
+			if (*str == (unsigned char)c)
+				return ((void *)str);
+			cpt++;
+			str++;
+		}
+	}
+	return (NULL);
+}

+ 33 - 0
srcs/ft_memcmp.c

@@ -0,0 +1,33 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memcmp.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/26 15:14:07 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:14:35 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_memcmp(const void *const s1, const void *const s2, size_t n)
+{
+	unsigned char	*ptr1;
+	unsigned char	*ptr2;
+	size_t			cpt;
+
+	if (!s1 && !s2 && !n)
+		return (0);
+	cpt = 0;
+	ptr1 = (unsigned char *)s1;
+	ptr2 = (unsigned char *)s2;
+	while (cpt < n)
+	{
+		if (ptr1[cpt] != ptr2[cpt])
+			return (ptr1[cpt] - ptr2[cpt]);
+		cpt++;
+	}
+	return (0);
+}

+ 34 - 0
srcs/ft_memcpy.c

@@ -0,0 +1,34 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memcpy.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/24 16:05:01 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/23 14:35:38 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	*ft_memcpy(void *dst, const void *src, size_t n)
+{
+	char *c_dst;
+	char *c_src;
+
+	if (dst == NULL || src == NULL)
+		return (NULL);
+	c_dst = (char *)dst;
+	c_src = (char *)src;
+	if (n == 0 || dst == src)
+		return ((void *)c_dst);
+	while (--n)
+	{
+		*c_dst = *c_src;
+		c_dst++;
+		c_src++;
+	}
+	*c_dst = *c_src;
+	return (dst);
+}

+ 21 - 0
srcs/ft_memdel.c

@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memdel.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 17:36:33 by bchanot           #+#    #+#             */
+/*   Updated: 2017/02/26 02:19:10 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+void	ft_memdel(void **ap)
+{
+	if (*ap)
+		free(*ap);
+	*ap = NULL;
+}

+ 28 - 0
srcs/ft_memdel2.c

@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memdel2.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/06/16 16:59:53 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/11 22:53:04 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include "stdlib.h"
+
+void	ft_memdel2(void ***ap)
+{
+	size_t	i;
+
+	if (ap != NULL && *ap != NULL)
+	{
+		i = -1;
+		while ((*ap)[++i])
+			ft_memdel((void **)&(*ap)[i]);
+		free(*ap);
+		*ap = NULL;
+	}
+}

+ 32 - 0
srcs/ft_memmove.c

@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memmove2.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/30 18:31:34 by bchanot           #+#    #+#             */
+/*   Updated: 2015/12/07 13:09:31 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	*ft_memmove(void *dst, const void *src, size_t len)
+{
+	char	*s_dst;
+	char	*s_src;
+
+	if (dst == src && !len)
+		return (NULL);
+	s_dst = (char *)dst;
+	s_src = (char *)src;
+	if (s_dst > s_src)
+	{
+		while (len--)
+			s_dst[len] = s_src[len];
+	}
+	else
+		dst = ft_memcpy(dst, (void *)src, len);
+	return (dst);
+}

+ 27 - 0
srcs/ft_memset.c

@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memset.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/24 14:45:37 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/12 22:31:51 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	*ft_memset(void *dst, int c, size_t len)
+{
+	unsigned char *tmp;
+
+	tmp = (unsigned char *)dst;
+	while (len > 0)
+	{
+		len--;
+		tmp[len] = (unsigned char)c;
+	}
+	dst = (void *)tmp;
+	return (dst);
+}

+ 30 - 0
srcs/ft_nb_word.c

@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_nb_word.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/02/17 18:19:42 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:27:56 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t	ft_nb_word(const char *src)
+{
+	size_t	i;
+
+	i = 0;
+	while (*src)
+	{
+		while (*src && *src < 33)
+			src++;
+		if (*src)
+			i++;
+		while (*src && *src > 32)
+			src++;
+	}
+	return (i);
+}

+ 43 - 0
srcs/ft_nbrlen.c

@@ -0,0 +1,43 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_nbrlen.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/10/12 02:16:31 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/12 02:40:13 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t	ft_nbrlen(t_int64 nb)
+{
+	t_int64	size;
+
+	size = 0;
+	if (nb >= 10)
+	{
+		size = ft_nbrlen(nb / 10);
+		size++;
+	}
+	else
+		size++;
+	return (size);
+}
+
+size_t	ft_nbrulen(t_uint64 nb)
+{
+	t_uint64	size;
+
+	size = 0;
+	if (nb >= 10)
+	{
+		size = ft_nbrulen(nb / 10);
+		size++;
+	}
+	else
+		size++;
+	return (size);
+}

+ 26 - 0
srcs/ft_pow.c

@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_pow.c                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/09/26 00:42:52 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/11 22:58:05 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t	ft_pow(int a, int b)
+{
+	size_t	r;
+
+	r = 1;
+	while (b > 0)
+	{
+		r *= a;
+		b--;
+	}
+	return (r);
+}

+ 56 - 0
srcs/ft_print_memory.c

@@ -0,0 +1,56 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_print_memory.c                                  :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/05/01 16:40:12 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:30:06 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	print_line(unsigned char *s, size_t start, size_t max)
+{
+	size_t i;
+
+	i = start;
+	while (i < start + 16 && i < max)
+	{
+		ft_puthex(s[i], 1);
+		if (i % 2)
+			ft_putchar(' ');
+		i++;
+	}
+	while (i < start + 16)
+	{
+		ft_putchar(' ');
+		ft_putchar(' ');
+		if (i % 2)
+			ft_putchar(' ');
+		i++;
+	}
+	i = start;
+	while (i < start + 16 && i < max)
+	{
+		ft_putascii(s[i]);
+		i++;
+	}
+	ft_putchar('\n');
+}
+
+void	ft_print_memory(const void *addr, size_t size)
+{
+	unsigned char	*s;
+	size_t			c;
+
+	s = (unsigned char *)addr;
+	c = 0;
+	while (c < size)
+	{
+		print_line(s, c, size);
+		c += 16;
+	}
+}

+ 99 - 0
srcs/ft_printf.c

@@ -0,0 +1,99 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_printf.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/11 00:22:06 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:40:26 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+#include <unistd.h>
+
+static int	(*g_func[])(va_list, t_inf) = {
+	pf_percent, pf_s, pf_s_up, pf_p,
+	pf_di, pf_d_up, pf_di, pf_o,
+	pf_o_up, pf_u, pf_u_up, pf_x,
+	pf_x_up, pf_c, pf_c_up, pf_b};
+
+int			pf_print_part(const char *format, char *s, int fd)
+{
+	int	len;
+
+	len = 0;
+	while (format + len != s)
+		len++;
+	write(fd, format, len);
+	return (len);
+}
+
+static int	ft_format(char **s, va_list ap, t_inf inf)
+{
+	int		len;
+
+	len = 0;
+	if (inf.type == -1)
+		return (-2);
+	else if (inf.type >= 0)
+		len = g_func[inf.type](ap, inf);
+	if (len < 0)
+		return (-1);
+	*s -= 1;
+	return (len);
+}
+
+static int	pf_printf(const char **format, va_list ap, char **s, int tmp[2])
+{
+	int		chk;
+	t_inf	inf;
+	int		len;
+
+	len = tmp[0];
+	len += pf_print_part(*format, *s, tmp[1]);
+	*s += 1;
+	inf = pf_take_inf(s, ap, tmp[1]);
+	if ((chk = ft_format(s, ap, inf)) < 0)
+	{
+		if (chk == -1)
+			return (-1);
+		if (pf_wrong_conv(s, format, inf, &len))
+			return (len);
+	}
+	else
+	{
+		*format = *s + 1;
+		len += chk;
+	}
+	return (len);
+}
+
+int			ft_printf(int fd, const char *format, ...)
+{
+	va_list		ap;
+	int			len[2];
+	char		*s;
+	int			col;
+
+	len[0] = 0;
+	len[1] = fd;
+	col = 0;
+	s = (char *)format;
+	va_start(ap, format);
+	while (*s)
+	{
+		if (*s == '{')
+			col = pf_take_color(&s, &format, &len[0], len[1]);
+		if (*s == '%')
+			if ((len[0] = pf_printf(&format, ap, &s, len) == -1))
+				return (-1);
+		s++;
+	}
+	va_end(ap);
+	len[0] += pf_putstr(format, fd);
+	if (col == 1)
+		ft_putstr_fd(EOC, fd);
+	return (len[0]);
+}

+ 66 - 0
srcs/ft_printf/pf_b.c

@@ -0,0 +1,66 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_b.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/03/18 19:17:43 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:37:41 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_b(char *s, t_inf inf, int len, int nb)
+{
+	int	i;
+
+	i = nb == 0 && inf.prec == -1 ? 0 : (int)ft_strlen(s);
+	if (inf.prec > i)
+	{
+		if (len < inf.width - inf.prec)
+			return (true);
+	}
+	else if (len < inf.width - i)
+		return (true);
+	return (false);
+}
+
+static int	pf_b2(int nb, char *s, t_inf inf, int len)
+{
+	if (nb == 0 && inf.prec == -1)
+		len += 0;
+	else
+		len += pf_putstr(s, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	return (len);
+}
+
+int			pf_b(va_list ap, t_inf inf)
+{
+	char	*s;
+	int		len;
+	int		nb;
+	int		cpt;
+
+	nb = va_arg(ap, int);
+	s = ft_itoa_base(nb, 2);
+	len = 0;
+	if (inf.zero && inf.prec != 0)
+		inf.zero = 0;
+	if (inf.width > 0 && !inf.min && !inf.zero && inf.width > inf.prec)
+		while (pf_width_b(s, inf, len, nb) && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	cpt = -1;
+	if (inf.prec > 0)
+		while (++cpt < inf.prec - ((int)ft_strlen(s)) && len++ >= 0)
+			ft_putchar_fd('0', inf.fd);
+	cpt = -1;
+	if (inf.width && inf.zero && !inf.min)
+		while (++cpt < inf.width - ((int)ft_strlen(s)) && len++ >= 0)
+			ft_putchar_fd('0', inf.fd);
+	return (pf_b2(nb, s, inf, len));
+}

+ 32 - 0
srcs/ft_printf/pf_c.c

@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_c.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:58:26 by bchanot           #+#    #+#             */
+/*   Updated: 2016/03/19 03:42:30 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+int	pf_c(va_list ap, t_inf inf)
+{
+	int	nb;
+	int	len;
+
+	len = 1;
+	if (inf.l)
+		return (pf_c_up(ap, inf));
+	nb = va_arg(ap, int);
+	if (inf.width > 0 && inf.min == 0)
+		while (len++ < inf.width)
+			ft_putchar_fd((inf.zero == 0 ? ' ' : '0'), inf.fd);
+	ft_putchar_fd(nb, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len++ < inf.width)
+			ft_putchar_fd(' ', inf.fd);
+	return (inf.width > 0 ? inf.width : 1);
+}

+ 60 - 0
srcs/ft_printf/pf_c_up.c

@@ -0,0 +1,60 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_c_up.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:59:11 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:37:20 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+#include <wchar.h>
+#include <stdlib.h>
+
+static int	pf_width_c_up(char *s, t_inf inf, int len)
+{
+	if (inf.prec < (int)ft_strlen(s) && inf.prec != 0)
+	{
+		if (len < inf.width - inf.prec)
+			return (true);
+	}
+	else if (len < inf.width - (int)ft_strlen(s))
+		return (true);
+	return (false);
+}
+
+static int	pf_c_up2(t_inf inf, char *s, int len)
+{
+	if (inf.prec > 0 && inf.prec < (int)ft_strlen(s))
+		len += pf_putnstr(s, inf.prec, inf.fd);
+	else
+		len += pf_putstr(s, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	if (s)
+		free(s);
+	return (len);
+}
+
+int			pf_c_up(va_list ap, t_inf inf)
+{
+	wchar_t c;
+	char	*s;
+	int		len;
+
+	len = inf.prec == -1 ? 1 : 0;
+	c = va_arg(ap, wchar_t);
+	s = ft_widechar(c);
+	if (c == 0)
+		return (1);
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_c_up(s, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero == 0 ? ' ' : '0'), inf.fd);
+	if (inf.prec == -1 && c != 0)
+		return (len - 1);
+	return (pf_c_up2(inf, s, len));
+}

+ 72 - 0
srcs/ft_printf/pf_d_up.c

@@ -0,0 +1,72 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_d_up.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:52:31 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:44:36 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_d(long long int nb, t_inf inf, int len)
+{
+	if (nb < 0)
+		if (len < inf.width - (inf.prec >= (int)ft_nbrlen(nb) ?
+								inf.prec + 1 : (int)ft_nbrlen(nb)))
+			return (true);
+	if (nb >= 0)
+		if (len < inf.width - (inf.prec >= (int)ft_nbrlen(nb) ?
+								inf.prec : (int)ft_nbrlen(nb)))
+			return (true);
+	return (false);
+}
+
+static int	pf_d_up2(t_int64 nb, int len, int min, t_inf inf)
+{
+	int i;
+
+	i = -1;
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_d(nb, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero == 1 && inf.prec == 0 ? '0' : ' '), inf.fd);
+	if (inf.plus && nb >= 0 && !min && inf.prec >= 0 && inf.done == 0)
+		ft_putchar_fd('+', inf.fd);
+	else if (inf.space == 1 && nb >= 0 && !min && inf.done == 0)
+		ft_putchar_fd(' ', inf.fd);
+	if (nb < 0 && nb != -9223372036854775807 - 1 && len++ >= 0)
+	{
+		ft_putchar_fd('-', inf.fd);
+		nb = -nb;
+	}
+	while (++i < inf.prec - (int)ft_nbrlen(nb) && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	ft_putnbr_fd(nb, inf.fd);
+	len += ft_nbrlen(nb);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	return (len);
+}
+
+int			pf_d_up(va_list ap, t_inf inf)
+{
+	long long int	nb;
+	int				len;
+	int				min;
+
+	nb = va_arg(ap, long long int);
+	min = 0;
+	len = ((inf.space == 1 || inf.plus == 1) && nb >= 0) ? 1 : 0;
+	if (inf.zero == 1 && nb < 0 && inf.prec == 0 &&
+		nb != -9223372036854775807 - 1 && len++ >= 0 && ++min == 1)
+	{
+		ft_putchar_fd('-', inf.fd);
+		nb = -nb;
+	}
+	pf_do_if(&inf, nb, min);
+	return (pf_d_up2(nb, len, min, inf));
+}

+ 97 - 0
srcs/ft_printf/pf_di.c

@@ -0,0 +1,97 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_di.c                                            :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:52:57 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:43:59 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+void		pf_do_if(t_inf *inf, long long int nb, int min)
+{
+	if (inf->plus && inf->prec == -1 && nb > 0 && inf->width && inf->zero)
+	{
+		inf->zero = 0;
+		inf->prec = 0;
+	}
+	if (inf->space && inf->plus)
+		inf->space = 0;
+	if (inf->zero == 1 && (inf->plus || inf->space) && nb >= 0 &&
+		min == 0 && inf->prec <= 0)
+	{
+		ft_putchar_fd((inf->space ? ' ' : '+'), inf->fd);
+		inf->done = 1;
+	}
+}
+
+static int	pf_width_di(long int nb, t_inf inf, int len)
+{
+	int i;
+
+	i = nb == 0 && inf.prec == -1 ? 0 : ft_nbrlen(nb);
+	if (nb < 0)
+	{
+		if (len < inf.width - (inf.prec >= i ? inf.prec + 1 : i))
+			return (true);
+	}
+	else if (len < inf.width - (inf.prec >= i ? inf.prec : i))
+		return (true);
+	return (false);
+}
+
+static int	pf_di2(long int nb, int len, int min, t_inf inf)
+{
+	int i;
+
+	i = -1;
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_di(nb, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero == 1 && inf.prec == 0 ? '0' : ' '), inf.fd);
+	if (inf.plus && nb >= 0 && !min && inf.prec >= 0 && inf.done == 0)
+		ft_putchar_fd('+', inf.fd);
+	else if (inf.space == 1 && nb >= 0 && !min && inf.done == 0)
+		ft_putchar_fd(' ', inf.fd);
+	if (nb < 0 && len++ >= 0)
+	{
+		ft_putchar_fd('-', inf.fd);
+		nb = -nb;
+	}
+	while (++i < inf.prec - (int)ft_nbrlen(nb) && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	ft_putnbr_fd(nb, inf.fd);
+	len += ft_nbrlen(nb);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	return (len);
+}
+
+int			pf_di(va_list ap, t_inf inf)
+{
+	long int	nb;
+	int			len;
+	int			min;
+
+	if (inf.l || inf.ll || inf.z || inf.j)
+		return (pf_d_up(ap, inf));
+	if (inf.hh)
+		nb = (char)va_arg(ap, int);
+	else
+		nb = inf.h ? (short)va_arg(ap, int) : va_arg(ap, int);
+	min = 0;
+	len = (inf.plus || inf.space) && nb >= 0 ? 1 : 0;
+	if (inf.zero == 1 && nb < 0 && inf.prec == 0)
+	{
+		ft_putchar_fd('-', inf.fd);
+		nb = -nb;
+		min = 1;
+		len++;
+	}
+	pf_do_if(&inf, nb, min);
+	return (pf_di2(nb, len, min, inf));
+}

+ 49 - 0
srcs/ft_printf/pf_len.c

@@ -0,0 +1,49 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_len.c                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/03/09 14:17:06 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:40:01 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+int	pf_hexlen(unsigned int n)
+{
+	if (n >= 16)
+		return (pf_hexlen(n / 16) + pf_hexlen(n % 16));
+	else
+		return (1);
+}
+
+int	pf_octlen(unsigned int n, t_inf inf)
+{
+	if (n == 0 && !inf.width && inf.prec <= 0)
+		return (0);
+	if (n >= 8)
+		return (pf_octlen(n / 8, inf) + pf_hexlen(n % 8));
+	else
+		return (1);
+}
+
+int	pf_hexulen(long long unsigned int n)
+{
+	if (n >= 16)
+		return (pf_hexulen(n / 16) + pf_hexulen(n % 16));
+	else
+		return (1);
+}
+
+int	pf_octulen(long long unsigned int n, t_inf inf)
+{
+	if (n == 0 && !inf.width && inf.prec <= 0)
+		return (0);
+	if (n >= 8)
+		return (pf_octulen(n / 8, inf) + pf_hexulen(n % 8));
+	else
+		return (1);
+}

+ 142 - 0
srcs/ft_printf/pf_more_inf.c

@@ -0,0 +1,142 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_more_inf.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/03/10 02:39:52 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:44:23 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+int			pf_wrong_conv(char **s, const char **format, t_inf inf, int *len)
+{
+	int i;
+
+	i = 0;
+	if (**s == '\0')
+	{
+		*format = *s;
+		return (true);
+	}
+	if (inf.width > 0 && inf.min == 0)
+		while (++i < inf.width)
+		{
+			ft_putchar_fd((inf.zero == 1 ? '0' : ' '), inf.fd);
+			*len += 1;
+		}
+	ft_putchar_fd(**s, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (++i < inf.width)
+		{
+			ft_putchar_fd(' ', inf.fd);
+			*len += 1;
+		}
+	*format = *s + 1;
+	*len += 1;
+	return (false);
+}
+
+int			pf_more_flag(char **s, t_inf *inf)
+{
+	if (**s == 'j')
+		inf->j = 1;
+	if (**s == 'z')
+		inf->z = 1;
+	if (**s == 'l')
+	{
+		*s += 1;
+		if (**s == 'l')
+			inf->ll = 1;
+		else
+			return (inf->l = 1);
+	}
+	if (**s == 'h')
+	{
+		*s += 1;
+		if (**s == 'h')
+			inf->hh = 1;
+		else
+			return (inf->h = 1);
+	}
+	return (false);
+}
+
+void		take_prec(char **s, t_inf *inf, va_list ap, int i)
+{
+	inf->prec = 0;
+	*s += 1;
+	if (**s == '*' && i++ >= 0)
+	{
+		inf->prec = va_arg(ap, int);
+		if (inf->prec < 0)
+			inf->prec = -1;
+		*s += 1;
+	}
+	else
+	{
+		while (ft_isdigit(**s) && i++ >= 0)
+		{
+			inf->prec = inf->prec * 10 + **s - '0';
+			*s += 1;
+		}
+	}
+	if (i == 0 || inf->prec == 0)
+		inf->prec = -1;
+	else if (inf->prec == -1)
+		inf->prec = 0;
+}
+
+static int	pf_more_color_please(char tmp[8], int fd)
+{
+	if (ft_strstr(tmp, "red"))
+		ft_putstr_fd(RED, fd);
+	else if (ft_strstr(tmp, "black"))
+		ft_putstr_fd(BLACK, fd);
+	else if (ft_strstr(tmp, "green"))
+		ft_putstr_fd(GREEN, fd);
+	else if (ft_strstr(tmp, "yellow"))
+		ft_putstr_fd(YELLOW, fd);
+	else if (ft_strstr(tmp, "blue"))
+		ft_putstr_fd(BLUE, fd);
+	else if (ft_strstr(tmp, "purple"))
+		ft_putstr_fd(PURPLE, fd);
+	else if (ft_strstr(tmp, "cyan"))
+		ft_putstr_fd(CYAN, fd);
+	else if (ft_strstr(tmp, "grey"))
+		ft_putstr_fd(GREY, fd);
+	else if (ft_strstr(tmp, "eoc"))
+		ft_putstr_fd(EOC, fd);
+	else
+		return (false);
+	return (true);
+}
+
+int			pf_take_color(char **s, const char **format, int *len, int fd)
+{
+	int		i;
+	char	tmp[8];
+
+	i = 0;
+	ft_bzero(&tmp, 8);
+	*len += pf_print_part(*format, *s, fd);
+	*s += 1;
+	while (**s != '}' && i < 7)
+	{
+		tmp[i] = **s;
+		*s += 1;
+		i++;
+	}
+	*s += 1;
+	if (!pf_more_color_please(tmp, fd))
+	{
+		*s -= i + 2;
+		*format = *s;
+		return (false);
+	}
+	*format = *s;
+	return (true);
+}

+ 63 - 0
srcs/ft_printf/pf_o.c

@@ -0,0 +1,63 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_o.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:55:02 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:40:51 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int			pf_width_o(unsigned int nb, t_inf inf, int len)
+{
+	if (inf.prec > pf_octlen(nb, inf))
+	{
+		if (len < inf.width - (inf.prec + inf.di))
+			return (true);
+	}
+	else if (len < inf.width - (pf_octlen(nb, inf) + inf.di))
+		return (true);
+	return (false);
+}
+
+static unsigned int	pf_check_h(va_list ap, t_inf inf)
+{
+	unsigned int nb;
+
+	if (inf.hh)
+		nb = (unsigned char)va_arg(ap, unsigned int);
+	else if (inf.h)
+		nb = (unsigned short)va_arg(ap, unsigned int);
+	else
+		nb = va_arg(ap, unsigned int);
+	return (nb);
+}
+
+int					pf_o(va_list ap, t_inf inf)
+{
+	unsigned int	nb;
+	int				len;
+	int				cpt;
+
+	if (inf.z || inf.l || inf.ll || inf.j)
+		return (pf_o_up(ap, inf));
+	nb = pf_check_h(ap, inf);
+	len = 0;
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_o(nb, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero == 1 && inf.prec == 0 ? '0' : ' '), inf.fd);
+	cpt = -1;
+	if (inf.di && (nb != 0 || (nb == 0 && inf.prec > 0)) && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	while (++cpt < inf.prec - pf_octlen(nb, inf) - inf.di && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	len += pf_putoctal(nb, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	return (len);
+}

+ 48 - 0
srcs/ft_printf/pf_o_up.c

@@ -0,0 +1,48 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_o_up.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:55:46 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:41:04 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_o_up(long long unsigned int nb, t_inf inf, int len)
+{
+	if (inf.prec > pf_octulen(nb, inf))
+	{
+		if (len < inf.width - (inf.prec + inf.di))
+			return (true);
+	}
+	else if (len < inf.width - (pf_octulen(nb, inf) + inf.di))
+		return (true);
+	return (false);
+}
+
+int			pf_o_up(va_list ap, t_inf inf)
+{
+	long long unsigned int	nb;
+	int						len;
+	int						cpt;
+
+	nb = va_arg(ap, long long unsigned int);
+	len = 0;
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_o_up(nb, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero == 1 && inf.prec == 0 ? '0' : ' '), inf.fd);
+	if (inf.di && (nb != 0 || (nb == 0 && inf.prec > 0)) && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	cpt = -1;
+	while (++cpt < inf.prec - pf_octulen(nb, inf) - inf.di && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	len += pf_putuoctal(nb, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	return (len);
+}

+ 97 - 0
srcs/ft_printf/pf_p.c

@@ -0,0 +1,97 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_p.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:51:30 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:36:55 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+#include <stdlib.h>
+
+static int	pf_width_p(char *s, t_inf inf, int len, void *p)
+{
+	int i;
+
+	i = p == (void *)0 && inf.prec == -1 ? 0 : (int)ft_strlen(s);
+	if (inf.prec > i)
+	{
+		if (len < inf.width - inf.prec)
+			return (true);
+	}
+	else if (len < inf.width - i)
+		return (true);
+	return (false);
+}
+
+static char	get_digit(int n)
+{
+	if (n >= 0 && n <= 9)
+		return (n + '0');
+	return (n - 10 + 'a');
+}
+
+static char	*ft_ptoa(void *p)
+{
+	unsigned long	tmpn;
+	unsigned long	n;
+	int				len;
+	char			*s;
+
+	n = (unsigned long)p;
+	tmpn = (unsigned long)p;
+	len = 2;
+	while (tmpn /= 16)
+		len++;
+	if (!(s = (char*)ft_memalloc(sizeof(char) * len)))
+		return (NULL);
+	s[--len] = '\0';
+	while (len--)
+	{
+		s[len] = get_digit(n % 16);
+		n = n / 16;
+	}
+	return (s);
+}
+
+static int	pf_p2(char *s, t_inf inf, int len)
+{
+	len += pf_putstr(s, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	if (s)
+		free(s);
+	return (len);
+}
+
+int			pf_p(va_list ap, t_inf inf)
+{
+	char	*s;
+	int		len;
+	void	*p;
+	int		cpt;
+
+	p = va_arg(ap, void*);
+	s = ft_ptoa(p);
+	len = 2;
+	if (inf.zero && inf.prec != 0)
+		inf.zero = 0;
+	if (inf.width > 0 && !inf.min && !inf.zero && inf.width > inf.prec)
+		while (pf_width_p(s, inf, len, p) && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	pf_putstr("0x", inf.fd);
+	cpt = -1;
+	if (inf.prec > 0)
+		while (++cpt < inf.prec - ((int)ft_strlen(s)) && len++ >= 0)
+			ft_putchar_fd('0', inf.fd);
+	cpt = -1;
+	if (inf.width && inf.zero && !inf.min)
+		while (++cpt < inf.width - ((int)ft_strlen(s) + 2) && len++ >= 0)
+			ft_putchar_fd('0', inf.fd);
+	return (pf_p2(s, inf, len));
+}

+ 29 - 0
srcs/ft_printf/pf_percent.c

@@ -0,0 +1,29 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_percent.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:48:12 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/29 04:00:05 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+int	pf_percent(va_list ap, t_inf inf)
+{
+	int	len;
+
+	len = 1;
+	(void)ap;
+	if (inf.width > 0 && inf.min == 0)
+		while (len++ < inf.width)
+			ft_putchar_fd((inf.zero == 0 ? ' ' : '0'), inf.fd);
+	ft_putchar_fd('%', inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len++ < inf.width)
+			ft_putchar_fd(' ', inf.fd);
+	return (inf.width > 0 ? inf.width : 1);
+}

+ 67 - 0
srcs/ft_printf/pf_putnbr.c

@@ -0,0 +1,67 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putnbr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/03/03 02:08:12 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:41:32 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+#include <stdlib.h>
+
+int	pf_puthex(unsigned int n, int fd)
+{
+	char *hex;
+
+	hex = NULL;
+	if (n >= 16)
+		return (pf_puthex(n / 16, fd) + pf_puthex(n % 16, fd));
+	else
+	{
+		hex = ft_strdup("0123456789abcdef");
+		ft_putchar_fd(hex[n], fd);
+		if (hex)
+			free(hex);
+		return (1);
+	}
+}
+
+int	pf_putoctal(unsigned int n, int fd)
+{
+	if (n >= 8)
+		return (pf_putoctal(n / 8, fd) + pf_puthex(n % 8, fd));
+	else
+	{
+		ft_putchar_fd(n + 48, fd);
+		return (1);
+	}
+}
+
+int	pf_puthexm(unsigned int n, int fd)
+{
+	char *hex;
+
+	hex = NULL;
+	if (n >= 16)
+		return (pf_puthexm(n / 16, fd) + pf_puthexm(n % 16, fd));
+	else
+	{
+		hex = ft_strdup("0123456789ABCDEF");
+		ft_putchar_fd(hex[n], fd);
+		if (hex)
+			free(hex);
+		return (1);
+	}
+}
+
+int	pf_putunbr(unsigned int n, int fd)
+{
+	if (n >= 10)
+		return (pf_putunbr(n / 10, fd) + pf_putunbr(n % 10, fd));
+	ft_putchar_fd(48 + n, fd);
+	return (1);
+}

+ 65 - 0
srcs/ft_printf/pf_putnbrlong.c

@@ -0,0 +1,65 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_putnbrlong.c                                    :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/03/13 16:21:57 by bchanot           #+#    #+#             */
+/*   Updated: 2016/04/12 02:10:56 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+#include <stdlib.h>
+
+int	pf_putuhex(long long unsigned int n, int fd)
+{
+	char *hex;
+
+	hex = NULL;
+	if (n >= 16)
+		return (pf_putuhex(n / 16, fd) + pf_putuhex(n % 16, fd));
+	else
+	{
+		hex = ft_strdup("0123456789abcdef");
+		ft_putchar_fd(hex[n], fd);
+		free(hex);
+		return (1);
+	}
+}
+
+int	pf_putuoctal(long long unsigned int n, int fd)
+{
+	if (n >= 8)
+		return (pf_putuoctal(n / 8, fd) + pf_putuhex(n % 8, fd));
+	else
+	{
+		ft_putchar_fd(n + 48, fd);
+		return (1);
+	}
+}
+
+int	pf_putuhexm(long long unsigned int n, int fd)
+{
+	char *hex;
+
+	hex = NULL;
+	if (n >= 16)
+		return (pf_putuhexm(n / 16, fd) + pf_putuhexm(n % 16, fd));
+	else
+	{
+		hex = ft_strdup("0123456789ABCDEF");
+		ft_putchar_fd(hex[n], fd);
+		free(hex);
+		return (1);
+	}
+}
+
+int	pf_putunbrlong(long long unsigned int n, int fd)
+{
+	if (n >= 10)
+		return (pf_putunbrlong(n / 10, fd) + pf_putunbrlong(n % 10, fd));
+	ft_putchar_fd(48 + n, fd);
+	return (1);
+}

+ 48 - 0
srcs/ft_printf/pf_putstr.c

@@ -0,0 +1,48 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_putstr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 00:48:09 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:36:14 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+#include <unistd.h>
+
+int		pf_xlong2(int len, t_inf *inf, unsigned long long nb)
+{
+	len += pf_putuhex(nb, inf->fd);
+	if (inf->width > 0 && inf->min == 1)
+		while (len < inf->width && len++ >= 0)
+			ft_putchar_fd(' ', inf->fd);
+	return (len);
+}
+
+int		pf_x_uplong2(int len, t_inf *inf, unsigned long long nb)
+{
+	len += pf_putuhexm(nb, inf->fd);
+	if (inf->width > 0 && inf->min == 1)
+		while (len < inf->width && len++ >= 0)
+			ft_putchar_fd(' ', inf->fd);
+	return (len);
+}
+
+int		pf_putstr(const char *s, int fd)
+{
+	int len;
+
+	len = -1;
+	while (s[++len])
+		ft_putchar_fd(s[len], fd);
+	return (len);
+}
+
+int		pf_putnstr(const char *s, int n, int fd)
+{
+	write(fd, s, n);
+	return (n);
+}

+ 50 - 0
srcs/ft_printf/pf_s.c

@@ -0,0 +1,50 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_s.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:48:47 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:43:12 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+int	pf_width_s(char *s, t_inf inf, int len)
+{
+	if (ft_strlen(s) && inf.prec < (int)ft_strlen(s) && inf.prec != 0)
+	{
+		if (len < inf.width - inf.prec)
+			return (true);
+	}
+	else if (len < inf.width - (int)ft_strlen(s))
+		return (true);
+	return (false);
+}
+
+int	pf_s(va_list ap, t_inf inf)
+{
+	char	*s;
+	int		len;
+
+	len = inf.prec == -1 ? 1 : 0;
+	if (inf.l)
+		return (pf_s_up(ap, inf));
+	if ((s = va_arg(ap, char *)) == NULL)
+		s = ft_strdup("(null)");
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_s(s, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero == 0 ? ' ' : '0'), inf.fd);
+	if (ft_strlen(s) && inf.prec > 0 && inf.prec < (int)ft_strlen(s))
+		len += pf_putnstr(s, inf.prec, inf.fd);
+	else
+		len += pf_putstr(s, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	if (!ft_strcmp(s, "(null)"))
+		ft_memdel((void **)&s);
+	return (len);
+}

+ 40 - 0
srcs/ft_printf/pf_s_up.c

@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_s_up.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:50:12 by bchanot           #+#    #+#             */
+/*   Updated: 2016/08/11 21:26:03 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+#include <wchar.h>
+
+int			pf_s_up(va_list ap, t_inf inf)
+{
+	wchar_t *s;
+	char	*str;
+	int		len;
+
+	len = inf.prec == -1 ? 1 : 0;
+	if ((s = va_arg(ap, wchar_t *)) == NULL)
+		str = ft_strdup("(null)");
+	else
+		str = ft_widestr(s);
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_s(str, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero ? '0' : ' '), inf.fd);
+	if (inf.prec > 0 && inf.prec < (int)ft_strlen(str))
+		len += pf_putnstr(str, inf.prec, inf.fd);
+	else
+		len += pf_putstr(str, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	if (s == NULL)
+		ft_memdel((void **)&str);
+	return (len);
+}

+ 95 - 0
srcs/ft_printf/pf_take_inf.c

@@ -0,0 +1,95 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_take_inf.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 00:23:20 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:42:18 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static char	g_type[] = {
+	'%', 's', 'S', 'p', 'd', 'D', 'i', 'o', 'O', 'u', 'U',
+	'x', 'X', 'c', 'C', 'b', 0};
+
+static void	take_flag(char **s, t_inf *inf)
+{
+	while (**s == '#' || **s == '0' || **s == '-' || **s == '+' || **s == ' ' \
+		|| **s == 'l' || **s == 'h' || **s == 'j' || **s == 'z')
+	{
+		if (**s == '+')
+			inf->plus = 1;
+		if (**s == '0')
+			inf->zero = 1;
+		if (**s == '#')
+			inf->di = 1;
+		if (**s == ' ')
+			inf->space = 1;
+		if (**s == '-')
+			inf->min = 1;
+		if (!pf_more_flag(s, inf))
+			*s += 1;
+		inf->flag++;
+	}
+}
+
+static int	take_width(char **s, t_inf *inf, va_list ap)
+{
+	if (**s == '*')
+	{
+		inf->width = va_arg(ap, int);
+		if (inf->width < 0)
+		{
+			inf->min = 1;
+			inf->width = -inf->width;
+		}
+		*s += 1;
+	}
+	else if (**s >= '0' && **s <= '9')
+	{
+		inf->width = 0;
+		while (ft_isdigit(**s))
+		{
+			inf->width = inf->width * 10 + **s - '0';
+			*s += 1;
+		}
+	}
+	return (true);
+}
+
+static int	take_type(char *s, t_inf *inf)
+{
+	int		i;
+
+	i = -1;
+	while (g_type[++i])
+	{
+		if (g_type[i] == *s)
+		{
+			inf->type = i;
+			return (true);
+		}
+	}
+	inf->type = -1;
+	return (false);
+}
+
+t_inf		pf_take_inf(char **s, va_list ap, int fd)
+{
+	t_inf	inf;
+
+	ft_bzero(&inf, sizeof(inf));
+	inf.fd = fd;
+	take_flag(s, &inf);
+	if (**s == '*' || (ft_isdigit(**s) && **s != '0'))
+		take_width(s, &inf, ap);
+	if (**s == '.')
+		take_prec(s, &inf, ap, 0);
+	if (take_type(*s, &inf))
+		*s += 1;
+	return (inf);
+}

+ 52 - 0
srcs/ft_printf/pf_u.c

@@ -0,0 +1,52 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_u.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:55:55 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/12 02:46:37 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_u(unsigned int nb, t_inf inf, int len)
+{
+	if (inf.prec > (int)ft_nbrulen(nb))
+	{
+		if (len < inf.width - inf.prec)
+			return (true);
+	}
+	else if (len < inf.width - (int)ft_nbrulen(nb))
+		return (true);
+	return (false);
+}
+
+int			pf_u(va_list ap, t_inf inf)
+{
+	unsigned int	nb;
+	size_t			cpt;
+	int				len;
+
+	if (inf.l || inf.ll || inf.z || inf.j)
+		return (pf_u_up(ap, inf));
+	if (inf.h || inf.hh)
+		nb = inf.hh ? (unsigned char)va_arg(ap, unsigned int) :
+			(unsigned short)va_arg(ap, unsigned int);
+	else
+		nb = va_arg(ap, unsigned int);
+	len = 0;
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_u(nb, inf, len) && ++len > 0)
+			ft_putchar_fd((inf.zero == 1 && inf.prec == 0 ? '0' : ' '), inf.fd);
+	cpt = -1;
+	while (++cpt < inf.prec - ft_nbrulen(nb) && ++len > 0)
+		ft_putchar_fd('0', inf.fd);
+	len += pf_putunbr(nb, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && ++len > 0)
+			ft_putchar_fd(' ', inf.fd);
+	return (len);
+}

+ 46 - 0
srcs/ft_printf/pf_u_up.c

@@ -0,0 +1,46 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_u_up.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 03:07:31 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/12 02:47:20 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_u_up(long long unsigned int nb, t_inf inf, int len)
+{
+	if (inf.prec > (int)ft_nbrulen(nb))
+	{
+		if (len < inf.width - inf.prec)
+			return (true);
+	}
+	else if (len < inf.width - (int)ft_nbrulen(nb))
+		return (true);
+	return (false);
+}
+
+int			pf_u_up(va_list ap, t_inf inf)
+{
+	long long unsigned int	nb;
+	int						len;
+	int						cpt;
+
+	nb = va_arg(ap, long long unsigned int);
+	len = 0;
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_u_up(nb, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero == 1 && inf.prec == 0 ? '0' : ' '), inf.fd);
+	cpt = -1;
+	while (++cpt < inf.prec - (int)ft_nbrulen(nb) && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	len += pf_putunbrlong(nb, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	return (len);
+}

+ 100 - 0
srcs/ft_printf/pf_x.c

@@ -0,0 +1,100 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_x.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:56:52 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:43:31 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_xl(long long unsigned int nb, t_inf *inf, int len)
+{
+	if (inf->prec > pf_hexulen(nb))
+	{
+		if (len < inf->width - (inf->prec + inf->di * 2))
+			return (true);
+	}
+	else if (len < inf->width - (pf_hexulen(nb) + inf->di * 2))
+		return (true);
+	return (false);
+}
+
+static int	pf_width_x(unsigned int nb, t_inf inf, int len)
+{
+	int i;
+
+	i = nb == 0 && inf.prec == -1 ? 0 : pf_hexlen(nb);
+	if (inf.prec > i)
+	{
+		if (len < inf.width - (inf.prec + inf.di * 2))
+			return (true);
+	}
+	else if (len < inf.width - (i + inf.di * 2))
+		return (true);
+	return (false);
+}
+
+static int	pf_xlong(va_list ap, t_inf *inf)
+{
+	long long unsigned int	nb;
+	int						len;
+	int						cpt;
+
+	nb = va_arg(ap, long long unsigned int);
+	len = 0;
+	if (inf->di == 1 && nb != 0 && inf->zero && !inf->prec)
+	{
+		inf->di = 0;
+		len += pf_putstr("0x", inf->fd);
+	}
+	if (inf->width > 0 && inf->min == 0)
+		while (pf_width_xl(nb, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf->zero && !inf->prec ? '0' : ' '), inf->fd);
+	if (inf->di == 1 && nb != 0)
+		len += pf_putstr("0x", inf->fd);
+	cpt = -1;
+	while (++cpt < inf->prec - pf_hexulen(nb) && len++ >= 0)
+		ft_putchar_fd('0', inf->fd);
+	return (pf_xlong2(len, inf, nb));
+}
+
+static int	pf_x2(unsigned int nb, t_inf inf, int len)
+{
+	len += pf_puthex(nb, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	return (len);
+}
+
+int			pf_x(va_list ap, t_inf inf)
+{
+	unsigned int	nb;
+	int				len;
+	int				cpt;
+
+	if (inf.z || inf.l || inf.ll || inf.j)
+		return (pf_xlong(ap, &inf));
+	nb = inf.hh ? (unsigned char)va_arg(ap, unsigned int) :
+		va_arg(ap, unsigned int);
+	len = 0;
+	if (inf.di == 1 && nb != 0 && inf.zero && !inf.prec)
+	{
+		inf.di = 0;
+		len += pf_putstr("0x", inf.fd);
+	}
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_x(nb, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero && !inf.prec ? '0' : ' '), inf.fd);
+	if (inf.di == 1 && nb != 0)
+		len += pf_putstr("0x", inf.fd);
+	cpt = -1;
+	while (++cpt < inf.prec - pf_hexlen(nb) && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	return (pf_x2(nb, inf, len));
+}

+ 97 - 0
srcs/ft_printf/pf_x_up.c

@@ -0,0 +1,97 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_x_up.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:57:47 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:43:55 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_xl(long long unsigned int nb, t_inf *inf, int len)
+{
+	if (inf->prec > pf_hexulen(nb))
+	{
+		if (len < inf->width - (inf->prec + inf->di * 2))
+			return (true);
+	}
+	else if (len < inf->width - (pf_hexulen(nb) + inf->di * 2))
+		return (true);
+	return (false);
+}
+
+static int	pf_width_x(unsigned int nb, t_inf inf, int len)
+{
+	if (inf.prec > pf_hexlen(nb))
+	{
+		if (len < inf.width - (inf.prec + inf.di * 2))
+			return (true);
+	}
+	else if (len < inf.width - (pf_hexlen(nb) + inf.di * 2))
+		return (true);
+	return (false);
+}
+
+static int	pf_x_uplong(va_list ap, t_inf *inf)
+{
+	long long unsigned int	nb;
+	int						len;
+	int						cpt;
+
+	nb = va_arg(ap, long long unsigned int);
+	len = 0;
+	if (inf->di == 1 && nb != 0 && inf->zero && !inf->prec)
+	{
+		inf->di = 0;
+		len += pf_putstr("0X", inf->fd);
+	}
+	if (inf->width > 0 && inf->min == 0)
+		while (pf_width_xl(nb, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf->zero && !inf->prec ? '0' : ' '), inf->fd);
+	if (inf->di == 1 && nb != 0)
+		len += pf_putstr("0X", inf->fd);
+	cpt = -1;
+	while (++cpt < inf->prec - pf_hexulen(nb) && len++ >= 0)
+		ft_putchar_fd('0', inf->fd);
+	return (pf_x_uplong2(len, inf, nb));
+}
+
+static int	pf_x_up2(unsigned int nb, t_inf inf, int len)
+{
+	len += pf_puthexm(nb, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (len < inf.width && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	return (len);
+}
+
+int			pf_x_up(va_list ap, t_inf inf)
+{
+	unsigned int	nb;
+	int				len;
+	int				cpt;
+
+	if (inf.z || inf.l || inf.ll || inf.j)
+		return (pf_x_uplong(ap, &inf));
+	nb = inf.hh ? (unsigned char)va_arg(ap, unsigned int) :
+		va_arg(ap, unsigned int);
+	len = 0;
+	if (inf.di == 1 && nb != 0 && inf.zero && !inf.prec)
+	{
+		inf.di = 0;
+		len += pf_putstr("0X", inf.fd);
+	}
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_x(nb, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero && !inf.prec ? '0' : ' '), inf.fd);
+	if (inf.di == 1 && nb != 0)
+		len += pf_putstr("0X", inf.fd);
+	cpt = -1;
+	while (++cpt < inf.prec - pf_hexlen(nb) && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	return (pf_x_up2(nb, inf, len));
+}

+ 21 - 0
srcs/ft_putascii.c

@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putascii.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/05/01 17:07:58 by bchanot           #+#    #+#             */
+/*   Updated: 2017/05/01 17:08:18 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_putascii(unsigned char c)
+{
+	if (c > 31 && c < 127)
+		ft_putchar(c);
+	else
+		ft_putchar('.');
+}

+ 30 - 0
srcs/ft_putchar.c

@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putchar.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 16:39:02 by bchanot           #+#    #+#             */
+/*   Updated: 2017/04/15 00:35:26 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <unistd.h>
+
+int	ft_putchar_fd(int c, int fd)
+{
+	if (!c)
+		return (false);
+	write(fd, &c, 1);
+	return (true);
+}
+
+int	ft_putchar(int c)
+{
+	if (!c)
+		return (false);
+	write(1, &c, 1);
+	return (true);
+}

+ 26 - 0
srcs/ft_putendl.c

@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putendl.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/06/15 19:02:39 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:14:10 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <unistd.h>
+
+void	ft_putendl_fd(const char *const s, int fd)
+{
+	if (s)
+		write(fd, s, ft_strlen(s));
+	ft_putchar_fd('\n', fd);
+}
+
+void	ft_putendl(const char *const s)
+{
+	return (ft_putendl_fd(s, 1));
+}

+ 23 - 0
srcs/ft_puthex.c

@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_puthex.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/05/01 17:08:27 by bchanot           #+#    #+#             */
+/*   Updated: 2017/05/01 17:14:54 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_puthex(unsigned char c, int maj)
+{
+	char	*hex;
+
+	hex = ft_strdup(maj ? "0123456789ABCDEF" : "0123456789abcdef");
+	ft_putchar(hex[c / 16]);
+	ft_putchar(hex[c % 16]);
+	ft_memdel((void **)&hex);
+}

+ 40 - 0
srcs/ft_putnbr.c

@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putnbr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/10/12 02:20:43 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/12 03:30:32 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_putunbr_fd(t_uint64 nb, int fd)
+{
+	if (nb < 10)
+		ft_putchar_fd(48 + nb, fd);
+	else
+	{
+		ft_putunbr_fd(nb / 10, fd);
+		ft_putunbr_fd(nb % 10, fd);
+	}
+}
+
+void	ft_putnbr_fd(t_int64 nb, int fd)
+{
+	if (nb < 0)
+	{
+		ft_putchar_fd('-', fd);
+		nb = -nb;
+	}
+	if (nb < 10)
+		ft_putchar_fd(48 + nb, fd);
+	else
+	{
+		ft_putnbr_fd(nb / 10, fd);
+		ft_putnbr_fd(nb % 10, fd);
+	}
+}

+ 22 - 0
srcs/ft_putnbr_base.c

@@ -0,0 +1,22 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putnbr_base.c                                   :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/02/02 02:30:08 by bchanot           #+#    #+#             */
+/*   Updated: 2017/02/02 02:31:34 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_putnbr_base(int value, int base)
+{
+	char *str;
+
+	str = ft_itoa_base(value, base);
+	ft_putstr(str);
+	ft_memdel((void **)&str);
+}

+ 26 - 0
srcs/ft_putstr.c

@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putstr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 16:39:48 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:13:53 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <unistd.h>
+
+void	ft_putstr_fd(const char *const s, int fd)
+{
+	if (s && fd >= 0)
+		write(fd, s, ft_strlen(s));
+}
+
+void	ft_putstr(const char *const s)
+{
+	if (s)
+		write(1, s, ft_strlen(s));
+}

+ 24 - 0
srcs/ft_puttab.c

@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_puttab.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/12/23 15:12:41 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/12 19:38:27 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_puttab(char **tab)
+{
+	if (!tab)
+		return ;
+	while (*tab)
+	{
+		ft_putendl(*tab);
+		tab++;
+	}
+}

+ 25 - 0
srcs/ft_sqrt.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_sqrt.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/01/28 22:43:47 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/11 23:12:24 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t	ft_sqrt(size_t nb)
+{
+	size_t cpt;
+
+	cpt = 0;
+	if (nb == 0)
+		return (false);
+	while (cpt * cpt < nb)
+		cpt++;
+	return (cpt);
+}

+ 23 - 0
srcs/ft_str_lower.c

@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_str_lower.c                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/09/23 22:51:32 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:23:59 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_str_lower(char *src)
+{
+	size_t	i;
+
+	i = -1;
+	while (src[++i])
+		src[i] = ft_tolower(src[i]);
+	return (src);
+}

+ 23 - 0
srcs/ft_str_upper.c

@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_str_upper.c                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/09/23 20:05:47 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:24:17 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_str_upper(char *src)
+{
+	size_t	i;
+
+	i = -1;
+	while (src[++i])
+		src[i] = ft_toupper(src[i]);
+	return (src);
+}

+ 20 - 0
srcs/ft_strcat.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strcat.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 16:18:39 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/13 20:50:09 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strcat(char *dst, const char *src)
+{
+	if (dst && src)
+		ft_strcpy(&dst[ft_strlen(dst)], src);
+	return (dst);
+}

+ 24 - 0
srcs/ft_strchr.c

@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strchr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 13:32:36 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/11 22:27:45 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strchr(const char *s, int c)
+{
+	if (!s)
+		return (NULL);
+	while (*s != (char)c && *s != '\0')
+		s++;
+	if (*s == (char)c)
+		return ((char *)s);
+	return (NULL);
+}

+ 28 - 0
srcs/ft_strcmp.c

@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strcmp.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 16:52:55 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 11:56:25 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_strcmp(const char *const s1, const char *const s2)
+{
+	size_t cpt;
+
+	cpt = 0;
+	if ((!s1 && !s2) || (!ft_strlen(s1) && !ft_strlen(s2)))
+		return (false);
+	if ((!s1 && s2) || (s1 && !s2) || (!ft_strlen(s1) && ft_strlen(s2)) ||
+		(ft_strlen(s1) && !ft_strlen(s2)))
+		return (true);
+	while (s1[cpt] == s2[cpt] && s1[cpt] && s2[cpt])
+		cpt++;
+	return ((unsigned char)s1[cpt] - (unsigned char)s2[cpt]);
+}

+ 27 - 0
srcs/ft_strcmp_end.c

@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strcmp_end.c                                    :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/08/29 03:46:31 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:13:07 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_strcmp_end(const char *s1, const char *const s2)
+{
+	size_t	len;
+
+	len = ft_strlen(s2);
+	if (!s2 || !s1 || len > ft_strlen(s1))
+		return (false);
+	while (*(s1 + len))
+		s1++;
+	if (!ft_strcmp(s1, s2))
+		return (true);
+	return (false);
+}

+ 32 - 0
srcs/ft_strcorr.c

@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strcorr.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/12/13 21:19:40 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:12:48 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strcorr(const char *const src, const char c)
+{
+	int	len;
+	int i;
+
+	i = 0;
+	if (!src || !c)
+		return (NULL);
+	while (src[i] && src[i] == c)
+		i++;
+	if (!src[i])
+		return (NULL);
+	len = ft_strlen(src) - 1;
+	while (len > 0 && src[len] == c)
+		len--;
+	len++;
+	return (ft_strsub(src, i, len - i));
+}

+ 18 - 0
srcs/ft_strcpy.c

@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strcpy.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 15:11:36 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/11 23:15:22 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strcpy(char *dst, const char *src)
+{
+	return ((char *)ft_memcpy(dst, src, ft_strlen(src)));
+}

+ 25 - 0
srcs/ft_strdup.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strdup.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 14:55:16 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/13 21:20:06 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strdup(const char *src)
+{
+	char	*s;
+
+	if (!src)
+		return (NULL);
+	if (!(s = ft_strnew(ft_strlen(src))))
+		return (NULL);
+	ft_strcpy(s, src);
+	return (s);
+}

+ 25 - 0
srcs/ft_strequ.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strequ.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 19:53:56 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 11:58:31 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_strequ(const char *const s1, const char *const s2)
+{
+	if (s1 && s2)
+	{
+		if (ft_strcmp(s1, s2) == 0)
+			return (true);
+	}
+	else if (s1 == s2)
+		return (true);
+	return (false);
+}

+ 31 - 0
srcs/ft_strichr.c

@@ -0,0 +1,31 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strichr.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <marvin@42.fr>                     +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/12/03 11:37:13 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 11:58:15 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t	ft_strichr(const char *const s, int c)
+{
+	size_t	i;
+
+	i = 0;
+	if (!s || !c)
+		return (false);
+	while (s[i])
+	{
+		if (s[i] == (char)c)
+			return (i);
+		i++;
+	}
+	if (s[i] == (char)c)
+		return (i);
+	return (-1);
+}

+ 36 - 0
srcs/ft_strisdigit.c

@@ -0,0 +1,36 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strisdigit.c                                    :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/06/16 16:16:37 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 03:26:30 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_strisdigit(const char *src)
+{
+	t_bool	end;
+
+	end = false;
+	if (!src)
+		return (false);
+	while (*src && *src == ' ')
+		src++;
+	if (*src == '-' || *src == '+')
+		src++;
+	while (*src)
+	{
+		if ((*src >= 48 && *src <= 57) && !end)
+			src++;
+		else if (*src == ' ' && !end)
+			end = true;
+		else
+			return (false);
+	}
+	return (true);
+}

+ 25 - 0
srcs/ft_striter.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_striter.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 18:21:53 by bchanot           #+#    #+#             */
+/*   Updated: 2017/11/21 16:35:15 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_striter(char *s, void (*f)(char *))
+{
+	if (s && f)
+	{
+		while (*s)
+		{
+			f(&(*s));
+			s++;
+		}
+	}
+}

+ 28 - 0
srcs/ft_striteri.c

@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_striteri.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 19:02:58 by bchanot           #+#    #+#             */
+/*   Updated: 2017/11/21 16:35:55 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_striteri(char *s, void (*f)(unsigned int, char *))
+{
+	unsigned int cpt;
+
+	cpt = 0;
+	if (s && f)
+	{
+		while (s[cpt])
+		{
+			(*f)(cpt, &s[cpt]);
+			cpt++;
+		}
+	}
+}

+ 27 - 0
srcs/ft_strjoin.c

@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strjoin.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/26 20:09:15 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 12:20:21 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+char	*ft_strjoin(const char *s1, const char *s2)
+{
+	char	*s;
+
+	if (!s1 || !s2)
+		return (NULL);
+	if (!(s = ft_strnew(ft_strlen(s1) + ft_strlen(s2))))
+		return (NULL);
+	s = ft_strcpy(s, s1);
+	s = ft_strcat(s, s2);
+	return (s);
+}

+ 34 - 0
srcs/ft_strlcat.c

@@ -0,0 +1,34 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strlcat.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/26 13:43:52 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 11:57:39 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t		ft_strlcat(char *dst, const char *const src, size_t size)
+{
+	size_t	dest_end;
+	size_t	i;
+
+	i = 0;
+	if (!src || !size)
+		return (0);
+	while (dst[i] && i < size)
+		i++;
+	dest_end = i;
+	while (src[i - dest_end] && i < size - 1)
+	{
+		dst[i] = src[i - dest_end];
+		i++;
+	}
+	if (i < size)
+		dst[i] = '\0';
+	return (dest_end + ft_strlen(src));
+}

+ 24 - 0
srcs/ft_strlen.c

@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strlen.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 14:47:27 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 11:58:05 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t		ft_strlen(const char *const s)
+{
+	size_t cpt;
+
+	cpt = 0;
+	if (s)
+		while (s[cpt])
+			cpt++;
+	return (cpt);
+}

+ 36 - 0
srcs/ft_strmap.c

@@ -0,0 +1,36 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strmap.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 19:07:42 by bchanot           #+#    #+#             */
+/*   Updated: 2015/12/07 19:43:14 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strmap(char const *s, char (*f)(char))
+{
+	char	*dst;
+	char	*src;
+	size_t	cpt;
+
+	src = (char*)s;
+	if (src && f)
+	{
+		dst = ft_strnew(ft_strlen(s));
+		if (!dst)
+			return (NULL);
+		cpt = 0;
+		while (src[cpt])
+		{
+			dst[cpt] = (*f)(src[cpt]);
+			cpt++;
+		}
+		return (dst);
+	}
+	return (NULL);
+}

+ 35 - 0
srcs/ft_strmapi.c

@@ -0,0 +1,35 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strmapi.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 19:31:59 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/23 14:29:31 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strmapi(char const *s, char (*f)(unsigned int, char))
+{
+	char			*dst;
+	char			*src;
+	unsigned int	cpt;
+
+	src = (char*)s;
+	if (src && f)
+	{
+		if (!(dst = ft_strnew(ft_strlen(s))))
+			return (NULL);
+		cpt = 0;
+		while (src[cpt])
+		{
+			dst[cpt] = (*f)(cpt, src[cpt]);
+			cpt++;
+		}
+		return (dst);
+	}
+	return (NULL);
+}

+ 23 - 0
srcs/ft_strmerge.c

@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strmerge.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/12/19 18:52:01 by bchanot           #+#    #+#             */
+/*   Updated: 2017/12/19 18:53:26 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strmerge(char *s1, char *s2)
+{
+	char	*tmp;
+
+	tmp = ft_strjoin(s1, s2);
+	ft_memdel((void **)&s1);
+	ft_memdel((void **)&s2);
+	return (tmp);
+}

+ 30 - 0
srcs/ft_strncat.c

@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strncat.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 16:30:39 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 11:57:23 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strncat(char *s1, const char *const s2, size_t n)
+{
+	size_t	i;
+	size_t	j;
+
+	i = ft_strlen(s1);
+	j = 0;
+	while (j < n && s2[j])
+	{
+		s1[i] = s2[j];
+		i++;
+		j++;
+	}
+	s1[i] = '\0';
+	return (s1);
+}

Некоторые файлы не были показаны из-за большого количества измененных файлов