This commit is contained in:
kinou-p 2022-02-06 09:42:26 +01:00
commit b8e4e6d879
96 changed files with 2566 additions and 0 deletions

68
libft/Makefile Normal file
View File

@ -0,0 +1,68 @@
NAME = libft.a
SRCS = ft_memset.c \
ft_bzero.c \
ft_memcpy.c \
ft_memccpy.c \
ft_memmove.c \
ft_memchr.c \
ft_memcmp.c \
ft_strlen.c \
ft_isalpha.c \
ft_isdigit.c \
ft_isalnum.c \
ft_isascii.c \
ft_isprint.c \
ft_toupper.c \
ft_tolower.c \
ft_strchr.c \
ft_strrchr.c \
ft_strncmp.c \
ft_strlcpy.c \
ft_strlcat.c \
ft_strnstr.c \
ft_atoi.c \
ft_calloc.c \
ft_strdup.c \
ft_substr.c \
ft_strtrim.c \
ft_split.c \
ft_strjoin.c \
ft_itoa.c \
ft_strmapi.c \
ft_putchar_fd.c \
ft_putstr_fd.c \
ft_putendl_fd.c \
ft_putnbr_fd.c \
get_next_line.c \
get_next_line_utils.c
OBJS = ${SRCS:.c=.o}
BONUS_C = 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_lstmap.c ft_lstbeforelast.c
BONUS_O = ${BONUS_C:.c=.o}
CC = gcc
CFLAGS = -Wall -Wextra
RM = rm -rf
.c.o:
${CC} ${CFLAGS} -c $< -o ${<:.c=.o}
${NAME}:${OBJS}
ar -rcs ${NAME} ${OBJS}
all: ${NAME}
bonus: all
${CC} ${CFLAGS} -c ${BONUS_C}
ar -rcs ${NAME} ${BONUS_O}
clean:
${RM} ${OBJS}
${RM} ${BONUS_O}
fclean: clean
${RM} ${NAME}
re: fclean all
.PHONY: all clean fclean re bonus

39
libft/ft_atoi.c Normal file
View File

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:09:17 by apommier #+# #+# */
/* Updated: 2022/01/18 06:50:22 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
long ft_atoi(const char *nptr)
{
int i;
long nbr;
long minus;
minus = 1;
nbr = 0;
i = 0;
while ((nptr[i] >= 9 && nptr[i] <= 13) || nptr[i] == 32)
i++;
if (nptr[i] == '+')
i++;
else if (nptr[i] == '-')
{
i++;
minus = -1;
}
while (nptr[i] >= '0' && nptr[i] <= '9')
{
nbr = nbr * 10 + nptr[i] - '0';
i++;
}
return (minus * nbr);
}

BIN
libft/ft_atoi.o Normal file

Binary file not shown.

28
libft/ft_bzero.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:09:48 by apommier #+# #+# */
/* Updated: 2022/01/17 11:26:30 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_bzero(void *s, size_t n)
{
char *p;
int i;
p = (char *)s;
i = 0;
while (n != 0)
{
p[i] = 0;
i++;
n--;
}
}

BIN
libft/ft_bzero.o Normal file

Binary file not shown.

31
libft/ft_calloc.c Normal file
View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:09:57 by apommier #+# #+# */
/* Updated: 2022/01/17 21:18:04 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
char *new;
int i;
i = 0;
new = malloc(size * nmemb);
if (new)
{
while (size * nmemb - i)
{
new[i] = 0;
i++;
}
}
return ((void *)new);
}

BIN
libft/ft_calloc.o Normal file

Binary file not shown.

23
libft/ft_isalnum.c Normal file
View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:08 by apommier #+# #+# */
/* Updated: 2020/12/12 09:26:43 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isalnum(int c)
{
if (c <= '9' && c >= '0')
return (1);
else if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
return (1);
else
return (0);
}

BIN
libft/ft_isalnum.o Normal file

Binary file not shown.

21
libft/ft_isalpha.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:17 by apommier #+# #+# */
/* Updated: 2020/12/12 09:28:12 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isalpha(int c)
{
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
return (1);
else
return (0);
}

BIN
libft/ft_isalpha.o Normal file

Binary file not shown.

21
libft/ft_isascii.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isascii.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:30 by apommier #+# #+# */
/* Updated: 2020/12/11 18:11:18 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isascii(int c)
{
if (c >= 0 && c <= 127)
return (1);
else
return (0);
}

BIN
libft/ft_isascii.o Normal file

Binary file not shown.

21
libft/ft_isdigit.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isdigit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:39 by apommier #+# #+# */
/* Updated: 2020/12/12 09:27:06 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isdigit(int c)
{
if (c <= '9' && c >= '0')
return (1);
else
return (0);
}

BIN
libft/ft_isdigit.o Normal file

Binary file not shown.

21
libft/ft_isprint.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isprint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:55 by apommier #+# #+# */
/* Updated: 2020/12/11 18:11:43 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isprint(int c)
{
if (c > 31 && c < 127)
return (1);
else
return (0);
}

BIN
libft/ft_isprint.o Normal file

Binary file not shown.

59
libft/ft_itoa.c Normal file
View File

@ -0,0 +1,59 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/08 18:20:19 by apommier #+# #+# */
/* Updated: 2022/01/17 11:28:01 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static char *fill(long n, int j, int minus)
{
char *dest;
j += minus;
dest = (char *)malloc(sizeof(char) * (j + 1));
if (dest == 0)
return (0);
dest[j] = 0;
if (n == 0)
dest[j - 1] = '0';
while (n)
{
dest[j - 1] = n % 10 + '0';
j--;
n /= 10;
}
if (minus)
dest[j - 1] = '-';
return (dest);
}
char *ft_itoa(int n)
{
long i;
long k;
int j;
int minus;
k = n;
minus = 0;
j = 1;
if (k < 0)
{
minus = 1;
k = k * -1;
}
i = k;
while (k >= 10)
{
k /= 10;
j++;
}
return (fill(i, j, minus));
}

BIN
libft/ft_itoa.o Normal file

Binary file not shown.

21
libft/ft_lstadd_back.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_back.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/09 19:30:14 by apommier #+# #+# */
/* Updated: 2020/12/11 15:32:53 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_back(t_list **alst, t_list *new)
{
if (*alst == 0)
*alst = new;
else
ft_lstlast(*alst)->next = new;
}

19
libft/ft_lstadd_front.c Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_front.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/09 01:31:45 by apommier #+# #+# */
/* Updated: 2020/12/11 17:34:24 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_front(t_list **alst, t_list *new)
{
new->next = *alst;
*alst = new;
}

28
libft/ft_lstbeforelast.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstbeforelast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/09 19:16:55 by apommier #+# #+# */
/* Updated: 2022/01/17 11:28:22 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstbeforelast(t_list *lst)
{
t_list *save;
save = 0;
if (!lst)
return (0);
while (lst->next)
{
save = lst;
lst = lst->next;
}
return (save);
}

28
libft/ft_lstclear.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/09 19:58:04 by apommier #+# #+# */
/* Updated: 2022/01/17 11:28:39 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *chr;
chr = *lst;
while (*lst)
{
chr = (*lst)->next;
del((*lst)->nbr);
free(*lst);
*lst = chr;
}
lst = 0;
}

21
libft/ft_lstdelone.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdelone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/09 19:54:40 by apommier #+# #+# */
/* Updated: 2020/12/12 09:10:11 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstdelone(t_list *lst, void (*del)(void*))
{
if (!lst)
return ;
del(lst->nbr);
free(lst);
}

22
libft/ft_lstiter.c Normal file
View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstiter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/09 20:14:47 by apommier #+# #+# */
/* Updated: 2020/12/11 17:47:39 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstiter(t_list *lst, void (*f)(void *))
{
while (lst)
{
f(lst->nbr);
lst = lst->next;
}
}

22
libft/ft_lstlast.c Normal file
View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/09 19:16:55 by apommier #+# #+# */
/* Updated: 2021/11/26 01:21:39 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstlast(t_list *lst)
{
if (!lst)
return (0);
while (lst->next)
lst = lst->next;
return (lst);
}

33
libft/ft_lstmap.c Normal file
View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/11 00:10:12 by apommier #+# #+# */
/* Updated: 2020/12/13 22:37:30 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
{
t_list *new;
t_list *begin;
begin = 0;
while (lst)
{
new = ft_lstnew(f(lst->nbr));
if (!new)
{
ft_lstclear(&begin, *del);
return (0);
}
ft_lstadd_back(&begin, new);
lst = lst->next;
}
return (begin);
}

26
libft/ft_lstnew.c Normal file
View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/09 01:06:20 by apommier #+# #+# */
/* Updated: 2022/01/17 11:29:09 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void *content)
{
t_list *new;
new = (t_list *)malloc(sizeof(t_list));
if (!new)
return (0);
new->swap = 0;
new->nbr = content;
new->next = 0;
return (new);
}

26
libft/ft_lstsize.c Normal file
View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/09 03:24:50 by apommier #+# #+# */
/* Updated: 2020/12/11 15:33:49 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int i;
i = 0;
while (lst)
{
lst = lst->next;
i++;
}
return (i);
}

32
libft/ft_memccpy.c Normal file
View File

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:11:04 by apommier #+# #+# */
/* Updated: 2022/01/17 11:29:38 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dest, const void *src, int c, size_t n)
{
char *p;
const char *p1;
size_t i;
i = 0;
p = (char *)dest;
p1 = (const char *)src;
while (i < n)
{
p[i] = p1[i];
if ((unsigned char)p[i] == (unsigned char)c)
return (dest + i + 1);
i++;
}
return (0);
}

BIN
libft/ft_memccpy.o Normal file

Binary file not shown.

28
libft/ft_memchr.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:11:39 by apommier #+# #+# */
/* Updated: 2022/01/17 11:29:51 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *str;
str = (unsigned char *)s;
while (n)
{
if ((unsigned char)c == *str)
return (str);
n--;
str++;
}
return (0);
}

BIN
libft/ft_memchr.o Normal file

Binary file not shown.

28
libft/ft_memcmp.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:11:51 by apommier #+# #+# */
/* Updated: 2022/01/17 11:30:32 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
int i;
i = 0;
while (n)
{
if (((unsigned char *)s1)[i] != ((unsigned char *)s2)[i])
return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
n--;
i++;
}
return (0);
}

BIN
libft/ft_memcmp.o Normal file

Binary file not shown.

32
libft/ft_memcpy.c Normal file
View File

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:12:03 by apommier #+# #+# */
/* Updated: 2022/01/17 11:30:43 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
size_t i;
char *p;
const char *p1;
if (!dest && !src)
return (dest);
p = (char *)dest;
p1 = (const char *)src;
i = 0;
while (i < n)
{
p[i] = p1[i];
i++;
}
return (dest);
}

BIN
libft/ft_memcpy.o Normal file

Binary file not shown.

39
libft/ft_memmove.c Normal file
View File

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:12:14 by apommier #+# #+# */
/* Updated: 2022/01/17 11:31:05 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t i;
i = 0;
if (!dest && !src)
return (dest);
if (dest > src)
{
while (n)
{
((unsigned char *)dest)[n - 1] = ((unsigned char *)src)[n - 1];
n--;
}
}
else
{
while (i < n)
{
((unsigned char *)dest)[i] = ((unsigned char *)src)[i];
i++;
}
}
return (dest);
}

BIN
libft/ft_memmove.o Normal file

Binary file not shown.

29
libft/ft_memset.c Normal file
View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:12:24 by apommier #+# #+# */
/* Updated: 2022/01/17 11:31:28 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memset(void *s, int c, size_t n)
{
int i;
unsigned char *p;
i = 0;
p = (unsigned char *)s;
while (n > 0)
{
p[i] = (unsigned char)c;
i++;
n--;
}
return (s);
}

BIN
libft/ft_memset.o Normal file

Binary file not shown.

18
libft/ft_putchar_fd.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/08 23:11:29 by apommier #+# #+# */
/* Updated: 2020/12/11 17:02:13 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putchar_fd(char c, int fd)
{
write(fd, &c, 1);
}

BIN
libft/ft_putchar_fd.o Normal file

Binary file not shown.

21
libft/ft_putendl_fd.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putendl_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/08 23:22:10 by apommier #+# #+# */
/* Updated: 2020/12/11 17:14:52 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putendl_fd(char *s, int fd)
{
if (s == 0)
return ;
write(fd, s, ft_strlen(s));
ft_putchar_fd('\n', fd);
}

BIN
libft/ft_putendl_fd.o Normal file

Binary file not shown.

28
libft/ft_putnbr_fd.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/08 23:25:57 by apommier #+# #+# */
/* Updated: 2022/01/17 11:31:56 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
long nbr;
nbr = n;
if (nbr < 0)
{
ft_putchar_fd('-', fd);
nbr *= -1;
}
if (nbr >= 10)
ft_putnbr_fd(nbr / 10, fd);
ft_putchar_fd(nbr % 10 + '0', fd);
}

BIN
libft/ft_putnbr_fd.o Normal file

Binary file not shown.

20
libft/ft_putstr_fd.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/08 23:15:25 by apommier #+# #+# */
/* Updated: 2020/12/11 17:15:10 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putstr_fd(char *s, int fd)
{
if (s == 0)
return ;
write(fd, s, ft_strlen(s));
}

BIN
libft/ft_putstr_fd.o Normal file

Binary file not shown.

80
libft/ft_split.c Normal file
View File

@ -0,0 +1,80 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_split.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/07 00:54:12 by apommier #+# #+# */
/* Updated: 2022/01/21 08:09:38 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int fill_tab(char *s, char c, char **dest, size_t index)
{
int i;
i = 0;
while (s[i] != c && s[i])
i++;
dest[index] = (char *)ft_calloc(i + 1, sizeof(char));
if (dest[index] == 0)
return (0);
i = 0;
while (s[i] != c && s[i])
{
dest[index][i] = s[i];
i++;
}
return (1);
}
static void call(char *s, char c, char **dest, int j)
{
int index;
int k;
k = 0;
index = 0;
while (j > index)
{
while (s[k] == c && s[k])
k++;
if (!s[k])
return ;
fill_tab(s + k, c, dest, index);
index++;
while (s[k] != c && s[k])
k++;
}
}
char **ft_split(char const *s, char c)
{
int i;
int j;
char **dest;
j = 0;
i = 0;
if (!s)
return (0);
while (s[i] == c && s[i])
i++;
while (s[i])
{
while (s[i] != c && s[i])
i++;
j++;
while (s[i] == c && s[i])
i++;
}
dest = (char **)ft_calloc(sizeof(char *), (i + j));
if (!dest)
return (0);
dest[j] = 0;
call((char *)s, c, dest, j);
return (dest);
}

BIN
libft/ft_split.o Normal file

Binary file not shown.

28
libft/ft_strchr.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/12 13:57:59 by apommier #+# #+# */
/* Updated: 2022/01/17 21:18:59 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
char *str;
if (!s)
return ("no s");
str = (char *)s;
while ((*str != c) && (*str != 0))
str++;
if (*str == c)
return ((char *)str);
else
return (0);
}

BIN
libft/ft_strchr.o Normal file

Binary file not shown.

34
libft/ft_strdup.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:12:43 by apommier #+# #+# */
/* Updated: 2020/12/11 18:35:10 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
int i;
char *sdup;
i = 0;
while (s[i])
i++;
sdup = malloc(sizeof(char) * (i + 1));
if (sdup == 0)
return (0);
i = 0;
while (s[i])
{
sdup[i] = s[i];
i++;
}
sdup[i] = 0;
return (sdup);
}

BIN
libft/ft_strdup.o Normal file

Binary file not shown.

41
libft/ft_strjoin.c Normal file
View File

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/20 21:44:01 by apommier #+# #+# */
/* Updated: 2022/01/21 08:07:04 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char *save, char *s2)
{
char *dest;
int i;
int j;
i = 0;
j = 0;
if (!save && !s2)
return (0);
dest = malloc(ft_strlen(save) + ft_strlen(s2) + 1);
while (save && save[i])
{
dest[j] = save[i];
j++;
i++;
}
i = 0;
while (s2 && s2[i])
{
dest[j] = s2[i];
j++;
i++;
}
dest[j] = 0;
return (dest);
}

BIN
libft/ft_strjoin.o Normal file

Binary file not shown.

34
libft/ft_strlcat.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:12:57 by apommier #+# #+# */
/* Updated: 2020/12/12 15:40:58 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t i;
size_t k;
if (!size)
return (ft_strlen(src));
i = 0;
k = ft_strlen(dst);
if (k >= size)
return (ft_strlen(src) + size);
while (size - k - 1 && src[i])
{
dst[k + i] = src[i];
i++;
size--;
}
dst[k + i] = 0;
return (k + ft_strlen(src));
}

BIN
libft/ft_strlcat.o Normal file

Binary file not shown.

36
libft/ft_strlcpy.c Normal file
View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:13:07 by apommier #+# #+# */
/* Updated: 2022/01/17 11:38:48 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t size)
{
int i;
int j;
j = 0;
i = 0;
if (!src || !dst)
return (0);
while (src[i])
i++;
if (!size)
return (i);
while (size - 1 && src[j] != 0)
{
dst[j] = src[j];
j++;
size--;
}
dst[j] = 0;
return (i);
}

BIN
libft/ft_strlcpy.o Normal file

Binary file not shown.

25
libft/ft_strlen.c Normal file
View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:13:19 by apommier #+# #+# */
/* Updated: 2022/01/17 21:12:05 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlen(const char *s)
{
size_t i;
i = 0;
if (!s)
return (0);
while (s[i] != 0)
i++;
return (i);
}

BIN
libft/ft_strlen.o Normal file

Binary file not shown.

32
libft/ft_strmapi.c Normal file
View File

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/08 19:03:09 by apommier #+# #+# */
/* Updated: 2022/01/17 11:39:05 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *dest;
int i;
if (!s)
return (0);
i = 0;
dest = (char *)ft_calloc(ft_strlen(s) + 1, sizeof(char));
if (!dest)
return (0);
while (s[i])
{
dest[i] = f(i, s[i]);
i++;
}
return (dest);
}

BIN
libft/ft_strmapi.o Normal file

Binary file not shown.

28
libft/ft_strncmp.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:13:31 by apommier #+# #+# */
/* Updated: 2022/01/17 11:39:13 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
int i;
i = 0;
while (n && (s1[i] || s2[i]))
{
if (s1[i] != s2[i])
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
n--;
i++;
}
return (0);
}

BIN
libft/ft_strncmp.o Normal file

Binary file not shown.

41
libft/ft_strnstr.c Normal file
View File

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:13:42 by apommier #+# #+# */
/* Updated: 2022/01/17 11:39:28 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *big, const char *little, size_t len)
{
int i;
int j;
i = 0;
if (!little[i])
return ((char *)big);
if (!little[i])
return ((char *)big);
while (big[i] && len - i)
{
j = 0;
if (little[j] != big[i])
i++;
else
{
while (little[j] == big[i + j] && little[j] && len - i - j)
j++;
if (little[j] == 0)
return ((char *)&big[i]);
else
i++;
}
}
return (0);
}

BIN
libft/ft_strnstr.o Normal file

Binary file not shown.

35
libft/ft_strrchr.c Normal file
View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:13:52 by apommier #+# #+# */
/* Updated: 2022/01/17 11:39:37 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
char *str;
char *last;
str = (char *)s;
if (c == 0)
{
while (*str)
str++;
return (str);
}
last = 0;
while (*str)
{
if (*str == c)
last = str;
str++;
}
return (last);
}

BIN
libft/ft_strrchr.o Normal file

Binary file not shown.

72
libft/ft_strtrim.c Normal file
View File

@ -0,0 +1,72 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 23:52:05 by apommier #+# #+# */
/* Updated: 2022/01/17 11:40:17 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int is_set(char const *set, char c)
{
int i;
i = 0;
while (set[i])
{
if (set[i] == c)
return (1);
i++;
}
return (0);
}
static int len_dest(const char *s1, char const *set)
{
int len;
int j;
int i;
i = 0;
j = 0;
len = ft_strlen(s1);
while (is_set(set, s1[i]))
i++;
while (is_set(set, s1[len - j - 1]))
j++;
len = len - j - i;
if (len < 0)
len = 0;
return (len);
}
char *ft_strtrim(char const *s1, char const *set)
{
int j;
int i;
int len;
char *dest;
i = 0;
j = 0;
if (!s1)
return (0);
len = len_dest(s1, set);
dest = ft_calloc(len + 1, 1);
if (!dest)
return (0);
while (is_set(set, s1[i]))
i++;
while (s1[i] && len - j && len > 0)
{
dest[j] = s1[i];
i++;
j++;
}
return (dest);
}

BIN
libft/ft_strtrim.o Normal file

Binary file not shown.

39
libft/ft_substr.c Normal file
View File

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_substr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 22:54:40 by apommier #+# #+# */
/* Updated: 2020/12/16 16:45:34 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_substr(char const *s, unsigned int start, size_t len)
{
char *dest;
unsigned int i;
if (!s)
return (0);
i = 0;
dest = malloc(1 * len + 1);
if (dest == 0)
return (0);
if (start > ft_strlen(s) || len == 0)
{
dest[i] = 0;
return (dest);
}
while (len && s[i + start])
{
dest[i] = s[i + start];
len--;
i++;
}
dest[i] = 0;
return (dest);
}

BIN
libft/ft_substr.o Normal file

Binary file not shown.

20
libft/ft_tolower.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tolower.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:14:05 by apommier #+# #+# */
/* Updated: 2020/11/29 17:20:51 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_tolower(int c)
{
if (c >= 65 && c <= 90)
c = c + 32;
return (c);
}

BIN
libft/ft_tolower.o Normal file

Binary file not shown.

20
libft/ft_toupper.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_toupper.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:14:15 by apommier #+# #+# */
/* Updated: 2020/11/29 17:21:12 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_toupper(int c)
{
if (c >= 'a' && c <= 'z')
c = c - 32;
return (c);
}

BIN
libft/ft_toupper.o Normal file

Binary file not shown.

100
libft/get_next_line.c Normal file
View File

@ -0,0 +1,100 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kinou <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/23 07:55:17 by kinou #+# #+# */
/* Updated: 2021/11/01 10:21:35 by kinou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_free(char *save, int *end)
{
if (!*end)
{
free(save);
free(end);
return (0);
}
free(end);
return (save);
}
char *set_line(char *line, char *save)
{
int i;
i = 0;
line = ft_strjoin(save, 0);
while (line[i] && line[i] != '\n')
i++;
if (line[i] == '\n')
{
while (line[i++])
line[i] = '\0';
}
return (line);
}
char *set_save(char *save)
{
char *delete;
int i;
i = 0;
delete = save;
while (save[i] && save[i] != '\n')
i++;
if (save[i] != '\n')
i = 0;
save = ft_strjoin((save + i + 1), 0);
free(delete);
return (save);
}
char *next_line(char *save, int *end, int fd)
{
char *delete;
char *dest;
while (!ft_strchr(save, '\n') && *end > 0)
{
dest = ft_calloc(1, 1 + 1);
*end = read(fd, dest, 1);
delete = save;
save = ft_strjoin(save, dest);
free(delete);
free(dest);
}
return (save);
}
char *get_next_line(int fd)
{
static char *save = NULL;
int *end;
char *line;
line = 0;
if (fd < 0)
return (0);
end = malloc(sizeof(int *));
*end = 1;
if (save == NULL)
save = ft_calloc(1, 1);
save = next_line(save, end, fd);
line = set_line(line, save);
if (ft_strlen(line) > 0)
{
save = set_save(save);
save = ft_free(save, end);
return (line);
}
free(line);
save = ft_free(save, end);
return (0);
}

19
libft/get_next_line.h Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/14 05:58:49 by apommier #+# #+# */
/* Updated: 2022/01/17 21:45:15 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef GET_NEXT_LINE_H
# define GET_NEXT_LINE_H
char *get_next_line(int fd);
char *ft_strjoin(char *save, char *s2);
#endif

BIN
libft/get_next_line.o Normal file

Binary file not shown.

View File

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/14 06:05:54 by apommier #+# #+# */
/* Updated: 2022/01/20 21:58:39 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char *save, char *s2)
{
char *dest;
int i;
int j;
i = 0;
j = 0;
if (!save && !s2)
return (0);
dest = malloc(ft_strlen(save) + ft_strlen(s2) + 1);
while (save && save[i])
{
dest[j] = save[i];
j++;
i++;
}
i = 0;
while (s2 && s2[i])
{
dest[j] = s2[i];
j++;
i++;
}
dest[j] = 0;
return (dest);
}

BIN
libft/get_next_line_utils.o Normal file

Binary file not shown.

BIN
libft/libft.a Normal file

Binary file not shown.

76
libft/libft.h Normal file
View File

@ -0,0 +1,76 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libft.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/11 03:21:27 by apommier #+# #+# */
/* Updated: 2022/01/20 21:46:04 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIBFT_H
# define LIBFT_H
# include <stdlib.h>
# include <unistd.h>
# include "get_next_line.h"
typedef struct t_slist
{
void *nbr;
int index;
int swap;
struct t_slist *next;
} t_list;
void *ft_memset(void *s, int c, size_t n);
void ft_bzero(void *s, size_t n);
void *ft_memcpy(void *dest, const void *src, size_t n);
void *ft_memccpy(void *dest, const void *src, int c, 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);
int ft_memcmp(const void *s1, const void *s2, size_t n);
size_t ft_strlen(const char *s);
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);
char *ft_strchr(const char *s, int c);
char *ft_strrchr(const char *s, int c);
int ft_strncmp(const char *s1, const char *s2, size_t n);
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_strjoin(char *save, char *s2);
char *ft_strnstr(const char *big, const char *little, size_t len);
long ft_atoi(const char *nptr);
void *ft_calloc(size_t nmenb, size_t size);
char *ft_strdup(const char *s);
char *ft_substr(char const *s, unsigned int start, size_t len);
char *ft_strtrim(char const *s1, char const *set);
char **ft_split(char const *s, char c);
char *ft_itoa(int n);
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
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);
t_list *ft_lstnew(void *content);
void ft_lstadd_front(t_list **alst, t_list *new);
int ft_lstsize(t_list *lst);
t_list *ft_lstlast(t_list *lst);
void ft_lstadd_back(t_list **alst, 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 *));
t_list *ft_lstmap(t_list *lst, void *(*f)(void *),
void (*del)(void *));
t_list *ft_lstbeforelast(t_list *lst);
#endif

228
main.c Normal file
View File

@ -0,0 +1,228 @@
#include <mlx.h>
#include "./libft/libft.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
//#include "mlx_int.h"
typedef struct s_data {
void *mlx;
void *mlx_win;
char **map_tab;
int item;
int move;
int bear;
} t_data;
void quit_game(t_data *img)
{
int i;
int j;
int *image;
i = 0;
j = 0;
printf("quit game\n");
image = mlx_new_image(img->mlx, 13 * 32, 10 * 32);
//mlx_put_image_to_window(img->mlx, img->mlx_win, image, 0, 0)
mlx_clear_window(img->mlx, img->mlx_win);
mlx_destroy_window(img->mlx, img->mlx_win);
if (img->mlx)
free(img->mlx);
//if (img->mlx_win)
//free(img->mlx_win);
while (img->map_tab[i])
free(img->map_tab[i++]);
//if (img->map_tab);
free(img->map_tab);
exit(1);
}
int *choose_bear(t_data *img)
{
int *buffer;
int img_width;
int img_height;
buffer = 0;
if (img->bear == 119)
buffer = mlx_xpm_file_to_image(img->mlx, "./sprite/back_bear.xpm", &img_width, &img_height);
else if (img->bear == 97)
buffer = mlx_xpm_file_to_image(img->mlx, "./sprite/left_bear.xpm", &img_width, &img_height);
else if (img->bear == 100)
buffer = mlx_xpm_file_to_image(img->mlx, "./sprite/right_bear.xpm", &img_width, &img_height);
else
buffer = mlx_xpm_file_to_image(img->mlx, "./sprite/front_bear.xpm", &img_width, &img_height);
if (buffer == 0)
return (0);
return (buffer);
}
void print_case(char type, t_data *img, int y, int x)
{
int *buffer;
int img_width;
int img_height;
if (type == '1')
buffer = mlx_xpm_file_to_image(img->mlx, "./sprite/snow_tree.xpm", &img_width, &img_height);
else if (type == 'P')
buffer = choose_bear(img);
else if (type == 'C')
buffer = mlx_xpm_file_to_image(img->mlx, "./sprite/honey.xpm", &img_width, &img_height);
else if (type == 'E')
buffer = mlx_xpm_file_to_image(img->mlx, "./sprite/exit.XPM", &img_width, &img_height);
else
buffer = mlx_xpm_file_to_image(img->mlx, "./sprite/back.xpm", &img_width, &img_height);
mlx_put_image_to_window(img->mlx, img->mlx_win, buffer, x * 32, y * 32);
//free(buffer);
mlx_destroy_image(img->mlx, buffer);
//free(buffer);
}
void print_map(char **map, t_data *img)
{
int i;
int j;
i = 0;
j = 0;
img->item = 0;
while (map[j])
{
i = 0;
while (map[j][i])
{
print_case(map[j][i], img, j, i);
if (map[j][i] == 'C')
img->item++;
i++;
}
j++;
}
}
int change_map(t_data *img, int y, int x, char *change)
{
if (*change == '0' || *change == 'C')
{
if (*change == 'C')
img->item--;
img->move++;
printf("%d\n", img->move);
img->map_tab[y][x] = '0';
*change = 'P';
}
else if (*change == 'E')
{
img->move++;
printf("%d\n", img->move);
if (img->item <= 0)
quit_game(img);
}
}
/*void choose_bear(t_data *img, int type)
{
img->bear = 0;
if (type == 119)
;
else if (type == 97)
change_map(img, j, i, &map[j][i - 1]);
else if (type == 115)
change_map(img, j, i, &map[j + 1][i]);
else if (type == 100)
change_map(img, j, i, &map[j][i + 1]);
}*/
int is_good(char **map, int type, t_data *img)
{
int j;
int i;
i = 0;
j = 0;
while (map[j] && map[j][i] != 'P')
{
i = 0;
while (map[j][i] && map[j][i] != 'P')
i++;
if (map[j][i] != 'P')
j++;
}
img->bear = type;
if (type == 119)
change_map(img, j, i, &map[j - 1][i]);
else if (type == 97)
change_map(img, j, i, &map[j][i - 1]);
else if (type == 115)
change_map(img, j, i, &map[j + 1][i]);
else if (type == 100)
change_map(img, j, i, &map[j][i + 1]);
else
return (0);
return 1;
}
int test(int code, t_data *img)
{
printf("code = %d\n", code);
if (code == 65307)
quit_game(img);
is_good(img->map_tab, code, img);
print_map(img->map_tab, img);
}
int main(int argc, char **argv)
{
t_data img;
char *map = 0;
char **map_tab;
int fd = 0;
char *swap = 0;
char *del;
img.bear = 0;
img.move = 0;
img.mlx = mlx_init();
img.mlx_win = mlx_new_window(img.mlx, 13 * 32, 10 * 32, "Hungry Bear");
fd = open(argv[1], O_RDONLY);
swap = get_next_line(fd);
while (swap)
{
del = map;
map = ft_strjoin(map, swap);
free(swap);
swap = get_next_line(fd);
free(del);
}
img.map_tab = ft_split(map, '\n');
print_map(img.map_tab, &img);
free(map);
mlx_key_hook(img.mlx_win, &test, &img);
mlx_loop(img.mlx);
printf("heeeeeeeeeeeeeeerreeeee\n\n\n\n");
}
/*img.img = mlx_xpm_file_to_image(mlx, "./sprite/back.xpm", &img_width, &img_height);
if (!img.img)
return 0;
//img.addr = mlx_get_data_addr(img.img, &img.bits_per_pixel, &img.line_length, &img.endian);
//my_mlx_pixel_put(&img, 5, 5, 0x00FF0000);
/*while (i != 320)
{
j = 0;
while (j != 320)
{
mlx_put_image_to_window(mlx, mlx_win, img.img, i, j);
j += 32;
}
i += 32;
}*/
//offset = (1920 * line_length + 1080 * (bits_per_pixel / 8));

10
map.ber Normal file
View File

@ -0,0 +1,10 @@
1111111111111
1E110C00C0001
1000P01011001
10C011C001C01
10C011C001C01
10C011C001C01
10C011C001C01
10C011C001C01
10C011C001C01
1111111111111

41
sprite/back.xpm Normal file
View File

@ -0,0 +1,41 @@
/* XPM */
static char *_49dd254199246a1977f20555a1f9063nPJ1VTqEOaIleAR1[] = {
/* columns rows colors chars-per-pixel */
"32 32 3 1 ",
" c #6E924D",
". c #4D733E",
"X c #87B055",
/* pixels */
" ",
" ",
" ",
" ",
" ",
" . ",
" . . ",
" . ",
" ",
" ",
" X ",
" XX ",
" X XX X ",
" X X.XX ",
" X X .XX. ",
" X X .. ",
" X ",
" ",
" ",
" X ",
" X X ",
" X ",
" ",
" ",
" ",
" . ",
" . . ",
" . ",
" X ",
" X X ",
" X X ",
" X "
};

77
sprite/back_bear.xpm Normal file
View File

@ -0,0 +1,77 @@
/* XPM */
static char *a0abf2d8550b4988d16f9b5953af240c1ODMacj9TddNcz6M[] = {
/* columns rows colors chars-per-pixel */
"32 32 39 1 ",
" c #6E924D",
". c #6D914D",
"X c #6A8E4B",
"o c black",
"O c #698D4B",
"+ c #6B904C",
"@ c #5C8245",
"# c #743F39",
"$ c #70944E",
"% c #B86F50",
"& c #71954E",
"* c #7EA552",
"= c #72964E",
"- c #81A853",
"; c #72974E",
": c #769B50",
"> c #73984F",
", c #6E934D",
"< c #7CA352",
"1 c #6F934D",
"2 c #7DA452",
"3 c #789E50",
"4 c #72964F",
"5 c #74994F",
"6 c #7CA351",
"7 c #6C904C",
"8 c #668B4A",
"9 c #5C8145",
"0 c #668A4A",
"q c #70954E",
"w c #6A8F4B",
"e c #71964E",
"r c #7EA452",
"t c #80A853",
"y c #81A854",
"u c #72974F",
"i c #83AB54",
"p c #759B50",
"a c #7EA553",
/* pixels */
" ",
" ",
" ",
" ",
" .X ",
" ooooo Oooooo ",
" ooooo +@ooooo ",
" o#####ooooo#####o ",
" o###ooooooooo###o ",
" o###ooooooooo###o ",
" oo#oo###o###o###oo#oo ",
" $ oooo%%#%%%###%%%#%%oooo ",
" &*&oooo%%#%%%###%%%#%%oooo ",
" =-;ooo%%%%%%%%%%%%%%%%%ooo ",
" =-:o##%##%%%%%%%%%%%##%##o ",
" &*:o#####%%%%%%%%%%%#####o ",
" &>o#####%%%%%%%%%%%#####o ",
" o###%%%%%#%%%#%%%%%###o ",
" o##o%%%###%%%###%%%o##o,& ",
" o##o%%%###%%%###%%%o##o><>1",
" o##ooo%%%#ooo#%%%ooo##o23*4",
" oo#oo#%%ooooo%%#oo#oo15651",
" oo#oo#%%ooooo%%#oo#oo 1&1 ",
" oo####ooo###ooo####oo ",
" oo###ooooooooooo###oo ",
" oo###ooooooooooo###oo ",
" 7oo#oo#oo oo#oo#oo ",
" 890. q ",
" .w. &erq ",
" =t:y& ",
" uipaq ",
" ui>e, "
};

42
sprite/exit.XPM Normal file
View File

@ -0,0 +1,42 @@
/* XPM */
static char *_643724825348[] = {
/* columns rows colors chars-per-pixel */
"32 32 4 1 ",
" c #6E924D",
". c #4D733E",
"X c #87B055",
"o c black",
/* pixels */
" . ",
" . ",
" ",
" X X ",
" XX .X ",
" . . ",
" .. .. . ",
" .. .oooooooooo. oooo.. ",
" .oooooooooooooooooo ",
" X oooooooooooooooooo. ",
" X X .oooooooooooooooooo ",
" .X ooooooooooooooooo. X ",
" ooooooooooooooooo. XX ",
" oooooooooooooooo. ",
" .ooooooooooooooooo. ",
" ooooooooooooooooooo ",
" .oooooooooooooooooo ",
" ooooooooooooooooo. ",
" .oooooooooooooooo. ",
" .ooooooooooooooooo. ",
" .ooooooooooooooooo. ",
" ooooooooooooooooooo X",
" .oooooooooooooooooo X. ",
" .ooooo.ooooooooooo. . ",
" ..o.. .oo....oo.o ",
" . ",
" . ",
" X ",
" .X X ",
" . XX ",
" . ",
" "
};

80
sprite/front_bear.xpm Normal file
View File

@ -0,0 +1,80 @@
/* XPM */
static char *_d0d658a3d084d86c4c05efb7288e42aDV5VnM4eFjwuSWPd[] = {
/* columns rows colors chars-per-pixel */
"32 32 42 1 ",
" c #6E924D",
". c #6D914D",
"X c #6A8E4B",
"o c black",
"O c #698D4B",
"+ c #6B904C",
"@ c #5C8245",
"# c #B86F50",
"$ c #743F39",
"% c #70944E",
"& c #71954E",
"* c #7EA552",
"= c #72964E",
"- c #81A853",
"; c #72974E",
": c white",
"> c #E8B796",
", c #769B50",
"< c #73984F",
"1 c #C28569",
"2 c #6E934D",
"3 c #7CA352",
"4 c #6F934D",
"5 c #7DA452",
"6 c #789E50",
"7 c #72964F",
"8 c #74994F",
"9 c #7CA351",
"0 c #6C904C",
"q c #668B4A",
"w c #5C8145",
"e c #668A4A",
"r c #70954E",
"t c #6A8F4B",
"y c #71964E",
"u c #7EA452",
"i c #80A853",
"p c #81A854",
"a c #72974F",
"s c #83AB54",
"d c #759B50",
"f c #7EA553",
/* pixels */
" ",
" ",
" ",
" ",
" .X ",
" ooooo Oooooo ",
" ooooo +@ooooo ",
" o###$$ooooo$$###o ",
" o##o$$#$$$#$$o##o ",
" o##o$$#$$$#$$o##o ",
" ooo$$$#########$$$ooo ",
" % o$$ooo####$$$####ooo$$o ",
" &*&o$$ooo####$$$####ooo$$o ",
" =-;o$$o$$o::o>>>o::o$$o$$o ",
" =-,o$$o##ooo>>>>>ooo##o$$o ",
" &*,o$$o##ooo>>>>>ooo##o$$o ",
" &<o$$$###$$>ooo>$$###$$$o ",
" o$$#$$#$$>111>$$#$$#$$o ",
" ooo###$ooooooooo$###ooo2& ",
" ooo###$ooooooooo$###ooo<3<4",
" o$$$###$$ooooo$$###$$$o56*7",
" oo#oo$$$$$$$$$$$oo#oo48984",
" oo#oo$$$$$$$$$$$oo#oo 4&4 ",
" oo###o$$o$$$o$$o###oo ",
" ooo##$ooooooooo$##ooo ",
" ooo##$ooooooooo$##ooo ",
" 0oo$oo$oo oo$oo$oo ",
" qwe. r ",
" .t. &yur ",
" =i,p& ",
" asdfr ",
" as<y2 "
};

100
sprite/honey.xpm Normal file
View File

@ -0,0 +1,100 @@
/* XPM */
static char *_968371782614669a5e917235fff3595uSQt4kTLWR2slnDN[] = {
/* columns rows colors chars-per-pixel */
"32 32 62 1 ",
" c #6E924D",
". c #6D914D",
"X c #6A8E4B",
"o c #698D4B",
"O c #5D8245",
"+ c #698E4B",
"@ c #6B904C",
"# c #5C8245",
"$ c #618647",
"% c #5B8044",
"& c #6B8F4B",
"* c #688D4B",
"= c black",
"- c #EA9B33",
"; c #FFB43F",
": c #70944E",
"> c #170625",
", c #D27E26",
"< c #B85F1C",
"1 c #71954E",
"2 c #7EA552",
"3 c #FFC600",
"4 c #FFE825",
"5 c #F6A800",
"6 c #72964E",
"7 c #81A853",
"8 c #72974E",
"9 c #71964E",
"0 c #95451A",
"q c #FFD800",
"w c #FFFD2C",
"e c #769B50",
"r c #73984F",
"t c #7EA452",
"y c #597146",
"u c #82320D",
"i c #A7521B",
"p c #4A5940",
"a c #6E934D",
"s c #6F934D",
"d c #7CA352",
"f c #C66F22",
"g c #7DA452",
"h c #789E50",
"j c #72964F",
"k c #74994F",
"l c #7CA351",
"z c #688C4A",
"x c #678B4A",
"c c #6C904C",
"v c #5C8145",
"b c #6B8F4C",
"n c #668B4A",
"m c #668A4A",
"M c #70954E",
"N c #6A8F4B",
"B c #80A853",
"V c #81A854",
"C c #72974F",
"Z c #83AB54",
"A c #759B50",
"S c #7EA553",
/* pixels */
" ",
" ",
" ",
" ",
" .X ",
" oO+ ",
" @#$%& ",
" *#o. ",
" ======== ",
" ===-;;;;-=== ",
" ===-;;;;-=== ",
" : >,--<,,,,<--,> ",
" 121 >>,<<<344435<<<,>> ",
" 6789>,,05qqwqwww43350,,> ",
" 67e2>,,54wwww444w4435,,> ",
" 12e7>00,q444wwww4335,00> ",
" 1rt9>>0,--q4ww4q--,0>> ",
" :y>>u0ii-;;;;-ii0u>>y ",
" ypp>u00i<<<<i00u>ppy a1 ",
" ypp>u00i<<<<i00u>ppy srdrs",
" yy>0ii<ffff<ii0>yy 1gh2j",
" y>>>i<<<<i>>>y sklks",
" ypp>>>>>>ppy s1s ",
" ",
" @. ",
" zOx ",
" cv$vb ",
" nvm. M ",
" .N. 19tM ",
" 6BeV1 ",
" CZASM ",
" CZr9a "
};

79
sprite/left_bear.xpm Normal file
View File

@ -0,0 +1,79 @@
/* XPM */
static char *a387b897507d436aab84d6d6246df66b1z1m15ZG2RCyiMAA[] = {
/* columns rows colors chars-per-pixel */
"32 32 41 1 ",
" c #6E924D",
". c black",
"X c #6A8E4B",
"o c #698E4B",
"O c #5D8245",
"+ c #743F39",
"@ c #B86F50",
"# c #70944E",
"$ c #C28569",
"% c #E8B796",
"& c white",
"* c #71954E",
"= c #7EA552",
"- c #72974E",
"; c #81A853",
": c #72964E",
"> c #769B50",
", c #73984F",
"< c #6E934D",
"1 c #6F934D",
"2 c #7CA352",
"3 c #72964F",
"4 c #789E50",
"5 c #7DA452",
"6 c #74994F",
"7 c #7CA351",
"8 c #6B8F4C",
"9 c #70954E",
"0 c #6D914D",
"q c #668A4A",
"w c #5C8145",
"e c #668B4A",
"r c #7EA452",
"t c #71964E",
"y c #6A8F4B",
"u c #81A854",
"i c #80A853",
"p c #7EA553",
"a c #759B50",
"s c #83AB54",
"d c #72974F",
/* pixels */
" ",
" ",
" ",
" ",
" ... X.... ",
" ... oO.... ",
" +++......+@@@. ",
" +..+++++++.@@... ",
" +..+++++++.@@... ",
" .@@+++@@@++++.++...... ",
" .+++..@@@@+...++@..+++. ",
" .+++..@@@@+...++@..+++. # ",
" .$$%...&&.@@@+++@@@+@@+*=* ",
" $%%%%%...+@@@+@@@@@@@@@-;: ",
" $%%%%%...+@@@+@@@@@@@@@>;: ",
" ...%%%+++@@@@+@@@@@+@@@>=* ",
" $$$%$$+++@+++@@@+@@.+++,* ",
" $$$%$$+++@+++@@@+@@.+++ ",
" *<...........@@@+++...@@+ ",
"1,2,1..+.....++++...@..+@@+ ",
"3=45*..+.....++++...@..+@@+ ",
"16761..++++++++...@@@++++++ ",
" 1*1 .++....++++@@....++. ",
" .++....++++@@....++. ",
" .+++....+++.....+++. ",
" ..+.. .++.++. .++. ",
" ..+.. .++.++. 8.++. ",
" 9 0qwe ",
" 9rt* 0y0 ",
" *u>i: ",
" 9pasd ",
" <t,sd "
};

79
sprite/right_bear.xpm Normal file
View File

@ -0,0 +1,79 @@
/* XPM */
static char *_b542e92ce9f4b05eb766e40c5809f52Uzoy5tL7xaCEixHC[] = {
/* columns rows colors chars-per-pixel */
"32 32 41 1 ",
" c #6E924D",
". c black",
"X c #6A8E4B",
"o c #5D8245",
"O c #698E4B",
"+ c #B86F50",
"@ c #743F39",
"# c #70944E",
"$ c #71954E",
"% c #7EA552",
"& c white",
"* c #E8B796",
"= c #C28569",
"- c #72964E",
"; c #81A853",
": c #72974E",
"> c #769B50",
", c #73984F",
"< c #6E934D",
"1 c #6F934D",
"2 c #7CA352",
"3 c #7DA452",
"4 c #789E50",
"5 c #72964F",
"6 c #74994F",
"7 c #7CA351",
"8 c #6B8F4C",
"9 c #668B4A",
"0 c #5C8145",
"q c #668A4A",
"w c #6D914D",
"e c #70954E",
"r c #6A8F4B",
"t c #71964E",
"y c #7EA452",
"u c #80A853",
"i c #81A854",
"p c #72974F",
"a c #83AB54",
"s c #759B50",
"d c #7EA553",
/* pixels */
" ",
" ",
" ",
" ",
" ....X ... ",
" ....oO ... ",
" .+++@......@@@ ",
" ...++.@@@@@@@..@ ",
" ...++.@@@@@@@..@ ",
" ......@@.@@@@+++@@@++. ",
" .@@@..+@@...@++++..@@@. ",
" # .@@@..+@@...@++++..@@@. ",
" $%$@++@+++@@@+++.&&...*==. ",
" -;:+++++++++@+++@...*****= ",
" -;>+++++++++@+++@...*****= ",
" $%>+++@+++++@++++@@@***... ",
" $,@@@.++@+++@@@+@@@==*=== ",
" @@@.++@+++@@@+@@@==*=== ",
" @++...@@@+++...........<$ ",
" @++@..+...@@@@.....@..1,2,1",
" @++@..+...@@@@.....@..$34%5",
" @@@@@@+++...@@@@@@@@..16761",
" .@@....++@@@@....@@. 1$1 ",
" .@@....++@@@@....@@. ",
" .@@@.....@@@....@@@. ",
" .@@. .@@.@@. ..@.. ",
" .@@.8 .@@.@@. ..@.. ",
" 90qw e ",
" wrw $tye ",
" -u>i$ ",
" pasde ",
" pa,t< "
};

176
sprite/snow_tree.xpm Normal file
View File

@ -0,0 +1,176 @@
/* XPM */
static char *ed1556952fcd432ffcab70bbc17ab48bTGW28QFGniQVrKcD[] = {
/* columns rows colors chars-per-pixel */
"32 32 138 2 ",
" c #6E924D",
". c #91AC78",
"X c #DCE5D4",
"o c white",
"O c #7D9E69",
"+ c #F3F6FE",
"@ c #D7E4FD",
"# c #85A36A",
"$ c #628B4D",
"% c #54925A",
"& c #EAF1FE",
"* c #789C78",
"= c #C4D9D5",
"- c #63A05C",
"; c #BFCFBE",
": c #97B28D",
"> c #4D9262",
", c #71A876",
"< c #6FA958",
"1 c #98C09B",
"2 c #619E7B",
"3 c #CCDFD9",
"4 c #ECF2FE",
"5 c #A1BBBE",
"6 c #5B864D",
"7 c #BACCB8",
"8 c #C0D6D4",
"9 c #7DA87D",
"0 c #E0E9FD",
"q c #C8DCD9",
"w c #D0E1E5",
"e c #55846A",
"r c #3E734E",
"t c #42734A",
"y c #7CA89B",
"u c #87B770",
"i c #6AA55A",
"p c #47865A",
"a c #4B8D5F",
"s c #427A53",
"d c #6C9578",
"f c #4B8355",
"g c #E3EEE6",
"h c #D4E5D9",
"j c #7FB186",
"k c #94BE98",
"l c #ADC4BF",
"z c #588B6F",
"x c #497A4E",
"c c #7FAFA0",
"v c #B9D2D8",
"b c #A6C6C5",
"n c #69A37B",
"m c #458258",
"M c #C5D3B8",
"N c #48875B",
"B c #B8CBB7",
"V c #468358",
"C c #437E55",
"Z c #78AC88",
"A c #8BAB95",
"S c #BACDBF",
"D c #87B055",
"F c #84A58C",
"G c #F7F9FF",
"H c #BFD8C6",
"J c #6F9A7C",
"K c #91B69C",
"L c #95B6BA",
"P c #4F7E4E",
"I c #BCCFD3",
"U c #DFECD6",
"Y c #A5C6BF",
"T c #93B1B6",
"R c #C7D7E1",
"E c #407851",
"W c #668D4D",
"Q c #517F4E",
"! c #83A594",
"~ c #608C78",
"^ c #769D94",
"/ c #709C7D",
"( c #B6CBD3",
") c #8FBC81",
"_ c #B8D3C0",
"` c #D6E5E5",
"' c #6BA487",
"] c #7AA498",
"[ c #86AA91",
"{ c #9CB593",
"} c #447F56",
"| c #498B5D",
" . c #87AD93",
".. c #B2C7B8",
"X. c #B5CEBD",
"o. c #72A180",
"O. c #68A45A",
"+. c #9FBAB7",
"@. c #94BEA1",
"#. c #5D896A",
"$. c #74A091",
"%. c #C3D8E4",
"&. c #CBDBFC",
"*. c #62917B",
"=. c #65977F",
"-. c #74A583",
";. c #7AAC99",
":. c #D1E1E2",
">. c #BFD6D8",
",. c #B7D2C6",
"<. c #88B5A0",
"1. c #99BEBE",
"2. c #58995F",
"3. c #46784E",
"4. c #78A796",
"5. c #424643",
"6. c #45283C",
"7. c #4D733E",
"8. c #695D3C",
"9. c #663931",
"0. c #522F38",
"q. c #5A783F",
"w. c #628245",
"e. c #526D39",
"r. c #4D6636",
"t. c #563A36",
"y. c #494E38",
"u. c #535B34",
"i. c #5E3534",
"p. c #4A2B3A",
"a. c #4D2C39",
"s. c #55703B",
"d. c #668848",
"f. c #5C4B33",
"g. c #584035",
"h. c #6D8E45",
"j. c #5E7B3B",
"k. c #618044",
/* pixels */
" ",
" . X o O ",
" . o + @ + # ",
" $ % & o o o o # ",
" * + = - + o o ; ",
" : > , < 1 2 3 4 5 6 ",
" 7 8 9 0 q w 0 e r t ",
" y u i p p p a > s d ",
" f g h j k g o o l 0 z x ",
" p c v b n > v 5 m m s 6 ",
" M o > m m N > > > > N s x ",
" B o - > V C C V > Z n A S 6 ",
" D F G H - > J A K > o o v L P ",
" D x I G H U Y T R & & T V E r W ",
" D D Q o ! ~ ^ y > > p r C m m / r 6 ",
" D D Q ( o ) > > > > > > > _ o 5 r 6 ",
" D Q s c 0 n ` o 4 2 > ' ] ] r [ { ",
" r r s } | ' c 2 > > | p ...5 x ",
" ..X.N Y ` h _ o.} | O._ 4 N E r ",
" +.o @.r ~ ^ #.$.T %.0 &.*.C s r D ",
" =.+ & -.r r r r r p p ..X.Y > r D D ",
" f ;.:.3 Z Z >.,.n <.& & 1.2.p r D ",
" 3.C 4.' > > p > > > > p r r $ ",
" 6 r s } E r r r r r r r W ",
" x r 5.6.6.6.6 ",
" 7. 8.9.0.0.0.q. ",
" 7. 7. w.e.r.t.9.9.0.0.y.r.r.q. ",
" 7. w.r.r.u.y.9.i.0.p.a.u.r.r.s. ",
" d.r.r.r.f.0.a.6.6.g.r.r.r.h. ",
" d.s.r.u.r.r.r.r.y.r.j.k.D ",
" d.k.k.k.k.k. D D ",
" D "
};