commit b8e4e6d879d8c78c535a016ddda68edb11fd0f9c Author: kinou-p Date: Sun Feb 6 09:42:26 2022 +0100 test diff --git a/libft/Makefile b/libft/Makefile new file mode 100644 index 0000000..f402b07 --- /dev/null +++ b/libft/Makefile @@ -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 + diff --git a/libft/ft_atoi.c b/libft/ft_atoi.c new file mode 100644 index 0000000..0073b7e --- /dev/null +++ b/libft/ft_atoi.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_atoi.o b/libft/ft_atoi.o new file mode 100644 index 0000000..bd02446 Binary files /dev/null and b/libft/ft_atoi.o differ diff --git a/libft/ft_bzero.c b/libft/ft_bzero.c new file mode 100644 index 0000000..5baa4fe --- /dev/null +++ b/libft/ft_bzero.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_bzero.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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--; + } +} diff --git a/libft/ft_bzero.o b/libft/ft_bzero.o new file mode 100644 index 0000000..07a6af3 Binary files /dev/null and b/libft/ft_bzero.o differ diff --git a/libft/ft_calloc.c b/libft/ft_calloc.c new file mode 100644 index 0000000..e4cea33 --- /dev/null +++ b/libft/ft_calloc.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_calloc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_calloc.o b/libft/ft_calloc.o new file mode 100644 index 0000000..e13f9d6 Binary files /dev/null and b/libft/ft_calloc.o differ diff --git a/libft/ft_isalnum.c b/libft/ft_isalnum.c new file mode 100644 index 0000000..7f628b5 --- /dev/null +++ b/libft/ft_isalnum.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalnum.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_isalnum.o b/libft/ft_isalnum.o new file mode 100644 index 0000000..3adcfbe Binary files /dev/null and b/libft/ft_isalnum.o differ diff --git a/libft/ft_isalpha.c b/libft/ft_isalpha.c new file mode 100644 index 0000000..51292d2 --- /dev/null +++ b/libft/ft_isalpha.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_isalpha.o b/libft/ft_isalpha.o new file mode 100644 index 0000000..974f39c Binary files /dev/null and b/libft/ft_isalpha.o differ diff --git a/libft/ft_isascii.c b/libft/ft_isascii.c new file mode 100644 index 0000000..be6ac40 --- /dev/null +++ b/libft/ft_isascii.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isascii.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_isascii.o b/libft/ft_isascii.o new file mode 100644 index 0000000..13e6e60 Binary files /dev/null and b/libft/ft_isascii.o differ diff --git a/libft/ft_isdigit.c b/libft/ft_isdigit.c new file mode 100644 index 0000000..81ca1f0 --- /dev/null +++ b/libft/ft_isdigit.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isdigit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_isdigit.o b/libft/ft_isdigit.o new file mode 100644 index 0000000..a403532 Binary files /dev/null and b/libft/ft_isdigit.o differ diff --git a/libft/ft_isprint.c b/libft/ft_isprint.c new file mode 100644 index 0000000..1915c16 --- /dev/null +++ b/libft/ft_isprint.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isprint.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_isprint.o b/libft/ft_isprint.o new file mode 100644 index 0000000..625565e Binary files /dev/null and b/libft/ft_isprint.o differ diff --git a/libft/ft_itoa.c b/libft/ft_itoa.c new file mode 100644 index 0000000..70f2fd0 --- /dev/null +++ b/libft/ft_itoa.c @@ -0,0 +1,59 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_itoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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)); +} diff --git a/libft/ft_itoa.o b/libft/ft_itoa.o new file mode 100644 index 0000000..2ba0bdf Binary files /dev/null and b/libft/ft_itoa.o differ diff --git a/libft/ft_lstadd_back.c b/libft/ft_lstadd_back.c new file mode 100644 index 0000000..87c0a15 --- /dev/null +++ b/libft/ft_lstadd_back.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_back.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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; +} diff --git a/libft/ft_lstadd_front.c b/libft/ft_lstadd_front.c new file mode 100644 index 0000000..8dfa145 --- /dev/null +++ b/libft/ft_lstadd_front.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_front.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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; +} diff --git a/libft/ft_lstbeforelast.c b/libft/ft_lstbeforelast.c new file mode 100644 index 0000000..535dd53 --- /dev/null +++ b/libft/ft_lstbeforelast.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstbeforelast.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_lstclear.c b/libft/ft_lstclear.c new file mode 100644 index 0000000..152fb31 --- /dev/null +++ b/libft/ft_lstclear.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstclear.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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; +} diff --git a/libft/ft_lstdelone.c b/libft/ft_lstdelone.c new file mode 100644 index 0000000..f0dea04 --- /dev/null +++ b/libft/ft_lstdelone.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstdelone.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_lstiter.c b/libft/ft_lstiter.c new file mode 100644 index 0000000..0e9ea7a --- /dev/null +++ b/libft/ft_lstiter.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstiter.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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; + } +} diff --git a/libft/ft_lstlast.c b/libft/ft_lstlast.c new file mode 100644 index 0000000..2bf317b --- /dev/null +++ b/libft/ft_lstlast.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstlast.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_lstmap.c b/libft/ft_lstmap.c new file mode 100644 index 0000000..252c0c6 --- /dev/null +++ b/libft/ft_lstmap.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstmap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_lstnew.c b/libft/ft_lstnew.c new file mode 100644 index 0000000..e108f42 --- /dev/null +++ b/libft/ft_lstnew.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_lstsize.c b/libft/ft_lstsize.c new file mode 100644 index 0000000..2f6aebe --- /dev/null +++ b/libft/ft_lstsize.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstsize.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_memccpy.c b/libft/ft_memccpy.c new file mode 100644 index 0000000..0b1644c --- /dev/null +++ b/libft/ft_memccpy.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memccpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_memccpy.o b/libft/ft_memccpy.o new file mode 100644 index 0000000..02b82f6 Binary files /dev/null and b/libft/ft_memccpy.o differ diff --git a/libft/ft_memchr.c b/libft/ft_memchr.c new file mode 100644 index 0000000..ce8f294 --- /dev/null +++ b/libft/ft_memchr.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_memchr.o b/libft/ft_memchr.o new file mode 100644 index 0000000..d96b5e1 Binary files /dev/null and b/libft/ft_memchr.o differ diff --git a/libft/ft_memcmp.c b/libft/ft_memcmp.c new file mode 100644 index 0000000..f9af3ee --- /dev/null +++ b/libft/ft_memcmp.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_memcmp.o b/libft/ft_memcmp.o new file mode 100644 index 0000000..a02b8ae Binary files /dev/null and b/libft/ft_memcmp.o differ diff --git a/libft/ft_memcpy.c b/libft/ft_memcpy.c new file mode 100644 index 0000000..92c0480 --- /dev/null +++ b/libft/ft_memcpy.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_memcpy.o b/libft/ft_memcpy.o new file mode 100644 index 0000000..01d853b Binary files /dev/null and b/libft/ft_memcpy.o differ diff --git a/libft/ft_memmove.c b/libft/ft_memmove.c new file mode 100644 index 0000000..0a8a6db --- /dev/null +++ b/libft/ft_memmove.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memmove.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_memmove.o b/libft/ft_memmove.o new file mode 100644 index 0000000..deae8a1 Binary files /dev/null and b/libft/ft_memmove.o differ diff --git a/libft/ft_memset.c b/libft/ft_memset.c new file mode 100644 index 0000000..58dacd9 --- /dev/null +++ b/libft/ft_memset.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_memset.o b/libft/ft_memset.o new file mode 100644 index 0000000..cc22010 Binary files /dev/null and b/libft/ft_memset.o differ diff --git a/libft/ft_putchar_fd.c b/libft/ft_putchar_fd.c new file mode 100644 index 0000000..96abcb5 --- /dev/null +++ b/libft/ft_putchar_fd.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_putchar_fd.o b/libft/ft_putchar_fd.o new file mode 100644 index 0000000..7b5993d Binary files /dev/null and b/libft/ft_putchar_fd.o differ diff --git a/libft/ft_putendl_fd.c b/libft/ft_putendl_fd.c new file mode 100644 index 0000000..a663173 --- /dev/null +++ b/libft/ft_putendl_fd.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putendl_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_putendl_fd.o b/libft/ft_putendl_fd.o new file mode 100644 index 0000000..e299d4d Binary files /dev/null and b/libft/ft_putendl_fd.o differ diff --git a/libft/ft_putnbr_fd.c b/libft/ft_putnbr_fd.c new file mode 100644 index 0000000..eb6aebd --- /dev/null +++ b/libft/ft_putnbr_fd.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_putnbr_fd.o b/libft/ft_putnbr_fd.o new file mode 100644 index 0000000..a1b9ade Binary files /dev/null and b/libft/ft_putnbr_fd.o differ diff --git a/libft/ft_putstr_fd.c b/libft/ft_putstr_fd.c new file mode 100644 index 0000000..61fb28a --- /dev/null +++ b/libft/ft_putstr_fd.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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)); +} diff --git a/libft/ft_putstr_fd.o b/libft/ft_putstr_fd.o new file mode 100644 index 0000000..d95d8d6 Binary files /dev/null and b/libft/ft_putstr_fd.o differ diff --git a/libft/ft_split.c b/libft/ft_split.c new file mode 100644 index 0000000..8302b45 --- /dev/null +++ b/libft/ft_split.c @@ -0,0 +1,80 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_split.o b/libft/ft_split.o new file mode 100644 index 0000000..d99b940 Binary files /dev/null and b/libft/ft_split.o differ diff --git a/libft/ft_strchr.c b/libft/ft_strchr.c new file mode 100644 index 0000000..d3699c2 --- /dev/null +++ b/libft/ft_strchr.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strchr.o b/libft/ft_strchr.o new file mode 100644 index 0000000..42dd88f Binary files /dev/null and b/libft/ft_strchr.o differ diff --git a/libft/ft_strdup.c b/libft/ft_strdup.c new file mode 100644 index 0000000..58ead0f --- /dev/null +++ b/libft/ft_strdup.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strdup.o b/libft/ft_strdup.o new file mode 100644 index 0000000..0c96dc8 Binary files /dev/null and b/libft/ft_strdup.o differ diff --git a/libft/ft_strjoin.c b/libft/ft_strjoin.c new file mode 100644 index 0000000..da55361 --- /dev/null +++ b/libft/ft_strjoin.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strjoin.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strjoin.o b/libft/ft_strjoin.o new file mode 100644 index 0000000..e3b3fda Binary files /dev/null and b/libft/ft_strjoin.o differ diff --git a/libft/ft_strlcat.c b/libft/ft_strlcat.c new file mode 100644 index 0000000..374d9d1 --- /dev/null +++ b/libft/ft_strlcat.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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)); +} diff --git a/libft/ft_strlcat.o b/libft/ft_strlcat.o new file mode 100644 index 0000000..5e01a5a Binary files /dev/null and b/libft/ft_strlcat.o differ diff --git a/libft/ft_strlcpy.c b/libft/ft_strlcpy.c new file mode 100644 index 0000000..05af28a --- /dev/null +++ b/libft/ft_strlcpy.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strlcpy.o b/libft/ft_strlcpy.o new file mode 100644 index 0000000..b690afd Binary files /dev/null and b/libft/ft_strlcpy.o differ diff --git a/libft/ft_strlen.c b/libft/ft_strlen.c new file mode 100644 index 0000000..5ac9d2b --- /dev/null +++ b/libft/ft_strlen.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strlen.o b/libft/ft_strlen.o new file mode 100644 index 0000000..b58b4b1 Binary files /dev/null and b/libft/ft_strlen.o differ diff --git a/libft/ft_strmapi.c b/libft/ft_strmapi.c new file mode 100644 index 0000000..a983137 --- /dev/null +++ b/libft/ft_strmapi.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmapi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strmapi.o b/libft/ft_strmapi.o new file mode 100644 index 0000000..7952445 Binary files /dev/null and b/libft/ft_strmapi.o differ diff --git a/libft/ft_strncmp.c b/libft/ft_strncmp.c new file mode 100644 index 0000000..6de7048 --- /dev/null +++ b/libft/ft_strncmp.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strncmp.o b/libft/ft_strncmp.o new file mode 100644 index 0000000..2bda454 Binary files /dev/null and b/libft/ft_strncmp.o differ diff --git a/libft/ft_strnstr.c b/libft/ft_strnstr.c new file mode 100644 index 0000000..e993e0d --- /dev/null +++ b/libft/ft_strnstr.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strnstr.o b/libft/ft_strnstr.o new file mode 100644 index 0000000..710f7d2 Binary files /dev/null and b/libft/ft_strnstr.o differ diff --git a/libft/ft_strrchr.c b/libft/ft_strrchr.c new file mode 100644 index 0000000..0d11e30 --- /dev/null +++ b/libft/ft_strrchr.c @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strrchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strrchr.o b/libft/ft_strrchr.o new file mode 100644 index 0000000..b5043c9 Binary files /dev/null and b/libft/ft_strrchr.o differ diff --git a/libft/ft_strtrim.c b/libft/ft_strtrim.c new file mode 100644 index 0000000..3930252 --- /dev/null +++ b/libft/ft_strtrim.c @@ -0,0 +1,72 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strtrim.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_strtrim.o b/libft/ft_strtrim.o new file mode 100644 index 0000000..3dece19 Binary files /dev/null and b/libft/ft_strtrim.o differ diff --git a/libft/ft_substr.c b/libft/ft_substr.c new file mode 100644 index 0000000..7e4d95b --- /dev/null +++ b/libft/ft_substr.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_substr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_substr.o b/libft/ft_substr.o new file mode 100644 index 0000000..e1a5dab Binary files /dev/null and b/libft/ft_substr.o differ diff --git a/libft/ft_tolower.c b/libft/ft_tolower.c new file mode 100644 index 0000000..d375233 --- /dev/null +++ b/libft/ft_tolower.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_tolower.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_tolower.o b/libft/ft_tolower.o new file mode 100644 index 0000000..73e4ed4 Binary files /dev/null and b/libft/ft_tolower.o differ diff --git a/libft/ft_toupper.c b/libft/ft_toupper.c new file mode 100644 index 0000000..e8c8d89 --- /dev/null +++ b/libft/ft_toupper.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_toupper.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/ft_toupper.o b/libft/ft_toupper.o new file mode 100644 index 0000000..5818e5c Binary files /dev/null and b/libft/ft_toupper.o differ diff --git a/libft/get_next_line.c b/libft/get_next_line.c new file mode 100644 index 0000000..24ca95c --- /dev/null +++ b/libft/get_next_line.c @@ -0,0 +1,100 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kinou +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/get_next_line.h b/libft/get_next_line.h new file mode 100644 index 0000000..35d74d6 --- /dev/null +++ b/libft/get_next_line.h @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 diff --git a/libft/get_next_line.o b/libft/get_next_line.o new file mode 100644 index 0000000..46cf0ce Binary files /dev/null and b/libft/get_next_line.o differ diff --git a/libft/get_next_line_utils.c b/libft/get_next_line_utils.c new file mode 100644 index 0000000..a8fde1b --- /dev/null +++ b/libft/get_next_line_utils.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/libft/get_next_line_utils.o b/libft/get_next_line_utils.o new file mode 100644 index 0000000..2ca9c14 Binary files /dev/null and b/libft/get_next_line_utils.o differ diff --git a/libft/libft.a b/libft/libft.a new file mode 100644 index 0000000..03fce54 Binary files /dev/null and b/libft/libft.a differ diff --git a/libft/libft.h b/libft/libft.h new file mode 100644 index 0000000..9976227 --- /dev/null +++ b/libft/libft.h @@ -0,0 +1,76 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 +# include +# 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 diff --git a/main.c b/main.c new file mode 100644 index 0000000..8976e6c --- /dev/null +++ b/main.c @@ -0,0 +1,228 @@ +#include +#include "./libft/libft.h" +#include +#include +#include +#include +#include +//#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)); \ No newline at end of file diff --git a/map.ber b/map.ber new file mode 100644 index 0000000..52dc518 --- /dev/null +++ b/map.ber @@ -0,0 +1,10 @@ +1111111111111 +1E110C00C0001 +1000P01011001 +10C011C001C01 +10C011C001C01 +10C011C001C01 +10C011C001C01 +10C011C001C01 +10C011C001C01 +1111111111111 diff --git a/sprite/back.xpm b/sprite/back.xpm new file mode 100644 index 0000000..b232879 --- /dev/null +++ b/sprite/back.xpm @@ -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 " +}; diff --git a/sprite/back_bear.xpm b/sprite/back_bear.xpm new file mode 100644 index 0000000..5670276 --- /dev/null +++ b/sprite/back_bear.xpm @@ -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, " +}; diff --git a/sprite/exit.XPM b/sprite/exit.XPM new file mode 100644 index 0000000..bbfbb45 --- /dev/null +++ b/sprite/exit.XPM @@ -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 ", +" . ", +" " +}; diff --git a/sprite/front_bear.xpm b/sprite/front_bear.xpm new file mode 100644 index 0000000..6ecc9b8 --- /dev/null +++ b/sprite/front_bear.xpm @@ -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 ", +" &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 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<<<ppy a1 ", +" ypp>u00i<<<ppy srdrs", +" yy>0iiyy 1gh2j", +" y>>>i<<<>>y sklks", +" ypp>>>>>>ppy s1s ", +" ", +" @. ", +" zOx ", +" cv$vb ", +" nvm. M ", +" .N. 19tM ", +" 6BeV1 ", +" CZASM ", +" CZr9a " +}; diff --git a/sprite/left_bear.xpm b/sprite/left_bear.xpm new file mode 100644 index 0000000..838631c --- /dev/null +++ b/sprite/left_bear.xpm @@ -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 ", +" 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< " +}; diff --git a/sprite/snow_tree.xpm b/sprite/snow_tree.xpm new file mode 100644 index 0000000..5da8414 --- /dev/null +++ b/sprite/snow_tree.xpm @@ -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 " +};