init avec fichiers ancienne libft
This commit is contained in:
223
OLDMakefile
Normal file
223
OLDMakefile
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
##
|
||||||
|
# # ------------------------------------------------------
|
||||||
|
# # utiliser le makefile pour creer une librairie statique
|
||||||
|
# # ------------------------------------------------------
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## - - - - - - - -
|
||||||
|
## compiler des .o
|
||||||
|
## - - - - - - - -
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## quand on ecrit un programme il contient un main et les
|
||||||
|
## fonctions dont le main a besoin (ex ft_putchar) :
|
||||||
|
##
|
||||||
|
### #include <unistd.h>
|
||||||
|
###
|
||||||
|
### void ft_putchar(char c)
|
||||||
|
### {
|
||||||
|
### write(1, &c, 1);
|
||||||
|
### }
|
||||||
|
###
|
||||||
|
### int main()
|
||||||
|
### {
|
||||||
|
### ft_putchar('0');
|
||||||
|
### return (0);
|
||||||
|
### }
|
||||||
|
##
|
||||||
|
## on peut compiler ce fichier avec gcc en faisant :
|
||||||
|
## gcc file.c
|
||||||
|
## et ca sort un executable a.out
|
||||||
|
## si on l'execute "./a.out" ca ecrit 0 dans la console
|
||||||
|
##
|
||||||
|
## mais pour ne pas reecrire a chaque fois ft_putchar
|
||||||
|
## on peut la mettre dans une librairie qu'on inclue dans
|
||||||
|
## le fichier qui l'utilise...
|
||||||
|
## si on sort ft_putchar du fichier :
|
||||||
|
##
|
||||||
|
### int main()
|
||||||
|
### {
|
||||||
|
### ft_putchar('0');
|
||||||
|
### return (0);
|
||||||
|
### }
|
||||||
|
##
|
||||||
|
## et qu'on l'execute "gcc file.c" on va avoir une erreur
|
||||||
|
## car file.c utilise ft_putchar mais gcc ne sait pas ce
|
||||||
|
## que c'est, donc il faut qu'on le rajoute a la compilation
|
||||||
|
## on peut par exemple l'ecrire dans un fichier ft_putchar.c
|
||||||
|
##
|
||||||
|
### #include <unistd.h>
|
||||||
|
###
|
||||||
|
### void ft_putchar(char c)
|
||||||
|
### {
|
||||||
|
### write(1, &c, 1);
|
||||||
|
### }
|
||||||
|
##
|
||||||
|
## et compiler les deux :
|
||||||
|
## gcc file.c ft_putchar.c
|
||||||
|
##
|
||||||
|
## ca fonctionne mais gcc doit a chaque fois recompiler
|
||||||
|
## ft_putchar.c alors qu'il n'est pas modifie, donc on peut
|
||||||
|
## le compiler une bonne fois pour toute et le rajouter a la
|
||||||
|
## compilation finale quand on en a besoin sans que l'ordi
|
||||||
|
## ait a tout retraduire dans son langage
|
||||||
|
##
|
||||||
|
## mais si on essaye de compiler ft_putchar seul
|
||||||
|
## gcc ft_putchar.c
|
||||||
|
## ca nous donne une erreur car pour compiler, gcc a besoin
|
||||||
|
## de trouver un main !
|
||||||
|
##
|
||||||
|
## on va donc utiliser l'option -c pour
|
||||||
|
## creer une fichier objet .o qui est deja traduit en langue
|
||||||
|
## d'ordinateur et pret a etre rajoute a la compilation :
|
||||||
|
## gcc -c ft_putchar.c --> donne ft_putchar.o
|
||||||
|
## qu'on peut compiler avec le fichier qui contient le main :
|
||||||
|
##
|
||||||
|
## gcc file.c ft_putchar.o
|
||||||
|
##
|
||||||
|
## on a nos bouts de codes comme ft_putchar.o dans des fichiers
|
||||||
|
## objets prets a etre ajoutes a la compilation du main
|
||||||
|
##
|
||||||
|
## on va maintenant voir comment faire une libraire qui contien
|
||||||
|
## tous nos fichiers objets
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## - - - - - - - -
|
||||||
|
## creer une lib.a
|
||||||
|
## - - - - - - - -
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## pour mettre tous les fichiers .o dans un seul fichier .a
|
||||||
|
## on utilise un programme d'archive ar avec les options rc
|
||||||
|
## r indique d'inserer les .o en remplacant si necessaire
|
||||||
|
## c de creer une nouvelle archive
|
||||||
|
## le nom de l'archive doit commencer par lib et finir en .a :
|
||||||
|
## ar rc nom_de_l'archive fichier_1.o fichier_2.o etc
|
||||||
|
##
|
||||||
|
## ar rc libtest.a ft_putchar.o
|
||||||
|
##
|
||||||
|
## on obtient un fichier libtest.a qui contient les fichiers
|
||||||
|
## objets .o
|
||||||
|
##
|
||||||
|
## on peut l'utiliser a la compilation de cette manniere :
|
||||||
|
##
|
||||||
|
## gcc file.c -L. -ltest
|
||||||
|
##
|
||||||
|
## -L indique ou est la librairie (ici elle est dans le
|
||||||
|
## dossier courant .)
|
||||||
|
## -l indique son nom ("test" car on n'indique pas lib et .a)
|
||||||
|
##
|
||||||
|
##
|
||||||
|
# # -----------------------------------------------
|
||||||
|
# # ecrire un make file pour aider a la compilation
|
||||||
|
# # -----------------------------------------------
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## exemple d'un makefilede basic
|
||||||
|
##
|
||||||
|
### NAME = libtest.h
|
||||||
|
### CC = gcc
|
||||||
|
### CFLAGS = -I. -c
|
||||||
|
### SRCS = example01.c \
|
||||||
|
### example02.c
|
||||||
|
### OBJ = $(SRCS:.c=.o) |ecrit les fichiers .c en .o
|
||||||
|
###
|
||||||
|
### all: $(NAME) |make execute sa premiere regle NAME
|
||||||
|
### $(NAME): $(OBJ) |NAME execute d'abord OBJ
|
||||||
|
### ar -rc $@ $< |
|
||||||
|
##
|
||||||
|
## Make a des built-in pattern rules :
|
||||||
|
## https://www.gnu.org/software/make/manual/html_node/Catalogue-of-Rules.html
|
||||||
|
## par exemple pour construire des .o a partir de .c
|
||||||
|
## qui sont utilisees par défaut si les variables
|
||||||
|
## sont bien nomee (genre CC ou CFLAGS)
|
||||||
|
##
|
||||||
|
## cependant si on veut mettre les fichiers .o dans un
|
||||||
|
## sous-fichier BUILDS il n'y a pas de built-in pattern
|
||||||
|
## il faut donc l'ecrire nous-meme :
|
||||||
|
##
|
||||||
|
### NAME = libtest.h
|
||||||
|
### CC = gcc
|
||||||
|
### CFLAGS = -I.
|
||||||
|
### SRCS = example01.c \
|
||||||
|
### example02.c
|
||||||
|
### ODIR = ./builds
|
||||||
|
### OBJS = $(addprefix $(ODIR)/, $(SRCS:.c=.o))
|
||||||
|
###
|
||||||
|
### all: $(NAME)
|
||||||
|
### $(NAME): $(OBJS)
|
||||||
|
### ar -rc $@ $<
|
||||||
|
###
|
||||||
|
### $(ODIR)/%.o : %.c
|
||||||
|
### $(COMPILE.c) -o $@ $<
|
||||||
|
##
|
||||||
|
## cette regle est appellee par $(OBJS) puisque
|
||||||
|
## cette variable appelle la regle $(ODIR/file.o)
|
||||||
|
##
|
||||||
|
## COMPILE est une built-in variable qui execute
|
||||||
|
## les regles CC et CFLAGS avec l'option -c
|
||||||
|
##
|
||||||
|
## % = "tout"
|
||||||
|
## $@ = "la valeur a gauche de :"
|
||||||
|
## $< = "la premiere valeur a droite de :"
|
||||||
|
## $^ = "toutes les valeurs a droite de :"
|
||||||
|
##
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------- #
|
||||||
|
# #
|
||||||
|
# variables modifiables #
|
||||||
|
# #
|
||||||
|
# ----------------------------------------------------------- #
|
||||||
|
|
||||||
|
NAME = libft.a
|
||||||
|
|
||||||
|
DEPS = libft.h
|
||||||
|
|
||||||
|
SDIR = ./src
|
||||||
|
ODIR = ./build
|
||||||
|
IDIR = ./includes
|
||||||
|
|
||||||
|
CC = gcc
|
||||||
|
CFLAGS = -Wall -Wextra -Werror -I$(IDIR)
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------- #
|
||||||
|
# #
|
||||||
|
# ne pas modifier en dessous #
|
||||||
|
# #
|
||||||
|
# ----------------------------------------------------------- #
|
||||||
|
|
||||||
|
## SUB_SDIR sera utilise pour creer les sous dossiers :
|
||||||
|
## avec mkdir -p ODIR/subdir1 ODIR/subdir2 ODIR/subdir3 etc...
|
||||||
|
## find $(SDIR) cherche recursivement tous le contenu de SDIR
|
||||||
|
## -type d ne trouve que les dossiers, pas les fichiers
|
||||||
|
## -mindepth 1 ne liste pas le dossier SDIR
|
||||||
|
## subst transform arg1 en arg2 dans arg3
|
||||||
|
|
||||||
|
SUB_SDIR = $(shell find $(SDIR) -mindepth 1 -type d)
|
||||||
|
SRC = $(shell find $(SDIR) -type f -not -name '.*' -name '*.c')
|
||||||
|
OBJ = $(subst $(SDIR), $(ODIR), $(SRC:.c=.o))
|
||||||
|
|
||||||
|
all: $(ODIR) $(NAME)
|
||||||
|
|
||||||
|
$(ODIR):
|
||||||
|
mkdir -p $(subst $(SDIR), $(ODIR), $(SUB_SDIR))
|
||||||
|
|
||||||
|
$(ODIR)/%.o: $(SDIR)/%.c
|
||||||
|
$(COMPILE.c) -o $@ $<
|
||||||
|
|
||||||
|
$(NAME): $(OBJ)
|
||||||
|
ar -rc $@ $^
|
||||||
|
@ranlib $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
/bin/rm -rf $(ODIR)
|
||||||
|
|
||||||
|
fclean: clean
|
||||||
|
/bin/rm -f $(NAME)
|
||||||
|
|
||||||
|
re: fclean all
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
BIN
OLDbuild/is/ft_isalnum.o
Normal file
BIN
OLDbuild/is/ft_isalnum.o
Normal file
Binary file not shown.
BIN
OLDbuild/is/ft_isalpha.o
Normal file
BIN
OLDbuild/is/ft_isalpha.o
Normal file
Binary file not shown.
BIN
OLDbuild/is/ft_isascii.o
Normal file
BIN
OLDbuild/is/ft_isascii.o
Normal file
Binary file not shown.
BIN
OLDbuild/is/ft_isdigit.o
Normal file
BIN
OLDbuild/is/ft_isdigit.o
Normal file
Binary file not shown.
BIN
OLDbuild/is/ft_isprint.o
Normal file
BIN
OLDbuild/is/ft_isprint.o
Normal file
Binary file not shown.
BIN
OLDbuild/is/ft_issort.o
Normal file
BIN
OLDbuild/is/ft_issort.o
Normal file
Binary file not shown.
BIN
OLDbuild/lst/ft_lstadd.o
Normal file
BIN
OLDbuild/lst/ft_lstadd.o
Normal file
Binary file not shown.
BIN
OLDbuild/lst/ft_lstdel.o
Normal file
BIN
OLDbuild/lst/ft_lstdel.o
Normal file
Binary file not shown.
BIN
OLDbuild/lst/ft_lstdelone.o
Normal file
BIN
OLDbuild/lst/ft_lstdelone.o
Normal file
Binary file not shown.
BIN
OLDbuild/lst/ft_lstiter.o
Normal file
BIN
OLDbuild/lst/ft_lstiter.o
Normal file
Binary file not shown.
BIN
OLDbuild/lst/ft_lstmap.o
Normal file
BIN
OLDbuild/lst/ft_lstmap.o
Normal file
Binary file not shown.
BIN
OLDbuild/lst/ft_lstnew.o
Normal file
BIN
OLDbuild/lst/ft_lstnew.o
Normal file
Binary file not shown.
BIN
OLDbuild/mem/ft_memalloc.o
Normal file
BIN
OLDbuild/mem/ft_memalloc.o
Normal file
Binary file not shown.
BIN
OLDbuild/mem/ft_memccpy.o
Normal file
BIN
OLDbuild/mem/ft_memccpy.o
Normal file
Binary file not shown.
BIN
OLDbuild/mem/ft_memchr.o
Normal file
BIN
OLDbuild/mem/ft_memchr.o
Normal file
Binary file not shown.
BIN
OLDbuild/mem/ft_memcmp.o
Normal file
BIN
OLDbuild/mem/ft_memcmp.o
Normal file
Binary file not shown.
BIN
OLDbuild/mem/ft_memcpy.o
Normal file
BIN
OLDbuild/mem/ft_memcpy.o
Normal file
Binary file not shown.
BIN
OLDbuild/mem/ft_memdel.o
Normal file
BIN
OLDbuild/mem/ft_memdel.o
Normal file
Binary file not shown.
BIN
OLDbuild/mem/ft_memmove.o
Normal file
BIN
OLDbuild/mem/ft_memmove.o
Normal file
Binary file not shown.
BIN
OLDbuild/mem/ft_memset.o
Normal file
BIN
OLDbuild/mem/ft_memset.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putchar.o
Normal file
BIN
OLDbuild/put/ft_putchar.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putchar_fd.o
Normal file
BIN
OLDbuild/put/ft_putchar_fd.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putendl.o
Normal file
BIN
OLDbuild/put/ft_putendl.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putendl_fd.o
Normal file
BIN
OLDbuild/put/ft_putendl_fd.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putnbr.o
Normal file
BIN
OLDbuild/put/ft_putnbr.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putnbr_fd.o
Normal file
BIN
OLDbuild/put/ft_putnbr_fd.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putnbrbase.o
Normal file
BIN
OLDbuild/put/ft_putnbrbase.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putnbrendl.o
Normal file
BIN
OLDbuild/put/ft_putnbrendl.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putnbrendl_fd.o
Normal file
BIN
OLDbuild/put/ft_putnbrendl_fd.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putstr.o
Normal file
BIN
OLDbuild/put/ft_putstr.o
Normal file
Binary file not shown.
BIN
OLDbuild/put/ft_putstr_fd.o
Normal file
BIN
OLDbuild/put/ft_putstr_fd.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strcat.o
Normal file
BIN
OLDbuild/str/ft_strcat.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strchr.o
Normal file
BIN
OLDbuild/str/ft_strchr.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strclr.o
Normal file
BIN
OLDbuild/str/ft_strclr.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strcmp.o
Normal file
BIN
OLDbuild/str/ft_strcmp.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strcpy.o
Normal file
BIN
OLDbuild/str/ft_strcpy.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strdel.o
Normal file
BIN
OLDbuild/str/ft_strdel.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strdup.o
Normal file
BIN
OLDbuild/str/ft_strdup.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strequ.o
Normal file
BIN
OLDbuild/str/ft_strequ.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_striter.o
Normal file
BIN
OLDbuild/str/ft_striter.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_striteri.o
Normal file
BIN
OLDbuild/str/ft_striteri.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strjoin.o
Normal file
BIN
OLDbuild/str/ft_strjoin.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strjoinfree.o
Normal file
BIN
OLDbuild/str/ft_strjoinfree.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strlcat.o
Normal file
BIN
OLDbuild/str/ft_strlcat.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strlen.o
Normal file
BIN
OLDbuild/str/ft_strlen.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strmap.o
Normal file
BIN
OLDbuild/str/ft_strmap.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strmapi.o
Normal file
BIN
OLDbuild/str/ft_strmapi.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strmultisplit.o
Normal file
BIN
OLDbuild/str/ft_strmultisplit.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strncat.o
Normal file
BIN
OLDbuild/str/ft_strncat.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strncmp.o
Normal file
BIN
OLDbuild/str/ft_strncmp.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strncpy.o
Normal file
BIN
OLDbuild/str/ft_strncpy.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strnequ.o
Normal file
BIN
OLDbuild/str/ft_strnequ.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strnew.o
Normal file
BIN
OLDbuild/str/ft_strnew.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strnstr.o
Normal file
BIN
OLDbuild/str/ft_strnstr.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strrchr.o
Normal file
BIN
OLDbuild/str/ft_strrchr.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strsplit.o
Normal file
BIN
OLDbuild/str/ft_strsplit.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strstr.o
Normal file
BIN
OLDbuild/str/ft_strstr.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strsub.o
Normal file
BIN
OLDbuild/str/ft_strsub.o
Normal file
Binary file not shown.
BIN
OLDbuild/str/ft_strtrim.o
Normal file
BIN
OLDbuild/str/ft_strtrim.o
Normal file
Binary file not shown.
BIN
OLDbuild/tab/ft_any.o
Normal file
BIN
OLDbuild/tab/ft_any.o
Normal file
Binary file not shown.
BIN
OLDbuild/tab/ft_arraymap.o
Normal file
BIN
OLDbuild/tab/ft_arraymap.o
Normal file
Binary file not shown.
BIN
OLDbuild/tab/ft_foreach.o
Normal file
BIN
OLDbuild/tab/ft_foreach.o
Normal file
Binary file not shown.
BIN
OLDbuild/trsf/ft_atoi.o
Normal file
BIN
OLDbuild/trsf/ft_atoi.o
Normal file
Binary file not shown.
BIN
OLDbuild/trsf/ft_atoibase.o
Normal file
BIN
OLDbuild/trsf/ft_atoibase.o
Normal file
Binary file not shown.
BIN
OLDbuild/trsf/ft_bzero.o
Normal file
BIN
OLDbuild/trsf/ft_bzero.o
Normal file
Binary file not shown.
BIN
OLDbuild/trsf/ft_convertbase.o
Normal file
BIN
OLDbuild/trsf/ft_convertbase.o
Normal file
Binary file not shown.
BIN
OLDbuild/trsf/ft_itoa.o
Normal file
BIN
OLDbuild/trsf/ft_itoa.o
Normal file
Binary file not shown.
BIN
OLDbuild/trsf/ft_tolower.o
Normal file
BIN
OLDbuild/trsf/ft_tolower.o
Normal file
Binary file not shown.
BIN
OLDbuild/trsf/ft_toupper.o
Normal file
BIN
OLDbuild/trsf/ft_toupper.o
Normal file
Binary file not shown.
101
OLDincludes/libft.h
Normal file
101
OLDincludes/libft.h
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* libft.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:22:07 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/04/07 14:22:04 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef LIBFT_H
|
||||||
|
# define LIBFT_H
|
||||||
|
# include <string.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
# include <stdlib.h>
|
||||||
|
|
||||||
|
int ft_atoi(const char *str);
|
||||||
|
void ft_bzero(void *s, size_t n);
|
||||||
|
int ft_isalnum(int c);
|
||||||
|
int ft_isalpha(int c);
|
||||||
|
int ft_isascii(int c);
|
||||||
|
int ft_isdigit(int c);
|
||||||
|
int ft_isprint(int c);
|
||||||
|
void *ft_memccpy(void *dst, const void *restrict src,
|
||||||
|
int c, size_t n);
|
||||||
|
void *ft_memchr(const void *s, int c, size_t n);
|
||||||
|
int ft_memcmp(const void *s1, const void *s2, size_t n);
|
||||||
|
void *ft_memcpy(void *dst, const void *src, size_t n);
|
||||||
|
void *ft_memmove(void *dst, const void *src, size_t len);
|
||||||
|
void *ft_memset(void *b, int c, size_t len);
|
||||||
|
char *ft_strcat(char *s1, const char *s2);
|
||||||
|
char *ft_strchr(const char *s, int c);
|
||||||
|
int ft_strcmp(const char *s1, const char *s2);
|
||||||
|
char *ft_strcpy(char *dst, const char *src);
|
||||||
|
char *ft_strdup(const char *s1);
|
||||||
|
size_t ft_strlcat(char *dst, const char *src, size_t size);
|
||||||
|
size_t ft_strlen(const char *str);
|
||||||
|
char *ft_strncat(char *s1, const char *s2, size_t n);
|
||||||
|
int ft_strncmp(const char *s1, const char *s2, size_t n);
|
||||||
|
char *ft_strncpy(char *dst, const char *src, size_t len);
|
||||||
|
char *ft_strnstr(const char *big, const char *little,
|
||||||
|
size_t len);
|
||||||
|
char *ft_strrchr(const char *s, int c);
|
||||||
|
char *ft_strstr(const char *big, const char *little);
|
||||||
|
int ft_tolower(int c);
|
||||||
|
int ft_toupper(int c);
|
||||||
|
|
||||||
|
char *ft_itoa(int n);
|
||||||
|
void *ft_memalloc(size_t size);
|
||||||
|
void ft_memdel(void **ap);
|
||||||
|
void ft_putchar(char c);
|
||||||
|
void ft_putchar_fd(char c, int fd);
|
||||||
|
void ft_putendl(char const *str);
|
||||||
|
void ft_putendl_fd(char const *s, int fd);
|
||||||
|
void ft_putnbr(int nbr);
|
||||||
|
void ft_putnbr_fd(int n, int fd);
|
||||||
|
void ft_putstr(char const *str);
|
||||||
|
void ft_putstr_fd(char const *s, int fd);
|
||||||
|
void ft_strclr(char *s);
|
||||||
|
void ft_strdel(char **as);
|
||||||
|
int ft_strequ(char const *s1, char const *s2);
|
||||||
|
void ft_striter(char *s, void (*f)(char *));
|
||||||
|
void ft_striteri(char *s, void (*f)(unsigned int, char *));
|
||||||
|
char *ft_strjoin(char const *s1, char const *s2);
|
||||||
|
char *ft_strjoinfree(char *s1, char *s2);
|
||||||
|
char *ft_strmap(char const *s, char (*f)(char));
|
||||||
|
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
|
||||||
|
int ft_strnequ(char const *s1, char const *s2, size_t n);
|
||||||
|
char *ft_strnew(size_t size);
|
||||||
|
char **ft_strsplit(char const *s, char c);
|
||||||
|
char *ft_strsub(char const *s, unsigned int start, size_t len);
|
||||||
|
char *ft_strtrim(char const *s);
|
||||||
|
|
||||||
|
typedef struct s_list
|
||||||
|
{
|
||||||
|
void *content;
|
||||||
|
size_t content_size;
|
||||||
|
struct s_list *next;
|
||||||
|
} t_list;
|
||||||
|
|
||||||
|
t_list *ft_lstnew(const void *content, size_t content_size);
|
||||||
|
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t));
|
||||||
|
void ft_lstdel(t_list **alst, void (*del)(void *, size_t));
|
||||||
|
void ft_lstadd(t_list **alst, t_list *n);
|
||||||
|
void ft_lstiter(t_list *lst, void (*f)(t_list *elem));
|
||||||
|
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem));
|
||||||
|
|
||||||
|
void ft_putnbrbase(int nbr, char *base);
|
||||||
|
int ft_atoibase(char *str, char *base);
|
||||||
|
char *ft_convertbase(char *nbr, char *base_from, char *base_to);
|
||||||
|
char **ft_strmultisplit(char *str, char *charset);
|
||||||
|
int ft_any(char **tab, int (*f)(char*));
|
||||||
|
void ft_foreach(int *tab, int length, void (*f)(int));
|
||||||
|
int ft_issort(int *tab, int length, int (*f)(int, int));
|
||||||
|
int *ft_arraymap(int *tab, int length, int(*f)(int));
|
||||||
|
void ft_putnbrendl(int n);
|
||||||
|
void ft_putnbrendl_fd(int n, int fd);
|
||||||
|
|
||||||
|
#endif
|
||||||
BIN
OLDlibft.a
Normal file
BIN
OLDlibft.a
Normal file
Binary file not shown.
BIN
OLDlibft.fr.pdf
Normal file
BIN
OLDlibft.fr.pdf
Normal file
Binary file not shown.
18
OLDsrc/is/ft_isalnum.c
Normal file
18
OLDsrc/is/ft_isalnum.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_isalnum.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:09:33 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:09:37 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
int ft_isalnum(int c)
|
||||||
|
{
|
||||||
|
return (ft_isalpha(c) || ft_isdigit(c));
|
||||||
|
}
|
||||||
18
OLDsrc/is/ft_isalpha.c
Normal file
18
OLDsrc/is/ft_isalpha.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_isalpha.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:09:44 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:09:46 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
int ft_isalpha(int c)
|
||||||
|
{
|
||||||
|
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
|
||||||
|
}
|
||||||
18
OLDsrc/is/ft_isascii.c
Normal file
18
OLDsrc/is/ft_isascii.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_isascii.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:09:53 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:09:55 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
int ft_isascii(int c)
|
||||||
|
{
|
||||||
|
return (c >= 0 && c <= 127);
|
||||||
|
}
|
||||||
18
OLDsrc/is/ft_isdigit.c
Normal file
18
OLDsrc/is/ft_isdigit.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_isdigit.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:10:01 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:10:05 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
int ft_isdigit(int c)
|
||||||
|
{
|
||||||
|
return (c >= '0' && c <= '9');
|
||||||
|
}
|
||||||
18
OLDsrc/is/ft_isprint.c
Normal file
18
OLDsrc/is/ft_isprint.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_isprint.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:10:19 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:10:20 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
int ft_isprint(int c)
|
||||||
|
{
|
||||||
|
return (c >= 32 && c < 127);
|
||||||
|
}
|
||||||
26
OLDsrc/is/ft_issort.c
Normal file
26
OLDsrc/is/ft_issort.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_issort.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/16 15:18:14 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/16 15:18:15 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
int ft_issort(int *tab, int length, int (*f)(int, int))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
|
if (!tab)
|
||||||
|
return (0);
|
||||||
|
while (++i < length - 1)
|
||||||
|
if (f(tab[i], tab[i + 1]) > 0)
|
||||||
|
return (0);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
19
OLDsrc/lst/ft_lstadd.c
Normal file
19
OLDsrc/lst/ft_lstadd.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_lstadd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:10:33 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/16 13:58:54 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_lstadd(t_list **alst, t_list *new)
|
||||||
|
{
|
||||||
|
new->next = *alst;
|
||||||
|
*alst = new;
|
||||||
|
}
|
||||||
20
OLDsrc/lst/ft_lstdel.c
Normal file
20
OLDsrc/lst/ft_lstdel.c
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_lstdel.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:10:49 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/16 13:59:10 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_lstdel(t_list **alst, void (*del)(void *, size_t))
|
||||||
|
{
|
||||||
|
if ((*alst)->next)
|
||||||
|
ft_lstdel(&(*alst)->next, del);
|
||||||
|
ft_lstdelone(alst, del);
|
||||||
|
}
|
||||||
20
OLDsrc/lst/ft_lstdelone.c
Normal file
20
OLDsrc/lst/ft_lstdelone.c
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_lstdelone.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:10:59 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/16 13:59:22 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t))
|
||||||
|
{
|
||||||
|
del((*alst)->content, (*alst)->content_size);
|
||||||
|
free(*alst);
|
||||||
|
*alst = NULL;
|
||||||
|
}
|
||||||
22
OLDsrc/lst/ft_lstiter.c
Normal file
22
OLDsrc/lst/ft_lstiter.c
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_lstiter.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:11:14 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/16 14:01:10 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_lstiter(t_list *lst, void (*f)(t_list *elem))
|
||||||
|
{
|
||||||
|
if (!lst)
|
||||||
|
return ;
|
||||||
|
if (lst->next)
|
||||||
|
ft_lstiter(lst->next, f);
|
||||||
|
f(lst);
|
||||||
|
}
|
||||||
35
OLDsrc/lst/ft_lstmap.c
Normal file
35
OLDsrc/lst/ft_lstmap.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_lstmap.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:11:20 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/16 14:01:23 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
|
||||||
|
{
|
||||||
|
t_list *new;
|
||||||
|
t_list *tmp;
|
||||||
|
|
||||||
|
if (!lst)
|
||||||
|
return (NULL);
|
||||||
|
tmp = f(lst);
|
||||||
|
new = tmp;
|
||||||
|
while (lst->next)
|
||||||
|
{
|
||||||
|
lst = lst->next;
|
||||||
|
if (!(tmp->next = f(lst)))
|
||||||
|
{
|
||||||
|
free(tmp->next);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
return (new);
|
||||||
|
}
|
||||||
35
OLDsrc/lst/ft_lstnew.c
Normal file
35
OLDsrc/lst/ft_lstnew.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_lstnew.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:11:42 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/16 14:01:36 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
t_list *ft_lstnew(void const *content, size_t content_size)
|
||||||
|
{
|
||||||
|
t_list *lst;
|
||||||
|
|
||||||
|
if (!(lst = (t_list *)malloc(sizeof(*lst))))
|
||||||
|
return (NULL);
|
||||||
|
if (!content)
|
||||||
|
{
|
||||||
|
lst->content = NULL;
|
||||||
|
lst->content_size = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(lst->content = malloc(content_size)))
|
||||||
|
return (NULL);
|
||||||
|
ft_memcpy(lst->content, content, content_size);
|
||||||
|
lst->content_size = content_size;
|
||||||
|
}
|
||||||
|
lst->next = NULL;
|
||||||
|
return (lst);
|
||||||
|
}
|
||||||
27
OLDsrc/mem/ft_memalloc.c
Normal file
27
OLDsrc/mem/ft_memalloc.c
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_memalloc.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:11:58 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/04/03 15:42:06 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** allocate size byte of memory and return a pointer to the allocated memory
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void *ft_memalloc(size_t size)
|
||||||
|
{
|
||||||
|
void *tmp;
|
||||||
|
|
||||||
|
if (!(tmp = malloc(size)))
|
||||||
|
return (NULL);
|
||||||
|
ft_bzero(tmp, size);
|
||||||
|
return (tmp);
|
||||||
|
}
|
||||||
36
OLDsrc/mem/ft_memccpy.c
Normal file
36
OLDsrc/mem/ft_memccpy.c
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_memccpy.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:12:10 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/04/03 15:42:41 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** copy string until character is found and place cursor in dst
|
||||||
|
** after last byte copied
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
|
||||||
|
{
|
||||||
|
unsigned char *dest;
|
||||||
|
unsigned char *sourc;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
|
dest = (unsigned char *)dst;
|
||||||
|
sourc = (unsigned char *)src;
|
||||||
|
while (++i < n)
|
||||||
|
{
|
||||||
|
dest[i] = sourc[i];
|
||||||
|
if (sourc[i] == (unsigned char)c)
|
||||||
|
return (dst + i + 1);
|
||||||
|
}
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
30
OLDsrc/mem/ft_memchr.c
Normal file
30
OLDsrc/mem/ft_memchr.c
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_memchr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:12:32 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/04/03 15:43:14 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** locate character in string and return its position
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void *ft_memchr(const void *s, int c, size_t n)
|
||||||
|
{
|
||||||
|
unsigned char *sbis;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
sbis = (unsigned char *)s;
|
||||||
|
i = -1;
|
||||||
|
while (++i < n)
|
||||||
|
if (sbis[i] == (unsigned char)c)
|
||||||
|
return ((void *)sbis + i);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
32
OLDsrc/mem/ft_memcmp.c
Normal file
32
OLDsrc/mem/ft_memcmp.c
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_memcmp.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:13:04 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/04/03 15:43:41 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** compare two bytes strings (doesnt recognize a null terminated string)
|
||||||
|
** and return value of difference between first two different character
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||||
|
{
|
||||||
|
unsigned char *frst;
|
||||||
|
unsigned char *scnd;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
frst = (unsigned char *)s1;
|
||||||
|
scnd = (unsigned char *)s2;
|
||||||
|
while (i < n && frst[i] == scnd[i])
|
||||||
|
i++;
|
||||||
|
return ((i == n) ? 0 : frst[i] - scnd[i]);
|
||||||
|
}
|
||||||
31
OLDsrc/mem/ft_memcpy.c
Normal file
31
OLDsrc/mem/ft_memcpy.c
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_memcpy.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:13:17 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/04/03 15:43:56 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** copy n characters from src to dst and return dst
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void *ft_memcpy(void *dst, const void *src, size_t n)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
char *ptr;
|
||||||
|
char *ptr2;
|
||||||
|
|
||||||
|
ptr = (char *)dst;
|
||||||
|
ptr2 = (char *)src;
|
||||||
|
i = -1;
|
||||||
|
while (++i < n)
|
||||||
|
ptr[i] = ptr2[i];
|
||||||
|
return (dst);
|
||||||
|
}
|
||||||
26
OLDsrc/mem/ft_memdel.c
Normal file
26
OLDsrc/mem/ft_memdel.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_memdel.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:13:26 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/04/03 15:44:12 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** free memory
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_memdel(void **ap)
|
||||||
|
{
|
||||||
|
if (ap && *ap)
|
||||||
|
{
|
||||||
|
free(*ap);
|
||||||
|
*ap = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
OLDsrc/mem/ft_memmove.c
Normal file
35
OLDsrc/mem/ft_memmove.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_memmove.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:13:34 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/04/03 15:44:28 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** copy n characters from src to dst in a non destructive way and return dst
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void *ft_memmove(void *dst, const void *src, size_t len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *source;
|
||||||
|
char *dest;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
|
source = (char *)src;
|
||||||
|
dest = (char *)dst;
|
||||||
|
if (source < dest)
|
||||||
|
while ((int)(--len) >= 0)
|
||||||
|
dest[len] = source[len];
|
||||||
|
else
|
||||||
|
while (++i < (int)len)
|
||||||
|
dest[i] = source[i];
|
||||||
|
return (dst);
|
||||||
|
}
|
||||||
29
OLDsrc/mem/ft_memset.c
Normal file
29
OLDsrc/mem/ft_memset.c
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_memset.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:13:41 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/04/03 15:44:44 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** copy n time a character in a string and return the string
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void *ft_memset(void *b, int c, size_t len)
|
||||||
|
{
|
||||||
|
char *ptr;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
ptr = (char *)b;
|
||||||
|
i = 0;
|
||||||
|
while (i < len)
|
||||||
|
ptr[i++] = c;
|
||||||
|
return (b);
|
||||||
|
}
|
||||||
18
OLDsrc/put/ft_putchar.c
Normal file
18
OLDsrc/put/ft_putchar.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putchar.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:14:00 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:14:01 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_putchar(char c)
|
||||||
|
{
|
||||||
|
write(1, &c, 1);
|
||||||
|
}
|
||||||
18
OLDsrc/put/ft_putchar_fd.c
Normal file
18
OLDsrc/put/ft_putchar_fd.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putchar_fd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:14:14 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:14:15 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_putchar_fd(char c, int fd)
|
||||||
|
{
|
||||||
|
write(fd, &c, 1);
|
||||||
|
}
|
||||||
19
OLDsrc/put/ft_putendl.c
Normal file
19
OLDsrc/put/ft_putendl.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putendl.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:14:32 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:14:33 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_putendl(char const *s)
|
||||||
|
{
|
||||||
|
ft_putstr(s);
|
||||||
|
ft_putchar('\n');
|
||||||
|
}
|
||||||
19
OLDsrc/put/ft_putendl_fd.c
Normal file
19
OLDsrc/put/ft_putendl_fd.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putendl_fd.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:14:47 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:14:48 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_putendl_fd(char const *s, int fd)
|
||||||
|
{
|
||||||
|
ft_putstr_fd(s, fd);
|
||||||
|
ft_putchar_fd('\n', fd);
|
||||||
|
}
|
||||||
18
OLDsrc/put/ft_putnbr.c
Normal file
18
OLDsrc/put/ft_putnbr.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putnbr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/11/14 21:14:57 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2018/11/14 21:14:58 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_putnbr(int n)
|
||||||
|
{
|
||||||
|
ft_putnbr_fd(n, 1);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user