Преглед изворни кода

added ft_ssl_md5 42 project - 2019

bchanot пре 5 месеци
родитељ
комит
d5157460cc
100 измењених фајлова са 4454 додато и 1 уклоњено
  1. 51 0
      .gitignore
  2. 65 0
      Makefile
  3. 9 1
      README.md
  4. 1 0
      auteur
  5. 336 0
      ft_ssl_md5.en.pdf
  6. 59 0
      includes/ft_ssl.h
  7. 35 0
      includes/sl_md5.h
  8. 54 0
      includes/sl_sha2.h
  9. 55 0
      includes/sl_sha3_5.h
  10. 153 0
      libs/libft/Makefile
  11. 43 0
      libs/libft/includes/ft_defs.h
  12. 116 0
      libs/libft/includes/libft.h
  13. 96 0
      libs/libft/includes/libftprintf.h
  14. 37 0
      libs/libft/srcs/ft_atoi.c
  15. 20 0
      libs/libft/srcs/ft_bzero.c
  16. 27 0
      libs/libft/srcs/ft_charjoin.c
  17. 29 0
      libs/libft/srcs/ft_cptchar.c
  18. 40 0
      libs/libft/srcs/ft_cptchar_glued.c
  19. 25 0
      libs/libft/srcs/ft_cptcmp.c
  20. 42 0
      libs/libft/srcs/ft_dup_first_word.c
  21. 21 0
      libs/libft/srcs/ft_exit.c
  22. 40 0
      libs/libft/srcs/ft_get_file_content.c
  23. 23 0
      libs/libft/srcs/ft_getchar.c
  24. 27 0
      libs/libft/srcs/ft_getenv.c
  25. 21 0
      libs/libft/srcs/ft_isalnum.c
  26. 20 0
      libs/libft/srcs/ft_isalpha.c
  27. 20 0
      libs/libft/srcs/ft_isascii.c
  28. 20 0
      libs/libft/srcs/ft_isdigit.c
  29. 20 0
      libs/libft/srcs/ft_islower.c
  30. 28 0
      libs/libft/srcs/ft_isnum.c
  31. 20 0
      libs/libft/srcs/ft_isprint.c
  32. 20 0
      libs/libft/srcs/ft_isupper.c
  33. 72 0
      libs/libft/srcs/ft_itoa_base.c
  34. 63 0
      libs/libft/srcs/ft_itoa_base_depth.c
  35. 24 0
      libs/libft/srcs/ft_memalloc.c
  36. 31 0
      libs/libft/srcs/ft_memccpy.c
  37. 33 0
      libs/libft/srcs/ft_memchr.c
  38. 33 0
      libs/libft/srcs/ft_memcmp.c
  39. 34 0
      libs/libft/srcs/ft_memcpy.c
  40. 21 0
      libs/libft/srcs/ft_memdel.c
  41. 28 0
      libs/libft/srcs/ft_memdel2.c
  42. 27 0
      libs/libft/srcs/ft_memset.c
  43. 30 0
      libs/libft/srcs/ft_nb_word.c
  44. 43 0
      libs/libft/srcs/ft_nbrlen.c
  45. 26 0
      libs/libft/srcs/ft_pow.c
  46. 56 0
      libs/libft/srcs/ft_print_memory.c
  47. 99 0
      libs/libft/srcs/ft_printf.c
  48. 66 0
      libs/libft/srcs/ft_printf/pf_b.c
  49. 32 0
      libs/libft/srcs/ft_printf/pf_c.c
  50. 60 0
      libs/libft/srcs/ft_printf/pf_c_up.c
  51. 72 0
      libs/libft/srcs/ft_printf/pf_d_up.c
  52. 97 0
      libs/libft/srcs/ft_printf/pf_di.c
  53. 49 0
      libs/libft/srcs/ft_printf/pf_len.c
  54. 142 0
      libs/libft/srcs/ft_printf/pf_more_inf.c
  55. 63 0
      libs/libft/srcs/ft_printf/pf_o.c
  56. 48 0
      libs/libft/srcs/ft_printf/pf_o_up.c
  57. 97 0
      libs/libft/srcs/ft_printf/pf_p.c
  58. 29 0
      libs/libft/srcs/ft_printf/pf_percent.c
  59. 67 0
      libs/libft/srcs/ft_printf/pf_putnbr.c
  60. 65 0
      libs/libft/srcs/ft_printf/pf_putnbrlong.c
  61. 48 0
      libs/libft/srcs/ft_printf/pf_putstr.c
  62. 50 0
      libs/libft/srcs/ft_printf/pf_s.c
  63. 40 0
      libs/libft/srcs/ft_printf/pf_s_up.c
  64. 95 0
      libs/libft/srcs/ft_printf/pf_take_inf.c
  65. 52 0
      libs/libft/srcs/ft_printf/pf_u.c
  66. 46 0
      libs/libft/srcs/ft_printf/pf_u_up.c
  67. 100 0
      libs/libft/srcs/ft_printf/pf_x.c
  68. 97 0
      libs/libft/srcs/ft_printf/pf_x_up.c
  69. 21 0
      libs/libft/srcs/ft_putascii.c
  70. 30 0
      libs/libft/srcs/ft_putchar.c
  71. 26 0
      libs/libft/srcs/ft_putendl.c
  72. 23 0
      libs/libft/srcs/ft_puthex.c
  73. 40 0
      libs/libft/srcs/ft_putnbr.c
  74. 26 0
      libs/libft/srcs/ft_putstr.c
  75. 24 0
      libs/libft/srcs/ft_puttab.c
  76. 25 0
      libs/libft/srcs/ft_sqrt.c
  77. 23 0
      libs/libft/srcs/ft_str_lower.c
  78. 23 0
      libs/libft/srcs/ft_str_upper.c
  79. 20 0
      libs/libft/srcs/ft_strcat.c
  80. 24 0
      libs/libft/srcs/ft_strchr.c
  81. 28 0
      libs/libft/srcs/ft_strcmp.c
  82. 27 0
      libs/libft/srcs/ft_strcmp_end.c
  83. 32 0
      libs/libft/srcs/ft_strcorr.c
  84. 18 0
      libs/libft/srcs/ft_strcpy.c
  85. 25 0
      libs/libft/srcs/ft_strdup.c
  86. 25 0
      libs/libft/srcs/ft_strequ.c
  87. 31 0
      libs/libft/srcs/ft_strichr.c
  88. 36 0
      libs/libft/srcs/ft_strisdigit.c
  89. 27 0
      libs/libft/srcs/ft_strjoin.c
  90. 34 0
      libs/libft/srcs/ft_strlcat.c
  91. 24 0
      libs/libft/srcs/ft_strlen.c
  92. 23 0
      libs/libft/srcs/ft_strmerge.c
  93. 30 0
      libs/libft/srcs/ft_strncat.c
  94. 30 0
      libs/libft/srcs/ft_strncmp.c
  95. 18 0
      libs/libft/srcs/ft_strncpy.c
  96. 23 0
      libs/libft/srcs/ft_strndup.c
  97. 25 0
      libs/libft/srcs/ft_strnequ.c
  98. 23 0
      libs/libft/srcs/ft_strnew.c
  99. 26 0
      libs/libft/srcs/ft_strnjoin.c
  100. 36 0
      libs/libft/srcs/ft_strnstr.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/
+

+ 65 - 0
Makefile

@@ -0,0 +1,65 @@
+#******************************************************************************#
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#*   Updated: 2018/10/26 11:18:16 by bchanot          ###   ########.fr       *#
+#                                                                              #
+#******************************************************************************#
+
+NAME = ft_ssl
+MAKE_LIBS = make --no-print-directory
+SRCS_DIR = srcs/
+OBJS_DIR = .objects/
+LIBS_DIR = libs/
+CC = gcc -Wall -Wextra -Werror -g
+LIB = -L./$(LIBS_DIR)/libft/ -lft
+INC = -I./includes -I./$(LIBS_DIR)/libft/includes
+FILES = main \
+		sl_get_inf \
+		sl_core \
+		sl_hash \
+		sl_md5 \
+		sl_sha2 \
+		sl_sha3_5 \
+		sl_sha_init \
+		sl_sha_registers
+SRCS = $(FILES)
+OBJS = $(addprefix $(OBJS_DIR), $(addsuffix .o, $(SRCS)))
+RED = \033[1;31m
+BLUE = \033[1;34m
+CYAN = \033[0;36m
+GREEN = \033[1;32m
+YELLOW = \033[1;33m
+EOC = \033[0m
+
+all: libs $(NAME)
+
+libs:
+	@$(MAKE_LIBS) -C $(LIBS_DIR)/libft
+
+$(NAME): $(OBJS)
+	@echo -e "$(GREEN)Objects created.$(EOC)"
+	@$(CC) $(OBJS) $(LIB) $(INC) -o $(NAME)
+	@echo -e "$(GREEN)Compilation complete.$(EOC)"
+
+$(OBJS_DIR)%.o: $(SRCS_DIR)%.c
+	@mkdir -p $(dir $@)
+	$(CC) -c $< $(INC) -o $@
+
+clean:
+	@echo -e "$(RED)Deleting objects.$(EOC)"
+	@/bin/rm -rf $(OBJS_DIR)
+	@$(MAKE_LIBS) clean -C $(LIBS_DIR)/libft
+
+fclean: clean
+	@echo -e "$(RED)Deleting binary.$(EOC)"
+	@/bin/rm -rf $(NAME)
+	@$(MAKE_LIBS) fclean -C $(LIBS_DIR)/libft
+
+re: fclean all
+
+.PHONY: all libs clean fclean re

+ 9 - 1
README.md

@@ -1,3 +1,11 @@
 # ft_ssl_md5
+Note : 122 / 100
 
-SSL MD5 project from 42 - 2019
+### Description
+You will recode part of the OpenSSL program, specifically the MD5 Hashing Algorithm.
+
+### Skills
+    - Unix
+    - Security
+    - Algorithms & AI
+    - Rigor 

+ 1 - 0
auteur

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

+ 336 - 0
ft_ssl_md5.en.pdf

@@ -0,0 +1,336 @@
+              ft_ssl [md5] [sha256]
+
+An introduction to cryptographic hashing algorithms
+
+                              Isaac Rhett irhett@student.42.us.org
+                                           42 staff staff@42.fr
+
+Summary: This project is the gateway to the encryption branch. You will recode part of
+      the OpenSSL program, specifically the MD5 and SHA-256 hashing algorithms.
+Contents
+
+I   Foreword                        2
+
+II  Introduction                    3
+
+III Objectives                      4
+
+IV General Instructions             5
+
+V   Mandatory Part                  6
+
+    V.0.1 Mangled Data 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
+
+    V.0.2 Space Human Adventures 256 . . . . . . . . . . . . . . . . . . . . 9
+
+VI Bonus part                       10
+
+VII Turn-in and peer-evaluation     11
+
+                                 1
+Chapter I
+Foreword
+
+              Enjoy these quality mashups by good ol’ Neil. (images are links)
+
+                     Be careful, these songs have extremely dangerous memetic properties.
+                     A paper bag is your only line of defense. It will not help.
+
+              Oh whoops this was supposed to be about Hashing not Mashing.
+               My bad, ’H’ and ’M’ are so close I visually can’t tell them apart.
+              Looks like I really need new glasses, or a good hashing algorithm.
+
+                                    Oh well... what’s done is done.
+
+                     "Hash up" and "Mash up" have a 5 character difference of 1 byte with
+                     only 2 bits changed, but when hashed with md5 their outputs differ by
+                     more than 37%
+
+                                                        2
+Chapter II
+
+Introduction
+
+This is what Wikipedia has to say on the subject of cryptographic hash functions:
+
+    A cryptographic hash function is a special class of hash function that has certain
+propertiesi which make it suitable for use in cryptography. It is a mathematical algorithm
+that maps data of arbitrary size to a bit string of a fixed size. It is designed to also be
+a one-way function, that is, a function which is infeasible to invert. The only way to
+recreate the input data from an ideal cryptographic hash function’s output is to attempt a
+brute-force search of possible inputs to see if they produce a match, or use a rainbow table
+of matched hashes. Bruce Schneier has called one-way hash functions "the workhorses of
+modern cryptography". The input data is often called the message, and the output (the
+hash value or hash) is often called the message digest or simply the digest.
+
+    The ideal cryptographic hash function has five main properties:
+    • it is deterministic, so the same message always results in the same hash
+    • it is quick to compute the hash value for any given message
+    • it is infeasible to generate a message from its digest except by trying all possible
+
+       messages
+    • a small change to a message should change the hash value so extensively that the
+
+       new hash value appears uncorrelated with the old hash value
+    • it is infeasible to find two different messages with the same hash value
+    Cryptographic hash functions have many information-security applications, notably in
+digital signatures, message authentication codes (MACs), and other forms of authen-
+tication. They can also be used as ordinary hash functions, to index data in hash tables,
+for fingerprinting, to detect duplicate data or uniquely identify files, and as checksums
+to detect accidental data corruption. Indeed, in information-security contexts, crypto-
+graphic hash values are sometimes called (digital) fingerprints, checksums, or just hash
+values, even though all these terms stand for more general functions with rather different
+properties and purposes.
+
+                                                        3
+Chapter III
+
+Objectives
+
+This is the first ft_ssl project on the path of Encryption and Security. You will
+recode some security technologies you may have already been using, from scratch.
+
+    You will want to plan out the structure of your executable before you begin, because
+you will build directly onto it in later security projects. It is of vital importance that
+your functions are modular, your code is easy to re-use and adding onto the executable
+doesn’t require rewriting the program.
+
+                     Re-read that last sentence again. I’m serious, do it.
+
+    This project will focus specifically on cryptographic hashing algorithms to solidify your
+understanding of bitwise operations, integer overflow, and one-way functions. A subplot
+to this project is to emphasize writing clean code that can be efficiently extended.
+
+                     If you have ever downloaded a file of significance from the internet
+                     (an operating system installation image, for example), you have
+                     probably noticed a section with either SHA-1 or MD5 followed by
+                     gibberish. If you were smart, you have looked up what the string
+                     meant and verified your download with the given algorithm to verify
+                     the hash. If you haven’t, I advise you do some research to learn
+                     more about digital fingerprinting so you can better protect yourself
+                     from malicious downloads.
+
+                                                        4
+Chapter IV
+
+General Instructions
+
+    • This project will only be corrected by other human beings. You are therefore free
+       to organize and name your files as you wish, although you need to respect some
+       requirements below.
+
+    • The executable file must be named ft_ssl.
+    • You must submit a Makefile. The Makefile must contain the usual rules and compile
+
+       the project as necessary.
+    • Your project must be written in accordance with the Norm.
+    • You have to handle errors carefully. In no way can your program quit unexpectedly
+
+       (Segfault, bus error, double free, etc). If you are unsure, handle the errors like
+       OpenSSL.
+    • You’ll have to submit an author file at the root of your repository. You know the
+       drill.
+    • You are allowed the following functions:
+
+          ◦ open
+          ◦ close
+          ◦ read
+          ◦ write
+          ◦ malloc
+          ◦ free
+    • You are allowed to use other functions as long as their use is justified. (Although
+       they should not be necessary, if you find you need strerror or exit, that is okay,
+       though printf because you are lazy is not)
+    • You can ask your questions in the slack channel #ft_ssl
+
+                                                        5
+Chapter V
+
+Mandatory Part
+
+OpenSSL is a cryptographic toolkit library written C that is used to secure communi-
+cations over computer networks. It implements the Secure Sockets Layer (SSL) and
+Transport Layer Security (TLS) network protocols to protect against eavesdropping
+and verify identities during network communication.
+
+    You must create a program named ft_ssl that will recreate part of the OpenSSL
+functionality. Take care to do it well; the other projects in this series will build directly
+onto this program.
+
+    For this project, you will implement the md5 and sha256 hashing functions.
+
+   > ./ft_ssl
+ usage: ft_ssl command [command opts] [command args]
+
+   >
+   > ./ft_ssl foobar
+ ft_ssl: Error: foobar is an invalid command.
+ Standard commands:
+ Message Digest commands:
+ md5
+ sha256
+ Cipher commands:
+
+                     You will add Standard and Cipher commands later.
+                     You will need to be able to input and output on STDIN/STDOUT and also
+                     files as necessary for the commands, but not for the ft_ssl itself.
+
+                     man openssl
+
+                   "Use a dispatcher buu-rp function pointers, Morty"
+                                       -actual Rick Sanchez quote
+
+                                                        6
+ft_ssl [md5] [sha256]  An introduction to cryptographic hashing algorithms
+
+V.0.1 Mangled Data 5
+
+MD5 is a cryptographic hash function. It is short for "Message Digest 5". It has found to
+contain several vulnerabilities, but can still be safely used as a checksum to verify data
+integrity against unintentional corruption.
+
+    You must create the md5 command for your ft_ssl program. You must include the
+following flags:
+
+    • -p, echo STDIN to STDOUT and append the checksum to STDOUT
+    • -q, quiet mode
+    • -r, reverse the format of the output.
+    • -s, print the sum of the given string
+
+Emulate the behavior of the md5 executable (since it is more versatile than OpenSSL).
+If flags are not provided, be prepared to read/write from/to the console.
+
+Example usage is on the next page.
+
+man md5
+
+                       7
+ft_ssl [md5] [sha256]  An introduction to cryptographic hashing algorithms
+
+ > echo "pickle rick" | openssl md5
+c5e433c1dbd7ba01e3763a9483e74b04
+
+ >
+ > echo "pickle rick" | md5
+c5e433c1dbd7ba01e3763a9483e74b04
+ >
+ > echo "pickle rick" | ./ft_ssl md5
+c5e433c1dbd7ba01e3763a9483e74b04
+ >
+ > echo "Do not pity the dead, Harry." | ./ft_ssl md5 -p
+Do not pity the dead, Harry.
+2d95365bc44bf0a298e09a3ab7b34d2f
+ >
+ > echo "Pity the living." | ./ft_ssl md5 -q -r
+e20c3b973f63482a778f3fd1869b7f25
+ >
+ > echo "And above all," > file
+ > ./ft_ssl md5 file
+MD5 (file) = 53d53ea94217b259c11a5a2d104ec58a
+ > ./ft_ssl md5 -r file
+53d53ea94217b259c11a5a2d104ec58a file
+ >
+ > ./ft_ssl md5 -s "pity those that aren t following baerista on spotify."
+MD5 ("pity those that aren t following baerista on spotify.") = a3c990a1964705d9bf0e602f44572f5f
+ >
+ > echo "be sure to handle edge cases carefully" | ./ft_ssl md5 -p file
+be sure to handle edge cases carefully
+3553dc7dc5963b583c056d1b9fa3349c
+MD5 (file) = 53d53ea94217b259c11a5a2d104ec58a
+ >
+ > echo "some of this will not make sense at first" | ./ft_ssl md5 file
+MD5 (file) = 53d53ea94217b259c11a5a2d104ec58a
+ >
+ > echo "but eventually you will understand" | ./ft_ssl md5 -p -r file
+but eventually you will understand
+dcdd84e0f635694d2a943fa8d3905281
+53d53ea94217b259c11a5a2d104ec58a file
+ >
+ > echo "GL HF let s go" | ./ft_ssl md5 -p -s "foo" file
+GL HF let s go
+d1e3cc342b6da09480b27ec57ff243e2
+MD5 ("foo") = acbd18db4cc2f85cedef654fccc4a4d8
+MD5 (file) = 53d53ea94217b259c11a5a2d104ec58a
+ >
+ > echo "one more thing" | ./ft_ssl md5 -r -p -s "foo" file -s "bar"
+one more thing
+a0bd1876c6f011dd50fae52827f445f5
+acbd18db4cc2f85cedef654fccc4a4d8 "foo"
+53d53ea94217b259c11a5a2d104ec58a file
+ft_ssl: md5: -s: No such file or directory
+ft_ssl: md5: bar: No such file or directory
+ >
+ > echo "just to be extra clear" | ./ft_ssl md5 -r -q -p -s "foo" file
+just to be extra clear
+3ba35f1ea0d170cb3b9a752e3360286c
+acbd18db4cc2f85cedef654fccc4a4d8
+53d53ea94217b259c11a5a2d104ec58a
+
+The error message syntax does not have to match perfectly so long as
+the error message itself is sensible. Use your brain!
+
+                       8
+ft_ssl [md5] [sha256]  An introduction to cryptographic hashing algorithms
+
+V.0.2 Space Human Adventures 256
+
+SHA-256 is one of the functions in the SHA (Secure Hash Algorithms) family. The SHA
+algorithms were designed by the NSA. SHA-512 is currently used in part of the process
+to authenticate Debian software packages.
+
+    You must create the sha256 command for your ft_ssl program. You must include
+the following flags:
+
+    • -p, echo STDIN to STDOUT and append the checksum to STDOUT
+
+    • -q, quiet mode
+
+    • -r, reverse the format of the output.
+
+    • -s, print the sum of the given string
+
+The behavior should be exactly the same as the command above, with the only difference
+being the hash algorithm in question.
+
+   > echo "https://www.youtube.com/watch?v=w-5yAtMtrSM" > big_smoke_order_remix
+   > ./ft_ssl sha256 -q big_smoke_order_remix
+ a8dc621c3dcf18a8a2eddae1845e8e5f6498970a867056ac5f7121ac3d66cfd9
+   >
+   > openssl sha -sha256 big_smoke_order_remix
+ SHA256 (big_smoke_order_remix) = a8dc621c3dcf18a8a2eddae1845e8e5f6498970a867056ac5f7121ac3d66cfd9
+   >
+   > ./ft_ssl sha256 -s "wubba lubba dub dub"
+ SHA256 ("wubba lubba dub dub") = 23a0944d11b5a54f1970492b5265c732044ae824b7d5656acb193e7f0e51e5fa
+
+man sha256 will not work on the macs.
+
+You can use shasum for testing.
+Google will have the BSD man pages for sha256.
+
+                       9
+Chapter VI
+Bonus part
+
+There are several bonuses that can be earned for this project.
+An easy one is to parse commands from STDIN the same way that OpenSSL does.
+You could also include additional hashing algorithms in your ft_ssl executable. The
+bonus algorithms are expected to have the same flag functionality as above.
+
+                     SHA-512 is a good option; Whirlpool is a better one.
+
+                     A hash function that is weaker than MD5 will not grant a bonus.
+
+    As you should expect by now, the bonus will not be considered unless the mandatory
+part is complete and perfect.
+
+                                                       10
+Chapter VII
+Turn-in and peer-evaluation
+
+Submit your code to your Git repository as usual. Only the work in the repository will be
+considered for the evaluation. Any extraneous files will count against you unless justified.
+
+     I almost got arrested at the doctors when I ran a checksum on my prescription,
+                 but I was let off because the hash was for medicinal purposes.
+                                                       11
+

+ 59 - 0
includes/ft_ssl.h

@@ -0,0 +1,59 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_ssl.h                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/09/20 23:18:13 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/14 04:07:26 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef FT_SSL_H
+# define FT_SSL_H
+
+# define ROL64(a, b) (((a) << (b)) | ((a) >> (64 - (b))))
+# define ROR64(a, b) (((a) >> (b)) | ((a) << (64 - (b))))
+# define ROL32(a, b) (((a) << (b)) | ((a) >> (32 - (b))))
+# define ROR32(a, b) (((a) >> (b)) | ((a) << (32 - (b))))
+
+# define CH(x, y, z) (((x) & (y)) ^ (~(x) & (z)))
+# define MAJ(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+
+# define HASH_FUNCTIONS sl_md5, sl_sha224, sl_sha256, sl_sha384, sl_sha512
+# define HASH_TAB "md5", "sha224", "sha256", "sha384", "sha512"
+# define NB_HASH 5
+
+# include "libft.h"
+
+typedef struct		s_files
+{
+	char			*name;
+	char			*string;
+	t_bool			s_opt;
+	struct s_files	*next;
+}					t_files;
+
+typedef struct		s_inf
+{
+	char			**opts;
+	char			*hash_tag;
+	void			(*func)(const char *str);
+	t_files			*files;
+}					t_inf;
+
+int					sl_get_inf(t_inf *inf, int ac, char **av);
+
+void				sl_choose_hash(t_inf *inf);
+void				sl_prepare_launch(t_inf *inf);
+
+void				sl_md5(const char *str);
+
+void				sl_sha224(const char *str);
+void				sl_sha256(const char *str);
+
+void				sl_sha384(const char *str);
+void				sl_sha512(const char *str);
+
+#endif

+ 35 - 0
includes/sl_md5.h

@@ -0,0 +1,35 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   sl_md5.h                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/09/25 19:20:50 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/10 12:56:50 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef SL_MD5_H
+# define SL_MD5_H
+
+typedef struct	s_md5
+{
+	t_uint32	buff[16];
+	t_uint32	state[4];
+	t_uint64	count;
+}				t_md5;
+
+typedef struct	s_process_md5
+{
+	t_uint32	a;
+	t_uint32	b;
+	t_uint32	c;
+	t_uint32	d;
+}				t_process_md5;
+
+void			sl_md5_final(t_md5 *ctx, t_uint8 *hash);
+void			sl_md5_update(t_md5 *ctx, const t_uint8 *data, size_t len);
+void			sl_md5_init(t_md5 *ctx);
+
+#endif

+ 54 - 0
includes/sl_sha2.h

@@ -0,0 +1,54 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   sl_sha2.h                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/09/26 20:13:19 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/10 12:55:47 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef SL_SHA2_H
+# define SL_SHA2_H
+
+# define EP0_SHA2(x) (ROR32(x, 2) ^ ROR32(x, 13) ^ ROR32(x, 22))
+# define EP1_SHA2(x) (ROR32(x, 6) ^ ROR32(x, 11) ^ ROR32(x, 25))
+# define SIG0_SHA2(x) (ROR32(x, 7) ^ ROR32(x, 18) ^ ((x) >> 3))
+# define SIG1_SHA2(x) (ROR32(x, 17) ^ ROR32(x, 19) ^ ((x) >> 10))
+
+# define SHA224 0
+# define SHA256 1
+
+typedef struct	s_sha2
+{
+	t_uint8		buff[64];
+	t_uint32	state[8];
+	t_uint32	count[2];
+}				t_sha2;
+
+typedef struct	s_process_sha2
+{
+	t_uint32	a;
+	t_uint32	b;
+	t_uint32	c;
+	t_uint32	d;
+	t_uint32	e;
+	t_uint32	f;
+	t_uint32	g;
+	t_uint32	h;
+}				t_process_sha2;
+
+void			sl_sha2_get_registers(t_uint32 *m, t_process_sha2 *t, \
+					size_t i);
+void			sl_sha2_process_init_add(t_sha2 *ctx, t_process_sha2 *t, \
+					t_bool init);
+
+void			sl_sha2_init(t_sha2 *ctx, t_uint8 sha);
+void			sl_sha2_update(t_sha2 *ctx, const t_uint8 *data, size_t len);
+void			sl_sha2_final(t_sha2 *ctx);
+
+void			sl_sha2_get_hash(t_sha2 *ctx, t_uint8 *hash);
+
+#endif

+ 55 - 0
includes/sl_sha3_5.h

@@ -0,0 +1,55 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   sl_sha3_5.h                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2018/09/26 20:13:19 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/10 12:57:18 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef SL_SHA3_5_H
+# define SL_SHA3_5_H
+
+# define EP0_SHA3_5(x) (ROR64(x, 28) ^ ROR64(x, 34) ^ ROR64(x, 39))
+# define EP1_SHA3_5(x) (ROR64(x, 14) ^ ROR64(x, 18) ^ ROR64(x, 41))
+# define SIG0_SHA3_5(x) (ROR64(x, 1) ^ ROR64(x, 8) ^ ((x) >> 7))
+# define SIG1_SHA3_5(x) (ROR64(x, 19) ^ ROR64(x, 61) ^ ((x) >> 6))
+
+# define SHA384 0
+# define SHA512 1
+
+typedef struct	s_sha3_5
+{
+	t_uint8		buff[128];
+	t_uint64	state[8];
+	t_uint64	count[4];
+}				t_sha3_5;
+
+typedef struct	s_process_sha3_5
+{
+	t_uint64	a;
+	t_uint64	b;
+	t_uint64	c;
+	t_uint64	d;
+	t_uint64	e;
+	t_uint64	f;
+	t_uint64	g;
+	t_uint64	h;
+}				t_process_sha3_5;
+
+void			sl_sha3_5_get_registers(t_uint64 *m, t_process_sha3_5 *t, \
+					size_t i);
+void			sl_sha3_5_process_init_add(t_sha3_5 *ctx, t_process_sha3_5 *t, \
+					t_bool init);
+
+void			sl_sha3_5_init(t_sha3_5 *ctx, t_uint8 sha);
+void			sl_sha3_5_update(t_sha3_5 *ctx, const t_uint8 *data, \
+					size_t len);
+void			sl_sha3_5_final(t_sha3_5 *ctx);
+
+void			sl_sha3_5_get_hash(t_sha3_5 *ctx, t_uint8 *hash);
+
+#endif

+ 153 - 0
libs/libft/Makefile

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

+ 43 - 0
libs/libft/includes/ft_defs.h

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

+ 116 - 0
libs/libft/includes/libft.h

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

+ 96 - 0
libs/libft/includes/libftprintf.h

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

+ 37 - 0
libs/libft/srcs/ft_atoi.c

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

+ 20 - 0
libs/libft/srcs/ft_bzero.c

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

+ 27 - 0
libs/libft/srcs/ft_charjoin.c

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

+ 29 - 0
libs/libft/srcs/ft_cptchar.c

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

+ 40 - 0
libs/libft/srcs/ft_cptchar_glued.c

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

+ 25 - 0
libs/libft/srcs/ft_cptcmp.c

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

+ 42 - 0
libs/libft/srcs/ft_dup_first_word.c

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

+ 21 - 0
libs/libft/srcs/ft_exit.c

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

+ 40 - 0
libs/libft/srcs/ft_get_file_content.c

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

+ 23 - 0
libs/libft/srcs/ft_getchar.c

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

+ 27 - 0
libs/libft/srcs/ft_getenv.c

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

+ 21 - 0
libs/libft/srcs/ft_isalnum.c

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

+ 20 - 0
libs/libft/srcs/ft_isalpha.c

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

+ 20 - 0
libs/libft/srcs/ft_isascii.c

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

+ 20 - 0
libs/libft/srcs/ft_isdigit.c

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

+ 20 - 0
libs/libft/srcs/ft_islower.c

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

+ 28 - 0
libs/libft/srcs/ft_isnum.c

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

+ 20 - 0
libs/libft/srcs/ft_isprint.c

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

+ 20 - 0
libs/libft/srcs/ft_isupper.c

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

+ 72 - 0
libs/libft/srcs/ft_itoa_base.c

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

+ 63 - 0
libs/libft/srcs/ft_itoa_base_depth.c

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

+ 24 - 0
libs/libft/srcs/ft_memalloc.c

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

+ 31 - 0
libs/libft/srcs/ft_memccpy.c

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

+ 33 - 0
libs/libft/srcs/ft_memchr.c

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

+ 33 - 0
libs/libft/srcs/ft_memcmp.c

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

+ 34 - 0
libs/libft/srcs/ft_memcpy.c

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

+ 21 - 0
libs/libft/srcs/ft_memdel.c

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

+ 28 - 0
libs/libft/srcs/ft_memdel2.c

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

+ 27 - 0
libs/libft/srcs/ft_memset.c

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

+ 30 - 0
libs/libft/srcs/ft_nb_word.c

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

+ 43 - 0
libs/libft/srcs/ft_nbrlen.c

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

+ 26 - 0
libs/libft/srcs/ft_pow.c

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

+ 56 - 0
libs/libft/srcs/ft_print_memory.c

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

+ 99 - 0
libs/libft/srcs/ft_printf.c

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

+ 66 - 0
libs/libft/srcs/ft_printf/pf_b.c

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

+ 32 - 0
libs/libft/srcs/ft_printf/pf_c.c

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

+ 60 - 0
libs/libft/srcs/ft_printf/pf_c_up.c

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

+ 72 - 0
libs/libft/srcs/ft_printf/pf_d_up.c

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

+ 97 - 0
libs/libft/srcs/ft_printf/pf_di.c

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

+ 49 - 0
libs/libft/srcs/ft_printf/pf_len.c

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

+ 142 - 0
libs/libft/srcs/ft_printf/pf_more_inf.c

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

+ 63 - 0
libs/libft/srcs/ft_printf/pf_o.c

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

+ 48 - 0
libs/libft/srcs/ft_printf/pf_o_up.c

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

+ 97 - 0
libs/libft/srcs/ft_printf/pf_p.c

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

+ 29 - 0
libs/libft/srcs/ft_printf/pf_percent.c

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

+ 67 - 0
libs/libft/srcs/ft_printf/pf_putnbr.c

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

+ 65 - 0
libs/libft/srcs/ft_printf/pf_putnbrlong.c

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

+ 48 - 0
libs/libft/srcs/ft_printf/pf_putstr.c

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

+ 50 - 0
libs/libft/srcs/ft_printf/pf_s.c

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

+ 40 - 0
libs/libft/srcs/ft_printf/pf_s_up.c

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

+ 95 - 0
libs/libft/srcs/ft_printf/pf_take_inf.c

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

+ 52 - 0
libs/libft/srcs/ft_printf/pf_u.c

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

+ 46 - 0
libs/libft/srcs/ft_printf/pf_u_up.c

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

+ 100 - 0
libs/libft/srcs/ft_printf/pf_x.c

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

+ 97 - 0
libs/libft/srcs/ft_printf/pf_x_up.c

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

+ 21 - 0
libs/libft/srcs/ft_putascii.c

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

+ 30 - 0
libs/libft/srcs/ft_putchar.c

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

+ 26 - 0
libs/libft/srcs/ft_putendl.c

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

+ 23 - 0
libs/libft/srcs/ft_puthex.c

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

+ 40 - 0
libs/libft/srcs/ft_putnbr.c

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

+ 26 - 0
libs/libft/srcs/ft_putstr.c

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

+ 24 - 0
libs/libft/srcs/ft_puttab.c

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

+ 25 - 0
libs/libft/srcs/ft_sqrt.c

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

+ 23 - 0
libs/libft/srcs/ft_str_lower.c

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

+ 23 - 0
libs/libft/srcs/ft_str_upper.c

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

+ 20 - 0
libs/libft/srcs/ft_strcat.c

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

+ 24 - 0
libs/libft/srcs/ft_strchr.c

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

+ 28 - 0
libs/libft/srcs/ft_strcmp.c

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

+ 27 - 0
libs/libft/srcs/ft_strcmp_end.c

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

+ 32 - 0
libs/libft/srcs/ft_strcorr.c

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

+ 18 - 0
libs/libft/srcs/ft_strcpy.c

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

+ 25 - 0
libs/libft/srcs/ft_strdup.c

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

+ 25 - 0
libs/libft/srcs/ft_strequ.c

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

+ 31 - 0
libs/libft/srcs/ft_strichr.c

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

+ 36 - 0
libs/libft/srcs/ft_strisdigit.c

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

+ 27 - 0
libs/libft/srcs/ft_strjoin.c

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

+ 34 - 0
libs/libft/srcs/ft_strlcat.c

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

+ 24 - 0
libs/libft/srcs/ft_strlen.c

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

+ 23 - 0
libs/libft/srcs/ft_strmerge.c

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

+ 30 - 0
libs/libft/srcs/ft_strncat.c

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

+ 30 - 0
libs/libft/srcs/ft_strncmp.c

@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strncmp.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 17:03:07 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/29 11:56:43 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int	ft_strncmp(const char *const s1, const char *const s2, size_t n)
+{
+	size_t	i;
+
+	i = 0;
+	if ((!s1 && !s2) || (!ft_strlen(s1) && !ft_strlen(s2)))
+		return (false);
+	if ((!s1 && s2) || (s1 && !s2) || (!ft_strlen(s1) && ft_strlen(s2)) ||
+		(ft_strlen(s1) && !ft_strlen(s2)))
+		return (true);
+	while (s1[i] == s2[i] && s1[i] && s2[i] && i < n)
+		i++;
+	if (i == n)
+		return (false);
+	return ((unsigned char)s1[i] - (unsigned char)s2[i]);
+}

+ 18 - 0
libs/libft/srcs/ft_strncpy.c

@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strncpy.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/23 15:38:25 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/12 23:16:17 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strncpy(char *dst, const char *src, size_t n)
+{
+	return ((char *)ft_memcpy(dst, src, n));
+}

+ 23 - 0
libs/libft/srcs/ft_strndup.c

@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strndup.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@student.42.fr>            +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/12/19 19:32:15 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/13 22:48:31 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strndup(const char *src, int n)
+{
+	char	*new;
+
+	if (!(new = ft_strnew(n)))
+		return (NULL);
+	ft_memcpy(new, src, n);
+	return (new);
+}

+ 25 - 0
libs/libft/srcs/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: 2018/10/29 11:57:01 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int		ft_strnequ(const char *const s1, const char *const s2, size_t n)
+{
+	if (s1 && s2)
+	{
+		if (ft_strncmp(s1, s2, n) == 0)
+			return (true);
+	}
+	else if (s1 == s2)
+		return (true);
+	return (false);
+}

+ 23 - 0
libs/libft/srcs/ft_strnew.c

@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strnew.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2015/11/25 17:38:59 by bchanot           #+#    #+#             */
+/*   Updated: 2018/10/13 22:49:16 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strnew(size_t size)
+{
+	char	*s;
+
+	if (!(s = (char *)ft_memalloc(sizeof(char) * (size + 1))))
+		return (NULL);
+	ft_bzero(s, size + 1);
+	return (s);
+}

+ 26 - 0
libs/libft/srcs/ft_strnjoin.c

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

+ 36 - 0
libs/libft/srcs/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: 2018/10/29 11:56:09 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+char	*ft_strnstr(const char *const s1, const char *const s2, size_t n)
+{
+	size_t	i;
+	size_t	j;
+
+	i = 0;
+	j = 0;
+	if (!s2 || !ft_strlen(s2))
+		return ((char *)s1);
+	while (s1[i])
+	{
+		while (s2[j] == s1[i + j] && i + j < n)
+		{
+			if (j == ft_strlen(s2) - 1)
+				return ((char *)&s1[i]);
+			j++;
+		}
+		j = 0;
+		i++;
+	}
+	return (NULL);
+}

Неке датотеке нису приказане због велике количине промена