mirror of
https://github.com/Ladebeze66/cub3D.git
synced 2026-11-09 13:47:10 +01:00
versiontexturecouleur
This commit is contained in:
102
libft/Makefile
Normal file
102
libft/Makefile
Normal file
@@ -0,0 +1,102 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/02/06 12:19:21 by fgras-ca #+# #+# #
|
||||
# Updated: 2024/01/15 22:06:15 by fgras-ca ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
RST = \033[0m
|
||||
GRAY = \033[0;90m
|
||||
RED = \033[0;91m
|
||||
GREEN = \033[0;92m
|
||||
YELLOW = \033[0;93m
|
||||
BLUE = \033[0;94m
|
||||
MAGENTA = \033[0;95m
|
||||
CYAN = \033[0;96m
|
||||
WHITE = \033[0;97m
|
||||
ORANGE = \033[38;5;214m
|
||||
|
||||
NAME = libft.a
|
||||
|
||||
SOURCES = ft_atoi.c \
|
||||
ft_isalpha.c \
|
||||
ft_memchr.c \
|
||||
ft_memset.c \
|
||||
ft_strlcat.c \
|
||||
ft_strnstr.c \
|
||||
ft_toupper.c \
|
||||
ft_bzero.c \
|
||||
ft_isascii.c \
|
||||
ft_memcmp.c \
|
||||
ft_strchr.c \
|
||||
ft_strlcpy.c \
|
||||
ft_strrchr.c \
|
||||
ft_calloc.c \
|
||||
ft_isdigit.c \
|
||||
ft_memcpy.c \
|
||||
ft_substr.c \
|
||||
ft_isalnum.c \
|
||||
ft_isprint.c \
|
||||
ft_memmove.c \
|
||||
ft_strncmp.c \
|
||||
ft_tolower.c\
|
||||
ft_strtrim.c \
|
||||
ft_putchar_fd.c \
|
||||
ft_putstr_fd.c \
|
||||
ft_putendl_fd.c \
|
||||
ft_putnbr_fd.c \
|
||||
ft_strmapi.c \
|
||||
ft_striteri.c \
|
||||
ft_itoa.c \
|
||||
ft_strcmp.c \
|
||||
ft_strstr.c \
|
||||
ft_reallocarray.c \
|
||||
ft_strcat.c \
|
||||
ft_strcpy.c \
|
||||
ft_realloc.c \
|
||||
ft_strncpy.c \
|
||||
ft_strtol.c \
|
||||
ft_strtok.c \
|
||||
|
||||
SRCBONUS = ft_lstnew.c \
|
||||
ft_lstadd_front.c \
|
||||
ft_lstsize.c \
|
||||
ft_lstlast.c \
|
||||
ft_lstadd_back.c \
|
||||
ft_lstdelone.c \
|
||||
ft_lstclear.c \
|
||||
ft_lstiter.c \
|
||||
ft_lstiter.c \
|
||||
ft_lstmap.c \
|
||||
|
||||
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
BONUS_OBJ = $(SRCBONUS:.c=.o)
|
||||
|
||||
CC = gcc
|
||||
|
||||
RM = rm -f
|
||||
|
||||
CFLAGS = -Wall -Werror -Wextra
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(NAME): $(OBJECTS)
|
||||
@echo $(CC) (CFLAGS) $(OBJECTS) -o $(NAME)
|
||||
|
||||
bonus: $(OBJECTS) $(BONUS_OBJ)
|
||||
$(CC) (CFLAGS) $(OBJECTS) $(BONUS_OBJ) -o $(NAME)
|
||||
|
||||
clean:
|
||||
@echo $(RM) $(OBJECTS) $(BONUS_OBJ)
|
||||
|
||||
fclean: clean
|
||||
@echo $(RM) $(NAME) $(BONUS_OBJ)
|
||||
|
||||
re: fclean all
|
||||
38
libft/ft_atoi.c
Normal file
38
libft/ft_atoi.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/11 16:16:54 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/21 09:57:55 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_atoi(const char *nptr)
|
||||
{
|
||||
int i;
|
||||
int sign;
|
||||
int res;
|
||||
|
||||
i = 0;
|
||||
sign = 1;
|
||||
res = 0;
|
||||
while (nptr[i] == 32 || (nptr[i] >= 9 && nptr[i] <= 13))
|
||||
i++;
|
||||
if (nptr[i] == '-' || nptr[i] == '+')
|
||||
{
|
||||
if (nptr[i] == '-')
|
||||
sign = - (1);
|
||||
i++;
|
||||
}
|
||||
while (nptr[i] >= 48 && nptr[i] <= 57)
|
||||
{
|
||||
res = res * 10 + nptr[i] - 48;
|
||||
i++;
|
||||
}
|
||||
return (res * sign);
|
||||
}
|
||||
BIN
libft/ft_atoi.o
Normal file
BIN
libft/ft_atoi.o
Normal file
Binary file not shown.
25
libft/ft_bzero.c
Normal file
25
libft/ft_bzero.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_bzero.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/04 11:37:30 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/20 16:07:19 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_bzero(void *ptr, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (i < len)
|
||||
{
|
||||
*(char *)(ptr + i) = 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
BIN
libft/ft_bzero.o
Normal file
BIN
libft/ft_bzero.o
Normal file
Binary file not shown.
28
libft/ft_calloc.c
Normal file
28
libft/ft_calloc.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_calloc.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/11 17:47:38 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/21 10:45:58 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void *ft_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if (!nmemb || !size)
|
||||
return (malloc(0));
|
||||
if ((nmemb * size) / size != nmemb)
|
||||
return (NULL);
|
||||
ptr = malloc(size * nmemb);
|
||||
if (!ptr)
|
||||
return (0);
|
||||
ft_bzero(ptr, size * nmemb);
|
||||
return (ptr);
|
||||
}
|
||||
BIN
libft/ft_calloc.o
Normal file
BIN
libft/ft_calloc.o
Normal file
Binary file not shown.
21
libft/ft_isalnum.c
Normal file
21
libft/ft_isalnum.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_isalnum.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/01 16:21:11 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/01 16:24:23 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_isalnum(int c)
|
||||
{
|
||||
if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c <= 57))
|
||||
return (1);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
BIN
libft/ft_isalnum.o
Normal file
BIN
libft/ft_isalnum.o
Normal file
Binary file not shown.
21
libft/ft_isalpha.c
Normal file
21
libft/ft_isalpha.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_isalpha.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/01 13:36:34 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/01 13:58:21 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_isalpha(int c)
|
||||
{
|
||||
if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122))
|
||||
return (1);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
BIN
libft/ft_isalpha.o
Normal file
BIN
libft/ft_isalpha.o
Normal file
Binary file not shown.
20
libft/ft_isascii.c
Normal file
20
libft/ft_isascii.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_isascii.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/01 16:40:31 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:07:04 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_isascii(int c)
|
||||
{
|
||||
if (c >= 0 && c <= 127)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
BIN
libft/ft_isascii.o
Normal file
BIN
libft/ft_isascii.o
Normal file
Binary file not shown.
21
libft/ft_isdigit.c
Normal file
21
libft/ft_isdigit.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_isdigit.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/01 14:46:59 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/01 15:55:00 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_isdigit(int c)
|
||||
{
|
||||
if (c >= 48 && c <= 57)
|
||||
return (1);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
BIN
libft/ft_isdigit.o
Normal file
BIN
libft/ft_isdigit.o
Normal file
Binary file not shown.
20
libft/ft_isprint.c
Normal file
20
libft/ft_isprint.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_isprint.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/03 12:43:03 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/03 13:25:31 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_isprint(int c)
|
||||
{
|
||||
if (c >= 32 && c <= 126)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
BIN
libft/ft_isprint.o
Normal file
BIN
libft/ft_isprint.o
Normal file
Binary file not shown.
56
libft/ft_itoa.c
Normal file
56
libft/ft_itoa.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_itoa.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/17 15:53:35 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/21 10:21:07 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
static size_t ft_len_nb(int nb)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = 0;
|
||||
if (nb <= 0)
|
||||
len++;
|
||||
while (nb)
|
||||
{
|
||||
len++;
|
||||
nb = nb / 10;
|
||||
}
|
||||
return (len);
|
||||
}
|
||||
|
||||
char *ft_itoa(int n)
|
||||
{
|
||||
int len;
|
||||
char *str;
|
||||
long nb;
|
||||
|
||||
len = ft_len_nb(n);
|
||||
nb = n;
|
||||
str = malloc(sizeof(char) * len +1);
|
||||
if (!str)
|
||||
return (0);
|
||||
if (nb < 0)
|
||||
{
|
||||
str[0] = '-';
|
||||
nb = -nb;
|
||||
}
|
||||
if (nb == 0)
|
||||
str[0] = '0';
|
||||
str[len--] = '\0';
|
||||
while (nb)
|
||||
{
|
||||
str[len] = nb % 10 + '0';
|
||||
len--;
|
||||
nb = nb / 10;
|
||||
}
|
||||
return (str);
|
||||
}
|
||||
BIN
libft/ft_itoa.o
Normal file
BIN
libft/ft_itoa.o
Normal file
Binary file not shown.
29
libft/ft_lstadd_back.c
Normal file
29
libft/ft_lstadd_back.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstadd_back.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/23 18:08:00 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/23 18:15:14 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_lstadd_back(t_list **lst, t_list *new)
|
||||
{
|
||||
t_list *temp;
|
||||
|
||||
if (new && lst)
|
||||
{
|
||||
if (*lst)
|
||||
{
|
||||
temp = ft_lstlast(*lst);
|
||||
temp->next = new;
|
||||
}
|
||||
else
|
||||
*lst = new;
|
||||
}
|
||||
}
|
||||
22
libft/ft_lstadd_front.c
Normal file
22
libft/ft_lstadd_front.c
Normal file
@@ -0,0 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstadd_front.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/22 18:06:54 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:06:52 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_lstadd_front(t_list **lst, t_list *new)
|
||||
{
|
||||
if (new)
|
||||
{
|
||||
new->next = *lst;
|
||||
*lst = new;
|
||||
}
|
||||
}
|
||||
25
libft/ft_lstclear.c
Normal file
25
libft/ft_lstclear.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstclear.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/23 18:19:42 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/23 18:22:17 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_lstclear(t_list **lst, void (*del)(void*))
|
||||
{
|
||||
t_list *temp;
|
||||
|
||||
while (*lst && lst)
|
||||
{
|
||||
temp = (*lst)->next;
|
||||
ft_lstdelone(*lst, (*del));
|
||||
*lst = temp;
|
||||
}
|
||||
}
|
||||
21
libft/ft_lstdelone.c
Normal file
21
libft/ft_lstdelone.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstdelone.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/23 18:17:06 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/23 18:33:01 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_lstdelone(t_list *lst, void (*del)(void*))
|
||||
{
|
||||
if (!lst || !del)
|
||||
return ;
|
||||
del(lst->content);
|
||||
free(lst);
|
||||
}
|
||||
24
libft/ft_lstiter.c
Normal file
24
libft/ft_lstiter.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstiter.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/23 18:22:52 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/23 18:24:51 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_lstiter(t_list *lst, void (*f)(void *))
|
||||
{
|
||||
if (!lst || !f)
|
||||
return ;
|
||||
while (lst)
|
||||
{
|
||||
f(lst->content);
|
||||
lst = lst->next;
|
||||
}
|
||||
}
|
||||
24
libft/ft_lstlast.c
Normal file
24
libft/ft_lstlast.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstlast.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/23 17:48:29 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/23 18:02:44 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
t_list *ft_lstlast(t_list *lst)
|
||||
{
|
||||
while (lst)
|
||||
{
|
||||
if (lst->next == NULL)
|
||||
return (lst);
|
||||
lst = lst->next;
|
||||
}
|
||||
return (lst);
|
||||
}
|
||||
35
libft/ft_lstmap.c
Normal file
35
libft/ft_lstmap.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstmap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/23 18:25:24 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/23 18:29:44 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
|
||||
{
|
||||
t_list *tmp;
|
||||
t_list *res;
|
||||
|
||||
if (!lst || !f)
|
||||
return (NULL);
|
||||
res = 0;
|
||||
while (lst)
|
||||
{
|
||||
tmp = ft_lstnew((*f)(lst->content));
|
||||
if (!tmp)
|
||||
{
|
||||
ft_lstclear(&res, del);
|
||||
return (NULL);
|
||||
}
|
||||
ft_lstadd_back(&res, tmp);
|
||||
lst = lst->next;
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
25
libft/ft_lstnew.c
Normal file
25
libft/ft_lstnew.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstnew.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/22 17:09:25 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:06:38 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
t_list *ft_lstnew(void *content)
|
||||
{
|
||||
t_list *new;
|
||||
|
||||
new = malloc(sizeof(t_list));
|
||||
if (!new)
|
||||
return (0);
|
||||
new->content = content;
|
||||
new->next = 0;
|
||||
return (new);
|
||||
}
|
||||
28
libft/ft_lstsize.c
Normal file
28
libft/ft_lstsize.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstsize.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/23 17:17:36 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:06:24 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_lstsize(t_list *lst)
|
||||
{
|
||||
int i;
|
||||
t_list *tmp;
|
||||
|
||||
tmp = lst;
|
||||
i = 0;
|
||||
while (tmp)
|
||||
{
|
||||
tmp = tmp->next;
|
||||
i++;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
27
libft/ft_memchr.c
Normal file
27
libft/ft_memchr.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/10 13:42:10 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/14 13:03:28 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void *ft_memchr(const void *s, int c, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
if (((unsigned char *)s)[i] == (unsigned char)c)
|
||||
return ((void *)(s + i));
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
BIN
libft/ft_memchr.o
Normal file
BIN
libft/ft_memchr.o
Normal file
Binary file not shown.
27
libft/ft_memcmp.c
Normal file
27
libft/ft_memcmp.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/10 14:45:56 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:18:05 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
if (((unsigned char *)s1)[i] != ((unsigned char *)s2)[i])
|
||||
return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
BIN
libft/ft_memcmp.o
Normal file
BIN
libft/ft_memcmp.o
Normal file
Binary file not shown.
32
libft/ft_memcpy.c
Normal file
32
libft/ft_memcpy.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/04 14:43:15 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/20 16:13:43 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void *ft_memcpy(void *dest, const void *src, size_t n)
|
||||
{
|
||||
char *destmov;
|
||||
char *srcmov;
|
||||
size_t i;
|
||||
|
||||
destmov = (char *)dest;
|
||||
srcmov = (char *)src;
|
||||
if (!dest && !src)
|
||||
return (0);
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
destmov[i] = srcmov[i];
|
||||
i++;
|
||||
}
|
||||
return (dest);
|
||||
}
|
||||
BIN
libft/ft_memcpy.o
Normal file
BIN
libft/ft_memcpy.o
Normal file
Binary file not shown.
42
libft/ft_memmove.c
Normal file
42
libft/ft_memmove.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memmove.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/07 11:11:49 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/07 16:04:25 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void *ft_memmove(void *dest, const void *src, size_t n)
|
||||
{
|
||||
char *destmov;
|
||||
char *srcmov;
|
||||
size_t i;
|
||||
|
||||
if (!dest && !src)
|
||||
return (0);
|
||||
destmov = (char *)dest;
|
||||
srcmov = (char *)src;
|
||||
i = 0;
|
||||
if (destmov > srcmov)
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
destmov[n] = srcmov[n];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
destmov[i] = srcmov[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return (destmov);
|
||||
}
|
||||
BIN
libft/ft_memmove.o
Normal file
BIN
libft/ft_memmove.o
Normal file
Binary file not shown.
26
libft/ft_memset.c
Normal file
26
libft/ft_memset.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memset.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/03 15:49:51 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:07:29 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void *ft_memset(void *s, int c, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
*(unsigned char *)(s + i) = (unsigned char)c;
|
||||
i++;
|
||||
}
|
||||
return (s);
|
||||
}
|
||||
BIN
libft/ft_memset.o
Normal file
BIN
libft/ft_memset.o
Normal file
Binary file not shown.
18
libft/ft_putchar_fd.c
Normal file
18
libft/ft_putchar_fd.c
Normal file
@@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putchar_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 11:23:07 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/15 11:30:37 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putchar_fd(char c, int fd)
|
||||
{
|
||||
write(fd, &c, 1);
|
||||
}
|
||||
BIN
libft/ft_putchar_fd.o
Normal file
BIN
libft/ft_putchar_fd.o
Normal file
Binary file not shown.
28
libft/ft_putendl_fd.c
Normal file
28
libft/ft_putendl_fd.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putendl_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 13:33:49 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/21 10:19:05 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putendl_fd(char *s, int fd)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (!s)
|
||||
return ;
|
||||
while (s[i])
|
||||
{
|
||||
write(fd, &s[i], 1);
|
||||
i++;
|
||||
}
|
||||
write(fd, "\n", 1);
|
||||
}
|
||||
BIN
libft/ft_putendl_fd.o
Normal file
BIN
libft/ft_putendl_fd.o
Normal file
Binary file not shown.
36
libft/ft_putnbr_fd.c
Normal file
36
libft/ft_putnbr_fd.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 13:53:25 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/15 14:00:06 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putnbr_fd(int n, int fd)
|
||||
{
|
||||
if (n == -2147483648)
|
||||
{
|
||||
write(fd, "-2147483648", 11);
|
||||
}
|
||||
else if (n >= 0 && n < 10)
|
||||
{
|
||||
n += 48;
|
||||
ft_putchar_fd(n, fd);
|
||||
}
|
||||
else if (n < 0)
|
||||
{
|
||||
ft_putchar_fd('-', fd);
|
||||
ft_putnbr_fd((n * (-1)), fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_putnbr_fd(n / 10, fd);
|
||||
ft_putnbr_fd(n % 10, fd);
|
||||
}
|
||||
}
|
||||
BIN
libft/ft_putnbr_fd.o
Normal file
BIN
libft/ft_putnbr_fd.o
Normal file
Binary file not shown.
27
libft/ft_putstr_fd.c
Normal file
27
libft/ft_putstr_fd.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 12:29:14 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/15 19:02:37 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putstr_fd(char *s, int fd)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (!s || !fd)
|
||||
return ;
|
||||
while (s[i])
|
||||
{
|
||||
write(fd, &s[i], 1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
BIN
libft/ft_putstr_fd.o
Normal file
BIN
libft/ft_putstr_fd.o
Normal file
Binary file not shown.
35
libft/ft_realloc.c
Normal file
35
libft/ft_realloc.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_realloc.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/15 16:31:35 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/12/10 13:59:12 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void *ft_realloc(void *ptr, size_t newsize, size_t oldsize)
|
||||
{
|
||||
char *newptr;
|
||||
|
||||
if (ptr == NULL)
|
||||
{
|
||||
return (malloc(newsize));
|
||||
}
|
||||
if (newsize <= oldsize)
|
||||
{
|
||||
return (ptr);
|
||||
}
|
||||
newptr = malloc(newsize);
|
||||
if (newptr == NULL)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
ft_memcpy(newptr, ptr, oldsize);
|
||||
free(ptr);
|
||||
return (newptr);
|
||||
}
|
||||
BIN
libft/ft_realloc.o
Normal file
BIN
libft/ft_realloc.o
Normal file
Binary file not shown.
32
libft/ft_reallocarray.c
Normal file
32
libft/ft_reallocarray.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_reallocarray.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/15 15:52:29 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/12/07 11:46:15 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
static size_t get_mul_no_overflow(void)
|
||||
{
|
||||
return ((size_t)1 << (sizeof(size_t) * 4));
|
||||
}
|
||||
|
||||
void *ft_reallocarray(void *optr, size_t nmemb, size_t size, size_t oldsize)
|
||||
{
|
||||
size_t mul_no_overflow;
|
||||
|
||||
mul_no_overflow = get_mul_no_overflow();
|
||||
if ((nmemb >= mul_no_overflow || size >= mul_no_overflow)
|
||||
&& nmemb > 0 && SIZE_MAX / nmemb < size)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return (NULL);
|
||||
}
|
||||
return (ft_realloc(optr, nmemb * size, oldsize));
|
||||
}
|
||||
BIN
libft/ft_reallocarray.o
Normal file
BIN
libft/ft_reallocarray.o
Normal file
Binary file not shown.
32
libft/ft_strcat.c
Normal file
32
libft/ft_strcat.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/21 19:20:36 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/21 19:28:29 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strcat(char *dest, const char *src)
|
||||
{
|
||||
char *save;
|
||||
|
||||
save = dest;
|
||||
while (*dest)
|
||||
{
|
||||
dest++;
|
||||
}
|
||||
while (*src)
|
||||
{
|
||||
*dest = *src;
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
*dest = '\0';
|
||||
return (save);
|
||||
}
|
||||
BIN
libft/ft_strcat.o
Normal file
BIN
libft/ft_strcat.o
Normal file
Binary file not shown.
32
libft/ft_strchr.c
Normal file
32
libft/ft_strchr.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/09 14:27:10 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/21 10:54:39 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strchr(const char *s, int c)
|
||||
|
||||
{
|
||||
int i;
|
||||
char *str;
|
||||
|
||||
str = (char *)s;
|
||||
i = 0;
|
||||
while (str[i])
|
||||
{
|
||||
if (str[i] == (char)c)
|
||||
return (&str[i]);
|
||||
i++;
|
||||
}
|
||||
if (str[i] == (char)c)
|
||||
return (&str[i]);
|
||||
return (0);
|
||||
}
|
||||
BIN
libft/ft_strchr.o
Normal file
BIN
libft/ft_strchr.o
Normal file
Binary file not shown.
23
libft/ft_strcmp.c
Normal file
23
libft/ft_strcmp.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/14 16:57:42 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:10:27 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1 && (*s1 == *s2))
|
||||
{
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return (*(const unsigned char *)s1 - *(const unsigned char *)s2);
|
||||
}
|
||||
BIN
libft/ft_strcmp.o
Normal file
BIN
libft/ft_strcmp.o
Normal file
Binary file not shown.
28
libft/ft_strcpy.c
Normal file
28
libft/ft_strcpy.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/21 19:23:08 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/21 19:26:36 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strcpy(char *dest, const char *src)
|
||||
{
|
||||
char *save;
|
||||
|
||||
save = dest;
|
||||
while (*src)
|
||||
{
|
||||
*dest = *src;
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
*dest = '\0';
|
||||
return (save);
|
||||
}
|
||||
BIN
libft/ft_strcpy.o
Normal file
BIN
libft/ft_strcpy.o
Normal file
Binary file not shown.
25
libft/ft_striteri.c
Normal file
25
libft/ft_striteri.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_striteri.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/16 14:25:00 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:08:02 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_striteri(char *s, void (*f)(unsigned int, char*))
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!s)
|
||||
return ;
|
||||
i = 0;
|
||||
while (s[i])
|
||||
{
|
||||
f(i, &s[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
BIN
libft/ft_striteri.o
Normal file
BIN
libft/ft_striteri.o
Normal file
Binary file not shown.
33
libft/ft_strlcat.c
Normal file
33
libft/ft_strlcat.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/08 14:10:58 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:09:41 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
size_t ft_strlcat(char *dst, const char *src, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
size_t dst_len;
|
||||
|
||||
i = 0;
|
||||
if (!dst && !size)
|
||||
return (0);
|
||||
dst_len = ft_strlen(dst);
|
||||
if (size <= dst_len)
|
||||
return (size + ft_strlen(src));
|
||||
while (src[i] && i < size - dst_len -1)
|
||||
{
|
||||
dst[dst_len + i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dst[dst_len + i] = 0;
|
||||
return (dst_len + ft_strlen(src));
|
||||
}
|
||||
BIN
libft/ft_strlcat.o
Normal file
BIN
libft/ft_strlcat.o
Normal file
Binary file not shown.
32
libft/ft_strlcpy.c
Normal file
32
libft/ft_strlcpy.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/08 13:24:31 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/08 13:33:32 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
size_t ft_strlcpy(char *dst, const char *src, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
if (size > 0)
|
||||
{
|
||||
while (src[i] && i < (size - 1))
|
||||
{
|
||||
dst[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dst[i] = 0;
|
||||
}
|
||||
while (src[i])
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
BIN
libft/ft_strlcpy.o
Normal file
BIN
libft/ft_strlcpy.o
Normal file
Binary file not shown.
33
libft/ft_strmapi.c
Normal file
33
libft/ft_strmapi.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strmapi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/16 13:38:52 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:04:43 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strmapi(const char *s, char (*f)(unsigned int, char))
|
||||
{
|
||||
char *result;
|
||||
unsigned int i;
|
||||
|
||||
if (!s)
|
||||
return (0);
|
||||
result = malloc(sizeof(char) * (ft_strlen(s) + 1));
|
||||
if (!result)
|
||||
return (0);
|
||||
i = 0;
|
||||
while (s[i])
|
||||
{
|
||||
result[i] = f(i, s[i]);
|
||||
i++;
|
||||
}
|
||||
result[i] = 0;
|
||||
return (result);
|
||||
}
|
||||
BIN
libft/ft_strmapi.o
Normal file
BIN
libft/ft_strmapi.o
Normal file
Binary file not shown.
29
libft/ft_strncmp.c
Normal file
29
libft/ft_strncmp.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/09 17:12:38 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/14 13:26:15 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
if (n == 0)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
while (s1[i] == s2[i] && (s1[i] != '\0' || s2[i] != '\0') && i < (n - 1))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
|
||||
}
|
||||
BIN
libft/ft_strncmp.o
Normal file
BIN
libft/ft_strncmp.o
Normal file
Binary file not shown.
31
libft/ft_strncpy.c
Normal file
31
libft/ft_strncpy.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/27 20:03:19 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/12/07 11:56:51 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strncpy(char *dest, char *src, unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
while (src[i] != '\0' && i < n)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
++i;
|
||||
}
|
||||
while (i < n)
|
||||
{
|
||||
dest[i] = '\0';
|
||||
i++;
|
||||
}
|
||||
return (dest);
|
||||
}
|
||||
BIN
libft/ft_strncpy.o
Normal file
BIN
libft/ft_strncpy.o
Normal file
Binary file not shown.
41
libft/ft_strnstr.c
Normal file
41
libft/ft_strnstr.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strnstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/11 14:31:40 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/21 10:08:36 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strnstr(const char *haystack, const char *needle, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
|
||||
i = 0;
|
||||
if (needle == haystack)
|
||||
return ((char *)haystack);
|
||||
if (!len && !haystack)
|
||||
return (0);
|
||||
while (haystack[i] != '\0')
|
||||
{
|
||||
j = 0;
|
||||
while (haystack[i + j] == needle[j] && (i + j) < len)
|
||||
{
|
||||
if (haystack[i + j] == '\0' && needle[j] == '\0')
|
||||
{
|
||||
return ((char *)&haystack[j]);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (needle[j] == '\0')
|
||||
return ((char *)(haystack + i));
|
||||
i++;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
BIN
libft/ft_strnstr.o
Normal file
BIN
libft/ft_strnstr.o
Normal file
Binary file not shown.
29
libft/ft_strrchr.c
Normal file
29
libft/ft_strrchr.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strrchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/09 16:10:11 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/14 15:36:23 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strrchr(const char *s, int c)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (s[i])
|
||||
i++;
|
||||
while (i >= 0)
|
||||
{
|
||||
if (s[i] == (char)c)
|
||||
return ((char *)(s + i));
|
||||
i--;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
BIN
libft/ft_strrchr.o
Normal file
BIN
libft/ft_strrchr.o
Normal file
Binary file not shown.
42
libft/ft_strstr.c
Normal file
42
libft/ft_strstr.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/14 20:54:44 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 21:08:57 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strstr(const char *haystack, const char *needle)
|
||||
{
|
||||
const char *p;
|
||||
const char *beginning;
|
||||
const char *n;
|
||||
|
||||
p = haystack;
|
||||
if (*needle == '\0')
|
||||
return ((char *)haystack);
|
||||
while (*p != '\0')
|
||||
{
|
||||
if (*p == *needle)
|
||||
{
|
||||
beginning = p;
|
||||
n = needle;
|
||||
while (*p == *n && *n != '\0' && *p != '\0')
|
||||
{
|
||||
p++;
|
||||
n++;
|
||||
}
|
||||
if (*n == '\0')
|
||||
return ((char *)beginning);
|
||||
p = beginning;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
BIN
libft/ft_strstr.o
Normal file
BIN
libft/ft_strstr.o
Normal file
Binary file not shown.
83
libft/ft_strtok.c
Normal file
83
libft/ft_strtok.c
Normal file
@@ -0,0 +1,83 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strtok.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/14 17:14:45 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/12/07 11:41:34 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
static char *init_str_and_lasts(char **lasts, char *str)
|
||||
{
|
||||
if (str == NULL)
|
||||
{
|
||||
str = *lasts;
|
||||
if (str == NULL)
|
||||
return (NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
*lasts = str;
|
||||
}
|
||||
return (str);
|
||||
}
|
||||
|
||||
static char *find_token_start(char **lasts, const char *delim)
|
||||
{
|
||||
int ch;
|
||||
|
||||
ch = **lasts;
|
||||
while (ch != '\0' && ft_strchr(delim, ch) != NULL)
|
||||
{
|
||||
(*lasts)++;
|
||||
ch = **lasts;
|
||||
}
|
||||
if (**lasts == '\0')
|
||||
{
|
||||
*lasts = NULL;
|
||||
return (NULL);
|
||||
}
|
||||
return (*lasts);
|
||||
}
|
||||
|
||||
static char *find_token_end(char **lasts, const char *delim)
|
||||
{
|
||||
int ch;
|
||||
char *str;
|
||||
|
||||
str = *lasts;
|
||||
ch = **lasts;
|
||||
while (ch != '\0' && ft_strchr(delim, ch) == NULL)
|
||||
{
|
||||
(*lasts)++;
|
||||
ch = **lasts;
|
||||
}
|
||||
if (**lasts != '\0')
|
||||
{
|
||||
**lasts = '\0';
|
||||
(*lasts)++;
|
||||
}
|
||||
else
|
||||
{
|
||||
*lasts = NULL;
|
||||
}
|
||||
return (str);
|
||||
}
|
||||
|
||||
char *ft_strtok(char *str, const char *delim)
|
||||
{
|
||||
static char *lasts;
|
||||
|
||||
str = init_str_and_lasts(&lasts, str);
|
||||
if (str == NULL)
|
||||
return (NULL);
|
||||
str = find_token_start(&lasts, delim);
|
||||
if (str == NULL)
|
||||
return (NULL);
|
||||
return (find_token_end(&lasts, delim));
|
||||
}
|
||||
BIN
libft/ft_strtok.o
Normal file
BIN
libft/ft_strtok.o
Normal file
Binary file not shown.
115
libft/ft_strtol.c
Normal file
115
libft/ft_strtol.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strtol.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/01 14:00:32 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/12/07 11:56:12 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
static int skip_whitespaces_and_sign(const char *str, int *sign)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] == ' ' || (str[i] >= '\t' && str[i] <= '\r'))
|
||||
i++;
|
||||
if (str[i] == '+' || str[i] == '-')
|
||||
{
|
||||
if (str[i] == '-')
|
||||
*sign = -1;
|
||||
i++;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
static int determine_base(const char *str, int *base, int index)
|
||||
{
|
||||
if ((*base == 0 || *base == 16) && str[index] == '0'
|
||||
&& (str[index + 1] == 'x' || str[index + 1] == 'X'))
|
||||
{
|
||||
*base = 16;
|
||||
index += 2;
|
||||
}
|
||||
else if (*base == 0)
|
||||
{
|
||||
if (str[index] == '0')
|
||||
*base = 8;
|
||||
else
|
||||
*base = 10;
|
||||
}
|
||||
return (index);
|
||||
}
|
||||
|
||||
static int check_base(const char *str, int *base, int *sign)
|
||||
{
|
||||
int i;
|
||||
|
||||
*sign = 1;
|
||||
i = skip_whitespaces_and_sign(str, sign);
|
||||
i = determine_base(str, base, i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
static long convert_strtol(const char *str, int base, int sign)
|
||||
{
|
||||
long result;
|
||||
int digit;
|
||||
|
||||
result = 0;
|
||||
while (*str)
|
||||
{
|
||||
digit = 0;
|
||||
if (*str >= '0' && *str <= '9')
|
||||
digit = *str - '0';
|
||||
else if (*str >= 'A' && *str <= 'Z')
|
||||
digit = *str - 'A' + 10;
|
||||
else if (*str >= 'a' && *str <= 'z')
|
||||
digit = *str - 'a' + 10;
|
||||
else
|
||||
break ;
|
||||
if (digit >= base)
|
||||
break ;
|
||||
if (sign > 0 && result > (LONG_MAX - digit) / base)
|
||||
return (errno = ERANGE, LONG_MAX);
|
||||
if (sign < 0 && result < (LONG_MIN + digit) / base)
|
||||
return (errno = ERANGE, LONG_MIN);
|
||||
result = result * base + digit;
|
||||
str++;
|
||||
}
|
||||
return (result * sign);
|
||||
}
|
||||
|
||||
long ft_strtol(const char *str, char **endptr, int base)
|
||||
{
|
||||
int sign;
|
||||
int i;
|
||||
long result;
|
||||
|
||||
if (base < 0 || base == 1 || base > 36)
|
||||
{
|
||||
if (endptr)
|
||||
*endptr = (char *)str;
|
||||
return (0);
|
||||
}
|
||||
i = check_base(str, &base, &sign);
|
||||
result = convert_strtol(str + i, base, sign);
|
||||
if (endptr)
|
||||
*endptr = (char *)(str + i);
|
||||
while (*str)
|
||||
{
|
||||
if ((*str >= '0' && *str <= '9' && *str - '0' < base)
|
||||
|| (*str >= 'A' && *str <= 'Z' && *str - 'A' + 10 < base)
|
||||
|| (*str >= 'a' && *str <= 'z' && *str - 'a' + 10 < base))
|
||||
*endptr = (char *)(str + 1);
|
||||
else
|
||||
break ;
|
||||
str++;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
BIN
libft/ft_strtol.o
Normal file
BIN
libft/ft_strtol.o
Normal file
Binary file not shown.
52
libft/ft_strtrim.c
Normal file
52
libft/ft_strtrim.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strtrim.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/14 16:30:26 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/03/13 14:12:41 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
static int char_in_set(char c, char const *set)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (set[i])
|
||||
{
|
||||
if (set[i] == c)
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
char *ft_strtrim(char const *s1, char const *set)
|
||||
{
|
||||
char *str;
|
||||
size_t i;
|
||||
size_t start;
|
||||
size_t end;
|
||||
|
||||
if (!s1)
|
||||
return (0);
|
||||
start = 0;
|
||||
while (s1[start] && char_in_set(s1[start], set))
|
||||
start++;
|
||||
end = ft_strlen(s1);
|
||||
while (end > start && char_in_set(s1[end - 1], set))
|
||||
end--;
|
||||
str = (char *)malloc(sizeof(*s1) * (end - start + 1));
|
||||
if (!str)
|
||||
return (0);
|
||||
i = 0;
|
||||
while (start < end)
|
||||
str[i++] = s1[start++];
|
||||
str[i] = 0;
|
||||
return (str);
|
||||
}
|
||||
BIN
libft/ft_strtrim.o
Normal file
BIN
libft/ft_strtrim.o
Normal file
Binary file not shown.
37
libft/ft_substr.c
Normal file
37
libft/ft_substr.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_substr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/13 15:40:49 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/11/14 17:07:20 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_substr(char const *s, unsigned int start, size_t len)
|
||||
{
|
||||
char *new_s;
|
||||
size_t i;
|
||||
size_t j;
|
||||
|
||||
new_s = (char *)malloc(sizeof(char) * (len + 1));
|
||||
if (!s || !new_s)
|
||||
return (NULL);
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (s[i])
|
||||
{
|
||||
if (i >= start && j < len)
|
||||
{
|
||||
new_s[j] = s[i];
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
new_s[j] = '\0';
|
||||
return (new_s);
|
||||
}
|
||||
BIN
libft/ft_substr.o
Normal file
BIN
libft/ft_substr.o
Normal file
Binary file not shown.
20
libft/ft_tolower.c
Normal file
20
libft/ft_tolower.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_tolower.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/09 14:09:59 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/14 13:36:02 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_tolower(int c)
|
||||
{
|
||||
if (c >= 65 && c <= 90)
|
||||
c += 32;
|
||||
return (c);
|
||||
}
|
||||
BIN
libft/ft_tolower.o
Normal file
BIN
libft/ft_tolower.o
Normal file
Binary file not shown.
20
libft/ft_toupper.c
Normal file
20
libft/ft_toupper.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_toupper.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/08 16:02:00 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/02/14 13:36:40 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_toupper(int c)
|
||||
{
|
||||
if (c >= 97 && c <= 122)
|
||||
c -= 32;
|
||||
return (c);
|
||||
}
|
||||
BIN
libft/ft_toupper.o
Normal file
BIN
libft/ft_toupper.o
Normal file
Binary file not shown.
BIN
libft/libft.a
Normal file
BIN
libft/libft.a
Normal file
Binary file not shown.
82
libft/libft.h
Normal file
82
libft/libft.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* libft.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/12 10:46:53 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/01/15 21:07:07 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LIBFT_H
|
||||
# define LIBFT_H
|
||||
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
# include <sys/types.h>
|
||||
# include <errno.h>
|
||||
# include <stdint.h>
|
||||
# include <limits.h>
|
||||
# include "../cub3d.h"
|
||||
|
||||
typedef struct s_list
|
||||
{
|
||||
void *content;
|
||||
struct s_list *next;
|
||||
} t_list;
|
||||
|
||||
int ft_isalpha(int c);
|
||||
int ft_isdigit(int c);
|
||||
int ft_isalnum(int c);
|
||||
int ft_isascii(int c);
|
||||
int ft_isprint(int c);
|
||||
int ft_toupper(int c);
|
||||
int ft_tolower(int c);
|
||||
int ft_strcmp(const char *s1, const char *s2);
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n);
|
||||
int ft_strcmp(const char *s1, const char *s2);
|
||||
int ft_memcmp(const void *s1, const void *s2, size_t n);
|
||||
int ft_atoi(const char *nptr);
|
||||
int ft_lstsize(t_list *lst);
|
||||
void *ft_memset(void *s, int c, size_t n);
|
||||
void ft_bzero(void *ptr, size_t len);
|
||||
void *ft_memcpy(void *dest, const void *src, size_t n);
|
||||
void *ft_memmove(void *dest, const void *src, size_t n);
|
||||
void *ft_memchr(const void *s, int c, size_t n);
|
||||
void *ft_calloc(size_t nmemb, size_t size);
|
||||
void ft_putchar_fd(char c, int fd);
|
||||
void ft_putstr_fd(char *s, int fd);
|
||||
void ft_putendl_fd(char *s, int fd);
|
||||
void ft_putnbr_fd(int n, int fd);
|
||||
void ft_striteri(char *s, void (*f)(unsigned int, char*));
|
||||
void ft_lstadd_front(t_list **lst, t_list *new);
|
||||
void ft_lstadd_back(t_list **lst, t_list *new);
|
||||
void ft_lstdelone(t_list *lst, void (*del)(void *));
|
||||
void ft_lstclear(t_list **lst, void (*del)(void *));
|
||||
void ft_lstiter(t_list *lst, void (*f)(void *));
|
||||
size_t ft_strlcpy(char *dst, const char *src, size_t size);
|
||||
size_t ft_strlcat(char *dst, const char *src, size_t size);
|
||||
char *ft_strrchr(const char *s, int c);
|
||||
char *ft_strtok(char *str, const char *delim);
|
||||
char *ft_strnstr(const char *haystack, const char *needle, size_t len);
|
||||
char *ft_strdup(const char *s);
|
||||
char *ft_strstr(const char *haystack, const char *needle);
|
||||
char *ft_substr(char const *s, unsigned int start, size_t len);
|
||||
char *ft_strtrim(char const *s1, char const *set);
|
||||
char *ft_strmapi(const char *s, char (*f)(unsigned int, char));
|
||||
char *ft_strncpy(char *dest, char *src, unsigned int n);
|
||||
void *ft_reallocarray(void *optr, size_t nmemb, size_t size, size_t oldsize);
|
||||
void *ft_realloc(void *ptr, size_t newsize, size_t oldsize);
|
||||
char *ft_itoa(int n);
|
||||
char *ft_strcat(char *dest, const char *src);
|
||||
char *ft_strcpy(char *dest, const char *src);
|
||||
t_list *ft_lstnew(void *content);
|
||||
t_list *ft_lstlast(t_list *lst);
|
||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
|
||||
long ft_strtol(const char *str, char **endptr, int base);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user