From 8d69e7d1dfbb2818241e19866e91f82188e53e2d Mon Sep 17 00:00:00 2001 From: pbonilla Date: Wed, 14 Feb 2024 09:58:04 +0100 Subject: [PATCH] init --- .gitignore | 3 + Makefile | 37 ++++++++++ ft_printf/Makefile | 63 ++++++++++++++++ ft_printf/includes/ft_printf.h | 41 +++++++++++ ft_printf/libft/Makefile | 102 ++++++++++++++++++++++++++ ft_printf/libft/ft_atoi.c | 35 +++++++++ ft_printf/libft/ft_bzero.c | 24 ++++++ ft_printf/libft/ft_calloc.c | 23 ++++++ ft_printf/libft/ft_convert_base.c | 118 ++++++++++++++++++++++++++++++ ft_printf/libft/ft_isalnum.c | 17 +++++ ft_printf/libft/ft_isalpha.c | 16 ++++ ft_printf/libft/ft_isascii.c | 16 ++++ ft_printf/libft/ft_isdigit.c | 16 ++++ ft_printf/libft/ft_isprint.c | 16 ++++ ft_printf/libft/ft_itoa.c | 58 +++++++++++++++ ft_printf/libft/ft_lstadd_back.c | 26 +++++++ ft_printf/libft/ft_lstadd_front.c | 22 ++++++ ft_printf/libft/ft_lstclear.c | 28 +++++++ ft_printf/libft/ft_lstdelone.c | 24 ++++++ ft_printf/libft/ft_lstiter.c | 27 +++++++ ft_printf/libft/ft_lstlast.c | 25 +++++++ ft_printf/libft/ft_lstmap.c | 34 +++++++++ ft_printf/libft/ft_lstnew.c | 24 ++++++ ft_printf/libft/ft_lstsize.c | 30 ++++++++ ft_printf/libft/ft_memccpy.c | 32 ++++++++ ft_printf/libft/ft_memchr.c | 29 ++++++++ ft_printf/libft/ft_memcmp.c | 32 ++++++++ ft_printf/libft/ft_memcpy.c | 29 ++++++++ ft_printf/libft/ft_memmove.c | 39 ++++++++++ ft_printf/libft/ft_memset.c | 26 +++++++ ft_printf/libft/ft_putchar_fd.c | 18 +++++ ft_printf/libft/ft_putendl_fd.c | 20 +++++ ft_printf/libft/ft_putnbr_base.c | 70 ++++++++++++++++++ ft_printf/libft/ft_putnbr_fd.c | 32 ++++++++ ft_printf/libft/ft_putstr_fd.c | 19 +++++ ft_printf/libft/ft_revert_int.c | 28 +++++++ ft_printf/libft/ft_split.c | 96 ++++++++++++++++++++++++ ft_printf/libft/ft_strchr.c | 30 ++++++++ ft_printf/libft/ft_strcmp .c | 19 +++++ ft_printf/libft/ft_strdup.c | 27 +++++++ ft_printf/libft/ft_strjoin.c | 39 ++++++++++ ft_printf/libft/ft_strlcat.c | 39 ++++++++++ ft_printf/libft/ft_strlcpy.c | 33 +++++++++ ft_printf/libft/ft_strlen.c | 27 +++++++ ft_printf/libft/ft_strmapi.c | 29 ++++++++ ft_printf/libft/ft_strncmp.c | 48 ++++++++++++ ft_printf/libft/ft_strnstr.c | 29 ++++++++ ft_printf/libft/ft_strrchr.c | 32 ++++++++ ft_printf/libft/ft_strtrim.c | 27 +++++++ ft_printf/libft/ft_substr.c | 38 ++++++++++ ft_printf/libft/ft_tolower.c | 18 +++++ ft_printf/libft/ft_toupper.c | 18 +++++ ft_printf/libft/ft_u_convert.c | 113 ++++++++++++++++++++++++++++ ft_printf/libft/ft_u_itoa.c | 51 +++++++++++++ ft_printf/libft/libft.h | 72 ++++++++++++++++++ ft_printf/srcs/ft_char_case.c | 34 +++++++++ ft_printf/srcs/ft_int_case.c | 67 +++++++++++++++++ ft_printf/srcs/ft_parser.c | 84 +++++++++++++++++++++ ft_printf/srcs/ft_percent_case.c | 33 +++++++++ ft_printf/srcs/ft_printf.c | 78 ++++++++++++++++++++ ft_printf/srcs/ft_printf_memset.c | 32 ++++++++ ft_printf/srcs/ft_ptr_case.c | 63 ++++++++++++++++ ft_printf/srcs/ft_str_case.c | 65 ++++++++++++++++ ft_printf/srcs/ft_ui_case.c | 60 +++++++++++++++ ft_printf/srcs/ft_x_case.c | 64 ++++++++++++++++ resources/sample | Bin 0 -> 4744 bytes resources/sample.c | 7 ++ resources/sample64 | Bin 0 -> 15960 bytes resources/woody | Bin 0 -> 6764 bytes srcs/main.c | 4 + 70 files changed, 2575 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 ft_printf/Makefile create mode 100644 ft_printf/includes/ft_printf.h create mode 100644 ft_printf/libft/Makefile create mode 100644 ft_printf/libft/ft_atoi.c create mode 100644 ft_printf/libft/ft_bzero.c create mode 100644 ft_printf/libft/ft_calloc.c create mode 100644 ft_printf/libft/ft_convert_base.c create mode 100644 ft_printf/libft/ft_isalnum.c create mode 100644 ft_printf/libft/ft_isalpha.c create mode 100644 ft_printf/libft/ft_isascii.c create mode 100644 ft_printf/libft/ft_isdigit.c create mode 100644 ft_printf/libft/ft_isprint.c create mode 100644 ft_printf/libft/ft_itoa.c create mode 100644 ft_printf/libft/ft_lstadd_back.c create mode 100644 ft_printf/libft/ft_lstadd_front.c create mode 100644 ft_printf/libft/ft_lstclear.c create mode 100644 ft_printf/libft/ft_lstdelone.c create mode 100644 ft_printf/libft/ft_lstiter.c create mode 100644 ft_printf/libft/ft_lstlast.c create mode 100644 ft_printf/libft/ft_lstmap.c create mode 100644 ft_printf/libft/ft_lstnew.c create mode 100644 ft_printf/libft/ft_lstsize.c create mode 100644 ft_printf/libft/ft_memccpy.c create mode 100644 ft_printf/libft/ft_memchr.c create mode 100644 ft_printf/libft/ft_memcmp.c create mode 100644 ft_printf/libft/ft_memcpy.c create mode 100644 ft_printf/libft/ft_memmove.c create mode 100644 ft_printf/libft/ft_memset.c create mode 100644 ft_printf/libft/ft_putchar_fd.c create mode 100644 ft_printf/libft/ft_putendl_fd.c create mode 100644 ft_printf/libft/ft_putnbr_base.c create mode 100644 ft_printf/libft/ft_putnbr_fd.c create mode 100644 ft_printf/libft/ft_putstr_fd.c create mode 100644 ft_printf/libft/ft_revert_int.c create mode 100644 ft_printf/libft/ft_split.c create mode 100644 ft_printf/libft/ft_strchr.c create mode 100644 ft_printf/libft/ft_strcmp .c create mode 100644 ft_printf/libft/ft_strdup.c create mode 100644 ft_printf/libft/ft_strjoin.c create mode 100644 ft_printf/libft/ft_strlcat.c create mode 100644 ft_printf/libft/ft_strlcpy.c create mode 100644 ft_printf/libft/ft_strlen.c create mode 100644 ft_printf/libft/ft_strmapi.c create mode 100644 ft_printf/libft/ft_strncmp.c create mode 100644 ft_printf/libft/ft_strnstr.c create mode 100644 ft_printf/libft/ft_strrchr.c create mode 100644 ft_printf/libft/ft_strtrim.c create mode 100644 ft_printf/libft/ft_substr.c create mode 100644 ft_printf/libft/ft_tolower.c create mode 100644 ft_printf/libft/ft_toupper.c create mode 100644 ft_printf/libft/ft_u_convert.c create mode 100644 ft_printf/libft/ft_u_itoa.c create mode 100644 ft_printf/libft/libft.h create mode 100644 ft_printf/srcs/ft_char_case.c create mode 100644 ft_printf/srcs/ft_int_case.c create mode 100644 ft_printf/srcs/ft_parser.c create mode 100644 ft_printf/srcs/ft_percent_case.c create mode 100644 ft_printf/srcs/ft_printf.c create mode 100644 ft_printf/srcs/ft_printf_memset.c create mode 100644 ft_printf/srcs/ft_ptr_case.c create mode 100644 ft_printf/srcs/ft_str_case.c create mode 100644 ft_printf/srcs/ft_ui_case.c create mode 100644 ft_printf/srcs/ft_x_case.c create mode 100755 resources/sample create mode 100644 resources/sample.c create mode 100755 resources/sample64 create mode 100755 resources/woody create mode 100644 srcs/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..985031d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.a +woody_woodpacker \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7c41f03 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +NAME = woody_woodpacker + +SRCS_PATH = srcs/ + +SRCS = $(SRCS_PATH)main.c + +OBJS = ${SRCS:.c=.o} + +CC = gcc + +RM = rm -f + +LIBFT_FLAGS = ft_printf/libftprintf.a + +CFLAGS = -Wall -Wextra -Werror + +all: ${NAME} + +.c.o: + ${CC} ${DEFINES} ${CFLAGS} -c $< -o $@ + +$(NAME): ${OBJS} + make -C ft_printf + ${CC} ${OBJS} ${LIBFT_FLAGS} -o ${NAME} + +clean: + make -C ft_printf clean + ${RM} ${OBJS} + +fclean: + make -C ft_printf fclean + ${RM} ${NAME} + +re: fclean + make all + +.PHONY : all clean fclean re diff --git a/ft_printf/Makefile b/ft_printf/Makefile new file mode 100644 index 0000000..b6f6db8 --- /dev/null +++ b/ft_printf/Makefile @@ -0,0 +1,63 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: pbonilla +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2021/01/18 18:08:51 by pbonilla #+# #+# # +# Updated: 2021/03/12 12:27:09 by pbonilla ### ########.fr # +# # +# **************************************************************************** # + +LIBFT = ./libft/libft.a + +NAME = libftprintf.a + +SRCS_PATH = srcs/ + +SRCS = $(SRCS_PATH)ft_printf.c \ + $(SRCS_PATH)ft_parser.c \ + $(SRCS_PATH)ft_int_case.c \ + $(SRCS_PATH)ft_char_case.c \ + $(SRCS_PATH)ft_str_case.c \ + $(SRCS_PATH)ft_ui_case.c \ + $(SRCS_PATH)ft_x_case.c \ + $(SRCS_PATH)ft_ptr_case.c \ + $(SRCS_PATH)ft_percent_case.c \ + $(SRCS_PATH)ft_printf_memset.c \ + +OBJS = ${SRCS:.c=.o} + +CC = gcc + +RM = rm -f + + +CFLAGS = -Wall -Wextra -Werror + +INCLUDES = -I libft + +all: ${NAME} + +.c.o: + ${CC} ${INCLUDES} ${DEFINES} ${CFLAGS} -c $< -o $@ + +$(NAME): ${OBJS} + $(MAKE) bonus -C ./libft + cp libft/libft.a $(NAME) + ar -rcs $(NAME) $(OBJS) + ranlib $(NAME) + +clean: + $(MAKE) clean -C ./libft + ${RM} ${OBJS} + + +fclean: clean + $(MAKE) fclean -C ./libft + ${RM} ${NAME} + +re: fclean all + +.PHONY : all clean fclean re diff --git a/ft_printf/includes/ft_printf.h b/ft_printf/includes/ft_printf.h new file mode 100644 index 0000000..c2bdadd --- /dev/null +++ b/ft_printf/includes/ft_printf.h @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/02/11 15:21:19 by pbonilla #+# #+# */ +/* Updated: 2021/03/21 20:11:37 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_PRINTF_H +# define FT_PRINTF_H + +# include "../libft/libft.h" +# include +# include + +typedef struct s_param +{ + int minus; + int zero; + int width; + int prec; + int type; + int len; +} t_param; +t_param ft_init_param(void); +void *ft_printf_memset(void *s, size_t n, t_param *param); +int ft_printf(const char *s, ...); +int ft_parse_param(const char *s, int i, t_param *par, +va_list args); +char *ft_int_case(t_param *param, int i); +char *ft_char_case(t_param *param, int i); +char *ft_ui_case(t_param *param, unsigned int i); +char *ft_x_case(t_param *param, unsigned long i); +char *ft_ptr_case(t_param *param, unsigned long long i); +char *ft_str_case(t_param *param, char *str); +char *ft_percent_case(t_param *param); +#endif diff --git a/ft_printf/libft/Makefile b/ft_printf/libft/Makefile new file mode 100644 index 0000000..0ff9c4e --- /dev/null +++ b/ft_printf/libft/Makefile @@ -0,0 +1,102 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: pbonilla +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2021/01/18 18:08:51 by pbonilla #+# #+# # +# Updated: 2021/02/07 14:20:29 by pbonilla ### ########.fr # +# # +# **************************************************************************** # + +NAME = libft.a + +SRCS_PATH = ./ + +SRCS = $(SRCS_PATH)ft_atoi.c \ + $(SRCS_PATH)ft_toupper.c \ + $(SRCS_PATH)ft_bzero.c \ + $(SRCS_PATH)ft_isalnum.c \ + $(SRCS_PATH)ft_tolower.c \ + $(SRCS_PATH)ft_memcpy.c \ + $(SRCS_PATH)ft_memccpy.c \ + $(SRCS_PATH)ft_memmove.c \ + $(SRCS_PATH)ft_memset.c \ + $(SRCS_PATH)ft_memchr.c \ + $(SRCS_PATH)ft_memcmp.c \ + $(SRCS_PATH)ft_strlcat.c \ + $(SRCS_PATH)ft_strnstr.c \ + $(SRCS_PATH)ft_strlcat.c \ + $(SRCS_PATH)ft_strlen.c \ + $(SRCS_PATH)ft_strchr.c \ + $(SRCS_PATH)ft_strrchr.c \ + $(SRCS_PATH)ft_isalpha.c \ + $(SRCS_PATH)ft_isascii.c \ + $(SRCS_PATH)ft_strlcpy.c \ + $(SRCS_PATH)ft_strncmp.c \ + $(SRCS_PATH)ft_isdigit.c \ + $(SRCS_PATH)ft_isprint.c \ + $(SRCS_PATH)ft_toupper.c \ + $(SRCS_PATH)ft_bzero.c \ + $(SRCS_PATH)ft_strdup.c \ + $(SRCS_PATH)ft_strnstr.c \ + $(SRCS_PATH)ft_calloc.c \ + $(SRCS_PATH)ft_substr.c \ + $(SRCS_PATH)ft_strjoin.c \ + $(SRCS_PATH)ft_u_itoa.c \ + $(SRCS_PATH)ft_itoa.c \ + $(SRCS_PATH)ft_strmapi.c \ + $(SRCS_PATH)ft_putchar_fd.c \ + $(SRCS_PATH)ft_putstr_fd.c \ + $(SRCS_PATH)ft_putnbr_fd.c \ + $(SRCS_PATH)ft_putendl_fd.c \ + $(SRCS_PATH)ft_strtrim.c \ + $(SRCS_PATH)ft_split.c \ + $(SRCS_PATH)ft_u_convert.c \ + $(SRCS_PATH)ft_convert_base.c \ + $(SRCS_PATH)ft_revert_int.c \ + + +BONUS = $(SRCS_PATH)ft_lstnew.c \ + $(SRCS_PATH)ft_lstadd_front.c \ + $(SRCS_PATH)ft_lstsize.c \ + $(SRCS_PATH)ft_lstlast.c \ + $(SRCS_PATH)ft_lstadd_back.c \ + $(SRCS_PATH)ft_lstdelone.c \ + $(SRCS_PATH)ft_lstclear.c \ + $(SRCS_PATH)ft_lstiter.c \ + $(SRCS_PATH)ft_lstmap.c \ + +OBJS = ${SRCS:.c=.o} + +BONUS_OBJS = $(BONUS:.c=.o) + +CC = gcc + +RM = rm -f + +CFLAGS = -Wall -Wextra -Werror + +$(NAME): $(OBJS) + ar rc $(NAME) $(OBJS) + ranlib $(NAME) + +all: $(NAME) + +.c.o: + ${CC} ${INCLUDES} ${DEFINES} ${CFLAGS} -c $< -o $@ + +clean: + rm -rf $(OBJS) $(BONUS_OBJS) + +fclean: clean + rm -rf $(NAME) + +re: fclean all + +bonus: $(OBJS) $(BONUS_OBJS) + ar rc $(NAME) $(OBJS) $(BONUS_OBJS) + ranlib $(NAME) + +.PHONY : all clean fclean re bonus \ No newline at end of file diff --git a/ft_printf/libft/ft_atoi.c b/ft_printf/libft/ft_atoi.c new file mode 100644 index 0000000..ac667ae --- /dev/null +++ b/ft_printf/libft/ft_atoi.c @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/11 16:00:14 by pbonilla #+# #+# */ +/* Updated: 2020/11/18 14:03:00 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_atoi(const char *nptr) +{ + int nbr; + int sgn; + + sgn = 1; + nbr = 0; + while (*nptr && (*nptr == ' ' || *nptr == '\n' || *nptr == '\t' || + *nptr == '\v' || *nptr == '\f' || *nptr == '\r')) + ++nptr; + if (*nptr == '-') + sgn *= -1; + if (*nptr == '-' || *nptr == '+') + ++nptr; + while (*nptr && *nptr >= '0' && *nptr <= '9') + { + nbr = nbr * 10 + (*nptr - 48); + ++nptr; + } + return (nbr * sgn); +} diff --git a/ft_printf/libft/ft_bzero.c b/ft_printf/libft/ft_bzero.c new file mode 100644 index 0000000..feba65c --- /dev/null +++ b/ft_printf/libft/ft_bzero.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_bzero.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/27 18:43:42 by pbonilla #+# #+# */ +/* Updated: 2020/11/11 15:25:20 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_bzero(void *s, size_t n) +{ + unsigned char *buff; + unsigned int i; + + buff = s; + i = -1; + while (++i != n) + *(buff + i) = 0; +} diff --git a/ft_printf/libft/ft_calloc.c b/ft_printf/libft/ft_calloc.c new file mode 100644 index 0000000..edf9ceb --- /dev/null +++ b/ft_printf/libft/ft_calloc.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_calloc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/11 18:51:50 by pbonilla #+# #+# */ +/* Updated: 2020/11/11 19:19:16 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void *ft_calloc(size_t nmemb, size_t size) +{ + char *s; + + if (!(s = malloc(size * nmemb))) + return (NULL); + ft_memset(s, 0, size * nmemb); + return (s); +} diff --git a/ft_printf/libft/ft_convert_base.c b/ft_printf/libft/ft_convert_base.c new file mode 100644 index 0000000..e44cd28 --- /dev/null +++ b/ft_printf/libft/ft_convert_base.c @@ -0,0 +1,118 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convert_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/09/22 19:22:14 by pbonilla #+# #+# */ +/* Updated: 2021/03/19 18:42:40 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include + +int isinbase(char c, char *base) +{ + int i; + + i = 0; + while (base[i]) + { + if (base[i] == c) + return (i); + ++i; + } + return (-1); +} + +long ft_atoi_base(char *str, char *base) +{ + int len_base; + int i; + int signe; + long long nbr; + + signe = 1; + i = 0; + nbr = 0; + len_base = ft_strlen(base); + while (str[i] == '-' || str[i] == '+') + { + if (str[i] == '-') + signe *= -1; + i++; + } + while (isinbase(str[i], base) >= 0) + { + nbr = (len_base * nbr) + isinbase(str[i], base); + i++; + } + return (signe * nbr); +} + +int get_size_in_char(long long nbr, int len_base) +{ + int i; + + i = 1; + if (nbr < 0) + ++i; + while (nbr / len_base) + { + nbr = nbr / len_base; + ++i; + } + return (i); +} + +char *write_base(char *str, long long nbr, char *base, int *i_sgn) +{ + int len_base; + long long nb; + + len_base = ft_strlen(base); + nb = nbr; + if (nb < 0) + nb *= -1; + if (nb >= len_base) + { + str[i_sgn[0]] = base[nb % len_base]; + i_sgn[0] += 1; + write_base(str, nb / len_base, base, i_sgn); + } + else + { + str[i_sgn[0]] = base[nb]; + if (i_sgn[1]) + str[i_sgn[0] + 1] = '-'; + str[i_sgn[0] + 1 + i_sgn[1]] = 0; + } + return (str); +} + +char *ft_convert_base(char *nbr, char *base_from, char *base_to) +{ + char *str; + int len_base; + int size_char; + long long number; + int i_sgn[2]; + + i_sgn[0] = 0; + i_sgn[1] = 0; + if (!nbr || !base_from || !base_to) + return (NULL); + number = ft_atoi_base(nbr, base_from); + len_base = ft_strlen(base_to); + size_char = get_size_in_char(number, len_base); + if (!(str = malloc(sizeof(char) * (size_char + 1)))) + return (ft_strdup("")); + if (number < 0) + i_sgn[1] = 1; + str = write_base(str, number, base_to, i_sgn); + str[size_char] = 0; + ft_rev_int_tab(str, size_char); + return (str); +} diff --git a/ft_printf/libft/ft_isalnum.c b/ft_printf/libft/ft_isalnum.c new file mode 100644 index 0000000..8f52460 --- /dev/null +++ b/ft_printf/libft/ft_isalnum.c @@ -0,0 +1,17 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalnum.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/25 17:21:39 by pbonilla #+# #+# */ +/* Updated: 2021/01/19 16:24:38 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_isalnum(int c) +{ + return ((c >= '0' && c <= '9') || + (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); +} diff --git a/ft_printf/libft/ft_isalpha.c b/ft_printf/libft/ft_isalpha.c new file mode 100644 index 0000000..7f4cdf3 --- /dev/null +++ b/ft_printf/libft/ft_isalpha.c @@ -0,0 +1,16 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/25 16:41:59 by pbonilla #+# #+# */ +/* Updated: 2021/01/19 16:26:50 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_isalpha(int c) +{ + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); +} diff --git a/ft_printf/libft/ft_isascii.c b/ft_printf/libft/ft_isascii.c new file mode 100644 index 0000000..a308b0d --- /dev/null +++ b/ft_printf/libft/ft_isascii.c @@ -0,0 +1,16 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isascii.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/25 17:35:50 by pbonilla #+# #+# */ +/* Updated: 2021/01/28 13:41:22 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_isascii(int c) +{ + return (c >= 0 && c <= 127); +} diff --git a/ft_printf/libft/ft_isdigit.c b/ft_printf/libft/ft_isdigit.c new file mode 100644 index 0000000..9e328dc --- /dev/null +++ b/ft_printf/libft/ft_isdigit.c @@ -0,0 +1,16 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isdigit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/25 16:43:33 by pbonilla #+# #+# */ +/* Updated: 2021/01/19 16:27:51 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_isdigit(int c) +{ + return (c >= '0' && c <= '9'); +} diff --git a/ft_printf/libft/ft_isprint.c b/ft_printf/libft/ft_isprint.c new file mode 100644 index 0000000..a182ab5 --- /dev/null +++ b/ft_printf/libft/ft_isprint.c @@ -0,0 +1,16 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isprint.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/25 17:38:36 by pbonilla #+# #+# */ +/* Updated: 2020/11/18 14:08:51 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_isprint(int c) +{ + return (c >= 32 && c <= 126); +} diff --git a/ft_printf/libft/ft_itoa.c b/ft_printf/libft/ft_itoa.c new file mode 100644 index 0000000..216448c --- /dev/null +++ b/ft_printf/libft/ft_itoa.c @@ -0,0 +1,58 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_itoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/24 21:27:16 by pbonilla #+# #+# */ +/* Updated: 2021/01/31 04:53:05 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int number_len(int n) +{ + int size; + + if (n == 0) + return (1); + size = 0; + if (n < 0) + { + n = -n; + ++size; + } + while (n != 0) + { + n /= 10; + ++size; + } + return (size); +} + +char *ft_itoa(int n) +{ + long long_n; + char *number; + int size; + + long_n = n; + size = number_len(n); + if (!(number = malloc(sizeof(char) * (size + 1)))) + return (NULL); + number[size] = 0; + --size; + if (long_n < 0) + long_n = -long_n; + while (size >= 0) + { + number[size] = '0' + (long_n % 10); + --size; + long_n /= 10; + } + if (n < 0) + number[0] = '-'; + return (number); +} diff --git a/ft_printf/libft/ft_lstadd_back.c b/ft_printf/libft/ft_lstadd_back.c new file mode 100644 index 0000000..7743327 --- /dev/null +++ b/ft_printf/libft/ft_lstadd_back.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_back_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/04 16:04:08 by pbonilla #+# #+# */ +/* Updated: 2020/12/04 16:04:11 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_lstadd_back(t_list **alst, t_list *new) +{ + t_list *suiv; + + if (!*alst) + { + *alst = new; + return ; + } + suiv = ft_lstlast(*alst); + suiv->next = new; +} diff --git a/ft_printf/libft/ft_lstadd_front.c b/ft_printf/libft/ft_lstadd_front.c new file mode 100644 index 0000000..7b16a93 --- /dev/null +++ b/ft_printf/libft/ft_lstadd_front.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_front_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/04 16:04:57 by pbonilla #+# #+# */ +/* Updated: 2020/12/04 16:04:59 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_lstadd_front(t_list **alst, t_list *new) +{ + if (alst && new) + { + new->next = *alst; + *alst = new; + } +} diff --git a/ft_printf/libft/ft_lstclear.c b/ft_printf/libft/ft_lstclear.c new file mode 100644 index 0000000..ff59ed6 --- /dev/null +++ b/ft_printf/libft/ft_lstclear.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstclear_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/04 16:05:21 by pbonilla #+# #+# */ +/* Updated: 2020/12/04 16:05:21 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_lstclear(t_list **lst, void (*del)(void*)) +{ + t_list *tmp; + + if (!lst) + return ; + while (*lst) + { + tmp = (*lst)->next; + ft_lstdelone(*lst, del); + (*lst) = tmp; + } + *lst = NULL; +} diff --git a/ft_printf/libft/ft_lstdelone.c b/ft_printf/libft/ft_lstdelone.c new file mode 100644 index 0000000..5f21f42 --- /dev/null +++ b/ft_printf/libft/ft_lstdelone.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstdelone_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/04 16:05:34 by pbonilla #+# #+# */ +/* Updated: 2020/12/04 16:05:37 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_lstdelone(t_list *lst, void (*del)(void *)) +{ + if (!lst) + return ; + if (del) + { + free(lst); + del(lst->content); + } +} diff --git a/ft_printf/libft/ft_lstiter.c b/ft_printf/libft/ft_lstiter.c new file mode 100644 index 0000000..fe43546 --- /dev/null +++ b/ft_printf/libft/ft_lstiter.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstiter_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/04 16:05:51 by pbonilla #+# #+# */ +/* Updated: 2020/12/04 16:05:52 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_lstiter(t_list *lst, void (*f)(void *)) +{ + t_list *tmp; + + tmp = lst; + if (!f) + return ; + while (tmp) + { + f(tmp->content); + tmp = tmp->next; + } +} diff --git a/ft_printf/libft/ft_lstlast.c b/ft_printf/libft/ft_lstlast.c new file mode 100644 index 0000000..dc803ff --- /dev/null +++ b/ft_printf/libft/ft_lstlast.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstlast_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/04 16:06:04 by pbonilla #+# #+# */ +/* Updated: 2020/12/04 16:06:04 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +t_list *ft_lstlast(t_list *lst) +{ + t_list *suiv; + + if (!lst) + return (NULL); + suiv = lst; + while (suiv->next) + suiv = suiv->next; + return (suiv); +} diff --git a/ft_printf/libft/ft_lstmap.c b/ft_printf/libft/ft_lstmap.c new file mode 100644 index 0000000..2ac4dcc --- /dev/null +++ b/ft_printf/libft/ft_lstmap.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstmap_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/04 16:06:16 by pbonilla #+# #+# */ +/* Updated: 2021/02/01 08:27:04 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +t_list *ft_lstmap(t_list *l, void *(*f)(void *), void (*del)(void *)) +{ + t_list *new_lst; + t_list *new_elem; + + if (!f) + return (NULL); + new_lst = NULL; + while (l) + { + if (!(new_elem = ft_lstnew(f(l->content)))) + { + ft_lstclear(&new_lst, del); + return (NULL); + } + ft_lstadd_back(&new_lst, new_elem); + l = l->next; + } + return (new_lst); +} diff --git a/ft_printf/libft/ft_lstnew.c b/ft_printf/libft/ft_lstnew.c new file mode 100644 index 0000000..76f4454 --- /dev/null +++ b/ft_printf/libft/ft_lstnew.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstnew_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/04 16:06:31 by pbonilla #+# #+# */ +/* Updated: 2020/12/04 16:06:31 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +t_list *ft_lstnew(void *content) +{ + t_list *new; + + if (!(new = malloc(sizeof(t_list)))) + return (NULL); + new->content = content; + new->next = NULL; + return (new); +} diff --git a/ft_printf/libft/ft_lstsize.c b/ft_printf/libft/ft_lstsize.c new file mode 100644 index 0000000..83daa46 --- /dev/null +++ b/ft_printf/libft/ft_lstsize.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstsize_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/04 16:06:42 by pbonilla #+# #+# */ +/* Updated: 2020/12/04 16:06:43 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_lstsize(t_list *lst) +{ + int i; + t_list *suiv; + + i = 1; + suiv = lst; + if (!lst) + return (0); + while (suiv->next) + { + suiv = suiv->next; + ++i; + } + return (i); +} diff --git a/ft_printf/libft/ft_memccpy.c b/ft_printf/libft/ft_memccpy.c new file mode 100644 index 0000000..608ac71 --- /dev/null +++ b/ft_printf/libft/ft_memccpy.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memccpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/27 19:40:08 by pbonilla #+# #+# */ +/* Updated: 2021/01/29 12:00:11 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void *ft_memccpy(void *dest, const void *src, int c, size_t n) +{ + unsigned char *buff; + unsigned char *buff2; + unsigned int i; + + buff = (unsigned char *)dest; + buff2 = (unsigned char *)src; + i = 0; + while (i < n) + { + buff[i] = buff2[i]; + if (buff2[i] == (unsigned char)c) + return ((void *)(dest + i + 1)); + ++i; + } + return (NULL); +} diff --git a/ft_printf/libft/ft_memchr.c b/ft_printf/libft/ft_memchr.c new file mode 100644 index 0000000..14378ac --- /dev/null +++ b/ft_printf/libft/ft_memchr.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/29 12:11:59 by pbonilla #+# #+# */ +/* Updated: 2020/11/20 23:33:24 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void *ft_memchr(const void *s, int c, size_t n) +{ + unsigned char *buff; + unsigned int i; + + buff = (unsigned char *)s; + i = 0; + while (i != n) + { + if (buff[i] == (unsigned char)c) + return ((void *)&buff[i]); + ++i; + } + return (NULL); +} diff --git a/ft_printf/libft/ft_memcmp.c b/ft_printf/libft/ft_memcmp.c new file mode 100644 index 0000000..96f3094 --- /dev/null +++ b/ft_printf/libft/ft_memcmp.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/29 12:23:50 by pbonilla #+# #+# */ +/* Updated: 2021/01/29 13:09:55 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_memcmp(const void *s1, const void *s2, size_t n) +{ + unsigned char *ss1; + unsigned char *ss2; + unsigned int i; + + ss1 = (unsigned char *)s1; + ss2 = (unsigned char *)s2; + i = -1; + if (n == 0) + return (0); + while (++i < n) + { + if (ss1[i] != ss2[i]) + return (ss1[i] - ss2[i]); + } + return (0); +} diff --git a/ft_printf/libft/ft_memcpy.c b/ft_printf/libft/ft_memcpy.c new file mode 100644 index 0000000..a3a4bbc --- /dev/null +++ b/ft_printf/libft/ft_memcpy.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/27 18:52:38 by pbonilla #+# #+# */ +/* Updated: 2021/01/29 12:11:19 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void *ft_memcpy(void *dest, const void *src, size_t n) +{ + unsigned char *buff; + unsigned char *buff2; + unsigned int i; + + buff = (unsigned char *)dest; + buff2 = (unsigned char *)src; + if (!buff && !buff2) + return (NULL); + i = -1; + while (++i != n) + buff[i] = buff2[i]; + return (buff); +} diff --git a/ft_printf/libft/ft_memmove.c b/ft_printf/libft/ft_memmove.c new file mode 100644 index 0000000..ed98957 --- /dev/null +++ b/ft_printf/libft/ft_memmove.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memmove.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/27 22:19:34 by pbonilla #+# #+# */ +/* Updated: 2021/01/29 13:08:14 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void *ft_memmove(void *dest, const void *src, size_t n) +{ + unsigned char *dest2; + unsigned char *src2; + unsigned int i; + + dest2 = (unsigned char *)dest; + src2 = (unsigned char *)src; + i = -1; + if (!dest2 && !src2) + return (dest2); + if (src >= dest) + { + while (++i != n) + *(dest2 + i) = *(src2 + i); + } + else + { + src2 += n; + dest2 += n; + while (n--) + *--dest2 = *--src2; + } + return (dest2); +} diff --git a/ft_printf/libft/ft_memset.c b/ft_printf/libft/ft_memset.c new file mode 100644 index 0000000..ed27787 --- /dev/null +++ b/ft_printf/libft/ft_memset.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/27 17:57:35 by pbonilla #+# #+# */ +/* Updated: 2020/11/11 15:46:56 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void *ft_memset(void *s, int c, size_t n) +{ + unsigned char *buff; + unsigned int i; + + buff = s; + i = -1; + while (++i != n) + *(buff + i) = c; + s = (void *)buff; + return (s); +} diff --git a/ft_printf/libft/ft_putchar_fd.c b/ft_printf/libft/ft_putchar_fd.c new file mode 100644 index 0000000..77686fb --- /dev/null +++ b/ft_printf/libft/ft_putchar_fd.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/25 18:28:15 by pbonilla #+# #+# */ +/* Updated: 2020/12/03 17:41:45 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putchar_fd(char c, int fd) +{ + write(fd, &c, 1); +} diff --git a/ft_printf/libft/ft_putendl_fd.c b/ft_printf/libft/ft_putendl_fd.c new file mode 100644 index 0000000..804ba0a --- /dev/null +++ b/ft_printf/libft/ft_putendl_fd.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putendl_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/01 18:27:47 by pbonilla #+# #+# */ +/* Updated: 2020/12/03 17:45:49 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putendl_fd(char *s, int fd) +{ + if (s) + write(fd, s, ft_strlen(s)); + write(fd, "\n", 1); +} diff --git a/ft_printf/libft/ft_putnbr_base.c b/ft_printf/libft/ft_putnbr_base.c new file mode 100644 index 0000000..ba27732 --- /dev/null +++ b/ft_printf/libft/ft_putnbr_base.c @@ -0,0 +1,70 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/09/16 14:58:50 by pbonilla #+# #+# */ +/* Updated: 2021/02/28 02:52:20 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void write_base(long nbr, char *base) +{ + long tmp; + int len_base; + + tmp = nbr; + len_base = ft_strlen(base); + if (tmp < 0) + { + ft_putchar('-'); + tmp *= -1; + } + if (tmp > len_base - 1) + { + write_base(tmp / len_base, base); + write_base(tmp % len_base, base); + } + else + ft_putchar(tmp + base[0]); +} + +int check_base(char *base, int len_base) +{ + int i; + int j; + + i = 0; + if (len_base > 1) + { + while (base[i]) + { + j = i; + while (base[j]) + { + if ((base[i] == base[j] && i != j) || + base[j] == '+' || base[j] == '-') + return (0); + j++; + } + i++; + } + return (1); + } + return (0); +} + +void ft_putnbr_base(int nbr, char *base) +{ + long tmp; + int len_base; + + tmp = nbr; + len_base = ft_strlen(base); + if (check_base(base, len_base)) + write_base(tmp, base); +} diff --git a/ft_printf/libft/ft_putnbr_fd.c b/ft_printf/libft/ft_putnbr_fd.c new file mode 100644 index 0000000..1a4a770 --- /dev/null +++ b/ft_printf/libft/ft_putnbr_fd.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/01 17:58:34 by pbonilla #+# #+# */ +/* Updated: 2020/12/01 18:25:48 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putnbr_fd(int n, int fd) +{ + long nb; + + nb = n; + if (nb < 0) + { + ft_putchar_fd('-', fd); + nb = -nb; + } + if (nb >= 10) + { + ft_putnbr_fd(nb / 10, fd); + ft_putnbr_fd(nb % 10, fd); + } + else + ft_putchar_fd(nb + '0', fd); +} diff --git a/ft_printf/libft/ft_putstr_fd.c b/ft_printf/libft/ft_putstr_fd.c new file mode 100644 index 0000000..65dd205 --- /dev/null +++ b/ft_printf/libft/ft_putstr_fd.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/12/01 17:49:54 by pbonilla #+# #+# */ +/* Updated: 2020/12/03 17:43:48 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putstr_fd(char *s, int fd) +{ + if (s) + write(fd, s, ft_strlen(s)); +} diff --git a/ft_printf/libft/ft_revert_int.c b/ft_printf/libft/ft_revert_int.c new file mode 100644 index 0000000..a27206e --- /dev/null +++ b/ft_printf/libft/ft_revert_int.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_revert_int.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/02/28 03:57:26 by pbonilla #+# #+# */ +/* Updated: 2021/03/19 18:44:09 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_rev_int_tab(char *tab, int size) +{ + char tmp; + int i; + + i = size; + while (i > size / 2) + { + tmp = tab[i - 1]; + tab[i - 1] = tab[size - i]; + tab[size - i] = tmp; + i--; + } +} diff --git a/ft_printf/libft/ft_split.c b/ft_printf/libft/ft_split.c new file mode 100644 index 0000000..722ca49 --- /dev/null +++ b/ft_printf/libft/ft_split.c @@ -0,0 +1,96 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/02/01 08:32:47 by pbonilla #+# #+# */ +/* Updated: 2021/02/07 14:09:27 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int count_word(char const *s, char c) +{ + int i; + int nb_word; + + i = -1; + nb_word = 0; + while (s[++i]) + { + if (s[i] == c && i != 0 && s[i - 1] != c) + ++nb_word; + } + if (i == 0 || s[i - 1] != c) + ++nb_word; + return (nb_word); +} + +int count_char(char const *s, char c, int i) +{ + int size; + + size = 0; + while (s[i] && s[i] != c) + { + ++size; + ++i; + } + return (size); +} + +char **free_all(char **splitey, int n) +{ + while (n > 0) + { + --n; + free(splitey[n]); + } + free(splitey); + return (NULL); +} + +char **fill_splitey(char const *s, char **splitey, char c, int nb) +{ + int i; + int j; + int k; + + i = 0; + j = 0; + while (s[i] && j < nb) + { + k = 0; + while (s[i] == c) + ++i; + if (!(splitey[j] = malloc(sizeof(char) * (count_char(s, c, i) + 1)))) + return (free_all(splitey, j)); + while (s[i] && s[i] != c) + splitey[j][k++] = s[i++]; + splitey[j][k] = 0; + ++j; + } + splitey[j] = 0; + return (splitey); +} + +char **ft_split(char const *s, char c) +{ + char **splitey; + int nb_words; + + if (!s) + return (NULL); + nb_words = count_word(s, c); + if (!(splitey = malloc(sizeof(char *) * (nb_words + 1)))) + return (NULL); + if (!nb_words) + { + splitey[0] = 0; + return (splitey); + } + return (fill_splitey(s, splitey, c, nb_words)); +} diff --git a/ft_printf/libft/ft_strchr.c b/ft_printf/libft/ft_strchr.c new file mode 100644 index 0000000..668066a --- /dev/null +++ b/ft_printf/libft/ft_strchr.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/29 12:37:26 by pbonilla #+# #+# */ +/* Updated: 2020/12/04 15:40:05 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strchr(const char *s, int c) +{ + int i; + char *buff; + + buff = (char *)s; + i = -1; + while (buff[++i]) + { + if (buff[i] == (char)c) + return ((char *)&buff[i]); + } + if (buff[i] == (char)c) + return ((char *)&buff[i]); + return (NULL); +} diff --git a/ft_printf/libft/ft_strcmp .c b/ft_printf/libft/ft_strcmp .c new file mode 100644 index 0000000..4a5b12d --- /dev/null +++ b/ft_printf/libft/ft_strcmp .c @@ -0,0 +1,19 @@ +#include "libft.h" + +int ft_strcmp(const char *s1, const char *s2) +{ + unsigned char *ss1; + unsigned char *ss2; + size_t i; + + ss1 = (unsigned char *)s1; + ss2 = (unsigned char *)s2; + i = 0; + while (ss1[i] || ss2[i]) + { + if (ss1[i] != ss2[i]) + return (ss1[i] - ss2[i]); + ++i; + } + return (0); +} diff --git a/ft_printf/libft/ft_strdup.c b/ft_printf/libft/ft_strdup.c new file mode 100644 index 0000000..7d83d96 --- /dev/null +++ b/ft_printf/libft/ft_strdup.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/11 18:45:41 by pbonilla #+# #+# */ +/* Updated: 2021/01/31 04:55:04 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strdup(const char *s) +{ + char *dup; + int i; + + if (!(dup = malloc(sizeof(char) * ft_strlen(s) + 1))) + return (NULL); + i = -1; + while (s[++i]) + dup[i] = s[i]; + dup[i] = 0; + return (dup); +} diff --git a/ft_printf/libft/ft_strjoin.c b/ft_printf/libft/ft_strjoin.c new file mode 100644 index 0000000..7270469 --- /dev/null +++ b/ft_printf/libft/ft_strjoin.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strjoin.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/24 15:20:38 by pbonilla #+# #+# */ +/* Updated: 2020/11/24 15:52:53 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strjoin(char const *s1, char const *s2) +{ + char *new; + size_t len_s1; + size_t len_s2; + size_t i; + + if (!(s1 && s2)) + return (NULL); + len_s1 = ft_strlen(s1); + len_s2 = ft_strlen(s2); + if (!(new = malloc(sizeof(char *) * (len_s1 + len_s2 + 1)))) + return (NULL); + i = -1; + while (s1[++i]) + new[i] = s1[i]; + i = -1; + while (s2[++i]) + { + new[len_s1] = s2[i]; + len_s1++; + } + new[len_s1] = 0; + return (new); +} diff --git a/ft_printf/libft/ft_strlcat.c b/ft_printf/libft/ft_strlcat.c new file mode 100644 index 0000000..353295d --- /dev/null +++ b/ft_printf/libft/ft_strlcat.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/09 19:11:10 by pbonilla #+# #+# */ +/* Updated: 2020/12/03 17:41:01 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +size_t ft_strlcat(char *dst, const char *src, size_t size) +{ + size_t dst_size; + size_t src_size; + size_t i; + + i = 0; + src_size = 0; + dst_size = 0; + while (src[src_size]) + src_size++; + if (size == 0) + return (src_size); + while (dst_size < size && dst[dst_size]) + dst_size++; + if (size <= dst_size) + return (size + src_size); + while (size && (--size - dst_size) && src[i]) + { + dst[dst_size + i] = src[i]; + i++; + } + dst[dst_size + i] = 0; + return (src_size + dst_size); +} diff --git a/ft_printf/libft/ft_strlcpy.c b/ft_printf/libft/ft_strlcpy.c new file mode 100644 index 0000000..9e1fcbd --- /dev/null +++ b/ft_printf/libft/ft_strlcpy.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/08 17:09:59 by pbonilla #+# #+# */ +/* Updated: 2020/11/11 21:38:14 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +size_t ft_strlcpy(char *dst, const char *src, size_t size) +{ + size_t i; + size_t j; + + if (!dst) + return (0); + i = ft_strlen(src); + if (size == 0) + return (i); + j = 0; + while (j < i && j < size - 1) + { + dst[j] = src[j]; + ++j; + } + dst[j] = 0; + return (i); +} diff --git a/ft_printf/libft/ft_strlen.c b/ft_printf/libft/ft_strlen.c new file mode 100644 index 0000000..9d43f37 --- /dev/null +++ b/ft_printf/libft/ft_strlen.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/29 12:32:56 by pbonilla #+# #+# */ +/* Updated: 2021/02/18 16:27:54 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +size_t ft_strlen(const char *s) +{ + char *buff; + size_t i; + + buff = (char *)s; + if (!buff) + return (0); + i = -1; + while (buff[++i]) + ; + return (i); +} diff --git a/ft_printf/libft/ft_strmapi.c b/ft_printf/libft/ft_strmapi.c new file mode 100644 index 0000000..5656e43 --- /dev/null +++ b/ft_printf/libft/ft_strmapi.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmapi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/25 17:46:08 by pbonilla #+# #+# */ +/* Updated: 2021/01/31 04:53:57 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) +{ + char *sf; + size_t i; + + if (!s || !f) + return (NULL); + if (!(sf = malloc(sizeof(char) * (ft_strlen(s) + 1)))) + return (NULL); + i = -1; + while (s[++i]) + sf[i] = (*f)(i, s[i]); + sf[i] = 0; + return (sf); +} diff --git a/ft_printf/libft/ft_strncmp.c b/ft_printf/libft/ft_strncmp.c new file mode 100644 index 0000000..5f54a01 --- /dev/null +++ b/ft_printf/libft/ft_strncmp.c @@ -0,0 +1,48 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/04 16:48:09 by pbonilla #+# #+# */ +/* Updated: 2021/02/04 02:28:25 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_strcmp(const char *s1, const char *s2) +{ + unsigned char *ss1; + unsigned char *ss2; + size_t i; + + ss1 = (unsigned char *)s1; + ss2 = (unsigned char *)s2; + i = 0; + while (ss1[i] || ss2[i]) + { + if (ss1[i] != ss2[i]) + return (ss1[i] - ss2[i]); + ++i; + } + return (0); +} + +int ft_strncmp(const char *s1, const char *s2, size_t n) +{ + unsigned char *ss1; + unsigned char *ss2; + size_t i; + + ss1 = (unsigned char *)s1; + ss2 = (unsigned char *)s2; + i = -1; + while (++i < n && (ss1[i] || ss2[i])) + { + if (ss1[i] != ss2[i]) + return (ss1[i] - ss2[i]); + } + return (0); +} diff --git a/ft_printf/libft/ft_strnstr.c b/ft_printf/libft/ft_strnstr.c new file mode 100644 index 0000000..62fc3fe --- /dev/null +++ b/ft_printf/libft/ft_strnstr.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/09 19:15:12 by pbonilla #+# #+# */ +/* Updated: 2021/01/30 18:31:22 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strnstr(const char *big, const char *little, size_t len) +{ + size_t len_l; + + if (*little == 0) + return ((char *)big); + len_l = ft_strlen(little); + while (*big != 0 && len-- >= len_l) + { + if (*big == *little && ft_strncmp(big, little, len_l) == 0) + return ((char *)big); + big++; + } + return (NULL); +} diff --git a/ft_printf/libft/ft_strrchr.c b/ft_printf/libft/ft_strrchr.c new file mode 100644 index 0000000..c3f8d2b --- /dev/null +++ b/ft_printf/libft/ft_strrchr.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strrchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/29 13:10:04 by pbonilla #+# #+# */ +/* Updated: 2020/11/19 15:09:23 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strrchr(const char *s, int c) +{ + int i; + int j; + + i = -1; + j = -1; + while (s[++i]) + { + if (s[i] == (char)c) + j = i; + } + if (s[i] == (char)c) + return ((char *)&s[i]); + if (j == -1) + return (NULL); + return ((char *)&s[j]); +} diff --git a/ft_printf/libft/ft_strtrim.c b/ft_printf/libft/ft_strtrim.c new file mode 100644 index 0000000..43a15f2 --- /dev/null +++ b/ft_printf/libft/ft_strtrim.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strtrim.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/26 15:19:18 by pbonilla #+# #+# */ +/* Updated: 2021/02/04 02:37:12 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strtrim(char const *s1, char const *set) +{ + size_t size_s1; + + if (!s1 || !set) + return (NULL); + while (*s1 && ft_strchr(set, *s1)) + ++s1; + size_s1 = ft_strlen(s1); + while (size_s1 && ft_strchr(set, s1[size_s1])) + --size_s1; + return (ft_substr(s1, 0, size_s1 + 1)); +} diff --git a/ft_printf/libft/ft_substr.c b/ft_printf/libft/ft_substr.c new file mode 100644 index 0000000..251f6ac --- /dev/null +++ b/ft_printf/libft/ft_substr.c @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_substr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/12 16:24:37 by pbonilla #+# #+# */ +/* Updated: 2021/01/31 05:13:41 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_substr(char const *s, unsigned int start, size_t len) +{ + char *sub; + size_t i; + size_t j; + + if (!s) + return (NULL); + if (!(sub = malloc(sizeof(char) * (len + 1)))) + return (NULL); + i = 0; + j = 0; + while (s[i]) + { + if (i >= start && j < len) + { + sub[j] = s[i]; + ++j; + } + i++; + } + sub[j] = 0; + return (sub); +} diff --git a/ft_printf/libft/ft_tolower.c b/ft_printf/libft/ft_tolower.c new file mode 100644 index 0000000..572928c --- /dev/null +++ b/ft_printf/libft/ft_tolower.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_tolower.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/25 17:10:14 by pbonilla #+# #+# */ +/* Updated: 2020/10/25 17:16:22 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_tolower(int c) +{ + if (c >= 'A' && c <= 'Z') + return (c + 32); + return (c); +} diff --git a/ft_printf/libft/ft_toupper.c b/ft_printf/libft/ft_toupper.c new file mode 100644 index 0000000..2d8bca6 --- /dev/null +++ b/ft_printf/libft/ft_toupper.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_toupper.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/25 17:04:47 by pbonilla #+# #+# */ +/* Updated: 2020/10/25 17:09:00 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_toupper(int c) +{ + if (c >= 'a' && c <= 'z') + return (c - 32); + return (c); +} diff --git a/ft_printf/libft/ft_u_convert.c b/ft_printf/libft/ft_u_convert.c new file mode 100644 index 0000000..9502de7 --- /dev/null +++ b/ft_printf/libft/ft_u_convert.c @@ -0,0 +1,113 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_u_convert.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/09/22 19:22:14 by pbonilla #+# #+# */ +/* Updated: 2021/03/19 19:07:30 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include + +int u_isinbase(char c, char *base) +{ + int i; + + i = 0; + while (base[i]) + { + if (base[i] == c) + return (i); + ++i; + } + return (-1); +} + +long u_ft_atoi_base(char *str, char *base) +{ + int len_base; + int i; + int signe; + unsigned long long nbr; + + signe = 1; + i = 0; + nbr = 0; + len_base = ft_strlen(base); + while (str[i] == '-' || str[i] == '+') + { + if (str[i] == '-') + signe *= -1; + i++; + } + while (u_isinbase(str[i], base) >= 0) + { + nbr = (len_base * nbr) + u_isinbase(str[i], base); + i++; + } + return (signe * nbr); +} + +int u_get_size_in_char(unsigned long long nbr, int len_base) +{ + int i; + + i = 1; + while (nbr / len_base) + { + nbr = nbr / len_base; + ++i; + } + return (i); +} + +char *u_write_base(char *s, unsigned long long n, +char *b, int *i) +{ + unsigned long long len_base; + unsigned long long nb; + + len_base = ft_strlen(b); + nb = n; + if (nb >= len_base) + { + s[i[0]] = b[nb % len_base]; + i[0] += 1; + u_write_base(s, nb / len_base, b, i); + } + else + { + s[i[0]] = b[nb]; + if (i[1]) + s[i[0] + 1] = '-'; + s[i[0] + 1 + i[1]] = 0; + } + return (s); +} + +char *ft_u_convert(char *nbr, char *b_f, char *b_t) +{ + char *str; + int len_base; + int size_char; + unsigned long long number; + int i_sgn[2]; + + i_sgn[0] = 0; + i_sgn[1] = 0; + if (!nbr || !b_f || !b_t) + return (NULL); + number = u_ft_atoi_base(nbr, b_f); + len_base = ft_strlen(b_t); + size_char = u_get_size_in_char(number, len_base); + if (!(str = malloc(sizeof(char) * (size_char + 1)))) + return (ft_strdup("")); + str = u_write_base(str, number, b_t, i_sgn); + str[size_char] = 0; + ft_rev_int_tab(str, size_char); + return (str); +} diff --git a/ft_printf/libft/ft_u_itoa.c b/ft_printf/libft/ft_u_itoa.c new file mode 100644 index 0000000..46ca104 --- /dev/null +++ b/ft_printf/libft/ft_u_itoa.c @@ -0,0 +1,51 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_u_itoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/24 21:27:16 by pbonilla #+# #+# */ +/* Updated: 2021/03/19 18:16:49 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int number_u_len(unsigned long long n) +{ + int size; + + if (n == 0) + return (1); + size = 0; + n = -n; + ++size; + while (n != 0) + { + n /= 10; + ++size; + } + return (size); +} + +char *ft_u_itoa(unsigned long long n) +{ + unsigned long long long_n; + char *number; + int size; + + long_n = n; + size = number_u_len(n); + if (!(number = malloc(sizeof(char) * (size + 1)))) + return (NULL); + number[size] = 0; + --size; + while (size >= 0) + { + number[size] = '0' + (long_n % 10); + --size; + long_n /= 10; + } + return (number); +} \ No newline at end of file diff --git a/ft_printf/libft/libft.h b/ft_printf/libft/libft.h new file mode 100644 index 0000000..93441d3 --- /dev/null +++ b/ft_printf/libft/libft.h @@ -0,0 +1,72 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/11/09 17:31:59 by pbonilla #+# #+# */ +/* Updated: 2021/03/19 19:07:47 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_H +# define LIBFT_H +# include +# include + +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_isalnum(int c); +int ft_isdigit(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_strcmp(const char *s1, const char *s2); +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_strnstr(const char *big, const char *little, size_t len); +int ft_atoi(const char *nptr); +char *ft_substr(char const *s, unsigned int start, size_t len); +char *ft_strjoin(char const *s1, char const *s2); +char *ft_u_itoa(unsigned long long n); +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_putnbr_fd(int n, int fd); +void ft_putendl_fd(char *s, int fd); +int ft_instr(char c, char const *set); +char *ft_strtrim(char const *s1, char const *set); +char **ft_split(char const *s, char c); +char *ft_strdup(const char *s); +void *ft_calloc(size_t nmemb, size_t size); +char *ft_convert_base(char *nbr, char *base_from, char *base_to); +char *ft_u_convert(char *nbr, char *base_from, char *base_to); +void ft_rev_int_tab(char *tab, int size); +typedef struct s_list +{ + void *content; + struct s_list *next; +} t_list; +t_list *ft_lstnew(void *content); +void ft_lstadd_front(t_list **alst, t_list *newlist); +int ft_lstsize(t_list *lst); +t_list *ft_lstlast(t_list *lst); +void ft_lstadd_back(t_list **alst, t_list *newlist); +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 *l, void *(*f)(void *), void (*del)(void *)); +#endif diff --git a/ft_printf/srcs/ft_char_case.c b/ft_printf/srcs/ft_char_case.c new file mode 100644 index 0000000..9edffbe --- /dev/null +++ b/ft_printf/srcs/ft_char_case.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_char_case.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/03 16:34:32 by pbonilla #+# #+# */ +/* Updated: 2021/03/19 21:53:46 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +char *ft_char_case(t_param *param, int i) +{ + int len; + int pos; + char *s; + + len = 1; + pos = 0; + if (param->width > len) + len = param->width; + if (!param->minus) + pos = len - 1; + if (!(s = malloc(sizeof(char) * (len + 1)))) + return (NULL); + s[len] = 0; + ft_memset(s, ' ', len); + s[pos] = i; + param->len = len; + return (s); +} diff --git a/ft_printf/srcs/ft_int_case.c b/ft_printf/srcs/ft_int_case.c new file mode 100644 index 0000000..1d905d2 --- /dev/null +++ b/ft_printf/srcs/ft_int_case.c @@ -0,0 +1,67 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_int_case.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/03 03:23:01 by pbonilla #+# #+# */ +/* Updated: 2021/03/19 19:12:14 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +char *fill_s_int(char *s, int len, char *s_i, t_param *param) +{ + int save; + int i; + int test; + + test = ft_atoi(s_i); + save = ft_strlen(s_i) - (s_i[0] == '-'); + i = ft_strlen(s_i); + while (--len >= 0 && --i >= 0 && s_i[i] != '-') + { + s[len] = s_i[i]; + if (test == 0 && param->prec == 0) + s[len] = ' '; + } + while (param->prec-- > save) + s[len--] = '0'; + if (param->zero && param->prec != -1) + len = 0; + if (s_i[0] == '-') + s[len] = '-'; + free(s_i); + return (s); +} + +char *ft_int_case(t_param *param, int i) +{ + int save; + int len; + char *s_i; + char *s; + + if (param->prec > -1 && param->zero) + param->zero = 0; + s_i = ft_itoa(i); + len = ft_strlen(s_i) - (s_i[0] == '-'); + if (i == 0 && param->prec == 0) + len = 0; + if (param->prec > len) + len = param->prec; + len += (s_i[0] == '-'); + save = len; + if (param->width > len) + len = param->width; + if (!(s = malloc(sizeof(char) * (len + 1)))) + return (NULL); + s[len] = 0; + ft_printf_memset(s, len, param); + if (param->minus) + len = save; + s = fill_s_int(s, len, s_i, param); + return (s); +} diff --git a/ft_printf/srcs/ft_parser.c b/ft_printf/srcs/ft_parser.c new file mode 100644 index 0000000..ddaa8f1 --- /dev/null +++ b/ft_printf/srcs/ft_parser.c @@ -0,0 +1,84 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_parser.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/03 02:19:59 by pbonilla #+# #+# */ +/* Updated: 2021/03/21 20:00:15 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +t_param ft_init_param(void) +{ + t_param param; + + param.minus = 0; + param.zero = 0; + param.width = 0; + param.prec = -1; + param.type = 0; + param.len = 0; + return (param); +} + +int is_valid_type(const char c) +{ + return (c == 'c' || c == 's' || c == 'p' || c == 'd' || + c == 'i' || c == 'u' || c == 'x' || c == 'X' || c == '%'); +} + +int ft_parse_para2(const char *s, int i, t_param *par, va_list args) +{ + if (s[i] == '.') + { + par->prec = 0; + if (s[++i] == '*') + { + par->prec = va_arg(args, int); + ++i; + } + else if (s[i] >= '0' && s[i] <= '9') + { + par->prec = ft_atoi(&s[i]); + while (s[i] >= '0' && s[i] <= '9') + ++i; + } + } + if (is_valid_type(s[i])) + par->type = (int)s[i]; + else + return (-1); + return (i); +} + +int ft_parse_param(const char *s, int i, t_param *par, va_list args) +{ + while (s[i] == '0' || s[i] == '-') + { + if (s[i] == '0') + par->zero = 1; + else if (s[i] == '-') + par->minus = 1; + ++i; + } + if (s[i] >= '0' && s[i] <= '9') + par->width = ft_atoi(&s[i]); + while (s[i] >= '0' && s[i] <= '9') + ++i; + if (s[i] == '*') + { + par->width = va_arg(args, int); + ++i; + } + if (par->width < 0) + { + par->width *= -1; + par->minus = 1; + } + i = ft_parse_para2(s, i, par, args); + return (i); +} diff --git a/ft_printf/srcs/ft_percent_case.c b/ft_printf/srcs/ft_percent_case.c new file mode 100644 index 0000000..13e9fb8 --- /dev/null +++ b/ft_printf/srcs/ft_percent_case.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_percent_case.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/12 12:21:58 by pbonilla #+# #+# */ +/* Updated: 2021/03/21 20:10:25 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +char *ft_percent_case(t_param *param) +{ + int len; + int pos; + char *s; + + len = 1; + pos = 0; + if (param->width > len) + len = param->width; + if (!param->minus) + pos = len - 1; + if (!(s = malloc(sizeof(char) * (len + 1)))) + return (NULL); + s[len] = 0; + ft_printf_memset(s, len, param); + s[pos] = '%'; + return (s); +} diff --git a/ft_printf/srcs/ft_printf.c b/ft_printf/srcs/ft_printf.c new file mode 100644 index 0000000..86d4f26 --- /dev/null +++ b/ft_printf/srcs/ft_printf.c @@ -0,0 +1,78 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/02 21:18:26 by pbonilla #+# #+# */ +/* Updated: 2021/03/21 20:10:56 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +int ft_print_param(t_param *param, va_list args, char **buff) +{ + if ((char)param->type == 'c') + *buff = ft_char_case(param, va_arg(args, int)); + else if ((char)param->type == 's') + *buff = ft_str_case(param, va_arg(args, char *)); + else if ((char)param->type == 'p') + *buff = ft_ptr_case(param, va_arg(args, unsigned long long)); + else if ((char)param->type == 'd' || (char)param->type == 'i') + *buff = ft_int_case(param, va_arg(args, int)); + else if ((char)param->type == 'u') + *buff = ft_ui_case(param, va_arg(args, unsigned int)); + else if ((char)param->type == 'x' || (char)param->type == 'X') + *buff = ft_x_case(param, va_arg(args, unsigned long)); + else if ((char)param->type == '%') + *buff = ft_percent_case(param); + if (param->type == 'c') + { + write(1, *buff, param->len); + return (param->len); + } + else + ft_putstr_fd(*buff, 1); + return (ft_strlen(*buff)); +} + +int ft_read_str(const char *s, va_list args) +{ + t_param param; + int i; + int nb_chars; + char *buff; + + i = -1; + nb_chars = 0; + while (s[++i]) + { + buff = NULL; + if (s[i] != '%') + nb_chars += write(1, &s[i], 1); + else if (s[i] == '%' && s[i + 1]) + { + param = ft_init_param(); + i = ft_parse_param(s, ++i, ¶m, args); + if (i == -1) + return (-1); + nb_chars += ft_print_param(¶m, args, &buff); + if (buff) + free(buff); + } + } + return (nb_chars); +} + +int ft_printf(const char *s, ...) +{ + va_list args; + int nb_chars; + + va_start(args, s); + nb_chars = ft_read_str(s, args); + va_end(args); + return (nb_chars); +} diff --git a/ft_printf/srcs/ft_printf_memset.c b/ft_printf/srcs/ft_printf_memset.c new file mode 100644 index 0000000..9ca3bf7 --- /dev/null +++ b/ft_printf/srcs/ft_printf_memset.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf_memset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/04 05:59:48 by pbonilla #+# #+# */ +/* Updated: 2021/03/19 19:13:48 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +void *ft_printf_memset(void *s, size_t n, t_param *param) +{ + unsigned char *buff; + unsigned int i; + int c; + + buff = s; + i = -1; + c = ' '; + if (param->prec > -1 && param->zero) + param->zero = 0; + if (param->zero && !param->minus) + c = '0'; + while (++i != n) + *(buff + i) = c; + s = (void *)buff; + return (s); +} diff --git a/ft_printf/srcs/ft_ptr_case.c b/ft_printf/srcs/ft_ptr_case.c new file mode 100644 index 0000000..eb2f542 --- /dev/null +++ b/ft_printf/srcs/ft_ptr_case.c @@ -0,0 +1,63 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ptr_case.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/11 12:54:20 by pbonilla #+# #+# */ +/* Updated: 2021/03/21 20:53:18 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +int zero_case(t_param *param, unsigned long long i) +{ + if (param->prec == 0 && i == 0) + return (0); + return (1); +} + +char *fill_s_ptr(unsigned long long j, int len, char *s_x, +t_param *param) +{ + char *s; + int i; + + if (!(s = malloc(sizeof(char) * (len + 1)))) + return (NULL); + s[len] = 0; + ft_printf_memset(s, len, param); + if (param->minus) + len = ft_strlen(s_x) + 1 + zero_case(param, j); + i = ft_strlen(s_x); + while (--len >= 0 && --i >= 0) + { + s[len] = s_x[i]; + if (j == 0 && param->prec == 0) + { + s[len] = ' '; + ++len; + } + } + s[len] = 'x'; + s[--len] = '0'; + free(s_x); + return (s); +} + +char *ft_ptr_case(t_param *param, unsigned long long i) +{ + char *s_x; + char *s_ul; + int len; + + s_ul = ft_u_itoa(i); + s_x = ft_u_convert(s_ul, "0123456789", "0123456789abcdef"); + free(s_ul); + len = ft_strlen(s_x) + 1 + zero_case(param, i); + if (param->width > len) + len = param->width; + return (fill_s_ptr(i, len, s_x, param)); +} diff --git a/ft_printf/srcs/ft_str_case.c b/ft_printf/srcs/ft_str_case.c new file mode 100644 index 0000000..c629e4c --- /dev/null +++ b/ft_printf/srcs/ft_str_case.c @@ -0,0 +1,65 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_case.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/04 05:25:41 by pbonilla #+# #+# */ +/* Updated: 2021/03/19 19:18:42 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +char *fill_s_str(char *s, int len, char *s_arg, t_param *param) +{ + int i; + + i = ft_strlen(s_arg); + if (param->prec != -1 && param->prec < i) + i = param->prec; + while (--len >= 0 && --i >= 0) + s[len] = s_arg[i]; + return (s); +} + +void change_par_str(t_param *param) +{ + if (param->width < 0 && param->width != -1) + { + param->width *= -1; + param->minus = 1; + } + if (param->prec < -1) + param->prec = -1; +} + +char *ft_str_case(t_param *param, char *str) +{ + int save; + int len; + char *s_arg; + char *s; + + change_par_str(param); + s_arg = str; + if (!str) + s_arg = ft_strdup("(null)"); + len = ft_strlen(s_arg); + if (param->prec != -1 && param->prec < len) + len = param->prec; + save = len; + if (param->width > len) + len = param->width; + if (!(s = malloc(sizeof(char) * len + 1))) + return (NULL); + s[len] = 0; + ft_printf_memset(s, len, param); + if (param->minus) + len = save; + s = fill_s_str(s, len, s_arg, param); + if (!str) + free(s_arg); + return (s); +} diff --git a/ft_printf/srcs/ft_ui_case.c b/ft_printf/srcs/ft_ui_case.c new file mode 100644 index 0000000..c833dbc --- /dev/null +++ b/ft_printf/srcs/ft_ui_case.c @@ -0,0 +1,60 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ui_case.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/08 06:18:38 by pbonilla #+# #+# */ +/* Updated: 2021/03/20 20:18:26 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +char *fill_s_uint(char *s, int len, char *s_ui, t_param *param) +{ + int save; + int i; + + save = ft_strlen(s_ui); + i = save; + while (--len >= 0 && --i >= 0) + { + s[len] = s_ui[i]; + if (s_ui[0] == '0' && param->prec == 0) + s[len] = ' '; + } + while (param->prec-- > save) + s[len--] = '0'; + return (s); +} + +char *ft_ui_case(t_param *param, unsigned int i) +{ + int save; + int len; + char *s_ui; + char *s; + + if (param->prec != -1 && param->zero) + param->zero = 0; + s_ui = ft_u_itoa(i); + len = ft_strlen(s_ui); + if (i == 0 && param->prec == 0) + len = 0; + if (param->prec > len) + len = param->prec; + save = len; + if (param->width > len) + len = param->width; + if (!(s = malloc(sizeof(char) * (len + 1)))) + return (NULL); + s[len] = 0; + ft_printf_memset(s, len, param); + if (param->minus) + len = save; + s = fill_s_uint(s, len, s_ui, param); + free(s_ui); + return (s); +} diff --git a/ft_printf/srcs/ft_x_case.c b/ft_printf/srcs/ft_x_case.c new file mode 100644 index 0000000..89d7d5e --- /dev/null +++ b/ft_printf/srcs/ft_x_case.c @@ -0,0 +1,64 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_x_case.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pbonilla +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/03/08 16:22:32 by pbonilla #+# #+# */ +/* Updated: 2021/03/21 20:38:30 by pbonilla ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft_printf.h" + +char *fill_s_x(int len, int save, char *s_x, t_param *param) +{ + char *s; + int size; + int i; + int test; + + test = ft_atoi(s_x); + if (!(s = malloc(sizeof(char) * (len + 1)))) + return (NULL); + s[len] = 0; + ft_printf_memset(s, len, param); + size = ft_strlen(s_x); + i = size; + if (param->minus) + len = save; + while (--len >= 0 && --i >= 0) + { + if (!(s_x[i] == '0' && !param->prec && !test && s_x[0] == '0')) + s[len] = s_x[i]; + } + while (param->prec-- > size) + s[len--] = '0'; + free(s_x); + return (s); +} + +char *ft_x_case(t_param *param, unsigned long i) +{ + int save; + int len; + char *s_ui; + char *s_x; + + s_ui = ft_u_itoa(i); + if (param->type == 'x') + s_x = ft_convert_base(s_ui, "0123456789", "0123456789abcdef"); + else + s_x = ft_convert_base(s_ui, "0123456789", "0123456789ABCDEF"); + free(s_ui); + len = ft_strlen(s_x); + if (i == 0 && param->prec == 0) + len = 0; + if (param->prec > len) + len = param->prec; + save = len; + if (param->width > len) + len = param->width; + return (fill_s_x(len, save, s_x, param)); +} diff --git a/resources/sample b/resources/sample new file mode 100755 index 0000000000000000000000000000000000000000..d24e98f8b502d196a6013c2bf30ec93862ea4597 GIT binary patch literal 4744 zcmb7IU2I%O6`u93(}lX5wPUCohjL3DaFBiDznDO&nzg8dUaxo8-Yxsb z?%iOwk=n3zh)FH2C9p0iFcE2OpOvN01Zc4gdOg z06MYqHge*0`Bt@BUHpYzyH3mUs{g4K$Aeb4XPkOHW z`lj9dQ)zhBZjgq-F=csGS<-O%+-C@R@liSur5zIIUq6lzFVu3(gDGY!XVXad)4|27 zrP{x~vV2TvzyDAHja8+~>m``+Gb(bpX}Pw7&%PMG#VMA2E$csdzgq3QycE8(1k!<=wiSh`egvQ&9m?_Xcv4T^*7sV z$h8WH0|-k}9e5shEU#A^d-DJ|@49Aio@Ji$~7>kkS3W8}DXq z^g4W8aQPYP@Bf0)I*^!2MYF~}v)k-!-?v9~jINH(-j2?WPT{Cy>1cM&IF=|BQ@O0s zZT6a7?cGMJ9i1!g9S=vsp^327-P^TyHkFO0_ZY1+QQU6^ppnRtQH9^5@9Z`FsWLdq0UMsJvR)TA(^!Jd-HCM7)8t#RXKSCyRLdo1& z)Tm88cNjUpDKmpqohJ7RRj8RuN)C{TQ=9U3DYM?O^P0_+!@~wp_^XR_;2=Y z_9FnEaSS8A`^AHhS>u?w4T#@_9K`o9QyXgT6BhLj-VjY<0J3h}?IV!&egvU!g{feCOeCGG?t#cXj?RXy$za<{u%R)+je{|^?&pF7vbCo}wuUNq@+NIf9Gloac4!Uc_>ld^%w#;%4u@ z{XKUFS-6-|RsY0!&Lhao&qt?;m=ybTYG3u`EHs4o<;4h;@YgeR@ZP+ug> z8RWw-RxHW*A+ z7jUAG7iKnRC(KaaNIPnZFq6?@Qke0DEDRO53&NbsmQ1GxZ4oT!3W+rFs*_LK!j$2e z=$dmmh<0Kgzsv(*a&m#pMAF&$WE?KEq)b%`C=1;5sx2T>F0Bh2xvx3UKmbbFjMqk_*SXbPc#~>P2(> z(c~L09PfM^0rAbKn~tx70h+^&yo*mk!SB>f4t literal 0 HcmV?d00001 diff --git a/resources/sample.c b/resources/sample.c new file mode 100644 index 0000000..5fffccb --- /dev/null +++ b/resources/sample.c @@ -0,0 +1,7 @@ +#include + +int +main(void) { + printf("Hello, World!\n"); + return (0x0); +} diff --git a/resources/sample64 b/resources/sample64 new file mode 100755 index 0000000000000000000000000000000000000000..3805814c4cd76e8dc82f86f412b94d592fe7fb74 GIT binary patch literal 15960 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 rw1;_&pv~VNV<`Vl{0VyT_}>Ly9C$o