Bladeren bron

added ft_select 42 project - 2019

bchanot 5 maanden geleden
bovenliggende
commit
9a6a10a643
100 gewijzigde bestanden met toevoegingen van 4424 en 1 verwijderingen
  1. 51 0
      .gitignore
  2. 56 0
      Makefile
  3. 12 1
      README.md
  4. 1 0
      auteur
  5. 253 0
      ft_select.fr.pdf
  6. 45 0
      includes/ft_select.h
  7. 217 0
      libft/Makefile
  8. 38 0
      libft/ft_atoi.c
  9. 19 0
      libft/ft_bzero.c
  10. 30 0
      libft/ft_charjoin.c
  11. 29 0
      libft/ft_check_last.c
  12. 29 0
      libft/ft_cptchar.c
  13. 21 0
      libft/ft_exit.c
  14. 21 0
      libft/ft_exit_err.c
  15. 114 0
      libft/ft_get_next_line.c
  16. 28 0
      libft/ft_getchar.c
  17. 44 0
      libft/ft_getstr.c
  18. 54 0
      libft/ft_htoa.c
  19. 21 0
      libft/ft_isalnum.c
  20. 20 0
      libft/ft_isalpha.c
  21. 20 0
      libft/ft_isascii.c
  22. 20 0
      libft/ft_isdigit.c
  23. 28 0
      libft/ft_isnum.c
  24. 20 0
      libft/ft_isprint.c
  25. 24 0
      libft/ft_isupper.c
  26. 40 0
      libft/ft_itoa.c
  27. 55 0
      libft/ft_itob.c
  28. 30 0
      libft/ft_itoo.c
  29. 25 0
      libft/ft_memalloc.c
  30. 33 0
      libft/ft_memccpy.c
  31. 33 0
      libft/ft_memchr.c
  32. 33 0
      libft/ft_memcmp.c
  33. 34 0
      libft/ft_memcpy.c
  34. 21 0
      libft/ft_memdel.c
  35. 28 0
      libft/ft_memdel2.c
  36. 32 0
      libft/ft_memmove.c
  37. 27 0
      libft/ft_memset.c
  38. 77 0
      libft/ft_nbrlen.c
  39. 99 0
      libft/ft_printf.c
  40. 66 0
      libft/ft_printf/pf_b.c
  41. 32 0
      libft/ft_printf/pf_c.c
  42. 60 0
      libft/ft_printf/pf_c_up.c
  43. 72 0
      libft/ft_printf/pf_d_up.c
  44. 97 0
      libft/ft_printf/pf_di.c
  45. 49 0
      libft/ft_printf/pf_len.c
  46. 142 0
      libft/ft_printf/pf_more_inf.c
  47. 63 0
      libft/ft_printf/pf_o.c
  48. 48 0
      libft/ft_printf/pf_o_up.c
  49. 97 0
      libft/ft_printf/pf_p.c
  50. 29 0
      libft/ft_printf/pf_percent.c
  51. 67 0
      libft/ft_printf/pf_putnbr.c
  52. 65 0
      libft/ft_printf/pf_putnbrlong.c
  53. 48 0
      libft/ft_printf/pf_putstr.c
  54. 50 0
      libft/ft_printf/pf_s.c
  55. 40 0
      libft/ft_printf/pf_s_up.c
  56. 95 0
      libft/ft_printf/pf_take_inf.c
  57. 55 0
      libft/ft_printf/pf_u.c
  58. 49 0
      libft/ft_printf/pf_u_up.c
  59. 103 0
      libft/ft_printf/pf_x.c
  60. 97 0
      libft/ft_printf/pf_x_up.c
  61. 26 0
      libft/ft_putchar.c
  62. 25 0
      libft/ft_putendl.c
  63. 63 0
      libft/ft_putnbr.c
  64. 24 0
      libft/ft_putstr.c
  65. 25 0
      libft/ft_puttab.c
  66. 25 0
      libft/ft_sqrt.c
  67. 20 0
      libft/ft_strcat.c
  68. 25 0
      libft/ft_strchr.c
  69. 24 0
      libft/ft_strclr.c
  70. 23 0
      libft/ft_strcmp.c
  71. 27 0
      libft/ft_strcpy.c
  72. 24 0
      libft/ft_strcut.c
  73. 19 0
      libft/ft_strdel.c
  74. 26 0
      libft/ft_strdup.c
  75. 25 0
      libft/ft_strequ.c
  76. 36 0
      libft/ft_strisdigit.c
  77. 28 0
      libft/ft_striter.c
  78. 28 0
      libft/ft_striteri.c
  79. 27 0
      libft/ft_strjoin.c
  80. 32 0
      libft/ft_strlcat.c
  81. 23 0
      libft/ft_strlen.c
  82. 36 0
      libft/ft_strmap.c
  83. 35 0
      libft/ft_strmapi.c
  84. 30 0
      libft/ft_strncat.c
  85. 25 0
      libft/ft_strncmp.c
  86. 31 0
      libft/ft_strncpy.c
  87. 25 0
      libft/ft_strnequ.c
  88. 24 0
      libft/ft_strnew.c
  89. 25 0
      libft/ft_strnjoin.c
  90. 36 0
      libft/ft_strnstr.c
  91. 25 0
      libft/ft_strrchr.c
  92. 73 0
      libft/ft_strsplit.c
  93. 38 0
      libft/ft_strstr.c
  94. 35 0
      libft/ft_strsub.c
  95. 36 0
      libft/ft_strtrim.c
  96. 23 0
      libft/ft_tablen.c
  97. 20 0
      libft/ft_tolower.c
  98. 20 0
      libft/ft_toupper.c
  99. 64 0
      libft/ft_unicode.c
  100. 42 0
      libft/ft_utoa.c

+ 51 - 0
.gitignore

@@ -0,0 +1,51 @@
+# ---> Vim
+[._]*.s[a-w][a-z]
+[._]s[a-w][a-z]
+*.un~
+Session.vim
+.netrwhist
+*~
+
+# ---> Linux
+*~
+
+# KDE directory preferences
+.directory
+
+# Linux trash folder which might appear on any partition or disk
+.Trash-*
+
+# ---> C
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+

+ 56 - 0
Makefile

@@ -0,0 +1,56 @@
+#******************************************************************************#
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#*   Updated: 2016/11/08 16:43:14 by bchanot          ###   ########.fr       *#
+#                                                                              #
+#******************************************************************************#
+
+NAME = ft_select
+FILES = main.c sl_loop.c sl_take_inf.c sl_screen.c sl_signal.c
+SRC = $(addprefix srcs/, $(FILES))
+FOBJ = $(SRC:srcs/%.c=%.o)
+OBJ = $(addprefix .objects/, $(FOBJ))
+FLAGS = -Wall -Werror -Wextra
+LIB = -L./libft -lft
+INC	= -I./includes -I./libft/includes
+NO_COLOR = \x1b[0m
+OK_COLOR = \x1b[32;01m
+ERROR_COLOR = \x1b[31;01m
+WARN_COLOR = \x1b[33;01m
+
+all: $(NAME)
+
+$(NAME): disp lib
+	@echo  "\t---COMPILING OBJECTS---"
+	@clang $(FLAGS) -c $(SRC) $(INC)
+	@mkdir -p .objects && mv $(FOBJ) .objects
+	@echo "$(OK_COLOR)\t---OBJECTS CREATED---$(NO_COLOR)"
+	@echo  "\t---COMPILING EXECUTABLE---"
+	@clang $(FLAGS) -ltermcap -o $(NAME) $(INC) $(OBJ) $(LIB)
+	@echo  "$(OK_COLOR)\t---EXECUTABLE CREATED---"
+	@echo  "---COMPILATION COMPLETE---$(NO_COLOR)"
+
+disp:
+	@echo  "$(WARN_COLOR)---PLEASE-WAIT---COMPILING--- $(NO_COLOR)"
+
+lib:
+	@echo "\t---CHECKING LIBRARY---"
+	@make -C libft
+	@echo "$(OK_COLOR)\t---LIBRARY UP TO DATE---$(NO_COLOR)"
+
+clean:
+	@/bin/rm -rf .objects
+	@make clean -C libft/
+	@echo "$(OK_COLOR)---OBJECTS DELETED---$(NO_COLOR)"
+
+fclean: clean
+	@/bin/rm -rf $(NAME)
+	@make fclean -C libft/
+	@echo "$(OK_COLOR)---BINARY DELETED---$(NO_COLOR)"
+
+re: fclean all

+ 12 - 1
README.md

@@ -1,3 +1,14 @@
 # ft_select
+Note : 103 / 100
 
-ft_select project from 42 - 2019
+### Description
+Ce projet a pour but de vous initier à la manipulation du terminal avec les termcaps. Vous allez ici apprendre à créer une interface utilisateur pour un programme lancé dans le terminal.
+
+### Objectives
+    - Interface utilisateur via le terminal
+    - Bibliothèque Termcaps
+
+### Skills
+    - Unix
+    - Imperative programming
+    - Rigor 

+ 1 - 0
auteur

@@ -0,0 +1 @@
+bchanot

+ 253 - 0
ft_select.fr.pdf

@@ -0,0 +1,253 @@
+            Projet à tendance UNIX
+
+                           ft_select
+
+Résumé: Ce projet a pour but de vous faire coder un petit programme en termcaps qui
+  permettra de selectionner un ensemble de choix parmi une liste et de le retourner à
+                                                 votre shell.
+Table des matières
+
+I   Préambule                    2
+
+II  Introduction                 4
+
+III Objectifs                    5
+
+IV Consignes générales           6
+
+V   Partie obligatoire           8
+
+VI Partie bonus                  10
+
+VII Rendu et peer-évaluation     11
+
+                              1
+Chapitre I
+Préambule
+
+                                                        2
+Projet à tendance UNIX     ft_select
+
+                        3
+Chapitre II
+Introduction
+
+    Des programmes comme votre shell, aptitude, top, tig, mcabber, dwarf fortress,
+zangband ou herrie ont tous au moins deux points communs : ces programmes s’exe-
+cutent dans un terminal et proposent une interface utilisateur avancée malgré l’absence
+d’interface graphique fenêtrée à laquelle Microsoft Windows et OSX (dans son utilisation
+Starbucks) vous ont habitué.
+
+                                                        4
+Chapitre III
+Objectifs
+
+    Réaliser une interface utilisateur pour un programme qui s’execute dans un terminal
+est possible et demande un travail de programmation qu’il est important de maitriser
+car dans son mode "brut", un terminal ne fait pas grand chose. Pour vous en convaincre,
+lancez la commande cat sans argument et appuyez sur des touches ou des combinaisons
+de touches de votre clavier...
+
+    Dans cette manipulation, tant que vous appuyez sur des touches alphanumériques,
+rien de particulier n’est à constater. Par contre, si vous appuyez sur les flèches, la touche
+echap ou les touches fn par exemple, des caractères arbitraires s’affichent... Refaites la
+manipulation dans votre shell maintenant. Vous êtes habitués à ce que la flèche gauche
+recule le curseur d’une colone. Pourquoi ces différences entre cat et votre shell ?
+
+    Votre terminal gère beaucoup de choses pour vous sans que vous y prêtiez la moindre
+attention, comme par exemple l’affichage des caractères au fur et à mesure que vous les
+tapez ou encore la bufferisation par ligne.
+
+    Si maintenant vous vous demandez comment vous pouvez prendre le contrôle de votre
+terminal, ce projet est fait pour vous. Vous y apprendrez à configurer votre termial via
+la structure "struct termios" et à utiliser ses capacités, les fameux "termcaps".
+
+                                                        5
+Chapitre IV
+
+Consignes générales
+
+     • Interdiction d’utiliser des variables globales, hormis celles qui pourraient déja être
+        définies pour vous. On tolerera une exception à cette règle pour gerer les signaux,
+        même s’il est possible de faire autrement.
+
+     • Un fonction locale à un fichier C (qui n’est donc pas prototypée dans fichier .h)
+        doit être définie static dans le respect de la Norme.
+
+     • Vous devez prêter attention à vos types et utiliser judicieusement les casts quand
+        c’est nécéssaire, en particulier lorsqu’un type void * est impliqué. Dans l’absolu,
+        évitez les casts implicites, quels que soient les types concernés.
+
+     • Vous pouvez utiliser autant de fonctions et de fichiers que vous le souhaitez.
+     • Vous devez rendre un Makefile qui compilera vos sources en C vers un éxécutable
+
+        nommé ft_select.
+     • Votre Makefile doit au moins proposer les règles $(NAME), all, clean, fclean et
+
+        re dans l’ordre qui vous paraîtra le plus adapté.
+     • Vous devez rendre, à la racine de votre dépôt de rendu, un fichier auteur contenant
+
+        votre login suivi d’un ’\n’ :
+
+             $>cat -e auteur
+             xlogin$
+
+     • Votre Makefile doit compiler votre travail avec les flags de compilation -Wall,
+        -Wextra et -Werror.
+
+     • Si vous êtes malin et que vous utilisez votre biliothèque libft pour votre ft_select,
+        vous devez en copier les sources et le Makefile associé dans un dossier nommé
+        libft qui devra être à la racine de votre dépot de rendu.
+
+     • Votre executable doit linker avec la bibliothq`ue termcap.
+     • Seul le contenu présent sur votre dépot sera évalué en soutenance.
+     • Votre projet doit être à la Norme. La Norminette sera utilisée pour vérifier la
+
+        Norme lors de la soutenance. Une faute de norme invalide immédiatement l’éva-
+        luation.
+
+                                                        6
+Projet à tendance UNIX     ft_select
+
+• En aucun cas votre programme ne doit quitter de façon inattendue (Segmentation
+  fault, bus error, double free, etc) ou diverger (boucle infinie). Votre projet serait
+  alors considéré comme non fonctionnel.
+
+• Un projet qui affiche de l’art abstrait (caractères étranges et/ou inadéquats) est
+  considéré comme non fonctionnel.
+
+• Dans le cas où votre programme est tué en cours d’éxécution, votre terminal doit
+  bien évidement fonctionner normalement ensuite...
+
+• Toute mémoire allouée sur le tas doit être libérée proprement.
+
+• Vous ne devez jamais rendre de code que vous n’avez pas écrit vous-même. En cas
+  de doute, vous serez invités à une séance de recode au bocal pour juger de votre
+  bonne foi.
+
+• La bibliothèque termcap est obligatoire pour ce projet.
+
+• Ce projet réclame une bonne réflexion. Il est absolument vital que vous discutiez
+  entre-vous et que vous partagiez vos informations !
+
+• Avant que vous ne posiez la question, la bibliothèque ncurse est interdite pour ce
+  projet. Sinon il n’y aurait pas de challenge...
+
+• Les fonctions autorisées sont :
+
+    ◦ isatty, ttyname, ttyslot
+    ◦ ioctl
+    ◦ getenv
+    ◦ tcsetattr, tcgetattr
+    ◦ tgetent, tgetflag, tgetnum, tgetstr, tgoto, tputs
+    ◦ open, close, write
+    ◦ malloc, free
+    ◦ read, exit
+    ◦ signal
+
+• Vous pouvez poser vos questions sur le Forum, Slack...
+
+                        7
+Chapitre V
+Partie obligatoire
+
+• Ecrire un programme "ft_select" qui prend en paramètre une série d’arguments.
+  La liste d’arguments s’affiche.
+
+• L’utilisateur peut alors se déplacer dans la liste des arguments à l’aide des flèches
+  (la liste est circulaire).
+
+• Un ou plusieurs choix peuvent être sélectionnés ou désélectionnés à l’aide de la
+  touche espace. A chaque sélection effectuée, le curseur doit automatiquement se
+  positionner sur l’élément suivant.
+
+• Dès que l’utilisateur valide la sélection à l’aide de la touche return, la liste des
+  choix doit être renvoyée au shell. Les choix renvoyés devront être separés par
+  le caractère espace. Ceci permettra alors d’utiliser votre programme ft_select à
+  l’intérieur d’un script shell (pour faire un "set", par exemple).
+
+• On doit pouvoir écrire les commandes suivantes :
+
+$> set reponse = ft_select choix1 choix2 choix3 choix4
+
+$> more ft_select *.c
+
+$> rm ft_select ~/*    NB: N utilisez cette commande QUE si
+                             vous etes SUR que votre ft_select
+                             fonctionne. Nous degageons toute
+                             responsabilite en cas de bug de
+                             votre ft_select...
+
+• Vous devrez également gérer le redimensionnement de la fenêtre par l’utilisateur.
+  La liste doit s’afficher sur plusieurs colonnes si la taille de la fenêtre ne comporte
+  pas assez de lignes pour tout afficher en une seule colonne. Si l’utilisateur redimen-
+  sionne la fenêtre en cours d’utilisation, l’ensemble des choix doit se repositionner
+  automatiquement et les choix selectionnés doivent le rester. Le curseur de selection
+  doit être positionné de manière raisonnable après un redimensionnement.
+
+• Si la fenêtre est trop petite pour tout afficher (pas assez de lignes et/ou de colonnes,
+  alors le programme doit réagir raisonnablement tant que la dimension de la fenêtre
+  n’est pas suffisante. En aucun cas il ne doit quitter. Lorsque la fenêtre est de
+  nouveau assez grande, le programme doit fonctionner de nouveau normalement.
+
+                                                  8
+Projet à tendance UNIX     ft_select
+
+• Si l’utilisateur appuie sur la touche echap, le programme ne doit rien renvoyer au
+  shell et terminer normalement.
+
+• Si l’utilisateur appuie sur la touche delete ou backspace, l’élément sur lequel
+  pointe le curseur doit être effacé de la liste. S’il n’y a plus d’élément dans la liste,
+  le comportement est le même que si l’utilisateur avait appuyé sur la touche echap.
+
+• choix non selectionné : texte normal.
+
+• choix selectionné : texte video inversé.
+
+• position curseur : texte souligné.
+
+• choix selectionné + position curseur : texte video inversé souligné.
+
+• Quelque soit le moyen par lequel votre programme se termine, la configuration
+  par defaut de votre terminal DOIT être restaurée. Oui, même après avoir reçu
+  un signal (sauf signaux qu’on ne peut pas intercepter, mais ca veut dire que votre
+  programme ne fonctionne pas de toute façon).
+
+• On doit pouvoir interrompre votre programme avec un ctrl+z et le restaurer avec
+  fg sans que cela influe sur son comportement.
+
+• Si le programme est lancé avec un environnement vide, vous devez adopter un
+  comportement raisonnable.
+
+                        9
+Chapitre VI
+Partie bonus
+
+    Si vous avez réussi parfaitement la partie obligatoire, cette section propose quelques
+pistes pour aller plus loin. Les bonus seront comptabilisés si vous validez la partie obli-
+gatoire.
+
+     • Les colonnes défilent de gauche à droite en fonction de la position du curseur quand
+        la fenêtre est trop petite.
+
+     • Après la terminaison du programme, ce qui doit l’être est effacé et le prompt
+        et le curseur apparaissent sur la ligne suivant l’appel du programme. Lancez la
+        commande tig pour voir ce que je veux dire. Pensez aux signaux !
+
+     • Une belle interface (c’est au correcteur de juger, pas à vous).
+     • Si les choix sont des fichiers, colorer selon l’extension (un peu comme ls -G sous
+
+        OSX).
+     • Positionnement du curseur lorsque l’on tape une séquence de caractères qui cor-
+
+        respond à un élément de la liste (recherche dynamique).
+
+                                                       10
+Chapitre VII
+Rendu et peer-évaluation
+
+    Rendez-votre travail sur votre dépot GiT comme d’habitude. Seul le travail présent
+sur votre dépot sera évalué en soutenance.
+
+                                                       11
+

+ 45 - 0
includes/ft_select.h

@@ -0,0 +1,45 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_select.h                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/11/02 07:00:23 by bchanot           #+#    #+#             */
+/*   Updated: 2016/11/08 11:19:56 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef FT_SELECT_H
+# define FT_SELECT_H
+# define ESCAPE 0x1B
+# define SPACE 0x20
+# define UP 0x415B1B
+# define DOWN 0x425B1B
+# define RIGHT 0x435B1B
+# define LEFT 0x445B1B
+# define ENTER 0xA
+# define BACKSPACE 0x7E335B1B
+# define DELETE 0x7F
+
+# include "../libft/includes/libft.h"
+# include <termios.h>
+
+typedef struct		s_inf
+{
+	struct termios	term;
+	char			**args;
+	int				*selected;
+	int				nb;
+	int				cur;
+}					t_inf;
+
+int					sl_launch_loop(t_inf *inf);
+void				sl_init_inf(int ac, char **av, t_inf *inf);
+void				sl_init_term(t_inf *inf);
+void				sl_display_screen(t_inf *inf);
+t_inf				*sl_set_inf(t_inf *inf);
+void				sl_set_signal(void);
+void				sl_exit(char *str, t_inf *inf, int bool);
+
+#endif

+ 217 - 0
libft/Makefile

@@ -0,0 +1,217 @@
+#******************************************************************************#
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2015/11/27 00:02:23 by bchanot           #+#    #+#              #
+#*   Updated: 2016/11/01 18:45:09 by bchanot          ###   ########.fr       *#
+#                                                                              #
+#******************************************************************************#
+
+FLAGS = -Wall -Wextra -Werror
+NAME = libft.a
+HEAD = includes/
+SRC = ft_atoi.c \
+	ft_itoo.c \
+	ft_striter.c \
+	ft_strrchr.c \
+	ft_bzero.c \
+	ft_memalloc.c \
+	ft_putnbr.c \
+	ft_striteri.c \
+	ft_strsplit.c \
+	ft_isalnum.c \
+	ft_isnum.c \
+	ft_memccpy.c \
+	ft_strjoin.c \
+	ft_strstr.c \
+	ft_isalpha.c \
+	ft_memchr.c \
+	ft_putstr.c \
+	ft_strlcat.c \
+	ft_strsub.c \
+	ft_isascii.c \
+	ft_memcmp.c \
+	ft_strlen.c \
+	ft_strtrim.c \
+	ft_isdigit.c \
+	ft_memcpy.c \
+	ft_strcat.c \
+	ft_strmap.c \
+	ft_tolower.c \
+	ft_isprint.c \
+	ft_memdel.c \
+	ft_strchr.c \
+	ft_strmapi.c \
+	ft_toupper.c \
+	ft_itoa.c \
+	ft_strclr.c \
+	ft_strncat.c \
+	ft_memmove.c \
+	ft_strcmp.c \
+	ft_strncmp.c \
+	ft_memset.c \
+	ft_strcpy.c \
+	ft_strncpy.c \
+	ft_putchar.c \
+	ft_strdel.c \
+	ft_strnequ.c \
+	ft_strdup.c \
+	ft_strnew.c \
+	ft_putendl.c \
+	ft_strequ.c \
+	ft_strnstr.c \
+	ft_cptchar.c \
+	ft_puttab.c \
+	ft_exit.c \
+	ft_sqrt.c \
+	ft_exit_err.c \
+	ft_htoa.c \
+	ft_utoa.c \
+	ft_nbrlen.c \
+	ft_unicode.c \
+	ft_itob.c \
+	ft_strnjoin.c \
+	ft_getchar.c \
+	ft_getstr.c \
+	ft_strcut.c \
+	ft_charjoin.c \
+	ft_isupper.c \
+	ft_memdel2.c \
+	ft_strisdigit.c \
+	ft_check_last.c \
+	ft_tablen.c \
+	ft_printf.c \
+	ft_printf/pf_b.c \
+	ft_printf/pf_c.c \
+	ft_printf/pf_c_up.c \
+	ft_printf/pf_d_up.c \
+	ft_printf/pf_di.c \
+	ft_printf/pf_len.c \
+	ft_printf/pf_more_inf.c \
+	ft_printf/pf_o.c \
+	ft_printf/pf_o_up.c \
+	ft_printf/pf_p.c \
+	ft_printf/pf_percent.c \
+	ft_printf/pf_putnbr.c \
+	ft_printf/pf_putnbrlong.c \
+	ft_printf/pf_putstr.c \
+	ft_printf/pf_s.c \
+	ft_printf/pf_s_up.c \
+	ft_printf/pf_take_inf.c \
+	ft_printf/pf_u.c \
+	ft_printf/pf_u_up.c \
+	ft_printf/pf_x.c \
+	ft_printf/pf_x_up.c \
+	get_next_line.c
+OBJ =  ft_atoi.o \
+	ft_striter.o \
+	ft_strrchr.o \
+	ft_bzero.o \
+	ft_memalloc.o \
+	ft_putnbr.o \
+	ft_striteri.o \
+	ft_strsplit.o \
+	ft_isalnum.o \
+	ft_memccpy.o \
+	ft_strjoin.o \
+	ft_strstr.o \
+	ft_isalpha.o \
+	ft_isnum.o \
+	ft_memchr.o \
+	ft_putstr.o \
+	ft_strlcat.o \
+	ft_strsub.o \
+	ft_isascii.o \
+	ft_memcmp.o \
+	ft_strlen.o \
+	ft_strtrim.o \
+	ft_isdigit.o \
+	ft_memcpy.o \
+	ft_strcat.o \
+	ft_strmap.o \
+	ft_tolower.o \
+	ft_isprint.o \
+	ft_memdel.o \
+	ft_strchr.o \
+	ft_strmapi.o \
+	ft_toupper.o \
+	ft_itoa.o \
+	ft_strclr.o \
+	ft_strncat.o \
+	ft_memmove.o \
+	ft_strcmp.o \
+	ft_strncmp.o \
+	ft_memset.o \
+	ft_strcpy.o \
+	ft_strncpy.o \
+	ft_putchar.o \
+	ft_strdel.o \
+	ft_strnequ.o \
+	ft_strdup.o \
+	ft_strnew.o \
+	ft_putendl.o \
+	ft_strequ.o \
+	ft_strnstr.o \
+	ft_cptchar.o \
+	ft_puttab.o \
+	ft_exit.o \
+	ft_sqrt.o \
+	ft_exit_err.o \
+	ft_htoa.o \
+	ft_utoa.o \
+	ft_nbrlen.o \
+	ft_unicode.o \
+	ft_itob.o \
+	ft_strnjoin.o \
+	ft_itoo.o \
+	ft_getchar.o \
+	ft_getstr.o \
+	ft_charjoin.o \
+	ft_isupper.o \
+	ft_check_last.o \
+	ft_strcut.o \
+	ft_tablen.o \
+	ft_printf.o \
+	ft_memdel2.o \
+	ft_strisdigit.o \
+	pf_b.o \
+	pf_c.o \
+	pf_c_up.o \
+	pf_d_up.o \
+	pf_di.o \
+	pf_len.o \
+	pf_more_inf.o \
+	pf_o.o \
+	pf_o_up.o \
+	pf_p.o \
+	pf_percent.o \
+	pf_putnbr.o \
+	pf_putnbrlong.o \
+	pf_putstr.o \
+	pf_s.o \
+	pf_s_up.o \
+	pf_take_inf.o \
+	pf_u.o \
+	pf_u_up.o \
+	pf_x.o \
+	pf_x_up.o \
+	get_next_line.o
+
+all: $(NAME)
+
+$(NAME):
+	@clang -c -I $(HEAD) $(FLAGS) $(SRC)
+	@ar rc $(NAME) $(OBJ)
+	@ranlib $(NAME)
+	@echo "\t---LIBFT---COMPILATED---"
+
+clean:
+	@/bin/rm -f $(OBJ)
+
+fclean: clean
+	@/bin/rm -f $(NAME)
+
+re: fclean all

+ 38 - 0
libft/ft_atoi.c

@@ -0,0 +1,38 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_atoi.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 17:07:30 by bchanot           #+#    #+#             */
+/*   Updated: 2015/12/29 16:18:37 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_atoi(const char *str)
+{
+	int cpt;
+	int nb;
+	int neg;
+
+	cpt = 0;
+	neg = 0;
+	nb = 0;
+	while (str[cpt] == ' ' || str[cpt] == '\n' || str[cpt] == '\v' ||
+	str[cpt] == '\r' || str[cpt] == '\t' || str[cpt] == '\f')
+		cpt++;
+	if (str[cpt] == '-')
+		neg = 1;
+	if (str[cpt] == '+' || str[cpt] == '-')
+		cpt++;
+	while (str[cpt] >= '0' && str[cpt] <= '9')
+	{
+		nb *= 10;
+		nb += (str[cpt] - 48);
+		cpt++;
+	}
+	return (neg == 1 ? -nb : nb);
+}

+ 19 - 0
libft/ft_bzero.c

@@ -0,0 +1,19 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_bzero.c                                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/24 15:27:39 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/23 14:22:17 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_bzero(void *s, size_t n)
+{
+	if (s)
+		ft_memset(s, 0, n);
+}

+ 30 - 0
libft/ft_charjoin.c

@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_charjoin.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/07/23 03:06:18 by bchanot           #+#    #+#             */
+/*   Updated: 2016/10/16 22:14:39 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+char	*ft_charjoin(char const *s1, char const c)
+{
+	char	*str;
+	int		cpt;
+
+	if (!s1 || !c)
+		return (NULL);
+	if (!(str = ft_strnew(ft_strlen(s1) + 1)))
+		return (NULL);
+	str = ft_strcpy(str, (char *)s1);
+	cpt = ft_strlen(str);
+	str[cpt] = c;
+	str[cpt + 1] = '\0';
+	return (str);
+}

+ 29 - 0
libft/ft_check_last.c

@@ -0,0 +1,29 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_check_last.c                                    :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/08/29 03:46:31 by bchanot           #+#    #+#             */
+/*   Updated: 2016/11/08 11:03:19 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_check_last(char *src, char *str)
+{
+	int		cpt;
+	size_t	c;
+
+	c = ft_strlen(str);
+	cpt = 0;
+	if (c > ft_strlen(src))
+		return (0);
+	while (src[cpt + c])
+		cpt++;
+	if (ft_strcmp(&src[cpt], str) == 0)
+		return (1);
+	return (0);
+}

+ 29 - 0
libft/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: 2016/02/08 16:22:26 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t	ft_cptchar(char *str, char c)
+{
+	size_t	cpt;
+	int		i;
+
+	i = 0;
+	cpt = 0;
+	while (str[i])
+	{
+		if (str[i] == c)
+			cpt++;
+		i++;
+	}
+	return (cpt);
+}

+ 21 - 0
libft/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: 2016/02/09 17:03:50 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+void	ft_exit(const char *str)
+{
+	if (str != NULL)
+		ft_putendl_fd(str, 1);
+	exit(EXIT_SUCCESS);
+}

+ 21 - 0
libft/ft_exit_err.c

@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_exit_err.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/09 17:04:55 by bchanot           #+#    #+#             */
+/*   Updated: 2016/02/09 17:05:32 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+void	ft_exit_err(const char *str)
+{
+	if (str != NULL)
+		ft_putendl_fd(str, 1);
+	exit(EXIT_FAILURE);
+}

+ 114 - 0
libft/ft_get_next_line.c

@@ -0,0 +1,114 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   get_next_line1.c                                   :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/01/11 15:09:42 by bchanot           #+#    #+#             */
+/*   Updated: 2016/07/22 23:59:06 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <unistd.h>
+#include <stdlib.h>
+
+static char	*ft_set_str(char *str)
+{
+	while (*str != '\n' && *str != '\0')
+		str++;
+	if (*str == '\n' && str[1] != '\0')
+		return (ft_strdup(++str));
+	else
+		return (NULL);
+}
+
+static void	ft_add(char **line, char *rest)
+{
+	size_t	i;
+	size_t	len;
+	char	*tmp;
+
+	i = 0;
+	if (*line)
+	{
+		tmp = ft_strdup(*line);
+		free(*line);
+		len = ft_strlen(tmp) + ft_strlen(rest);
+		*line = (char *)malloc(sizeof(char) * (len + 1));
+		ft_strcpy(*line, tmp);
+		free(tmp);
+		while ((*line)[i])
+			i++;
+	}
+	else
+	{
+		len = ft_strlen(rest);
+		*line = (char *)malloc(sizeof(char) * (len + 1));
+	}
+	while (*rest != '\0' && *rest != '\n')
+		(*line)[i++] = *rest++;
+	(*line)[i] = '\0';
+}
+
+static int	ft_take_rest(char **line, char **rest)
+{
+	char *buf;
+
+	if (*rest && ft_strchr(*rest, '\n'))
+	{
+		ft_add(line, *rest);
+		buf = *rest;
+		*rest = ft_set_str(buf);
+		free(buf);
+		return (1);
+	}
+	else if (*rest && !ft_strchr(*rest, '\n'))
+	{
+		*line = ft_strdup(*rest);
+		free(*rest);
+		*rest = NULL;
+	}
+	return (0);
+}
+
+static int	ft_check(char **line, char **rest, int const fd)
+{
+	if (line)
+		*line = NULL;
+	else
+		return (-1);
+	if (BUFF_SIZE <= 0 || fd < 0)
+		return (-1);
+	if (ft_take_rest(line, rest))
+		return (1);
+	return (0);
+}
+
+int			ft_get_next_line(int const fd, char **line)
+{
+	int			check;
+	int			res;
+	char		*str;
+	static char *rest;
+
+	check = ft_check(line, &rest, fd);
+	if (check != 0)
+		return (check);
+	str = ft_strnew(BUFF_SIZE);
+	while ((res = read(fd, str, BUFF_SIZE)) > 0 && !ft_strchr(str, '\n'))
+	{
+		ft_add(line, str);
+		ft_bzero(str, BUFF_SIZE + 1);
+	}
+	if (res > 0)
+	{
+		str[res] = '\0';
+		ft_add(line, str);
+		rest = ft_set_str(str);
+	}
+	free(str);
+	res = (res > 1) ? 1 : res;
+	return ((res == 0 && *line != NULL) ? 1 : res);
+}

+ 28 - 0
libft/ft_getchar.c

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

+ 44 - 0
libft/ft_getstr.c

@@ -0,0 +1,44 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_getstr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/06/15 18:51:15 by bchanot           #+#    #+#             */
+/*   Updated: 2016/10/16 22:19:16 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <unistd.h>
+
+char	*ft_getstr_fd(int fd, char x)
+{
+	char c;
+	char *str;
+	char *tmp;
+
+	str = ft_strnew(1);
+	ft_bzero(str, 1);
+	while (read(fd, &c, 1) != 0)
+	{
+		if (c == x)
+			break ;
+		else
+		{
+			tmp = ft_charjoin(str, c);
+			ft_memdel((void **)&str);
+			str = ft_strdup(tmp);
+			ft_memdel((void **)&tmp);
+		}
+	}
+	tmp = ft_charjoin(str, '\0');
+	ft_memdel((void **)&str);
+	return (tmp);
+}
+
+char	*ft_getstr(char x)
+{
+	return (ft_getstr_fd(0, x));
+}

+ 54 - 0
libft/ft_htoa.c

@@ -0,0 +1,54 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_htoa.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/11 19:54:05 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/15 21:41:51 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.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++;
+	}
+	str = (char *)malloc(sizeof(char *) * cpt + 1);
+	if (str)
+	{
+		str[cpt + 1] = '\0';
+		while (cpt >= 0)
+		{
+			x = nb % 16;
+			str[cpt] = valuehex(x);
+			nb /= 16;
+			cpt--;
+		}
+	}
+	return (str);
+}

+ 21 - 0
libft/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: 2015/12/29 16:18:35 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 (1);
+	return (0);
+}

+ 20 - 0
libft/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: 2015/12/04 01:43:06 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_isalpha(int c)
+{
+	if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122))
+		return (1);
+	return (0);
+}

+ 20 - 0
libft/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: 2015/11/28 00:07:54 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_isascii(int c)
+{
+	if (c >= 0 && c <= 127)
+		return (1);
+	return (0);
+}

+ 20 - 0
libft/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: 2015/12/04 01:42:49 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_isdigit(int c)
+{
+	if (c >= 48 && c <= 57)
+		return (1);
+	return (0);
+}

+ 28 - 0
libft/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: 2016/07/20 14:25:22 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_isnum(const char *s)
+{
+	if (*s == '+' || *s == '-')
+		s++;
+	if (*s == '\0')
+		return (0);
+	while (*s)
+	{
+		if (!ft_isdigit(*s))
+			return (0);
+		s++;
+	}
+	return (1);
+}

+ 20 - 0
libft/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: 2015/12/04 01:42:40 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_isprint(int c)
+{
+	if (c >= 32 && c <= 126)
+		return (1);
+	return (0);
+}

+ 24 - 0
libft/ft_isupper.c

@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isupper.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/08/09 23:42:37 by bchanot           #+#    #+#             */
+/*   Updated: 2016/09/28 13:07:54 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_isupper(char c)
+{
+	if (c >= 65 && c <= 90)
+		return (1);
+	else if (c >= 97 && c <= 122)
+		return (0);
+	else if (c >= 48 && c <= 57)
+		return (-1);
+	return (-42);
+}

+ 40 - 0
libft/ft_itoa.c

@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_itoa.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 15:33:13 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/23 15:36:03 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.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 *)malloc(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);
+}

+ 55 - 0
libft/ft_itob.c

@@ -0,0 +1,55 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_itob.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/03/18 20:56:24 by bchanot           #+#    #+#             */
+/*   Updated: 2016/11/08 11:04:50 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include "libft.h"
+
+static char	*ft_itob2(char *str)
+{
+	int	cpt;
+
+	cpt = 0;
+	while (str[cpt] == '0')
+		cpt++;
+	while ((ft_strlen(&str[cpt]) % 4) != 0)
+		cpt--;
+	return (ft_strdup(&str[cpt]));
+}
+
+char		*ft_itob(int nb)
+{
+	int		bin;
+	int		cpt;
+	char	*str;
+
+	bin = 4096;
+	cpt = -1;
+	str = (char *)malloc(sizeof(char *) * 14);
+	str[13] = 0;
+	if (nb < 0)
+		nb = -nb;
+	while (++cpt < 13)
+	{
+		if (nb >= bin)
+		{
+			str[cpt] = '1';
+			nb = nb - bin;
+			bin = (bin % 2) + (bin / 2);
+		}
+		else
+		{
+			str[cpt] = '0';
+			bin = (bin % 2) + (bin / 2);
+		}
+	}
+	return (ft_itob2(str));
+}

+ 30 - 0
libft/ft_itoo.c

@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_itoo.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/05/15 20:07:34 by bchanot           #+#    #+#             */
+/*   Updated: 2016/11/08 11:03:54 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+long long int	ft_itoo(long long unsigned int nb)
+{
+	long long int	oct;
+	long long int	mult;
+
+	oct = 0;
+	mult = 1;
+	while ((nb / 8) > 0)
+	{
+		oct += mult * (nb - 8 * (nb / 8));
+		nb = nb / 8;
+		mult = mult * 10;
+	}
+	oct += mult * nb;
+	return (oct);
+}

+ 25 - 0
libft/ft_memalloc.c

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

+ 33 - 0
libft/ft_memccpy.c

@@ -0,0 +1,33 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memccpy.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/26 17:54:45 by bchanot           #+#    #+#             */
+/*   Updated: 2015/12/01 01:15:23 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
libft/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: 2016/05/23 14:43:43 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
libft/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: 2015/12/01 01:18:00 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_memcmp(const void *s1, const void *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
libft/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
libft/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: 2016/11/08 11:05:21 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+void	ft_memdel(void **ap)
+{
+	if (*ap)
+		free(*ap);
+	*ap = NULL;
+}

+ 28 - 0
libft/ft_memdel2.c

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

+ 32 - 0
libft/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
libft/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: 2016/05/23 14:21:29 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	*ft_memset(void *b, int c, size_t len)
+{
+	unsigned char *t;
+
+	t = (unsigned char *)b;
+	while (len > 0)
+	{
+		len--;
+		t[len] = (unsigned char)c;
+	}
+	b = (void *)t;
+	return (b);
+}

+ 77 - 0
libft/ft_nbrlen.c

@@ -0,0 +1,77 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_cptnbr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/12 17:36:08 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/23 15:43:27 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_nbrlen(long long int nb)
+{
+	int size;
+
+	size = (nb < 0 ? 1 : 0);
+	while ((nb = nb / 10))
+		size++;
+	size++;
+	return (size);
+}
+
+int		ft_nbrlonglen(long long int nb)
+{
+	int size;
+
+	size = 0;
+	if (nb < 0)
+	{
+		if (nb == -9223372036854775807 - 1)
+			return (20);
+		nb = -nb;
+		size = ft_nbrlonglen(nb);
+		size++;
+	}
+	else if (nb >= 10)
+	{
+		size = ft_nbrlonglen(nb / 10);
+		size++;
+	}
+	else
+		size++;
+	return (size);
+}
+
+int		ft_nbrlgulen(long long unsigned int nb)
+{
+	int size;
+
+	size = 0;
+	if (nb >= 10)
+	{
+		size = ft_nbrlgulen(nb / 10);
+		size++;
+	}
+	else
+		size++;
+	return (size);
+}
+
+int		ft_nbrulen(unsigned int nb)
+{
+	int size;
+
+	size = 0;
+	if (nb >= 10)
+	{
+		size = ft_nbrulen(nb / 10);
+		size++;
+	}
+	else
+		size++;
+	return (size);
+}

+ 99 - 0
libft/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: 2016/11/08 11:06:14 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 *str, int fd)
+{
+	int	len;
+
+	len = 0;
+	while (format + len != str)
+		len++;
+	write(fd, format, len);
+	return (len);
+}
+
+static int	ft_format(char **str, 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);
+	*str -= 1;
+	return (len);
+}
+
+static int	pf_printf(const char **format, va_list ap, char **str, int tmp[2])
+{
+	int		chk;
+	t_inf	inf;
+	int		len;
+
+	len = tmp[0];
+	len += pf_print_part(*format, *str, tmp[1]);
+	*str += 1;
+	inf = pf_take_inf(str, ap, tmp[1]);
+	if ((chk = ft_format(str, ap, inf)) < 0)
+	{
+		if (chk == -1)
+			return (-1);
+		if (pf_wrong_conv(str, format, inf, &len))
+			return (len);
+	}
+	else
+	{
+		*format = *str + 1;
+		len += chk;
+	}
+	return (len);
+}
+
+int			ft_printf(int fd, const char *format, ...)
+{
+	va_list		ap;
+	int			len[2];
+	char		*str;
+	int			col;
+
+	len[0] = 0;
+	len[1] = fd;
+	col = 0;
+	str = (char *)format;
+	va_start(ap, format);
+	while (*str)
+	{
+		if (*str == '{')
+			col = pf_take_color(&str, &format, &len[0], len[1]);
+		if (*str == '%')
+			if ((len[0] = pf_printf(&format, ap, &str, len) == -1))
+				return (-1);
+		str++;
+	}
+	va_end(ap);
+	len[0] += pf_putstr(format, fd);
+	if (col == 1)
+		ft_putstr_fd(EOC, fd);
+	return (len[0]);
+}

+ 66 - 0
libft/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: 2016/03/28 21:42:33 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_b(char *str, t_inf inf, int len, int nb)
+{
+	int i;
+
+	i = nb == 0 && inf.prec == -1 ? 0 : (int)ft_strlen(str);
+	if (inf.prec > i)
+	{
+		if (len < inf.width - inf.prec)
+			return (1);
+	}
+	else if (len < inf.width - i)
+		return (1);
+	return (0);
+}
+
+static int	pf_b2(int nb, char *str, t_inf inf, int len)
+{
+	if (nb == 0 && inf.prec == -1)
+		len += 0;
+	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);
+	return (len);
+}
+
+int			pf_b(va_list ap, t_inf inf)
+{
+	char	*str;
+	int		len;
+	int		nb;
+	int		cpt;
+
+	nb = va_arg(ap, int);
+	str = ft_itob(nb);
+	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(str, inf, len, nb) && len++ >= 0)
+			ft_putchar_fd(' ', inf.fd);
+	cpt = -1;
+	if (inf.prec > 0)
+		while (++cpt < inf.prec - ((int)ft_strlen(str)) && len++ >= 0)
+			ft_putchar_fd('0', inf.fd);
+	cpt = -1;
+	if (inf.width && inf.zero && !inf.min)
+		while (++cpt < inf.width - ((int)ft_strlen(str)) && len++ >= 0)
+			ft_putchar_fd('0', inf.fd);
+	return (pf_b2(nb, str, inf, len));
+}

+ 32 - 0
libft/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
libft/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: 2016/08/11 21:35:38 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+#include <wchar.h>
+#include <stdlib.h>
+
+static int	pf_width_c_up(char *str, t_inf inf, int len)
+{
+	if (inf.prec < (int)ft_strlen(str) && inf.prec != 0)
+	{
+		if (len < inf.width - inf.prec)
+			return (1);
+	}
+	else if (len < inf.width - (int)ft_strlen(str))
+		return (1);
+	return (0);
+}
+
+static int	pf_c_up2(t_inf inf, char *str, int len)
+{
+	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 (str)
+		free(str);
+	return (len);
+}
+
+int			pf_c_up(va_list ap, t_inf inf)
+{
+	wchar_t c;
+	char	*str;
+	int		len;
+
+	len = inf.prec == -1 ? 1 : 0;
+	c = va_arg(ap, wchar_t);
+	str = ft_widechar(c);
+	if (c == 0)
+		return (1);
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_c_up(str, 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, str, len));
+}

+ 72 - 0
libft/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: 2016/05/29 03:40:25 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 >= ft_nbrlonglen(nb) ?
+								inf.prec + 1 : ft_nbrlonglen(nb)))
+			return (1);
+	if (nb >= 0)
+		if (len < inf.width - (inf.prec >= ft_nbrlonglen(nb) ?
+								inf.prec : ft_nbrlonglen(nb)))
+			return (1);
+	return (0);
+}
+
+static int	pf_d_up2(long long int nb, int len, int min, t_inf inf)
+{
+	int cpt;
+
+	cpt = -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 (++cpt < inf.prec - ft_nbrlonglen(nb) && len++ >= 0)
+		ft_putchar_fd('0', inf.fd);
+	ft_putnbrlong(nb, inf.fd);
+	len += ft_nbrlonglen(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
libft/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: 2016/08/11 21:35:08 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 (1);
+	}
+	else if (len < inf.width - (inf.prec >= i ? inf.prec : i))
+		return (1);
+	return (0);
+}
+
+static int	pf_di2(long int nb, int len, int min, t_inf inf)
+{
+	int cpt;
+
+	cpt = -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 (++cpt < inf.prec - 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
libft/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: 2016/06/13 21:54:15 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
libft/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: 2016/11/08 11:10:31 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+int			pf_wrong_conv(char **str, const char **format, t_inf inf, int *len)
+{
+	int cpt;
+
+	cpt = 0;
+	if (**str == '\0')
+	{
+		*format = *str;
+		return (1);
+	}
+	if (inf.width > 0 && inf.min == 0)
+		while (++cpt < inf.width)
+		{
+			ft_putchar_fd((inf.zero == 1 ? '0' : ' '), inf.fd);
+			*len += 1;
+		}
+	ft_putchar_fd(**str, inf.fd);
+	if (inf.width > 0 && inf.min == 1)
+		while (++cpt < inf.width)
+		{
+			ft_putchar_fd(' ', inf.fd);
+			*len += 1;
+		}
+	*format = *str + 1;
+	*len += 1;
+	return (0);
+}
+
+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 (0);
+}
+
+void		take_prec(char **s, t_inf *inf, va_list ap, int cpt)
+{
+	inf->prec = 0;
+	*s += 1;
+	if (**s == '*' && cpt++ >= 0)
+	{
+		inf->prec = va_arg(ap, int);
+		if (inf->prec < 0)
+			inf->prec = -1;
+		*s += 1;
+	}
+	else
+	{
+		while (ft_isdigit(**s) && cpt++ >= 0)
+		{
+			inf->prec = inf->prec * 10 + **s - '0';
+			*s += 1;
+		}
+	}
+	if (cpt == 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 (0);
+	return (1);
+}
+
+int			pf_take_color(char **str, const char **format, int *len, int fd)
+{
+	int		cpt;
+	char	tmp[8];
+
+	cpt = 0;
+	tmp[7] = '\0';
+	*len += pf_print_part(*format, *str, fd);
+	*str += 1;
+	while (**str != '}' && cpt < 7)
+	{
+		tmp[cpt] = **str;
+		*str += 1;
+		cpt++;
+	}
+	*str += 1;
+	if (!pf_more_color_please(tmp, fd))
+	{
+		*str -= cpt + 2;
+		*format = *str;
+		return (0);
+	}
+	*format = *str;
+	return (1);
+}

+ 63 - 0
libft/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: 2016/08/11 21:34:13 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 (1);
+	}
+	else if (len < inf.width - (pf_octlen(nb, inf) + inf.di))
+		return (1);
+	return (0);
+}
+
+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
libft/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: 2016/08/11 21:31:21 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 (1);
+	}
+	else if (len < inf.width - (pf_octulen(nb, inf) + inf.di))
+		return (1);
+	return (0);
+}
+
+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
libft/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: 2016/05/29 04:03:02 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+#include <stdlib.h>
+
+static int	pf_width_p(char *str, t_inf inf, int len, void *p)
+{
+	int i;
+
+	i = p == (void *)0 && inf.prec == -1 ? 0 : (int)ft_strlen(str);
+	if (inf.prec > i)
+	{
+		if (len < inf.width - inf.prec)
+			return (1);
+	}
+	else if (len < inf.width - i)
+		return (1);
+	return (0);
+}
+
+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			*str;
+
+	n = (unsigned long)p;
+	tmpn = (unsigned long)p;
+	len = 2;
+	while (tmpn /= 16)
+		len++;
+	if ((str = (char*)malloc(sizeof(char) * len)) == NULL)
+		return (NULL);
+	str[--len] = '\0';
+	while (len--)
+	{
+		str[len] = get_digit(n % 16);
+		n = n / 16;
+	}
+	return (str);
+}
+
+static int	pf_p2(char *str, t_inf inf, int len)
+{
+	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 (str)
+		free(str);
+	return (len);
+}
+
+int			pf_p(va_list ap, t_inf inf)
+{
+	char	*str;
+	int		len;
+	void	*p;
+	int		cpt;
+
+	p = va_arg(ap, void*);
+	str = 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(str, 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(str)) && len++ >= 0)
+			ft_putchar_fd('0', inf.fd);
+	cpt = -1;
+	if (inf.width && inf.zero && !inf.min)
+		while (++cpt < inf.width - ((int)ft_strlen(str) + 2) && len++ >= 0)
+			ft_putchar_fd('0', inf.fd);
+	return (pf_p2(str, inf, len));
+}

+ 29 - 0
libft/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
libft/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: 2016/04/25 00:37:31 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
libft/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
libft/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: 2016/06/13 21:45:37 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 *str, int fd)
+{
+	int len;
+
+	len = -1;
+	while (str[++len])
+		ft_putchar_fd(str[len], fd);
+	return (len);
+}
+
+int		pf_putnstr(const char *str, int n, int fd)
+{
+	write(fd, str, n);
+	return (n);
+}

+ 50 - 0
libft/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: 2016/11/08 11:07:10 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+int	pf_width_s(char *str, t_inf inf, int len)
+{
+	if (inf.prec < (int)ft_strlen(str) && inf.prec != 0)
+	{
+		if (len < inf.width - inf.prec)
+			return (1);
+	}
+	else if (len < inf.width - (int)ft_strlen(str))
+		return (1);
+	return (0);
+}
+
+int	pf_s(va_list ap, t_inf inf)
+{
+	char	*str;
+	int		len;
+
+	len = inf.prec == -1 ? 1 : 0;
+	if (inf.l)
+		return (pf_s_up(ap, inf));
+	if ((str = va_arg(ap, char *)) == NULL)
+		str = ft_strdup("(null)");
+	if (inf.width > 0 && inf.min == 0)
+		while (pf_width_s(str, inf, len) && len++ >= 0)
+			ft_putchar_fd((inf.zero == 0 ? ' ' : '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 (!ft_strcmp(str, "(null)"))
+		ft_memdel((void **)&str);
+	return (len);
+}

+ 40 - 0
libft/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
libft/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: 2016/08/21 04:20:17 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 (1);
+}
+
+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 (1);
+		}
+	}
+	inf->type = -1;
+	return (0);
+}
+
+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);
+}

+ 55 - 0
libft/ft_printf/pf_u.c

@@ -0,0 +1,55 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_u.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:55:55 by bchanot           #+#    #+#             */
+/*   Updated: 2016/06/13 21:57:29 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_u(unsigned int nb, t_inf inf, int len)
+{
+	int i;
+
+	i = nb == 0 && inf.prec == -1 ? 0 : ft_nbrulen(nb);
+	if (inf.prec > ft_nbrulen(nb))
+	{
+		if (len < inf.width - inf.prec)
+			return (1);
+	}
+	else if (len < inf.width - ft_nbrulen(nb))
+		return (1);
+	return (0);
+}
+
+int			pf_u(va_list ap, t_inf inf)
+{
+	unsigned int	nb;
+	int				len;
+	int				cpt;
+
+	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);
+}

+ 49 - 0
libft/ft_printf/pf_u_up.c

@@ -0,0 +1,49 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_u_up.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 03:07:31 by bchanot           #+#    #+#             */
+/*   Updated: 2016/06/13 21:57:43 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_u_up(long long unsigned int nb, t_inf inf, int len)
+{
+	int i;
+
+	i = nb == 0 && inf.prec == -1 ? 0 : ft_nbrlgulen(nb);
+	if (inf.prec > ft_nbrlgulen(nb))
+	{
+		if (len < inf.width - inf.prec)
+			return (1);
+	}
+	else if (len < inf.width - ft_nbrlgulen(nb))
+		return (42);
+	return (0);
+}
+
+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 - ft_nbrlgulen(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);
+}

+ 103 - 0
libft/ft_printf/pf_x.c

@@ -0,0 +1,103 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   pf_x.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/27 01:56:52 by bchanot           #+#    #+#             */
+/*   Updated: 2016/06/13 21:57:58 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libftprintf.h"
+
+static int	pf_width_xl(long long unsigned int nb, t_inf *inf, int len)
+{
+	int i;
+
+	i = nb == 0 && inf->prec == -1 && inf->width ? 0 : pf_hexulen(nb);
+	if (inf->prec > pf_hexulen(nb))
+	{
+		if (len < inf->width - (inf->prec + inf->di * 2))
+			return (1);
+	}
+	else if (len < inf->width - (pf_hexulen(nb) + inf->di * 2))
+		return (1);
+	return (0);
+}
+
+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 (1);
+	}
+	else if (len < inf.width - (i + inf.di * 2))
+		return (1);
+	return (0);
+}
+
+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
libft/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: 2016/05/29 03:51:43 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 (1);
+	}
+	else if (len < inf->width - (pf_hexulen(nb) + inf->di * 2))
+		return (1);
+	return (0);
+}
+
+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 (1);
+	}
+	else if (len < inf.width - (pf_hexlen(nb) + inf.di * 2))
+		return (1);
+	return (0);
+}
+
+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));
+}

+ 26 - 0
libft/ft_putchar.c

@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putchar.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 16:39:02 by bchanot           #+#    #+#             */
+/*   Updated: 2016/11/02 13:56:35 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <unistd.h>
+
+int	ft_putchar_fd(int c, int fd)
+{
+	write(fd, &c, 1);
+	return (1);
+}
+
+int	ft_putchar(int c)
+{
+	write(1, &c, 1);
+	return (1);
+}

+ 25 - 0
libft/ft_putendl.c

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

+ 63 - 0
libft/ft_putnbr.c

@@ -0,0 +1,63 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putnbr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 16:54:21 by bchanot           #+#    #+#             */
+/*   Updated: 2016/06/16 15:43:06 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_putnbr_fd(long int n, int fd)
+{
+	long nbr;
+
+	nbr = n;
+	if (nbr == -2147483648)
+	{
+		ft_putstr_fd("-2147483648", fd);
+		return ;
+	}
+	if (nbr < 0)
+	{
+		ft_putchar_fd('-', fd);
+		nbr = -nbr;
+	}
+	if (nbr > 9)
+	{
+		ft_putnbr_fd((nbr / 10), fd);
+		ft_putnbr_fd((nbr % 10), fd);
+	}
+	else
+		ft_putchar_fd((nbr + 48), fd);
+}
+
+void	ft_putnbr(long int n)
+{
+	return (ft_putnbr_fd(n, 1));
+}
+
+void	ft_putnbrlong(long long int nb, int fd)
+{
+	if (nb < 0)
+	{
+		ft_putchar_fd('-', fd);
+		if (nb == (-9223372036854775807 - 1))
+		{
+			ft_putstr_fd("9223372036854775808", fd);
+			return ;
+		}
+		nb = -nb;
+	}
+	if (nb < 10)
+		ft_putchar_fd(48 + nb, fd);
+	else
+	{
+		ft_putnbrlong(nb / 10, fd);
+		ft_putnbrlong(nb % 10, fd);
+	}
+}

+ 24 - 0
libft/ft_putstr.c

@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putstr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 16:39:48 by bchanot           #+#    #+#             */
+/*   Updated: 2016/06/15 19:07:37 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <unistd.h>
+
+void	ft_putstr_fd(char const *s, int fd)
+{
+	write(fd, s, ft_strlen(s));
+}
+
+void	ft_putstr(const char *s)
+{
+	write(1, s, ft_strlen(s));
+}

+ 25 - 0
libft/ft_puttab.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_puttab.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/12/23 15:12:41 by bchanot           #+#    #+#             */
+/*   Updated: 2015/12/23 15:15:17 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_puttab(char **tab)
+{
+	int cpt;
+
+	cpt = 0;
+	while (tab[cpt])
+	{
+		ft_putendl(tab[cpt]);
+		cpt++;
+	}
+}

+ 25 - 0
libft/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: 2016/01/28 22:46:49 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_sqrt(int nb)
+{
+	int cpt;
+
+	cpt = 0;
+	if (nb == 0)
+		return (0);
+	while (cpt * cpt < nb)
+		cpt++;
+	return (cpt);
+}

+ 20 - 0
libft/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: 2016/05/22 21:09:03 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strcat(char *s1, const char *s2)
+{
+	if (s1 && s2)
+		ft_strcpy(&s1[ft_strlen(s1)], s2);
+	return (s1);
+}

+ 25 - 0
libft/ft_strchr.c

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

+ 24 - 0
libft/ft_strclr.c

@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strclr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 18:16:43 by bchanot           #+#    #+#             */
+/*   Updated: 2015/11/28 23:24:29 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_strclr(char *s)
+{
+	int	cpt;
+
+	if (s == NULL)
+		return ;
+	cpt = ft_strlen(s);
+	while (cpt--)
+		s[cpt] = '\0';
+}

+ 23 - 0
libft/ft_strcmp.c

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

+ 27 - 0
libft/ft_strcpy.c

@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strcpy.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 15:11:36 by bchanot           #+#    #+#             */
+/*   Updated: 2015/11/27 14:43:18 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strcpy(char *dst, const char *src)
+{
+	int	cpt;
+
+	cpt = 0;
+	while (src[cpt])
+	{
+		dst[cpt] = src[cpt];
+		cpt++;
+	}
+	dst[cpt] = '\0';
+	return (dst);
+}

+ 24 - 0
libft/ft_strcut.c

@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strcut.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/06/16 00:05:33 by bchanot           #+#    #+#             */
+/*   Updated: 2016/06/16 00:07:01 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strcut(char *str, char c)
+{
+	int cpt;
+
+	cpt = 0;
+	while (str[cpt] != c)
+		cpt++;
+	cpt++;
+	return (&str[cpt]);
+}

+ 19 - 0
libft/ft_strdel.c

@@ -0,0 +1,19 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strdel.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 18:14:35 by bchanot           #+#    #+#             */
+/*   Updated: 2015/12/07 18:27:05 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_strdel(char **as)
+{
+	if (as != NULL && *as != NULL)
+		ft_memdel((void *)as);
+}

+ 26 - 0
libft/ft_strdup.c

@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strdup.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 14:55:16 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/23 14:27:24 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strdup(const char *s1)
+{
+	char	*str;
+
+	if (!s1)
+		return (NULL);
+	str = ft_strnew(ft_strlen(s1));
+	if (!str)
+		return (NULL);
+	ft_strcpy(str, s1);
+	return (str);
+}

+ 25 - 0
libft/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: 2015/11/28 23:32:07 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_strequ(char const *s1, char const *s2)
+{
+	if (s1 && s2)
+	{
+		if (ft_strcmp(s1, s2) == 0)
+			return (1);
+	}
+	else if (s1 == s2)
+		return (1);
+	return (0);
+}

+ 36 - 0
libft/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: 2016/10/16 22:09:34 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_strisdigit(char *str)
+{
+	int		i;
+	int		end;
+
+	i = -1;
+	end = 0;
+	while (str[++i] == ' ')
+		;
+	if (str[i] == '-' || str[i] == '+')
+		i++;
+	while (str[i])
+	{
+		if ((str[i] >= 48 && str[i] <= 57) && end == 0)
+			i++;
+		else if (str[i] == ' ' && end == 0)
+			end = 1;
+		else
+			return (0);
+	}
+	return (1);
+}

+ 28 - 0
libft/ft_striter.c

@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_striter.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 18:21:53 by bchanot           #+#    #+#             */
+/*   Updated: 2015/11/28 22:24:05 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void	ft_striter(char *s, void (*f)(char *))
+{
+	int cpt;
+
+	cpt = 0;
+	if (s && f)
+	{
+		while (s[cpt])
+		{
+			f(&s[cpt]);
+			cpt++;
+		}
+	}
+}

+ 28 - 0
libft/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: 2015/12/07 15:28:05 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
libft/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: 2016/10/16 22:13:42 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+char	*ft_strjoin(char const *s1, char const *s2)
+{
+	char	*str;
+
+	if (!s1 || !s2)
+		return (NULL);
+	if (!(str = ft_strnew(ft_strlen(s1) + ft_strlen(s2))))
+		return (NULL);
+	str = ft_strcpy(str, (char *)s1);
+	str = ft_strcat(str, (char *)s2);
+	return (str);
+}

+ 32 - 0
libft/ft_strlcat.c

@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strlcat.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/26 13:43:52 by bchanot           #+#    #+#             */
+/*   Updated: 2015/11/28 21:43:59 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t		ft_strlcat(char *dst, const char *src, size_t size)
+{
+	size_t	cpt;
+	size_t	dest_end;
+
+	cpt = 0;
+	while (dst[cpt] && cpt < size)
+		cpt++;
+	dest_end = cpt;
+	while (src[cpt - dest_end] && cpt < size - 1)
+	{
+		dst[cpt] = src[cpt - dest_end];
+		cpt++;
+	}
+	if (cpt < size)
+		dst[cpt] = '\0';
+	return (dest_end + ft_strlen(src));
+}

+ 23 - 0
libft/ft_strlen.c

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

+ 36 - 0
libft/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
libft/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);
+}

+ 30 - 0
libft/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: 2015/12/04 01:36:49 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strncat(char *s1, const char *s2, size_t n)
+{
+	size_t	cpt;
+	size_t	cpt2;
+
+	cpt = ft_strlen(s1);
+	cpt2 = 0;
+	while (cpt2 < n && s2[cpt2])
+	{
+		s1[cpt] = s2[cpt2];
+		cpt++;
+		cpt2++;
+	}
+	s1[cpt] = '\0';
+	return (s1);
+}

+ 25 - 0
libft/ft_strncmp.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strncmp.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 17:03:07 by bchanot           #+#    #+#             */
+/*   Updated: 2015/12/01 13:33:09 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_strncmp(const char *s1, const char *s2, size_t n)
+{
+	size_t	cpt;
+
+	cpt = 0;
+	while (s1[cpt] == s2[cpt] && s1[cpt] && s2[cpt] && cpt < n)
+		cpt++;
+	if (cpt == n)
+		return (0);
+	return ((unsigned char)s1[cpt] - (unsigned char)s2[cpt]);
+}

+ 31 - 0
libft/ft_strncpy.c

@@ -0,0 +1,31 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strncpy.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 15:38:25 by bchanot           #+#    #+#             */
+/*   Updated: 2015/11/28 20:50:25 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strncpy(char *dst, const char *src, size_t n)
+{
+	size_t	cpt;
+
+	cpt = 0;
+	while (cpt < n && src[cpt])
+	{
+		dst[cpt] = src[cpt];
+		cpt++;
+	}
+	while (cpt < n)
+	{
+		dst[cpt] = '\0';
+		cpt++;
+	}
+	return (dst);
+}

+ 25 - 0
libft/ft_strnequ.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strnequ.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 20:03:58 by bchanot           #+#    #+#             */
+/*   Updated: 2015/11/28 23:33:50 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_strnequ(char const *s1, char const *s2, size_t n)
+{
+	if (s1 && s2)
+	{
+		if (ft_strncmp(s1, s2, n) == 0)
+			return (1);
+	}
+	else if (s1 == s2)
+		return (1);
+	return (0);
+}

+ 24 - 0
libft/ft_strnew.c

@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strnew.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 17:38:59 by bchanot           #+#    #+#             */
+/*   Updated: 2016/09/01 23:42:27 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+char	*ft_strnew(size_t size)
+{
+	char	*str;
+
+	if (!(str = (char *)malloc(sizeof(char) * (size + 1))))
+		return (NULL);
+	ft_bzero(str, size);
+	return (str);
+}

+ 25 - 0
libft/ft_strnjoin.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strnjoin.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/05/15 16:51:36 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/15 16:54:16 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strnjoin(char const *s1, char const *s2, size_t n)
+{
+	char	*str;
+
+	if (!s1 || !s2)
+		return (NULL);
+	str = ft_strnew(ft_strlen(s1) + n + 1);
+	str = ft_strcpy(str, (char *)s1);
+	str = ft_strncat(str, (char *)s2, n);
+	return (str);
+}

+ 36 - 0
libft/ft_strnstr.c

@@ -0,0 +1,36 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strnstr.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/26 12:21:03 by bchanot           #+#    #+#             */
+/*   Updated: 2015/11/29 00:13:56 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strnstr(const char *s1, const char *s2, size_t n)
+{
+	size_t	cpt;
+	size_t	cpt2;
+
+	cpt = 0;
+	cpt2 = 0;
+	if (!ft_strlen(s2))
+		return ((char *)s1);
+	while (s1[cpt])
+	{
+		while (s2[cpt2] == s1[cpt + cpt2] && cpt + cpt2 < n)
+		{
+			if (cpt2 == ft_strlen(s2) - 1)
+				return ((char *)&s1[cpt]);
+			cpt2++;
+		}
+		cpt2 = 0;
+		cpt++;
+	}
+	return (NULL);
+}

+ 25 - 0
libft/ft_strrchr.c

@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strrchr.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 13:54:03 by bchanot           #+#    #+#             */
+/*   Updated: 2015/11/27 03:41:08 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strrchr(const char *s, int c)
+{
+	int len;
+
+	len = ft_strlen(s);
+	while (s[len] != (char)c && len >= 0)
+		len--;
+	if (s[len] == (char)c)
+		return ((char *)&s[len]);
+	return (NULL);
+}

+ 73 - 0
libft/ft_strsplit.c

@@ -0,0 +1,73 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strsplit.c                                      :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/29 02:25:46 by bchanot           #+#    #+#             */
+/*   Updated: 2016/09/13 12:32:37 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+static int		ft_cpt(char const *s, char c)
+{
+	int cpt;
+	int cpt2;
+
+	cpt = 0;
+	cpt2 = 0;
+	while (s[cpt])
+	{
+		while (s[cpt] == c && s[cpt])
+			cpt++;
+		if (s[cpt] != c && s[cpt])
+			cpt2++;
+		while (s[cpt] != c && s[cpt])
+			cpt++;
+	}
+	return (cpt2);
+}
+
+static int		ft_word_len(char const *s, char c)
+{
+	int len;
+
+	len = 0;
+	while (s[len] != c && s[len])
+		len++;
+	if (!len)
+		len++;
+	return (len);
+}
+
+char			**ft_strsplit(char const *s, char c)
+{
+	char	**t_str;
+	int		word;
+	int		i;
+
+	word = 0;
+	i = 0;
+	if (!s)
+		return (NULL);
+	t_str = (char **)malloc(sizeof(char *) * (ft_cpt(s, c) + 1));
+	if (!t_str)
+		return (NULL);
+	while (s[i])
+	{
+		if (s[i] == c)
+			i++;
+		else
+		{
+			t_str[word] = ft_strsub(&s[i], 0, ft_word_len(&s[i], c), 0);
+			i = i + ft_word_len(&s[i], c);
+			word++;
+		}
+	}
+	t_str[word] = NULL;
+	return (t_str);
+}

+ 38 - 0
libft/ft_strstr.c

@@ -0,0 +1,38 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strstr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 16:41:28 by bchanot           #+#    #+#             */
+/*   Updated: 2015/12/01 01:38:22 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strstr(const char *s1, const char *s2)
+{
+	int	cpt;
+	int cpt2;
+	int size;
+
+	cpt = 0;
+	cpt2 = 0;
+	size = ft_strlen(s2);
+	if (size == 0)
+		return ((char *)s1);
+	while (s1[cpt])
+	{
+		while (s2[cpt2] == s1[cpt + cpt2])
+		{
+			if (cpt2 == size - 1)
+				return ((char *)&s1[cpt]);
+			cpt2++;
+		}
+		cpt2 = 0;
+		cpt++;
+	}
+	return (NULL);
+}

+ 35 - 0
libft/ft_strsub.c

@@ -0,0 +1,35 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strsub.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/26 18:22:34 by bchanot           #+#    #+#             */
+/*   Updated: 2016/09/13 12:35:48 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+char	*ft_strsub(char const *s, unsigned int start, size_t len, int bool)
+{
+	char	*str;
+	size_t	cpt;
+
+	str = ft_strnew(len);
+	if (!s || start > ft_strlen(s) || !str)
+		return (NULL);
+	cpt = 0;
+	while (cpt < len && s[start])
+	{
+		str[cpt] = s[start];
+		cpt++;
+		start++;
+	}
+	str[cpt] = '\0';
+	if (bool)
+		free((char *)s);
+	return (str);
+}

+ 36 - 0
libft/ft_strtrim.c

@@ -0,0 +1,36 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strtrim.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/26 20:22:02 by bchanot           #+#    #+#             */
+/*   Updated: 2016/09/13 12:30:32 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strtrim(char const *s)
+{
+	char	*str;
+	int		len;
+	int		cpt;
+
+	cpt = 0;
+	if (!s)
+		return (NULL);
+	len = ft_strlen(s) - 1;
+	while (s[len] == ' ' || s[len] == '\n' || s[len] == '\t')
+		len--;
+	len++;
+	while ((cpt < len) && (s[cpt] == ' ' || s[cpt] == '\n' || s[cpt] == '\t'))
+		cpt++;
+	len -= cpt;
+	str = ft_strsub((char *)s, cpt, len, 0);
+	if (!str)
+		return (NULL);
+	str[len] = '\0';
+	return (str);
+}

+ 23 - 0
libft/ft_tablen.c

@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_tablen.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/11/01 18:35:45 by bchanot           #+#    #+#             */
+/*   Updated: 2016/11/01 18:37:07 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_tablen(char **tab)
+{
+	int cpt;
+
+	cpt = 0;
+	while (tab[cpt])
+		cpt++;
+	return (cpt);
+}

+ 20 - 0
libft/ft_tolower.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_tolower.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 13:04:09 by bchanot           #+#    #+#             */
+/*   Updated: 2016/08/09 23:43:22 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_tolower(int c)
+{
+	if (c >= 65 && c <= 90)
+		c += 32;
+	return (c);
+}

+ 20 - 0
libft/ft_toupper.c

@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_toupper.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 13:00:42 by bchanot           #+#    #+#             */
+/*   Updated: 2015/12/01 03:38:01 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_toupper(int c)
+{
+	if (c >= 97 && c <= 122)
+		c -= 32;
+	return (c);
+}

+ 64 - 0
libft/ft_unicode.c

@@ -0,0 +1,64 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_unicode.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/03/10 01:44:46 by bchanot           #+#    #+#             */
+/*   Updated: 2016/10/16 22:15:23 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <locale.h>
+
+char	*ft_widechar(wchar_t c)
+{
+	char	str[5];
+
+	ft_bzero(str, 5);
+	if (c < 128)
+		str[0] = (char)c;
+	else if (c < 2048)
+	{
+		str[0] = (c >> 6) + 192;
+		str[1] = (c & 63) + 128;
+	}
+	else if (c < 65536)
+	{
+		str[0] = (c >> 12) + 224;
+		str[1] = ((c >> 6) & 63) + 128;
+		str[2] = (c & 63) + 128;
+	}
+	else if (c < 1114112)
+	{
+		str[0] = (c >> 18) + 240;
+		str[1] = ((c >> 12) & 63) + 128;
+		str[2] = ((c >> 6) & 63) + 128;
+		str[3] = (c & 63) + 128;
+	}
+	return (ft_strdup(str));
+}
+
+char	*ft_widestr(wchar_t *src)
+{
+	char *str;
+	char *ante;
+	char *post;
+
+	if (!(str = ft_strnew(0)))
+		return (NULL);
+	while (*src)
+	{
+		ante = str;
+		if (!(post = ft_widechar(*src)))
+			return (NULL);
+		if (!(str = ft_strjoin(ante, post)))
+			return (NULL);
+		src++;
+		ft_strdel(&ante);
+		ft_strdel(&post);
+	}
+	return (str);
+}

+ 42 - 0
libft/ft_utoa.c

@@ -0,0 +1,42 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_utoa.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/02/11 19:54:05 by bchanot           #+#    #+#             */
+/*   Updated: 2016/05/15 21:31:00 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include <stdlib.h>
+
+char	*ft_utoa(long long unsigned int nb)
+{
+	long long unsigned int	x;
+	char					*str;
+	int						cpt;
+
+	x = nb;
+	cpt = 0;
+	while (x > 10)
+	{
+		x /= 10;
+		cpt++;
+	}
+	str = (char *)malloc(sizeof(char *) * cpt + 1);
+	if (str)
+	{
+		str[cpt + 1] = '\0';
+		while (cpt >= 0)
+		{
+			x = nb % 10;
+			str[cpt] = 48 + x;
+			nb /= 10;
+			cpt--;
+		}
+	}
+	return (str);
+}

Some files were not shown because too many files changed in this diff