From 362668fe3525020cd0b1d504ec71558ad1cdf6cd Mon Sep 17 00:00:00 2001 From: Philippe BLAGOJEVIC Date: Wed, 4 May 2022 14:38:34 +0200 Subject: [PATCH] Added memorybook to parsing and cleaned most of the files --- Makefile | 5 +- headers/colors.h | 13 +- headers/cube3d.h | 13 +- headers/cube3d_macro.h | 12 + headers/cube3d_proto.h | 63 +- headers/cube3d_struct.h | 52 +- headers/memorybook.h | 12 + libs/libft | 1 - libs/libft/Makefile | 964 ++++++++++++++++++ libs/libft/deleted/ft_lst_find.bak | 24 + libs/libft/deleted/ft_lstadd_back.bak | 94 ++ libs/libft/deleted/ft_lstadd_front.bak | 94 ++ libs/libft/deleted/ft_lstclear.bak | 107 ++ libs/libft/deleted/ft_lstdelone.bak | 97 ++ libs/libft/deleted/ft_lstiter.bak | 85 ++ libs/libft/deleted/ft_lstlast.bak | 100 ++ libs/libft/deleted/ft_lstmap.bak | 145 +++ libs/libft/deleted/ft_lstnew.bak | 57 ++ libs/libft/deleted/ft_lstsize.bak | 86 ++ libs/libft/deleted/ft_putchar.c | 18 + libs/libft/deleted/ft_putendl.c | 19 + libs/libft/deleted/ft_putendl_fd.c | 23 + libs/libft/deleted/ft_putnbr.c | 18 + libs/libft/deleted/ft_putnbrendl.c | 18 + libs/libft/deleted/ft_putnbrendl_fd.c | 29 + libs/libft/deleted/ft_putstr.c | 22 + libs/libft/includes/ft_gnl.h | 31 + libs/libft/includes/ft_printf.h | 62 ++ libs/libft/includes/libft.h | 140 +++ libs/libft/srcs/ft_abs.c | 20 + libs/libft/srcs/ft_any.c | 32 + libs/libft/srcs/ft_arraymap.c | 28 + libs/libft/srcs/ft_arrint.c | 31 + libs/libft/srcs/ft_atoi.c | 33 + libs/libft/srcs/ft_atoibase.c | 75 ++ libs/libft/srcs/ft_atol.c | 22 + libs/libft/srcs/ft_bzero.c | 27 + libs/libft/srcs/ft_calloc.c | 64 ++ libs/libft/srcs/ft_concat_free.c | 53 + libs/libft/srcs/ft_convertbase.c | 196 ++++ libs/libft/srcs/ft_convertbase_free.c | 198 ++++ libs/libft/srcs/ft_foreach.c | 22 + libs/libft/srcs/ft_free_tab.c | 15 + libs/libft/srcs/ft_gnl.c | 138 +++ libs/libft/srcs/ft_greater.c | 8 + libs/libft/srcs/ft_isalnum.c | 18 + libs/libft/srcs/ft_isalpha.c | 18 + libs/libft/srcs/ft_isascii.c | 18 + libs/libft/srcs/ft_isdigit.c | 18 + libs/libft/srcs/ft_isnumber.c | 19 + libs/libft/srcs/ft_isprint.c | 18 + libs/libft/srcs/ft_issort.c | 26 + libs/libft/srcs/ft_itoa.c | 91 ++ libs/libft/srcs/ft_lstbegin.c | 24 + libs/libft/srcs/ft_lstcopy.c | 33 + libs/libft/srcs/ft_lstcreate.c | 30 + libs/libft/srcs/ft_lstend.c | 24 + libs/libft/srcs/ft_lsterase.c | 31 + libs/libft/srcs/ft_lstfind.c | 25 + libs/libft/srcs/ft_lstfree.c | 32 + libs/libft/srcs/ft_lstinsert.c | 26 + libs/libft/srcs/ft_lstlen.c | 30 + libs/libft/srcs/ft_lstloop.c | 29 + libs/libft/srcs/ft_lstloop_back.c | 29 + libs/libft/srcs/ft_lstpush_back.c | 41 + libs/libft/srcs/ft_lstpush_front.c | 24 + libs/libft/srcs/ft_memalloc.c | 28 + libs/libft/srcs/ft_memccpy.c | 36 + libs/libft/srcs/ft_memchr.c | 51 + libs/libft/srcs/ft_memcmp.c | 32 + libs/libft/srcs/ft_memcpy.c | 46 + libs/libft/srcs/ft_memdel.c | 26 + libs/libft/srcs/ft_memmove.c | 68 ++ libs/libft/srcs/ft_memset.c | 29 + libs/libft/srcs/ft_printf_files/ft_convert.c | 105 ++ .../srcs/ft_printf_files/ft_flag_transform.c | 199 ++++ .../ft_printf_files/ft_flag_transform_bonus.c | 75 ++ .../libft/srcs/ft_printf_files/ft_next_word.c | 98 ++ libs/libft/srcs/ft_printf_files/ft_printf.c | 162 +++ libs/libft/srcs/ft_putchar_fd.c | 18 + libs/libft/srcs/ft_putnbr_fd.c | 28 + libs/libft/srcs/ft_putnbrbase.c | 59 ++ libs/libft/srcs/ft_putstr_fd.c | 23 + libs/libft/srcs/ft_sign.c | 20 + libs/libft/srcs/ft_smaller.c | 8 + libs/libft/srcs/ft_split.c | 139 +++ libs/libft/srcs/ft_sqrt.c | 15 + libs/libft/srcs/ft_strcat.c | 32 + libs/libft/srcs/ft_strchr.c | 33 + libs/libft/srcs/ft_strchrset.c | 32 + libs/libft/srcs/ft_strclr.c | 23 + libs/libft/srcs/ft_strcmp.c | 28 + libs/libft/srcs/ft_strcpy.c | 28 + libs/libft/srcs/ft_strdel.c | 26 + libs/libft/srcs/ft_strdup.c | 33 + libs/libft/srcs/ft_strequ.c | 24 + libs/libft/srcs/ft_striter.c | 23 + libs/libft/srcs/ft_striteri.c | 26 + libs/libft/srcs/ft_strjoin.c | 79 ++ libs/libft/srcs/ft_strjoinfree.c | 29 + libs/libft/srcs/ft_strlcat.c | 108 ++ libs/libft/srcs/ft_strlcpy.c | 70 ++ libs/libft/srcs/ft_strlen.c | 27 + libs/libft/srcs/ft_strmap.c | 32 + libs/libft/srcs/ft_strmapi.c | 75 ++ libs/libft/srcs/ft_strmultisplit.c | 83 ++ libs/libft/srcs/ft_strncat.c | 32 + libs/libft/srcs/ft_strncmp.c | 32 + libs/libft/srcs/ft_strncpy.c | 30 + libs/libft/srcs/ft_strnequ.c | 25 + libs/libft/srcs/ft_strnew.c | 27 + libs/libft/srcs/ft_strnstr.c | 42 + libs/libft/srcs/ft_strrchr.c | 32 + libs/libft/srcs/ft_strstr.c | 42 + libs/libft/srcs/ft_strtrim.c | 101 ++ libs/libft/srcs/ft_substr.c | 105 ++ libs/libft/srcs/ft_tolower.c | 20 + libs/libft/srcs/ft_toupper.c | 20 + libs/libft/srcs/ft_utoa.c | 74 ++ libs/libft/testing/Makefile | 154 +++ libs/libft/testing/includes/libftest.h | 104 ++ libs/libft/testing/libftest | Bin 0 -> 321368 bytes libs/libft/testing/main.c | 95 ++ libs/libft/testing/srcs/test_abs.c | 23 + libs/libft/testing/srcs/test_any.c | 131 +++ libs/libft/testing/srcs/test_arraymap.c | 28 + libs/libft/testing/srcs/test_atoi.c | 39 + libs/libft/testing/srcs/test_atoibase.c | 75 ++ libs/libft/testing/srcs/test_bzero.c | 27 + libs/libft/testing/srcs/test_calloc.c | 64 ++ libs/libft/testing/srcs/test_concat_free.c | 53 + libs/libft/testing/srcs/test_convertbase.c | 196 ++++ .../testing/srcs/test_convertbase_free.c | 198 ++++ libs/libft/testing/srcs/test_foreach.c | 22 + libs/libft/testing/srcs/test_gnl.c | 135 +++ libs/libft/testing/srcs/test_greater.c | 8 + libs/libft/testing/srcs/test_isalnum.c | 18 + libs/libft/testing/srcs/test_isalpha.c | 18 + libs/libft/testing/srcs/test_isascii.c | 18 + libs/libft/testing/srcs/test_isdigit.c | 18 + libs/libft/testing/srcs/test_isprint.c | 18 + libs/libft/testing/srcs/test_issort.c | 26 + libs/libft/testing/srcs/test_itoa.c | 91 ++ libs/libft/testing/srcs/test_lstadd_back.c | 90 ++ libs/libft/testing/srcs/test_lstadd_front.c | 94 ++ libs/libft/testing/srcs/test_lstclear.c | 107 ++ libs/libft/testing/srcs/test_lstdelone.c | 97 ++ libs/libft/testing/srcs/test_lstiter.c | 85 ++ libs/libft/testing/srcs/test_lstlast.c | 100 ++ libs/libft/testing/srcs/test_lstmap.c | 145 +++ libs/libft/testing/srcs/test_lstnew.c | 59 ++ libs/libft/testing/srcs/test_lstsize.c | 86 ++ libs/libft/testing/srcs/test_memalloc.c | 27 + libs/libft/testing/srcs/test_memccpy.c | 36 + libs/libft/testing/srcs/test_memchr.c | 51 + libs/libft/testing/srcs/test_memcmp.c | 32 + libs/libft/testing/srcs/test_memcpy.c | 46 + libs/libft/testing/srcs/test_memdel.c | 26 + libs/libft/testing/srcs/test_memmove.c | 68 ++ libs/libft/testing/srcs/test_memset.c | 29 + libs/libft/testing/srcs/test_printf.c | 0 libs/libft/testing/srcs/test_putchar.c | 18 + libs/libft/testing/srcs/test_putchar_fd.c | 18 + libs/libft/testing/srcs/test_putendl.c | 19 + libs/libft/testing/srcs/test_putendl_fd.c | 23 + libs/libft/testing/srcs/test_putnbr.c | 18 + libs/libft/testing/srcs/test_putnbr_fd.c | 28 + libs/libft/testing/srcs/test_putnbrbase.c | 59 ++ libs/libft/testing/srcs/test_putnbrendl.c | 18 + libs/libft/testing/srcs/test_putnbrendl_fd.c | 29 + libs/libft/testing/srcs/test_putstr.c | 22 + libs/libft/testing/srcs/test_putstr_fd.c | 23 + libs/libft/testing/srcs/test_sign.c | 8 + libs/libft/testing/srcs/test_smaller.c | 8 + libs/libft/testing/srcs/test_split.c | 137 +++ libs/libft/testing/srcs/test_sqrt.c | 15 + libs/libft/testing/srcs/test_strcat.c | 32 + libs/libft/testing/srcs/test_strchr.c | 33 + libs/libft/testing/srcs/test_strchrset.c | 32 + libs/libft/testing/srcs/test_strclr.c | 23 + libs/libft/testing/srcs/test_strcmp.c | 28 + libs/libft/testing/srcs/test_strcpy.c | 28 + libs/libft/testing/srcs/test_strdel.c | 26 + libs/libft/testing/srcs/test_strdup.c | 32 + libs/libft/testing/srcs/test_strequ.c | 24 + libs/libft/testing/srcs/test_striter.c | 23 + libs/libft/testing/srcs/test_striteri.c | 26 + libs/libft/testing/srcs/test_strjoin.c | 79 ++ libs/libft/testing/srcs/test_strjoinfree.c | 29 + libs/libft/testing/srcs/test_strlcat.c | 108 ++ libs/libft/testing/srcs/test_strlcpy.c | 70 ++ libs/libft/testing/srcs/test_strlen.c | 27 + libs/libft/testing/srcs/test_strmap.c | 32 + libs/libft/testing/srcs/test_strmapi.c | 75 ++ libs/libft/testing/srcs/test_strmultisplit.c | 83 ++ libs/libft/testing/srcs/test_strncat.c | 32 + libs/libft/testing/srcs/test_strncmp.c | 32 + libs/libft/testing/srcs/test_strncpy.c | 30 + libs/libft/testing/srcs/test_strnequ.c | 25 + libs/libft/testing/srcs/test_strnew.c | 27 + libs/libft/testing/srcs/test_strnstr.c | 42 + libs/libft/testing/srcs/test_strrchr.c | 32 + libs/libft/testing/srcs/test_strstr.c | 42 + libs/libft/testing/srcs/test_strtrim.c | 101 ++ libs/libft/testing/srcs/test_substr.c | 104 ++ libs/libft/testing/srcs/test_tolower.c | 20 + libs/libft/testing/srcs/test_toupper.c | 7 + libs/libft/testing/srcs/test_utoa.c | 74 ++ maps/map_valid_03.cub | 24 +- srcs/cube3d.c | 26 +- srcs/draw/draw.c | 85 +- srcs/draw/draw_column.c | 22 +- srcs/draw/ray_intersect.c | 12 + srcs/draw/raycast.c | 89 +- srcs/hook/key_action_1.c | 36 +- srcs/hook/key_action_2.c | 20 +- srcs/hook/keyhook.c | 63 +- srcs/init/init_game.c | 37 +- srcs/init/init_struct.c | 15 +- srcs/init/init_textures.c | 12 + srcs/mem/memorybook.c | 14 +- srcs/mem/memorybook_2d.c | 30 +- srcs/mem/memorybook_utils.c | 12 + srcs/parsing/check_map_borders.c | 44 + .../{check_map.c => check_map_content.c} | 48 +- srcs/parsing/check_path.c | 24 +- srcs/parsing/check_rgb.c | 8 +- srcs/parsing/init_parsing.c | 27 +- srcs/player/player_limits.c | 12 + srcs/player/player_moves.c | 12 + srcs/player/player_rotates.c | 21 +- 231 files changed, 11474 insertions(+), 405 deletions(-) delete mode 160000 libs/libft create mode 100644 libs/libft/Makefile create mode 100644 libs/libft/deleted/ft_lst_find.bak create mode 100644 libs/libft/deleted/ft_lstadd_back.bak create mode 100644 libs/libft/deleted/ft_lstadd_front.bak create mode 100644 libs/libft/deleted/ft_lstclear.bak create mode 100644 libs/libft/deleted/ft_lstdelone.bak create mode 100644 libs/libft/deleted/ft_lstiter.bak create mode 100644 libs/libft/deleted/ft_lstlast.bak create mode 100644 libs/libft/deleted/ft_lstmap.bak create mode 100644 libs/libft/deleted/ft_lstnew.bak create mode 100644 libs/libft/deleted/ft_lstsize.bak create mode 100644 libs/libft/deleted/ft_putchar.c create mode 100644 libs/libft/deleted/ft_putendl.c create mode 100644 libs/libft/deleted/ft_putendl_fd.c create mode 100644 libs/libft/deleted/ft_putnbr.c create mode 100644 libs/libft/deleted/ft_putnbrendl.c create mode 100644 libs/libft/deleted/ft_putnbrendl_fd.c create mode 100644 libs/libft/deleted/ft_putstr.c create mode 100644 libs/libft/includes/ft_gnl.h create mode 100644 libs/libft/includes/ft_printf.h create mode 100644 libs/libft/includes/libft.h create mode 100644 libs/libft/srcs/ft_abs.c create mode 100644 libs/libft/srcs/ft_any.c create mode 100644 libs/libft/srcs/ft_arraymap.c create mode 100644 libs/libft/srcs/ft_arrint.c create mode 100644 libs/libft/srcs/ft_atoi.c create mode 100644 libs/libft/srcs/ft_atoibase.c create mode 100644 libs/libft/srcs/ft_atol.c create mode 100644 libs/libft/srcs/ft_bzero.c create mode 100644 libs/libft/srcs/ft_calloc.c create mode 100644 libs/libft/srcs/ft_concat_free.c create mode 100644 libs/libft/srcs/ft_convertbase.c create mode 100644 libs/libft/srcs/ft_convertbase_free.c create mode 100644 libs/libft/srcs/ft_foreach.c create mode 100644 libs/libft/srcs/ft_free_tab.c create mode 100644 libs/libft/srcs/ft_gnl.c create mode 100644 libs/libft/srcs/ft_greater.c create mode 100644 libs/libft/srcs/ft_isalnum.c create mode 100644 libs/libft/srcs/ft_isalpha.c create mode 100644 libs/libft/srcs/ft_isascii.c create mode 100644 libs/libft/srcs/ft_isdigit.c create mode 100644 libs/libft/srcs/ft_isnumber.c create mode 100644 libs/libft/srcs/ft_isprint.c create mode 100644 libs/libft/srcs/ft_issort.c create mode 100644 libs/libft/srcs/ft_itoa.c create mode 100644 libs/libft/srcs/ft_lstbegin.c create mode 100644 libs/libft/srcs/ft_lstcopy.c create mode 100644 libs/libft/srcs/ft_lstcreate.c create mode 100644 libs/libft/srcs/ft_lstend.c create mode 100644 libs/libft/srcs/ft_lsterase.c create mode 100644 libs/libft/srcs/ft_lstfind.c create mode 100644 libs/libft/srcs/ft_lstfree.c create mode 100644 libs/libft/srcs/ft_lstinsert.c create mode 100644 libs/libft/srcs/ft_lstlen.c create mode 100644 libs/libft/srcs/ft_lstloop.c create mode 100644 libs/libft/srcs/ft_lstloop_back.c create mode 100644 libs/libft/srcs/ft_lstpush_back.c create mode 100644 libs/libft/srcs/ft_lstpush_front.c create mode 100644 libs/libft/srcs/ft_memalloc.c create mode 100644 libs/libft/srcs/ft_memccpy.c create mode 100644 libs/libft/srcs/ft_memchr.c create mode 100644 libs/libft/srcs/ft_memcmp.c create mode 100644 libs/libft/srcs/ft_memcpy.c create mode 100644 libs/libft/srcs/ft_memdel.c create mode 100644 libs/libft/srcs/ft_memmove.c create mode 100644 libs/libft/srcs/ft_memset.c create mode 100644 libs/libft/srcs/ft_printf_files/ft_convert.c create mode 100644 libs/libft/srcs/ft_printf_files/ft_flag_transform.c create mode 100644 libs/libft/srcs/ft_printf_files/ft_flag_transform_bonus.c create mode 100644 libs/libft/srcs/ft_printf_files/ft_next_word.c create mode 100644 libs/libft/srcs/ft_printf_files/ft_printf.c create mode 100644 libs/libft/srcs/ft_putchar_fd.c create mode 100644 libs/libft/srcs/ft_putnbr_fd.c create mode 100644 libs/libft/srcs/ft_putnbrbase.c create mode 100644 libs/libft/srcs/ft_putstr_fd.c create mode 100644 libs/libft/srcs/ft_sign.c create mode 100644 libs/libft/srcs/ft_smaller.c create mode 100644 libs/libft/srcs/ft_split.c create mode 100644 libs/libft/srcs/ft_sqrt.c create mode 100644 libs/libft/srcs/ft_strcat.c create mode 100644 libs/libft/srcs/ft_strchr.c create mode 100644 libs/libft/srcs/ft_strchrset.c create mode 100644 libs/libft/srcs/ft_strclr.c create mode 100644 libs/libft/srcs/ft_strcmp.c create mode 100644 libs/libft/srcs/ft_strcpy.c create mode 100644 libs/libft/srcs/ft_strdel.c create mode 100644 libs/libft/srcs/ft_strdup.c create mode 100644 libs/libft/srcs/ft_strequ.c create mode 100644 libs/libft/srcs/ft_striter.c create mode 100644 libs/libft/srcs/ft_striteri.c create mode 100644 libs/libft/srcs/ft_strjoin.c create mode 100644 libs/libft/srcs/ft_strjoinfree.c create mode 100644 libs/libft/srcs/ft_strlcat.c create mode 100644 libs/libft/srcs/ft_strlcpy.c create mode 100644 libs/libft/srcs/ft_strlen.c create mode 100644 libs/libft/srcs/ft_strmap.c create mode 100644 libs/libft/srcs/ft_strmapi.c create mode 100644 libs/libft/srcs/ft_strmultisplit.c create mode 100644 libs/libft/srcs/ft_strncat.c create mode 100644 libs/libft/srcs/ft_strncmp.c create mode 100644 libs/libft/srcs/ft_strncpy.c create mode 100644 libs/libft/srcs/ft_strnequ.c create mode 100644 libs/libft/srcs/ft_strnew.c create mode 100644 libs/libft/srcs/ft_strnstr.c create mode 100644 libs/libft/srcs/ft_strrchr.c create mode 100644 libs/libft/srcs/ft_strstr.c create mode 100644 libs/libft/srcs/ft_strtrim.c create mode 100644 libs/libft/srcs/ft_substr.c create mode 100644 libs/libft/srcs/ft_tolower.c create mode 100644 libs/libft/srcs/ft_toupper.c create mode 100644 libs/libft/srcs/ft_utoa.c create mode 100644 libs/libft/testing/Makefile create mode 100644 libs/libft/testing/includes/libftest.h create mode 100755 libs/libft/testing/libftest create mode 100644 libs/libft/testing/main.c create mode 100644 libs/libft/testing/srcs/test_abs.c create mode 100644 libs/libft/testing/srcs/test_any.c create mode 100644 libs/libft/testing/srcs/test_arraymap.c create mode 100644 libs/libft/testing/srcs/test_atoi.c create mode 100644 libs/libft/testing/srcs/test_atoibase.c create mode 100644 libs/libft/testing/srcs/test_bzero.c create mode 100644 libs/libft/testing/srcs/test_calloc.c create mode 100644 libs/libft/testing/srcs/test_concat_free.c create mode 100644 libs/libft/testing/srcs/test_convertbase.c create mode 100644 libs/libft/testing/srcs/test_convertbase_free.c create mode 100644 libs/libft/testing/srcs/test_foreach.c create mode 100644 libs/libft/testing/srcs/test_gnl.c create mode 100644 libs/libft/testing/srcs/test_greater.c create mode 100644 libs/libft/testing/srcs/test_isalnum.c create mode 100644 libs/libft/testing/srcs/test_isalpha.c create mode 100644 libs/libft/testing/srcs/test_isascii.c create mode 100644 libs/libft/testing/srcs/test_isdigit.c create mode 100644 libs/libft/testing/srcs/test_isprint.c create mode 100644 libs/libft/testing/srcs/test_issort.c create mode 100644 libs/libft/testing/srcs/test_itoa.c create mode 100644 libs/libft/testing/srcs/test_lstadd_back.c create mode 100644 libs/libft/testing/srcs/test_lstadd_front.c create mode 100644 libs/libft/testing/srcs/test_lstclear.c create mode 100644 libs/libft/testing/srcs/test_lstdelone.c create mode 100644 libs/libft/testing/srcs/test_lstiter.c create mode 100644 libs/libft/testing/srcs/test_lstlast.c create mode 100644 libs/libft/testing/srcs/test_lstmap.c create mode 100644 libs/libft/testing/srcs/test_lstnew.c create mode 100644 libs/libft/testing/srcs/test_lstsize.c create mode 100644 libs/libft/testing/srcs/test_memalloc.c create mode 100644 libs/libft/testing/srcs/test_memccpy.c create mode 100644 libs/libft/testing/srcs/test_memchr.c create mode 100644 libs/libft/testing/srcs/test_memcmp.c create mode 100644 libs/libft/testing/srcs/test_memcpy.c create mode 100644 libs/libft/testing/srcs/test_memdel.c create mode 100644 libs/libft/testing/srcs/test_memmove.c create mode 100644 libs/libft/testing/srcs/test_memset.c create mode 100644 libs/libft/testing/srcs/test_printf.c create mode 100644 libs/libft/testing/srcs/test_putchar.c create mode 100644 libs/libft/testing/srcs/test_putchar_fd.c create mode 100644 libs/libft/testing/srcs/test_putendl.c create mode 100644 libs/libft/testing/srcs/test_putendl_fd.c create mode 100644 libs/libft/testing/srcs/test_putnbr.c create mode 100644 libs/libft/testing/srcs/test_putnbr_fd.c create mode 100644 libs/libft/testing/srcs/test_putnbrbase.c create mode 100644 libs/libft/testing/srcs/test_putnbrendl.c create mode 100644 libs/libft/testing/srcs/test_putnbrendl_fd.c create mode 100644 libs/libft/testing/srcs/test_putstr.c create mode 100644 libs/libft/testing/srcs/test_putstr_fd.c create mode 100644 libs/libft/testing/srcs/test_sign.c create mode 100644 libs/libft/testing/srcs/test_smaller.c create mode 100644 libs/libft/testing/srcs/test_split.c create mode 100644 libs/libft/testing/srcs/test_sqrt.c create mode 100644 libs/libft/testing/srcs/test_strcat.c create mode 100644 libs/libft/testing/srcs/test_strchr.c create mode 100644 libs/libft/testing/srcs/test_strchrset.c create mode 100644 libs/libft/testing/srcs/test_strclr.c create mode 100644 libs/libft/testing/srcs/test_strcmp.c create mode 100644 libs/libft/testing/srcs/test_strcpy.c create mode 100644 libs/libft/testing/srcs/test_strdel.c create mode 100644 libs/libft/testing/srcs/test_strdup.c create mode 100644 libs/libft/testing/srcs/test_strequ.c create mode 100644 libs/libft/testing/srcs/test_striter.c create mode 100644 libs/libft/testing/srcs/test_striteri.c create mode 100644 libs/libft/testing/srcs/test_strjoin.c create mode 100644 libs/libft/testing/srcs/test_strjoinfree.c create mode 100644 libs/libft/testing/srcs/test_strlcat.c create mode 100644 libs/libft/testing/srcs/test_strlcpy.c create mode 100644 libs/libft/testing/srcs/test_strlen.c create mode 100644 libs/libft/testing/srcs/test_strmap.c create mode 100644 libs/libft/testing/srcs/test_strmapi.c create mode 100644 libs/libft/testing/srcs/test_strmultisplit.c create mode 100644 libs/libft/testing/srcs/test_strncat.c create mode 100644 libs/libft/testing/srcs/test_strncmp.c create mode 100644 libs/libft/testing/srcs/test_strncpy.c create mode 100644 libs/libft/testing/srcs/test_strnequ.c create mode 100644 libs/libft/testing/srcs/test_strnew.c create mode 100644 libs/libft/testing/srcs/test_strnstr.c create mode 100644 libs/libft/testing/srcs/test_strrchr.c create mode 100644 libs/libft/testing/srcs/test_strstr.c create mode 100644 libs/libft/testing/srcs/test_strtrim.c create mode 100644 libs/libft/testing/srcs/test_substr.c create mode 100644 libs/libft/testing/srcs/test_tolower.c create mode 100644 libs/libft/testing/srcs/test_toupper.c create mode 100644 libs/libft/testing/srcs/test_utoa.c create mode 100644 srcs/parsing/check_map_borders.c rename srcs/parsing/{check_map.c => check_map_content.c} (65%) diff --git a/Makefile b/Makefile index f1efa2a..cbcaf0e 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,8 @@ SRCS += init_parsing.c \ check_extension.c \ check_path.c \ check_rgb.c \ - check_map.c + check_map_borders.c \ + check_map_content.c # hook/ SRCS += keyhook.c \ key_action_1.c \ @@ -79,7 +80,7 @@ RM_OBJS = rm -rf $(D_OBJS) # flags CFLAGS = -Wall -Wextra -Werror $(INCLUDES) -CFLAGS += -g3 +CFLAGS += -g3 -fsanitize=address LFLAGS = -L$(D_LFT) -lft LFLAGS += -L$(D_LMLX) -lm -lmlx -lXext -lX11 diff --git a/headers/colors.h b/headers/colors.h index 0374e42..1ffa70a 100644 --- a/headers/colors.h +++ b/headers/colors.h @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* colors.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:34:26 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:35:12 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef COLORS_H # define COLORS_H @@ -22,4 +34,3 @@ # define RESET "\e[0m" #endif - diff --git a/headers/cube3d.h b/headers/cube3d.h index d436996..9749e1d 100644 --- a/headers/cube3d.h +++ b/headers/cube3d.h @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* cube3d.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:34:54 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:35:31 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef CUBE3D_H # define CUBE3D_H @@ -10,7 +22,6 @@ # include // for open() # include // for open flags - # include "colors.h" # include "memorybook.h" diff --git a/headers/cube3d_macro.h b/headers/cube3d_macro.h index 0900fab..34118b0 100644 --- a/headers/cube3d_macro.h +++ b/headers/cube3d_macro.h @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* cube3d_macro.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:34:39 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:34:46 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef CUBE3D_MACRO_H # define CUBE3D_MACRO_H diff --git a/headers/cube3d_proto.h b/headers/cube3d_proto.h index 32b21c9..1fae9d7 100644 --- a/headers/cube3d_proto.h +++ b/headers/cube3d_proto.h @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* cube3d_proto.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:36:55 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:38:53 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef CUBE3D_PROTO_H # define CUBE3D_PROTO_H @@ -6,59 +18,56 @@ // ------------------------------- // cube3d.c void destroy_mlx(void *param); -int shut_down(); - +int shut_down(void); // ------------------------------- // SRC/INIT // ------------------------------- // init_struct.c -t_game *init_struct(void); +t_game *init_struct(void); // init_game.c -void init_game(t_game *game); +void init_game(t_game *game); // init_textures.c void init_txtr(t_txt *txt, void *mlx_ptr); - // ------------------------------- // SRC/GNL // ------------------------------- // get_next_line.c -int get_next_line(int fd, char **line); - +int get_next_line(int fd, char **line); // ------------------------------- // SRC/PARSING // ------------------------------- // init_parsing.c -int init_parsing(t_game *game, char *file); +int init_parsing(t_game *game, char *file); // check_extension.c -int check_extension(char *filename, char *ext); +int check_extension(char *filename, char *ext); // check_path.c -int check_elements(t_game *game, char *file); +int check_elements(t_game *game, char *file); // check_rgb.c -int check_rgb(t_txt *txt, char *element, char identifier); -// check_map.c -int check_map(t_map *map); - +int check_rgb(t_txt *txt, char *element, char identifier); +// check_map_borders.c +int check_map(t_map *map); +// check_map_content.c +int check_content(t_map *map); // ------------------------------- // SRC/HOOK // ------------------------------- // keyhook.c -int keypress(int keycode, t_game *game); -int keyrelease(int keycode, t_game *game); -int hook_action(t_game *game); +int keypress(int keycode, t_game *game); +int keyrelease(int keycode, t_game *game); +int hook_action(t_game *game); // key_action_1.c -int is_esc(int *k_hook, int *is_action); -int is_go_left(int *k_hook, int *is_action); -int is_go_right(int *k_hook, int *is_action); -int is_go_forward(int *k_hook, int *is_action); -int is_go_backward(int *k_hook, int *is_action); +int is_esc(int *k_hook, int *is_action); +int is_go_left(int *k_hook, int *is_action); +int is_go_right(int *k_hook, int *is_action); +int is_go_forward(int *k_hook, int *is_action); +int is_go_backward(int *k_hook, int *is_action); // key_action_2.c -int is_turn_left(int *k_hook, int *is_action); -int is_turn_right(int *k_hook, int *is_action); - +int is_turn_left(int *k_hook, int *is_action); +int is_turn_right(int *k_hook, int *is_action); // ------------------------------- // SRC/PLAYER @@ -75,8 +84,8 @@ void plr_turn(t_plr *plr, int deg); void plr_turn_right(t_plr *plr); void plr_turn_left(t_plr *plr); // player_limits.c -int is_wall(t_game *game, int cell_x, int cell_y); -int plr_out_limits(t_game *game, int x, int y); +int is_wall(t_game *game, int cell_x, int cell_y); +int plr_out_limits(t_game *game, int x, int y); // ------------------------------- // SRC/DRAW diff --git a/headers/cube3d_struct.h b/headers/cube3d_struct.h index 542f315..0cfdbc2 100644 --- a/headers/cube3d_struct.h +++ b/headers/cube3d_struct.h @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* cube3d_struct.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:31:38 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:34:07 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef CUBE3D_STRUCT_H # define CUBE3D_STRUCT_H @@ -8,19 +20,19 @@ * - vector (two points) */ -typedef struct s_d_coord +typedef struct s_d_coord { double x; double y; } t_d_coord; -typedef struct s_coord +typedef struct s_coord { int x; int y; } t_coord; -typedef struct s_vec +typedef struct s_vec { t_coord start; t_coord end; @@ -30,7 +42,7 @@ typedef struct s_vec * struct with all elements for raycasting */ -typedef struct s_wall +typedef struct s_wall { t_vec vec; int height; @@ -44,7 +56,7 @@ typedef struct s_wall * struct with all elements for raycasting */ -typedef struct s_rcast +typedef struct s_rcast { t_vec screen_size; t_vec ray; @@ -76,14 +88,14 @@ typedef struct s_rcast * structs for windows, and images associated */ -typedef struct s_win +typedef struct s_win { void *ptr; int size_x; int size_y; } t_win; -typedef struct s_img +typedef struct s_img { void *ptr; char *data; @@ -98,7 +110,7 @@ typedef struct s_img * wall textures and floor/ceiling colors */ -typedef struct s_txt +typedef struct s_txt { char *txt_north; char *txt_south; @@ -116,7 +128,7 @@ typedef struct s_txt * structs for the map */ -typedef struct s_map +typedef struct s_map { char **content; char *tmp_str; @@ -132,12 +144,10 @@ typedef struct s_map * structs for the player and its moves */ -typedef struct s_plr +typedef struct s_plr { - // player t_d_coord exact; t_coord pos; - // rot int rot; int deg; double cosi; @@ -150,32 +160,16 @@ typedef struct s_plr * struct with all elements for the project */ -typedef struct s_game +typedef struct s_game { void *mlx_ptr; - // game window t_win win; t_img img; - // player t_plr plr; - // rays t_rcast rcast; - // textures and colors t_txt txt; - // map t_map map; - //tmp draw map - // // map window - // t_win map_win; - // t_img map_img; - // // rays - // int ray_highlight; - // int ray_activ; - // t_vec ray; - // tmp end - - // key hook int k_hook[MAX_NB_KEY]; } t_game; diff --git a/headers/memorybook.h b/headers/memorybook.h index d620f46..200cf78 100644 --- a/headers/memorybook.h +++ b/headers/memorybook.h @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* memorybook.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:35:47 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:36:44 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef MEMORYBOOK_H # define MEMORYBOOK_H diff --git a/libs/libft b/libs/libft deleted file mode 160000 index 8fe8437..0000000 --- a/libs/libft +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8fe843722b5af4fa5bdb31fcd1a1a7051a59c9a9 diff --git a/libs/libft/Makefile b/libs/libft/Makefile new file mode 100644 index 0000000..2181f97 --- /dev/null +++ b/libs/libft/Makefile @@ -0,0 +1,964 @@ +# - - - - - - - - - # +# variables names # +# - - - - - - - - - # + +NAME = libft.a +CC = gcc +VPATH = srcs/ \ + srcs/ft_printf_files/ + +IDIR = ./includes +_DEP = libft.h +DEPS = $(_DEP:%.h=$(IDIR)/%.h) + +CFLAGS = -I$(IDIR) +CFLAGS += -Wall -Wextra -Werror -g3 + +SRCS = ft_memset.c \ + ft_bzero.c \ + ft_memcpy.c \ + ft_memccpy.c \ + ft_memmove.c \ + ft_memchr.c \ + ft_memcmp.c \ + ft_memalloc.c \ + ft_memdel.c \ + ft_calloc.c \ + \ + ft_isalpha.c \ + ft_isdigit.c \ + ft_isalnum.c \ + ft_isnumber.c \ + ft_isascii.c \ + ft_isprint.c \ + ft_toupper.c \ + ft_tolower.c \ + \ + ft_strlen.c \ + ft_strchr.c \ + ft_strrchr.c \ + ft_strchrset.c \ + ft_strncmp.c \ + ft_strlcpy.c \ + ft_strlcat.c \ + ft_strnstr.c \ + ft_strdup.c \ + ft_strjoin.c \ + ft_strtrim.c \ + ft_strmapi.c \ + ft_strcat.c \ + ft_strcmp.c \ + ft_strcpy.c \ + ft_strncat.c \ + ft_strncpy.c \ + ft_strstr.c \ + ft_strjoinfree.c \ + ft_strclr.c \ + ft_strdel.c \ + ft_strequ.c \ + ft_striter.c \ + ft_striteri.c \ + ft_strmap.c \ + ft_strnequ.c \ + ft_strnew.c \ + ft_substr.c \ + ft_split.c \ + \ + ft_atoi.c \ + ft_atol.c \ + ft_itoa.c \ + ft_utoa.c \ + \ + ft_putchar_fd.c \ + ft_putstr_fd.c \ + ft_putnbr_fd.c \ + ft_putnbrbase.c \ + \ + ft_lstcreate.c \ + ft_lstpush_back.c \ + ft_lstpush_front.c \ + ft_lstloop.c \ + ft_lstloop_back.c \ + ft_lstbegin.c \ + ft_lstend.c \ + ft_lstfind.c \ + ft_lstinsert.c \ + ft_lsterase.c \ + ft_lstfree.c \ + ft_lstlen.c \ + ft_lstcopy.c \ + \ + ft_any.c \ + ft_atoibase.c \ + ft_convertbase.c \ + ft_convertbase_free.c \ + ft_foreach.c \ + ft_issort.c \ + ft_arraymap.c \ + ft_strmultisplit.c \ + \ + ft_gnl.c \ + ft_concat_free.c \ + \ + ft_printf.c \ + ft_next_word.c \ + ft_convert.c \ + ft_flag_transform.c \ + ft_flag_transform_bonus.c \ + ft_abs.c \ + ft_greater.c \ + ft_smaller.c \ + ft_sign.c \ + ft_sqrt.c \ + ft_free_tab.c \ + \ + ft_arrint.c + + # deleted : \ + 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_putstr.c \ + ft_putchar.c \ + ft_putendl.c \ + ft_putnbr.c \ + ft_putnbrendl.c \ + ft_putnbrendl_fd.c \ + ft_putendl_fd.c \ + + +ODIR = ./builds +OBJS = $(SRCS:%.c=$(ODIR)/%.o) + + +# - - - - - - - - - - - # +# rules to execute # +# - - - - - - - - - - - # + + +all: $(NAME) + +$(ODIR): + @printf "\033[35m" + mkdir -p $(ODIR) + @printf "\033[0m" + +$(NAME): $(ODIR) $(OBJS) $(DEPS) + @printf "\033[33m" + ar -rc $@ $(OBJS) + ranlib $@ + @printf "\033[0m" + +$(ODIR)/%.o: %.c + @printf "\033[36m" + $(CC) $(CFLAGS) -c -o $@ $< + +clean: + @printf "\033[31m" + /bin/rm -rf $(ODIR) + @printf "\033[0m" + +fclean: clean + @printf "\033[31m" + /bin/rm -f $(NAME) + @printf "\033[0m" + +re: fclean all + +.PHONY: clean fclean re all + + + + + + + + + + + +# ------------------------------------------------------ # +# explication complete etapes par etapes depuis le debut # +# ------------------------------------------------------ # + +## 1 - compiler avec gcc [25 gj] +# compiler un programme [29 gj] +# compiler en plusieurs fichiers [54 gj] +# les .o : compiler et linker [102 gj] + +## 2 - creer une librairie [135 gj] +# ar rc [139 gj] +# ar rc en plusieurs fois [164 gj] +# ranlib [185 gj] + +## 3 - fichiers .h [198 gj] +# a quoi sert un header [202 gj] +# ecrire un header [229 gj] +# comment ca se compile [273 gj] + +## 4 - ecrire un make file [305 gj] +# basic makefile [309 gj] +# makefile with subdirectories [462 gj] +# makefile making another makefile [583 gj] +# makefile for a library [690 gj] + +## ---------------------- +## 1 - compiler avec gcc +## ---------------------- + +# - - - - - - - - - - - - - - - - - - - - - - +# compiler un programme qui contient un main +# - - - - - - - - - - - - - - - - - - - - - - + +# quand on ecrit un programme il contient un main et les +# fonctions dont le main a besoin (ex ft_putchar) : +# +# # #include +# # +# # void ft_putchar(char c) +# # { +# # write(1, &c, 1); +# # } +# # +# # int main() +# # { +# # ft_putchar('0'); +# # return (0); +# # } +# +# on peut compiler ce fichier avec gcc en faisant : +# gcc file.c +# et ca sort un executable a.out +# si on l'execute "./a.out" ca ecrit 0 dans la console + +# - - - - - - - - - - - - - - - - - - - - - - - +# compiler un programme en plusieurs fichiers +# - - - - - - - - - - - - - - - - - - - - - - - + +# on va vite vouloir mettre chaque fonctions utilisee +# dans un fichier a part afin de mieux gerer les modules +# d'un programme. donc si on sort ft_putchar du fichier : +# +# # int main() +# # { +# # ft_putchar('0'); +# # return (0); +# # } +# +# et qu'on execute "gcc file.c" on va avoir une erreur +# car file.c utilise ft_putchar mais gcc ne sait pas ce +# que c'est, donc il faut faire deux choses : +# +# 1 - d'une part indiquer a main() que ft_putchar() +# existe, en ecrivant au dessus non pas toute la fonction +# (puisqu'on veut la mettre dans un fichier a part) mais +# uniquement son prototype : +# +# # void ft_putchar(char c); +# +# 2 - et d'autre part qu'on rajoute le fichier contenant +# la fonction ft_putchar a la compilation : +# +# [ft_putchar.c] +# # #include +# # +# # void ft_putchar(char c) +# # { +# # write(1, &c, 1); +# # } +# +# [main.c] +# # void ft_putchar(char c); +# # +# # int main() +# # { +# # ft_putchar('0'); +# # return (0); +# # } +# +# si on compile les deux ca marche : +# gcc main.c ft_putchar.c + +# - - - - - - - - - - - - - - - +# les .o : compiler et linker +# - - - - - - - - - - - - - - - + +# ca fonctionne mais gcc doit a chaque fois recompiler +# ft_putchar.c alors qu'il n'est pas modifie, donc on peut +# le compiler une bonne fois pour toute et l'ajouter a la +# compilation finale quand on en a besoin sans que l'ordi +# ait a tout retraduire dans son langage +# +# mais si on essaye de compiler ft_putchar seul +# +# # gcc ft_putchar.c +# +# ca nous donne une erreur car pour compiler, gcc a besoin +# de trouver un main ! +# +# on va donc utiliser l'option -c pour creer un fichier +# objet .o qui est deja traduit en langue d'ordinateur +# et pret a etre rajoute a la compilation : +# +# # gcc -c ft_putchar.c --> donne ft_putchar.o +# # gcc -c main.c --> donne main.o +# +# cette etape qui consiste a transformer les fichiers en +# objets .o s'appelle la compilation, il faut ensuite +# linker les objets, ce qui avec gcc se fait simplement : +# +# # gcc main.o ft_putchar.o +# +# on va maintenant voir comment faire une libraire qui +# contient tous nos fichiers objets + +## ------------------------ +## 2 - creer une librairie +## ------------------------ + +# - - - - +# ar rc +# - - - - + +# pour mettre tous les fichiers .o dans un seul fichier .a +# on utilise un programme d'archive ar avec les options rc +# - r indique d'inserer les .o en remplacant si necessaire +# - c de creer une nouvelle archive +# +# le nom de l'archive doit commencer par lib et +# finir par .a : +# +# # ar rc libtest.a ft_putchar.o +# +# on obtient un fichier libtest.a qui contient les +# fichiers objets .o +# +# on peut l'utiliser a la compilation de cette manniere : +# +# # gcc main.c -L. -ltest +# +# -L indique ou est la librairie (ici elle est dans le +# dossier courant .) +# -l indique son nom (TEST car on n'indique pas lib et .a) + +# - - - - - - - - - - - - - +# ar rc en plusieurs fois +# - - - - - - - - - - - - - + +# on n'est pas oblige de creer une librairie en une seule +# fois, ce qui est bien pratique nottament pour les +# makefiles, on verra ca apres. +# +# ca signifie que si notre librairie contient plusieurs +# fonctions, par exmple la librairie libfruits.a contient +# banane.o et orange.o, on peut creer la librairie +# avec banane.o puis y ajouter orange.o, sans auncune +# manipulation speciale : +# +# # ar rc libfruits.a banane.o +# # ar rc libfruits.a orange.o +# +# revient au meme qu'ecrire : +# +# # ar rc libfruits.a banane.o orange.o + +# - - - - +# ranlib +# - - - - + +# ranlib creer un index du contenu de la librairie et le +# place dedans, c'est utile des que la librairie est tres +# grande afin que gcc sache acceder rapidement aux +# fonctions dont il a besoin dedans +# +# # ranlib libtest.a +# +# ranlib s'utilise apres avoir creer la lib avec ar rc + +## ---------------- +## 3 - fichiers .h +## ---------------- + +# - - - - - - - - - - - - +# a quoi sert un header +# - - - - - - - - - - - - +# si on utilise une librairie c'est parce qu'on peut avoir +# souvent besoin des memes fonctions dans un programme +# mais si a chaque fois qu'on utilise une fonction de la +# librairie on doit ecrire son prototype, ca va poser deux +# problemes : +# +# le prototype d'une seule fonction peut etre ecrit a +# pleins d'endroits, donc si la fonction change un peu on +# doit retrouver tous les emplacements des prototypes et +# les modifier un par un +# +# et d'autre part, si on utilise pleins de fonctions dans +# l'ecriture d'un programme on va devoir reecrire a chaque +# fois son prototype et c'est tres relou +# +# afin d'eviter ca on ecrit tous les prototypes, ainsi que +# les includes, et les structures, les defines, et autres, +# dans un seul fichier pour tout un programme, ou dans le +# cas present pour toute la librairie, et on l'inclus +# systematiquement au debut d'un fichier contenant des +# fonctions de la librairie, gcc s'occupera de l'expandre +# a la precompilation +# + +# - - - - - - - - - +# ecrire un header +# - - - - - - - - - + +# [ft_putchar.c] +# # #include "libtest.h" +# # +# # void ft_putchar(char c) +# # { +# # write(1, &c, 1); +# # } +# +# [main.c] +# # #include "libtest.h" +# # +# # int main() +# # { +# # ft_putchar('0'); +# # return (0); +# # } +# +# [libetest.h] +# # # ifndef LIBTEST_H +# # # define LIBTEST_H +# # +# # #include +# # +# # void ft_putchar(char c); +# # +# # # endif +# +# en tete de chaque fichier de fonctions on ecrit +# l'include de la librairie, comme un include classique, +# precede d'un #, mais avec le nom de la librairie entre +# guillemets et non pas entre signes comparateurs +# +# dans le fichier de la librairie on ajoute les includes +# dont on peut avoir besoin pour que la librairie ou des +# fonctions auont besoin, et les prototypes des fonctions +# +# on entoure toutes ces infos par une definition, afin +# de proteger le .h d'etre expand plusieurs fois dans +# un fichier + +# - - - - - - - - - - - - +# comment ca se compile +# - - - - - - - - - - - - + +# au moment de la compilation il faut indiquer a gcc ou +# se trouve le fichier .h avec le flag -I +# +# par exemple pour l'architecture de dossier suivante : +# +# # file/ +# # main.c +# # ft_putchar.c +# # libtest.h +# +# il faut ecrire : +# +# # gcc main.c ft_putchar.c -I. +# +# et si la compilation utilise une librairie, par exemple +# si on met la fonction ft_putchar.c dans une librairie : +# +# # gcc -c ft_putchar.c +# # (donne ft_putchar.o) +# # ar rc libtest.a ft_putchar.o +# +# on peut alors compiler avec la librairie .a et le +# fichier .h : +# +# # gcc main.c -I. -L. -ltest -o test +# +# qui sort l'executable "test" + +## ---------------------------------------------------- +## 4 - ecrire un make file pour aider a la compilation +## ---------------------------------------------------- + +# - - - - - - - - - +# makefile basique +# - - - - - - - - - + +# exemple for a basic makefile : +# +# [architecture] +# # main.c +# # function01.c +# # function02.c +# # header.h +# # libtest.a +# # Makefile +# +# [Makefile] +# # #-------------# +# # # VARIABLES # +# # #-------------# +# # NAME = program_test +# # CC = gcc +# # CFLAGS = -I. +# # LFLAGS = -L. -ltest +# # DEPS = header.h +# # SRCS = main.c \ +# # function01.c \ +# # function02.c +# # ODIR = ./builds +# # OBJS = $(SRCS:%.c=%.o) +# # +# # #---------# +# # # RULES # +# # #---------# +# # all: $(ODIR) $(NAME) +# # $(NAME): $(OBJS) $(DEPS) +# # $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) +# # %.o: %.c +# # $(CC) $(CFLAGS) -c -o $@ $< +# # clean: +# # /bin/rm -rf $(ODIR) +# # fclean: clean +# # /bin/rm -f $(NAME) +# # re: fclean all +# # .PHONY: all clean fclean re +# +# # prompt "make" execute the first rule ("all") +# +# [architecture] +# # main.c +# # main.o +# # function01.c +# # function01.o ++ +# # function02.c +# # function02.o ++ +# # header.h +# # libtest.a +# # Makefile +# # program_test ++ +# +# ----- +# +# shape of a rule : +# +# target: prerequisites ... +# recipe ... +# +# when a target is called, its execution depends of the +# prerequisites, if they have been more recently modify +# than the target the makefile execute the recipe +# +# to execute a rull you have to call it's name with make : +# "make rule", and by default the first rule is execute +# +# ----- +# +# "automatic variables" +# +# $@ is the name of the target that called the rule +# $< is the name of the first prerequisite +# $^ is the name of all the prerequisites +# +# ----- +# +# $(SRCS:%.c=%.o) +# +# is a built-in function called a "substitute reference", +# an abbreviation for the expansion function "patsubst" : +# +# $(patsubst pattern,replacement,text) +# $(text:pattern=replacement) +# +# $() is a variable which expand in its value +# +# % match everything, the value of the first % in +# "replacement" is replaced with the text matched by the +# first % in "pattern", it only works for the firsts +# +# ----- +# +# all: $(ODIR) $(NAME) +# +# ALL depends on ODIR and NAME, so if ODIR doesn't exist +# it will be created, and then NAME is called +# +# ----- +# +# $(NAME): $(OBJS) $(DEPS) +# $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) +# +# NAME depends on OBJS and DEPS, so if any .o or any .h +# have more recent date of modification NAME will execute +# only for them +# +# ----- +# +# %.o: %.c +# $(CC) $(CFLAGS) -c -o $@ $< +# +# when $(OBJS) expand in the list of .o files at the call +# of the NAME rule, each of them call the rule "%.o" wich +# depends on the equivalent .c, so if one has been +# modified since last execution of ALL, it's recompiled in +# object file with use of automatic variables $@ and $< +# +# ----- +# +# #clean: +# /bin/rm -rf $(ODIR) +# +# "make clean" suppress all the .o files +# +# ----- +# +# fclean: clean +# /bin/rm -f $(NAME) +# +# "make fclean" call CLEAN and suppress the executable +# +# ----- +# +# re: fclean all +# +# "make fclean" basically rerun make +# +# ----- +# +# .PHONY: all clean fclean re +# +# a phony target is one that is not the name of a file +# if a file called "clean" for instance exist, the rule +# CLEAN will never be executed when prompt "make clean" +# because it will be considered up to date, but if it's +# declared to be phony it will be executed in any case + +# - - - - - - - - - - - - - - - +# makefile with subdirectories +# - - - - - - - - - - - - - - - + +# put the .o in a "builds/" directory +# +# have the .c in a "srcs/" directory +# +# have the .h in an "includes" directory +# +# have multiples .a files +# +# [architecture] +# # srcs/ +# # main.c +# # function01.c +# # function02.c +# # includes/ +# # header01.h +# # header02.h +# # libtest.a +# # liboption.a +# # Makefile +# +# # #-------------# +# # # VARIABLES # +# # #-------------# +# # NAME = program_test +# # CC = gcc +# # VPATH = srcs +# # +# # IDIR = includes +# # _DEPS = header01.h \ +# # header02.h +# # DEPS = $(_DEPS:%.h=$(IDIR)/%.h) +# # +# # LDIR = ./ +# # _LIBS = libtest.a \ +# # liboption.a +# # LIBS = $(_LIBS:lib%.a=%) +# # +# # SRCS = main.c \ +# # function01.c +# # function02.c +# # ODIR = ./builds +# # OBJS = $(SRCS:%.c=$(ODIR)/%.o) +# # +# # CFLAGS = -I$(IDIR) +# # LFLAGS = -L$(LDIR) -l$(LIBS) +# # +# # #---------# +# # # RULES # +# # #---------# +# # all: $(ODIR) $(NAME) +# # $(NAME): $(OBJS) $(DEPS) +# # $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) +# # $(ODIR): +# # mkdir -p $@ +# # $(ODIR)/%.o: %.c +# # $(CC) $(CFLAGS) -c -o $@ $< +# # clean: +# # /bin/rm -rf $(ODIR) +# # fclean: clean +# # /bin/rm -f $(NAME) +# # re: fclean all +# # .PHONY: all clean fclean re +# +# # prompt "make" execute the first rule ("all") +# +# [architecture] +# # srcs/ +# # main.c +# # function01.c +# # function02.c +# # includes/ +# # header01.h +# # header02.h +# # builds/ ++ +# # main.o ++ +# # function01.o ++ +# # function02.o ++ +# # libtest.a +# # liboption.a +# # Makefile +# # program_test ++ +# +# ----- +# +# VPATH = srcs +# +# build-in variable VPATH is a list of directories where +# makefile looks for files that it doesn't find in the +# first place, so it let you easily put .c files into +# subdirectories +# +# ----- +# +# LIBS = $(_LIBS:lib%.a=%) +# +# from "libtest.a" and "liboption.a" it creates "test" +# and "option" +# +# as said, the value of the % in "replacement" is +# replaced with the text matched by the % in "pattern" +# +# ----- +# +# OBJS = $(SRCS:%.c=$(ODIR)/%.o) +# +# creates the list of .o from the .c with addition of the +# path directory "builds/main.o" +# +# it could be : +# $(patsubst %.c,$(ODIR)/%.o,$(SRCS)) +# or : +# $(addprefix $(ODIR)/, $(SRCS:.c=.o)) +# +# ----- +# +# $(NAME): $(OBJS) $(DEPS) +# $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) +# +# NAME depends on OBJS and DEPS, so if any .o or any .h +# have more recent date of modification NAME will execute +# again only for them + +# - - - - - - - - - - - - - - - - - +# makefile making another makefile +# - - - - - - - - - - - - - - - - - + +# compiling a makefile with compiling another makefile in +# a subdirectory wich contain the library used by the +# roots makefile +# +# [architecture] +# # srcs/ +# # main.c +# # function01.c +# # function02.c +# # includes/ +# # header01.h +# # header02.h +# # libtest/ +# # Makefile +# # header_lib.h +# # function_lib01.c +# # function_lib02.c +# # libtest.a +# # Makefile +# +# # #-------------# +# # # VARIABLES # +# # #-------------# +# # NAME = program_test +# # CC = gcc +# # VPATH = srcs +# # +# # IDIR = includes +# # _DEPS = header01.h \ +# # header02.h +# # DEPS = $(_DEPS:%.h=$(IDIR)/%.h) +# # +# # LDIR = ./libtest/ +# # _LIBS = libtest.a \ +# # LIBS = $(_LIBS:lib%.a=%) +# # +# # SRCS = main.c \ +# # function01.c +# # function02.c +# # ODIR = ./builds +# # OBJS = $(SRCS:%.c=$(ODIR)/%.o) +# # +# # CFLAGS = -I$(IDIR) +# # LFLAGS = -L$(LDIR) -l$(LIBS) +# # +# # #---------# +# # # RULES # +# # #---------# +# # all: $(ODIR) $(NAME) +# # $(NAME): $(OBJS) $(DEPS) +# # make -C $(LDIR) +# # $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) +# # $(ODIR): +# # mkdir -p $@ +# # $(ODIR)/%.o: %.c +# # $(CC) $(CFLAGS) -c -o $@ $< +# # clean: +# # make clean -C $(LDIR) +# # /bin/rm -rf $(ODIR) +# # fclean: clean +# # make fclean -C $(LDIR) +# # /bin/rm -f $(NAME) +# # re: fclean all +# # .PHONY: all clean fclean re +# +# # prompt "make" execute the first rule ("all") +# +# [archtecture] +# # srcs/ +# # main.c +# # function01.c +# # function02.c +# # includes/ +# # header01.h +# # header02.h +# # builds/ ++ +# # main.o ++ +# # function01.o ++ +# # function02.o ++ +# # libtest/ +# # Makefile +# # header_lib.h +# # function_lib01.c +# # function_lib02.c +# # libtest.a +# # Makefile +# # program_test ++ +# +# ----- +# +# make -C $(LDIR) +# +# make -C +# +# the -C option says to makefile it should first go to the +# path location and then do "make" +# +# it's similar to : +# +# rule: +# cd $(LDIR) && make +# + +# - - - - - - - - - - - - +# makefile for a library +# - - - - - - - - - - - - + +# +# exemple of a makefile used not for a compilation into a +# binary executable, but to create a library +# +# [architecture] +# # srcs/ +# # function01.c +# # function02.c +# # includes/ +# # header.h +# # Makefile +# +# # #-------------# +# # # VARIABLES # +# # #-------------# +# # NAME = libtest.a +# # CC = gcc +# # VPATH = srcs +# # +# # IDIR = includes +# # _DEPS = header.h +# # DEPS = $(_DEPS:%.h=$(IDIR)/%.h) +# # +# # SRCS = function01.c \ +# # function02.c +# # ODIR = ./builds +# # OBJS = $(SRCS:%.c=$(ODIR)/%.o) +# # +# # CFLAGS = -I$(IDIR) +# # +# # #---------# +# # # RULES # +# # #---------# +# # all: $(ODIR) $(NAME) +# # $(NAME): $(OBJS) $(DEP) +# # ar -rc $@ $(OBJS) +# # @ranlib $@ +# # $(ODIR): +# # mkdir -p $@ +# # $(ODIR)/%.o: %.c +# # $(CC) $(CFLAGS) -c -o $@ $< +# # clean: +# # /bin/rm -rf $(ODIR) +# # fclean: clean +# # /bin/rm -f $(NAME) +# # re: fclean all +# # .PHONY: all clean fclean re +# +# # prompt "make" execute the first rule ("all") +# +# [archtecture] +# # srcs/ +# # function01.c +# # function02.c +# # includes/ +# # header.h +# # builds/ +# # function01.o +# # function02.o +# # libtest.a +# # Makefile +# +# ----- +# +# NAME = libtest.a +# +# name is now the name of the library to be built +# +# ----- +# +# @ranlib $@ +# +# @ tells makefile not to show the line in prompt +# + +# +# THE END +# enjoy, futur me +# diff --git a/libs/libft/deleted/ft_lst_find.bak b/libs/libft/deleted/ft_lst_find.bak new file mode 100644 index 0000000..86a0dbe --- /dev/null +++ b/libs/libft/deleted/ft_lst_find.bak @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstfind.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/23 22:48:47 by simplonco #+# #+# */ +/* Updated: 2022/03/23 22:49:16 by simplonco ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * find an element with the comp function, and return a pointer to it + */ + +#include "libft.h" + +t_list *ft_lstfind(t_list *lst, void *to_find, int (*comp)(void*, void *)) +{ + while (lst && (!comp(to_find, lst->content))) + lst = lst->next; + return (lst); +} diff --git a/libs/libft/deleted/ft_lstadd_back.bak b/libs/libft/deleted/ft_lstadd_back.bak new file mode 100644 index 0000000..dceb7e0 --- /dev/null +++ b/libs/libft/deleted/ft_lstadd_back.bak @@ -0,0 +1,94 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_back.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:11:53 by hulamy #+# #+# */ +/* Updated: 2022/03/23 21:50:42 by simplonco ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** add an element to the end of a list, or first if list has no element yet +** return NULL if element is NULL (eg, it returned from ft_lstnew and failed) +** or else address to the element added +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_back(t_list **alst, t_list *new); +** +** int main(void) +** { +** char tresor; +** char matos; +** char friends; +** t_list *toto; +** t_list *tmp; +** +** tresor = 'a'; +** matos = 'b'; +** friends = 'c'; +** toto = ft_lstnew(&tresor); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** tmp = ft_lstnew(&matos); +** ft_lstadd_back(&toto, tmp); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** tmp = ft_lstnew(&friends); +** ft_lstadd_back(&toto, tmp); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +void *ft_lstadd_back(t_list **alst, t_list *new) +{ + t_list *tmp; + + if (!new) + return (NULL); + if (alst) + { + tmp = *alst; + if (!tmp) + *alst = new; + else + { + while (tmp->next) + tmp = tmp->next; + tmp->next = new; + } + } + return (tmp); +} diff --git a/libs/libft/deleted/ft_lstadd_front.bak b/libs/libft/deleted/ft_lstadd_front.bak new file mode 100644 index 0000000..3f90569 --- /dev/null +++ b/libs/libft/deleted/ft_lstadd_front.bak @@ -0,0 +1,94 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_front.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:12:02 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:36:54 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** add an element to the begining of a list +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** void *ft_memcpy(void *dst, const void *src, size_t n) +** { +** size_t i; +** char *ptr; +** char *ptr2; +** +** ptr = (char *)dst; +** ptr2 = (char *)src; +** i = -1; +** while (++i < n) +** ptr[i] = ptr2[i]; +** return (dst); +** } +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** { +** if (!(lst->content = malloc(sizeof(content)))) +** return (NULL); +** ft_memcpy(lst->content, content, sizeof(content)); +** } +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_front(t_list **alst, t_list *new); +** +** int main(void) +** { +** char tresor; +** char matos; +** char friends; +** t_list *toto; +** t_list *tmp; +** +** tresor = 'a'; +** matos = 'b'; +** friends = 'c'; +** toto = ft_lstnew(&tresor); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** tmp = ft_lstnew(&matos); +** ft_lstadd_front(&toto, tmp); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** tmp = ft_lstnew(&friends); +** ft_lstadd_front(&toto, tmp); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->dqta:%c\n",*(char*)(toto->next->next->content)); +** return (0); +** } +*/ + +#include "libft.h" + +void ft_lstadd_front(t_list **alst, t_list *new) +{ + new->next = *alst; + *alst = new; +} diff --git a/libs/libft/deleted/ft_lstclear.bak b/libs/libft/deleted/ft_lstclear.bak new file mode 100644 index 0000000..a28d366 --- /dev/null +++ b/libs/libft/deleted/ft_lstclear.bak @@ -0,0 +1,107 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstclear.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:13:30 by hulamy #+# #+# */ +/* Updated: 2019/11/28 17:06:48 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** delete and free an element of the list and all the followings +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_back(t_list **alst, t_list *new) +** { +** t_list *tmp; +** +** if (alst) +** { +** tmp = *alst; +** if (!tmp) +** *alst = new; +** else +** { +** while (tmp->next) +** tmp = tmp->next; +** tmp->next = new; +** } +** new->next = NULL; +** } +** } +** +** void ft_delete(void *element) +** { +** *(char*)element = '\0'; +** } +** +** void ft_lstdelone(t_list *lst, void (*del)(void *)) +** { +** del(lst->content); +** free(lst); +** lst = NULL; +** } +** +** void ft_lstclear(t_list **lst, void (*del)(void *)); +** +** int main(void) +** { +** t_list *toto; +** void (ft_delete)(void*); +** +** printf("sizeof(t_list)%lu\n",sizeof(t_list)); +** toto = ft_lstnew("a"); +** toto->next = ft_lstnew("b"); +** toto->next->next = ft_lstnew("c"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** ft_lstclear(&(toto->next), ft_delete); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt :%s\n",(char*)(toto->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +void ft_lstclear(t_list **lst, void (*del)(void *)) +{ + t_list *next; + + while (*lst != NULL) + { + next = (*lst)->next; + ft_lstdelone(*lst, del); + *lst = next; + } +} diff --git a/libs/libft/deleted/ft_lstdelone.bak b/libs/libft/deleted/ft_lstdelone.bak new file mode 100644 index 0000000..0cf925a --- /dev/null +++ b/libs/libft/deleted/ft_lstdelone.bak @@ -0,0 +1,97 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstdelone.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:14:03 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:35:53 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** free an element and delete its content with del +** next is not free +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_back(t_list **alst, t_list *new) +** { +** t_list *tmp; +** +** if (alst) +** { +** tmp = *alst; +** if (!tmp) +** *alst = new; +** else +** { +** while (tmp->next) +** tmp = tmp->next; +** tmp->next = new; +** } +** new->next = NULL; +** } +** } +** +** void ft_delete(void *element) +** { +** *(char*)element = '\0'; +** } +** +** void ft_lstdelone(t_list *lst, void (*del)(void *)); +** +** int main(void) +** { +** t_list *toto; +** void (ft_delete)(void*); +** +** toto = ft_lstnew("a"); +** toto->next = ft_lstnew("b"); +** toto->next->next = ft_lstnew("c"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** ft_lstdelone(toto->next, ft_delete); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +void ft_lstdelone(t_list *lst, void (*del)(void *)) +{ + if (lst->content && del) + del(lst->content); + free(lst); + lst = NULL; +} diff --git a/libs/libft/deleted/ft_lstiter.bak b/libs/libft/deleted/ft_lstiter.bak new file mode 100644 index 0000000..ee67de6 --- /dev/null +++ b/libs/libft/deleted/ft_lstiter.bak @@ -0,0 +1,85 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstiter.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:14:11 by hulamy #+# #+# */ +/* Updated: 2019/12/01 16:03:40 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** go through all elements of the list and apply the function f to each of them +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstiter(t_list *lst, void (*f)(void*)); +** +** void to_uppercase(void *element) +** { +** // *(char*)(((t_list*)element)->content) -= 32; +** // or : +** t_list *tmp; +** +** tmp = (t_list*)element; +** *(char*)(tmp->content) -= 32; +** } +** +** int main(void) +** { +** t_list *toto; +** void to_uppercase(void*); +** +** toto = ft_lstnew("a"); +** toto->next = ft_lstnew("b"); +** toto->next->next = ft_lstnew("c"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** printf("---------------------------\n"); +** ft_lstiter(toto, to_uppercase); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +void ft_lstiter(t_list *lst, void (*f)(void *)) +{ + if (!f) + return ; + while (lst) + { + f(lst->content); + lst = lst->next; + } +} diff --git a/libs/libft/deleted/ft_lstlast.bak b/libs/libft/deleted/ft_lstlast.bak new file mode 100644 index 0000000..e6173f2 --- /dev/null +++ b/libs/libft/deleted/ft_lstlast.bak @@ -0,0 +1,100 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstlast.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:14:49 by hulamy #+# #+# */ +/* Updated: 2019/11/28 16:43:18 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return a pointer to the last element of a list +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** void *ft_memcpy(void *dst, const void *src, size_t n) +** { +** size_t i; +** char *ptr; +** char *ptr2; +** +** ptr = (char *)dst; +** ptr2 = (char *)src; +** i = -1; +** while (++i < n) +** ptr[i] = ptr2[i]; +** return (dst); +** } +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** { +** if (!(lst->content = malloc(sizeof(content)))) +** return (NULL); +** ft_memcpy(lst->content, content, sizeof(content)); +** } +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_front(t_list **alst, t_list *new) +** { +** new->next = *alst; +** *alst = new; +** } +** +** t_list *ft_lstlast(t_list *lst); +** +** int main(void) +** { +** char tresor; +** t_list *toto; +** t_list *tmp; +** +** tresor = 'a'; +** toto = ft_lstnew(&tresor); +** tresor = 'b'; +** tmp = ft_lstnew(&tresor); +** ft_lstadd_front(&toto, tmp); +** tresor = 'c'; +** tmp = ft_lstnew(&tresor); +** ft_lstadd_front(&toto, tmp); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** tmp = ft_lstlast(toto); +** printf("%c\n",*(char*)(tmp->content)); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** return (0); +** } +*/ + +#include "libft.h" + +t_list *ft_lstlast(t_list *lst) +{ + if (lst) + while (lst->next) + lst = lst->next; + return (lst); +} diff --git a/libs/libft/deleted/ft_lstmap.bak b/libs/libft/deleted/ft_lstmap.bak new file mode 100644 index 0000000..41e7a25 --- /dev/null +++ b/libs/libft/deleted/ft_lstmap.bak @@ -0,0 +1,145 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstmap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:15:42 by hulamy #+# #+# */ +/* Updated: 2019/12/01 16:02:13 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** iterate trhough linked list and apply to each element a function f +** if necessary the function del is used to delete an element +*/ + +/* +** #include +** #include +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_back(t_list **alst, t_list *new) +** { +** t_list *tmp; +** +** if (alst) +** { +** tmp = *alst; +** if (!tmp) +** *alst = new; +** else +** { +** while (tmp->next) +** tmp = tmp->next; +** tmp->next = new; +** } +** new->next = NULL; +** } +** } +** +** char *ft_strdup(const char *src) +** { +** int i; +** char *str; +** +** i = 0; +** while (src[i] != '\0') +** i++; +** if (!(str = (char*)malloc(sizeof(*str) * (i + 1)))) +** return (NULL); +** while (i-- >= 0) +** str[i + 1] = src[i + 1]; +** return (str); +** } +** +** void *to_uppercase(void *element) +** { +** char *i; +** +** if (!(i = ft_strdup((char*)element))) +** return (NULL); +** *i -= 32; +** return ((void *)i); +** } +** +** void ft_delete(void *element) +** { +** *(char*)element = '\0'; +** } +** +** t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)); +** +** int main(void) +** { +** t_list *toto; +** void *(to_uppercase)(void *); +** void (ft_delete)(void*); +** +** toto = ft_lstnew("aa"); +** toto->next = ft_lstnew("b"); +** toto->next->next = ft_lstnew("c"); +** printf("toto->data :%s\n",(char*)(toto->content)); +** printf("toto->nxt->data :%s\n",(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%s\n",(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** toto = ft_lstmap(toto, to_uppercase, ft_delete); +** printf("----------------------\n"); +** printf("toto->data :%s\n",(char*)(toto->content)); +** printf("toto->nxt->data :%s\n",(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%s\n",(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) +{ + t_list *new; + t_list *tmp; + + if (!lst) + return (NULL); + if (!(tmp = ft_lstnew(f(lst->content)))) + { + del(tmp->content); + free(tmp); + return (NULL); + } + new = tmp; + while (lst->next) + { + lst = lst->next; + if (!(tmp->next = ft_lstnew(f(lst->content)))) + { + del(tmp->next->content); + free(tmp->next); + return (NULL); + } + tmp = tmp->next; + } + return (new); +} diff --git a/libs/libft/deleted/ft_lstnew.bak b/libs/libft/deleted/ft_lstnew.bak new file mode 100644 index 0000000..0c64f4e --- /dev/null +++ b/libs/libft/deleted/ft_lstnew.bak @@ -0,0 +1,57 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:16:20 by hulamy #+# #+# */ +/* Updated: 2022/03/23 20:24:40 by simplonco ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new list +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content); +** +** int main(void) +** { +** char tresor; +** t_list *toto; +** +** tresor = 'd'; +** printf("tresor : %c\n",tresor); +** toto = ft_lstnew(&tresor); +** //toto->content was alocated as void* so it need cast +** printf("toto->content : %c\n",*(char*)(toto->content)); +** tresor = 'D'; +** printf("transform tresor : %c\n",tresor); +** printf("and also toto->content: %c\n",*(char*)(toto->content)); +** return (0); +** } +*/ + +#include "libft.h" + +t_list *ft_lstnew(void *content) +{ + t_list *lst; + + lst = (t_list *)malloc(sizeof(*lst)); + if (!lst) + return (NULL); + lst->content = content; + lst->next = NULL; + return (lst); +} diff --git a/libs/libft/deleted/ft_lstsize.bak b/libs/libft/deleted/ft_lstsize.bak new file mode 100644 index 0000000..5ff5f2d --- /dev/null +++ b/libs/libft/deleted/ft_lstsize.bak @@ -0,0 +1,86 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstsize.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:31:48 by hulamy #+# #+# */ +/* Updated: 2019/11/25 16:06:41 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return the size of the linked list +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_front(t_list **alst, t_list *new) +** { +** new->next = *alst; +** *alst = new; +** } +** +** int ft_lstsize(t_list *lst); +** +** int main(void) +** { +** char tresor; +** t_list *toto; +** t_list *tmp; +** +** tresor = 'a'; +** toto = ft_lstnew(&tresor); +** tresor = 'b'; +** tmp = ft_lstnew(&tresor); +** ft_lstadd_front(&toto, tmp); +** tresor = 'c'; +** tmp = ft_lstnew(&tresor); +** ft_lstadd_front(&toto, tmp); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->dqta:%c\n",*(char*)(toto->next->next->content)); +** printf("%i\n",ft_lstsize(toto)); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->dqta:%c\n",*(char*)(toto->next->next->content)); +** return (0); +** } +*/ + +#include "libft.h" + +int ft_lstsize(t_list *lst) +{ + int size; + + size = 0; + while (lst) + { + size++; + lst = lst->next; + } + return (size); +} diff --git a/libs/libft/deleted/ft_putchar.c b/libs/libft/deleted/ft_putchar.c new file mode 100644 index 0000000..b0aa9cb --- /dev/null +++ b/libs/libft/deleted/ft_putchar.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:14:00 by hulamy #+# #+# */ +/* Updated: 2018/11/14 21:14:01 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putchar(char c) +{ + write(1, &c, 1); +} diff --git a/libs/libft/deleted/ft_putendl.c b/libs/libft/deleted/ft_putendl.c new file mode 100644 index 0000000..c1d9a6a --- /dev/null +++ b/libs/libft/deleted/ft_putendl.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putendl.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:14:32 by hulamy #+# #+# */ +/* Updated: 2018/11/14 21:14:33 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putendl(char const *s) +{ + ft_putstr(s); + ft_putchar('\n'); +} diff --git a/libs/libft/deleted/ft_putendl_fd.c b/libs/libft/deleted/ft_putendl_fd.c new file mode 100644 index 0000000..5a0ef44 --- /dev/null +++ b/libs/libft/deleted/ft_putendl_fd.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putendl_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:59:47 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:59:48 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** write the string s on the given file descriptor fd, followed by a newline +*/ + +#include "libft.h" + +void ft_putendl_fd(char *s, int fd) +{ + ft_putstr_fd(s, fd); + ft_putchar_fd('\n', fd); +} diff --git a/libs/libft/deleted/ft_putnbr.c b/libs/libft/deleted/ft_putnbr.c new file mode 100644 index 0000000..bb8e2d7 --- /dev/null +++ b/libs/libft/deleted/ft_putnbr.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:14:57 by hulamy #+# #+# */ +/* Updated: 2018/11/14 21:14:58 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putnbr(int n) +{ + ft_putnbr_fd(n, 1); +} diff --git a/libs/libft/deleted/ft_putnbrendl.c b/libs/libft/deleted/ft_putnbrendl.c new file mode 100644 index 0000000..ddd05f6 --- /dev/null +++ b/libs/libft/deleted/ft_putnbrendl.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbrendl.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/02/19 10:38:07 by hulamy #+# #+# */ +/* Updated: 2019/02/19 10:42:46 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putnbrendl(int n) +{ + ft_putnbrendl_fd(n, 1); +} diff --git a/libs/libft/deleted/ft_putnbrendl_fd.c b/libs/libft/deleted/ft_putnbrendl_fd.c new file mode 100644 index 0000000..266dc55 --- /dev/null +++ b/libs/libft/deleted/ft_putnbrendl_fd.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbrendl_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/02/19 10:37:58 by hulamy #+# #+# */ +/* Updated: 2019/02/19 10:42:48 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putnbrendl_fd(int n, int fd) +{ + long l; + + l = n; + if (l < 0) + { + ft_putchar_fd('-', fd); + l *= -1; + } + if (l >= 10) + ft_putnbr_fd(l / 10, fd); + ft_putchar_fd((l % 10) + '0', fd); + ft_putchar_fd('\n', fd); +} diff --git a/libs/libft/deleted/ft_putstr.c b/libs/libft/deleted/ft_putstr.c new file mode 100644 index 0000000..78617eb --- /dev/null +++ b/libs/libft/deleted/ft_putstr.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:15:19 by hulamy #+# #+# */ +/* Updated: 2018/11/14 21:15:19 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putstr(char const *s) +{ + int i; + + i = 0; + while (s && s[i]) + ft_putchar(s[i++]); +} diff --git a/libs/libft/includes/ft_gnl.h b/libs/libft/includes/ft_gnl.h new file mode 100644 index 0000000..078f81d --- /dev/null +++ b/libs/libft/includes/ft_gnl.h @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/01/29 10:19:37 by hulamy #+# #+# */ +/* Updated: 2020/02/25 18:48:49 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef GET_NEXT_LINE_H +# define GET_NEXT_LINE_H + +# ifndef BUFFER_SIZE +# define BUFFER_SIZE 1000 +# endif + +typedef struct s_gnlist +{ + int lfd; + char *str; + struct s_gnlist *next; +} t_gnlist; + +int ft_gnl(const int fd, char **line); +int multi_fd(int fd, t_gnlist **lst); +int free_lst(t_gnlist **lst, int ret); + +#endif diff --git a/libs/libft/includes/ft_printf.h b/libs/libft/includes/ft_printf.h new file mode 100644 index 0000000..1f0e1fa --- /dev/null +++ b/libs/libft/includes/ft_printf.h @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/27 12:07:47 by hulamy #+# #+# */ +/* Updated: 2020/03/12 20:35:10 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_PRINTF_H +# define FT_PRINTF_H +# include // to use va_arg + +/* +** ft_printf.c +*/ + +char *specifier(char *s); +int ft_expand_star(int nbr, char **string); +int ft_put_word(char *s, char *type, int size); +char *convert_with_flags(char *s, va_list ap, char *type, int *size); +int ft_printf(char *string, ...); + +/* +** ft_next_word.c +*/ + +int width_precision(char *s); +int word_length(char *s); +char *next_word(char **s); + +/* +** ft_convert.c +*/ + +char *conv_i(char c, long int i); +char *conv_u(char c, unsigned long int i); +char *ft_convert(va_list ap, char *type, char **s); + +/* +** ft_flag_transform.c +*/ + +char *precision_int(char *print, int precision); +char *ft_precision(char *s, char *print, char *type); +char *width_flags(char *print, char *s, int width, int zero); +char *ft_width(char *s, char *print, int *size, char *type); +char *ft_flag_transform(char *s, char *print, char *type, int *size); + +/* +** ft_flag_transform_bonus.c +*/ + +char *ft_plus(char *s, char *print, char *type); +char *ft_sharp(char *s, char *print, char *type); +char *ft_sharp_again(char *s, char *print, char *type); +char *ft_space(char *s, char *print, char *type, int *size); + +#endif diff --git a/libs/libft/includes/libft.h b/libs/libft/includes/libft.h new file mode 100644 index 0000000..2425bb0 --- /dev/null +++ b/libs/libft/includes/libft.h @@ -0,0 +1,140 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:45:53 by hulamy #+# #+# */ +/* Updated: 2022/04/21 19:31:18 by simplonco ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_H +# define LIBFT_H +# include // for write +# include // for malloc and free +# include "ft_gnl.h" +# include "ft_printf.h" + +void *ft_memset(void *b, int c, size_t len); +void ft_bzero(void *s, size_t n); +void *ft_memcpy(void *dst, const void *src, size_t n); +void *ft_memccpy(void *dst, const void *src, int c, size_t n); +void *ft_memmove(void *dst, const void *src, size_t len); +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 *str); +int ft_isalpha(int c); +int ft_isdigit(int c); +int ft_isnumber(char *nb); +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); +char *ft_strchrset(const char *s, const char *set); +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 *b, const char *l, size_t s); +int ft_atoi(const char *str); +long ft_atol(const char *str); +void *ft_calloc(size_t count, size_t size); +char *ft_strdup(const char *s1); + +char *ft_substr(char const *s, unsigned int start, size_t len); +char *ft_strjoin(char const *s1, char const *s2); +char *ft_strtrim(char const *s1, char const *set); +char **ft_split(char const *s, char c); +char *ft_itoa(long int n); +char *ft_utoa(unsigned long 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_putnbrbase(int nbr, char *base); + +/* +void ft_putchar(char c); +void ft_putendl(char const *str); +void ft_putnbr(int nbr); +void ft_putstr(char const *str); +void ft_putendl_fd(char *s, int fd); +*/ + +typedef struct s_list +{ + void *content; + struct s_list *prev; + struct s_list *next; +} t_list; + +/* +t_list *ft_lstnew(void *content); +void ft_lstadd_front(t_list **alst, t_list *n); +void *ft_lstadd_back(t_list **alst, t_list *n); +int ft_lstsize(t_list *lst); +t_list *ft_lstlast(t_list *lst); +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 (*d)(void*)); +*/ +//void ft_lstremove(t_list *lst, void (*del)(void *)); +//t_list *ft_lstfind(t_list *lst, void *to_find, int (*comp)(void*, void *)); +t_list *ft_lstcreate(void *content); +void *ft_lstpush_back(t_list **lst, t_list *new); +void ft_lstpush_front(t_list **alst, t_list *new); +void ft_lstloop(t_list *lst, void (*f)(void *)); +void ft_lstloop_back(t_list *lst, void (*f)(void *)); +t_list *ft_lstbegin(t_list *lst); +t_list *ft_lstend(t_list *lst); +t_list *ft_lstfind(t_list *lst, void *to_find, int (*comp)(void*, void *)); +void ft_lstinsert(t_list *lst, t_list *new); +void ft_lsterase(t_list *lst, void (*del)(void *)); +void ft_lstfree(t_list *lst, void (*del)(void *)); +int ft_lstlen(t_list *lst); +t_list *ft_lstcopy(t_list *lst, void *(*cpy)(void *)); + +char *ft_strcat(char *s1, const char *s2); +int ft_strcmp(const char *s1, const char *s2); +char *ft_strcpy(char *dst, const char *src); +char *ft_strncat(char *s1, const char *s2, size_t n); +char *ft_strncpy(char *dst, const char *src, size_t len); +char *ft_strstr(const char *big, const char *little); +void ft_strclr(char *s); +void ft_strdel(char **as); +int ft_strequ(char const *s1, char const *s2); +void ft_striter(char *s, void (*f)(char *)); +void ft_striteri(char *s, void (*f)(unsigned int, char *)); +char *ft_strjoinfree(char *s1, char *s2); +char *ft_strmap(char const *s, char (*f)(char)); +int ft_strnequ(char const *s1, char const *s2, size_t n); +char *ft_strnew(size_t size); +void *ft_memalloc(size_t size); +void ft_memdel(void **ap); +int ft_atoibase(char *str, char *base); +char *ft_convertbase(char *nbr, char *base_from, char *base_to); +char *ft_convertbase_free(char *nbr, char *b_from, char *b_to); +char **ft_strmultisplit(char *str, char *charset); +int ft_any(char **tab, int (*f)(char*)); +void ft_foreach(int *tab, int length, void (*f)(int)); +int ft_issort(int *tab, int length, int (*f)(int, int)); +int *ft_arraymap(int *tab, int length, int(*f)(int)); +void ft_putnbrendl(int n); +void ft_putnbrendl_fd(int n, int fd); +char *ft_concat_free(char *str1, char *str2); +int ft_abs(int n); +int ft_greater(int a, int b); +int ft_smaller(int a, int b); +int ft_sign(int i); +int ft_sqrt(int i); +void ft_free_tab(char **tab); + +int ft_arrint(int * intarr, int comp, size_t size); + +#endif diff --git a/libs/libft/srcs/ft_abs.c b/libs/libft/srcs/ft_abs.c new file mode 100644 index 0000000..ef8b811 --- /dev/null +++ b/libs/libft/srcs/ft_abs.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_abs.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 14:13:33 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 14:13:41 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_abs(int n) +{ + if (n < 0) + n *= -1; + return (n); +} diff --git a/libs/libft/srcs/ft_any.c b/libs/libft/srcs/ft_any.c new file mode 100644 index 0000000..9322945 --- /dev/null +++ b/libs/libft/srcs/ft_any.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_any.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:14:49 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:14:53 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** i don't understand the purpose of this function... +** it takes a 2D array, and for each array it checks +** if a function given in parameters is true or false +*/ + +#include "libft.h" + +int ft_any(char **tab, int (*f)(char*)) +{ + int i; + + i = -1; + if (!tab) + return (0); + while (tab[++i]) + if (f(tab[i]) == 1) + return (1); + return (0); +} diff --git a/libs/libft/srcs/ft_arraymap.c b/libs/libft/srcs/ft_arraymap.c new file mode 100644 index 0000000..267510a --- /dev/null +++ b/libs/libft/srcs/ft_arraymap.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_arraymap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:17:24 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:17:27 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int *ft_arraymap(int *tab, int length, int (*f)(int)) +{ + int i; + int *newtab; + + i = -1; + if (!tab) + return (NULL); + if (!(newtab = (int*)malloc(sizeof(*newtab) * (length + 1)))) + return (NULL); + while (++i < length) + newtab[i] = (*f)(tab[i]); + return (newtab); +} diff --git a/libs/libft/srcs/ft_arrint.c b/libs/libft/srcs/ft_arrint.c new file mode 100644 index 0000000..7f7a78b --- /dev/null +++ b/libs/libft/srcs/ft_arrint.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_arrint.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/21 19:30:25 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:04:53 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * search through an arr of int if it contains the int comp + * return 0 if found, 1 otherwise + */ + +#include "libft.h" + +int ft_arrint(int *intarr, int comp, size_t size) +{ + size_t i; + + if (!intarr) + return (1); + i = -1; + while (++i < size) + if (intarr[i] == comp) + return (0); + return (1); +} diff --git a/libs/libft/srcs/ft_atoi.c b/libs/libft/srcs/ft_atoi.c new file mode 100644 index 0000000..778f21e --- /dev/null +++ b/libs/libft/srcs/ft_atoi.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:54:29 by hulamy #+# #+# */ +/* Updated: 2022/05/04 14:09:01 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_atoi(const char *str) +{ + long nbr; + int i; + int negatif; + + i = 0; + negatif = 1; + nbr = 0; + while ((str[i] == ' ') || (str[i] > 8 && str[i] < 14)) + i++; + if (str[i] == '-') + negatif = -1; + if (str[i] == '+' || str[i] == '-') + i++; + while (str[i] >= '0' && str[i] <= '9') + nbr = nbr * 10 + (str[i++] - '0'); + return (nbr * negatif); +} diff --git a/libs/libft/srcs/ft_atoibase.c b/libs/libft/srcs/ft_atoibase.c new file mode 100644 index 0000000..fdb92d1 --- /dev/null +++ b/libs/libft/srcs/ft_atoibase.c @@ -0,0 +1,75 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoibase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:15:31 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:22:34 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +static int is_valid_base(char *base, int i, int j) +{ + while (base[i]) + { + j = i + 1; + while (base[j]) + { + if (base[i] == base[j]) + return (0); + j++; + } + if (base[i] == '-' || base[i] == '+') + return (0); + i++; + } + if (i >= 2) + return (1); + return (0); +} + +static int skip(int i, char *str, int *n) +{ + while ((str[i] == 32) || (str[i] > 8 && str[i] < 14)) + i++; + if (str[i] == '+' || str[i] == '-') + { + if (str[i] == '-') + *n = -1; + i++; + } + return (i); +} + +int ft_atoibase(char *str, char *base) +{ + int i; + int j; + int length; + int res; + int n; + + length = 0; + res = 0; + n = 1; + if (!is_valid_base(base, 0, 0)) + return (0); + while (base[length]) + length++; + i = skip(0, str, &n); + while (str[i] && str[i] > 32 && str[i] != '-' && str[i] != '+') + { + j = 0; + while (str[i] != base[j] && base[j]) + j++; + if (base[j] == '\0') + return (0); + res = (res * length) + j; + i++; + } + return (res * n); +} diff --git a/libs/libft/srcs/ft_atol.c b/libs/libft/srcs/ft_atol.c new file mode 100644 index 0000000..1bf87cf --- /dev/null +++ b/libs/libft/srcs/ft_atol.c @@ -0,0 +1,22 @@ + +#include "libft.h" + +long ft_atol(const char *str) +{ + long long nbr; + int i; + int negatif; + + i = 0; + negatif = 1; + nbr = 0; + while ((str[i] == ' ') || (str[i] > 8 && str[i] < 14)) + i++; + if (str[i] == '-') + negatif = -1; + if (str[i] == '+' || str[i] == '-') + i++; + while (str[i] >= '0' && str[i] <= '9') + nbr = nbr * 10 + (str[i++] - '0'); + return (nbr * negatif); +} diff --git a/libs/libft/srcs/ft_bzero.c b/libs/libft/srcs/ft_bzero.c new file mode 100644 index 0000000..f66336a --- /dev/null +++ b/libs/libft/srcs/ft_bzero.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_bzero.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:54:43 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:54:44 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_bzero(void *s, size_t n) +{ + size_t i; + unsigned char *ptr; + + if (n) + { + ptr = (unsigned char *)s; + i = 0; + while (i < n) + ptr[i++] = '\0'; + } +} diff --git a/libs/libft/srcs/ft_calloc.c b/libs/libft/srcs/ft_calloc.c new file mode 100644 index 0000000..b84f0ee --- /dev/null +++ b/libs/libft/srcs/ft_calloc.c @@ -0,0 +1,64 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_calloc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:54:53 by hulamy #+# #+# */ +/* Updated: 2019/12/01 16:04:12 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** allocate count * size byte of memory and +** return a pointer to the allocated memory +** +** exemple allocation for 5 integers with malloc then calloc : +** a = (int *)malloc(5 * sizeof(int)); //5*4bytes = 20 bytes +** free(a); +** a = (int *)calloc(5, sizeof(int)); +*/ + +/* +** #include +** +** void ft_bzero(void *s, size_t n) +** { +** size_t i; +** unsigned char *ptr; +** +** if (n) +** { +** ptr = (unsigned char *)s; +** i = 0; +** while (i < n) +** ptr[i++] = '\0'; +** } +** } +** +** void *ft_calloc(size_t count, size_t size); +** +** int main(void) +** { +** void *str; +** +** str = ft_calloc(0, 0); +** if (str == ((void *)0)) +** printf("failed\n"); +** free(str); +** return (0); +** } +*/ + +#include "libft.h" + +void *ft_calloc(size_t count, size_t size) +{ + void *tmp; + + if (!(tmp = malloc(count * size))) + return (NULL); + ft_bzero(tmp, count * size); + return (tmp); +} diff --git a/libs/libft/srcs/ft_concat_free.c b/libs/libft/srcs/ft_concat_free.c new file mode 100644 index 0000000..d31a4cd --- /dev/null +++ b/libs/libft/srcs/ft_concat_free.c @@ -0,0 +1,53 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_concat_free.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/27 18:04:09 by hulamy #+# #+# */ +/* Updated: 2020/02/27 18:06:44 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new string size of str1 + str2 +** fill it with concated str1 and str2m as "str1str2" +** free the received strings str1 and str2 +** return the new string +*/ + +/* +** #include +** #include "libft.h" +** +** char *ft_concat_free(char *str1, char *str2); +** +** int main(int ac, char **av) +** { +** if (ac != 3) +** return (0); +** printf("%s\n", ft_concat_free(ft_strdup(av[1]), ft_strdup(av[2]))); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_concat_free(char *str1, char *str2) +{ + char *cat; + int i; + int j; + + cat = ft_memalloc(sizeof(char) * (ft_strlen(str1) + ft_strlen(str2) + 1)); + i = -1; + j = 0; + while (str1[++i]) + cat[i] = str1[i]; + while (str2[j]) + cat[i++] = str2[j++]; + free(str1); + free(str2); + return (cat); +} diff --git a/libs/libft/srcs/ft_convertbase.c b/libs/libft/srcs/ft_convertbase.c new file mode 100644 index 0000000..43f6ec4 --- /dev/null +++ b/libs/libft/srcs/ft_convertbase.c @@ -0,0 +1,196 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convertbase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/26 20:19:54 by hulamy #+# #+# */ +/* Updated: 2020/02/26 20:20:14 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** take a string that is a number in a certain base +** and convert it in another base +** it works with unsigned long int +** return the new string +*/ + +/* +** #include // for printf +** #include // for atoi +** +** char *ft_convertbase(char *nbr, char *base_from, char *base_to); +** +** int main(int ac, char **av) +** { +** if (ac != 4) +** { +** printf("usage:\nchar *nbr, char *base_from, char *base_to\n"); +** printf("try the max long unsigned int : 18446744073709551615\n"); +** } +** else +** printf("[%s]\n",ft_convertbase(av[1], av[2], av[3])); +** return (0); +** } +*/ + +#include "libft.h" + +/* +** check : +** -if the base has no characters that appear more than one time +** -if the signes '-' and '+' are not part of the set +** -if there are no invisible characters (inferior to 32 or equal to 127) +*/ + +int + is_valid_base(char *base) +{ + int i; + int j; + + i = 0; + while (base[i]) + { + j = i + 1; + while (base[j]) + if (base[i] == base[j++]) + return (0); + if (base[i] == '-' || base[i] == '+' || base[i] < 33 || base[i] == 127) + return (0); + i++; + } + if (i >= 2) + return (1); + return (0); +} + +/* +** check : +** -if base is valid +** -if nbr contain characters +** -if nbr is made of elements of base only +*/ + +int + is_valid_nbr(char *nbr, char *base) +{ + int i; + int j; + + i = 0; + if (!is_valid_base(base)) + return (0); + while (nbr[i]) + { + j = 0; + while (base[j] && nbr[i] != base[j]) + j++; + if (base[j] == '\0') + return (0); + i++; + } + if (i == 0) + return (0); + return (1); +} + +/* +** -transform a nbr written as a string into a decimal nbr +** -it's an unsigned nbr because the negativity is managed elsewhere +** -if the number is bigger than the max unsigned long int it's false +** as it's impossible to verify if a number is bigger than the biggest +** unsigned, we verify the difference before the multiplication +*/ + +unsigned long int + base_to_decimal(char *nbr, char *base, int *error) +{ + unsigned long int decimal; + int i; + int j; + int length; + + decimal = 0; + i = 0; + length = 0; + while (base[length]) + length++; + while (nbr[i]) + { + j = 0; + while (nbr[i] != base[j] && base[j]) + j++; + if ((18446744073709551615U - j) / length < decimal) + return (*error = 1); + decimal = (decimal * length) + j; + i++; + } + return (decimal); +} + +/* +** -it counts the size needed to be allocated +** -if the given nbr was a negative one it add the place for the '-' +** -then convert the nbr from decimal base to destination base +** into the string allocated +*/ + +char + *decimal_to_base(unsigned long int decimal, char *base, int malloc_size) +{ + int base_size; + int neg; + char *result; + unsigned long int nb; + + neg = malloc_size; + base_size = 0; + while (base[base_size]) + base_size++; + nb = decimal; + while (nb /= base_size) + malloc_size++; + result = (char *)malloc(sizeof(char) * (malloc_size + 2)); + result[malloc_size + 1] = '\0'; + if (neg) + result[0] = '-'; + while (malloc_size >= 0) + { + result[malloc_size--] = base[decimal % base_size]; + decimal /= base_size; + } + return (result); +} + +/* +** -main function to convert from one base to another +** -function base_to_decimal has an awfull int *error because it cannot +** return -1 in case of error, since it's an unsigned, and it cannot +** return 0 to check the error since it would be confusing with an actual +** return of 0 if the number to convert is 0 +*/ + +char + *ft_convertbase(char *nbr, char *base_from, char *base_to) +{ + int length; + unsigned long int decimal; + int error; + + error = 0; + length = 0; + if (nbr[0] == '-') + { + nbr++; + length = 1; + } + if (!is_valid_nbr(nbr, base_from) || !is_valid_base(base_to)) + return (NULL); + decimal = base_to_decimal(nbr, base_from, &error); + if (error == 1) + return (NULL); + return (decimal_to_base(decimal, base_to, length)); +} diff --git a/libs/libft/srcs/ft_convertbase_free.c b/libs/libft/srcs/ft_convertbase_free.c new file mode 100644 index 0000000..1f2bae7 --- /dev/null +++ b/libs/libft/srcs/ft_convertbase_free.c @@ -0,0 +1,198 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convertbase_free.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/26 20:19:54 by hulamy #+# #+# */ +/* Updated: 2020/02/27 20:23:22 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** (just like ft_convert, but free the string it receive) +** take a string that is a number in a certain base +** and convert it in another base +** it works with unsigned long int +** return the new string +*/ + +/* +** #include // for printf +** #include // for atoi +** +** char *ft_convertbase_free(char *nbr, char *base_from, char *base_to); +** +** int main(int ac, char **av) +** { +** if (ac != 4) +** { +** printf("usage:\nchar *nbr, char *base_from, char *base_to\n"); +** printf("try the max long unsigned int : 18446744073709551615\n"); +** } +** else +** printf("[%s]\n",ft_convertbase_free(av[1], av[2], av[3])); +** return (0); +** } +*/ + +#include "libft.h" + +/* +** check : +** -if the base has no characters that appear more than one time +** -if the signes '-' and '+' are not part of the set +** -if there are no invisible characters (inferior to 32 or equal to 127) +*/ + +int + is_base_valid(char *base) +{ + int i; + int j; + + i = 0; + while (base[i]) + { + j = i + 1; + while (base[j]) + if (base[i] == base[j++]) + return (0); + if (base[i] == '-' || base[i] == '+' || base[i] < 33 || base[i] == 127) + return (0); + i++; + } + if (i >= 2) + return (1); + return (0); +} + +/* +** check : +** -if base is valid +** -if nbr contain characters +** -if nbr is made of elements of base only +*/ + +int + is_nbr_valid(char *nbr, char *base) +{ + int i; + int j; + + i = 0; + if (!is_base_valid(base)) + return (0); + while (nbr[i]) + { + j = 0; + while (base[j] && nbr[i] != base[j]) + j++; + if (base[j] == '\0') + return (0); + i++; + } + if (i == 0) + return (0); + return (1); +} + +/* +** -transform a nbr written as a string into a decimal nbr +** -it's an unsigned nbr because the negativity is managed elsewhere +** -if the number is bigger than the max unsigned long int it's false +** as it's impossible to verify if a number is bigger than the biggest +** unsigned, we verify the difference before the multiplication +*/ + +unsigned long int + base_2_decimal(char *nbr, char *base, int *error) +{ + unsigned long int decimal; + int i; + int j; + int length; + + decimal = 0; + i = 0; + length = 0; + while (base[length]) + length++; + while (nbr[i]) + { + j = 0; + while (nbr[i] != base[j] && base[j]) + j++; + if ((18446744073709551615U - j) / length < decimal) + return (*error = 1); + decimal = (decimal * length) + j; + i++; + } + return (decimal); +} + +/* +** -it counts the size needed to be allocated +** -if the given nbr was a negative one it add the place for the '-' +** -then convert the nbr from decimal base to destination base +** into the string allocated +*/ + +char + *decimal_2_base(unsigned long int decimal, char *base, int malloc_size) +{ + int base_size; + int neg; + char *result; + unsigned long int nb; + + neg = malloc_size; + base_size = 0; + while (base[base_size]) + base_size++; + nb = decimal; + while (nb /= base_size) + malloc_size++; + result = (char *)malloc(sizeof(char) * (malloc_size + 2)); + result[malloc_size + 1] = '\0'; + if (neg) + result[0] = '-'; + while (malloc_size >= 0) + { + result[malloc_size--] = base[decimal % base_size]; + decimal /= base_size; + } + return (result); +} + +/* +** -main function to convert from one base to another +** -function base_to_decimal has an awfull int *error because it cannot +** return -1 in case of error, since it's an unsigned, and it cannot +** return 0 to check the error since it would be confusing with an actual +** return of 0 if the number to convert is 0 +*/ + +char + *ft_convertbase_free(char *nbr, char *base_from, char *base_to) +{ + int length; + unsigned long int decimal; + int error; + + error = 0; + length = 0; + if (nbr[0] == '-') + { + nbr++; + length = 1; + } + if (!is_nbr_valid(nbr, base_from) || !is_base_valid(base_to)) + return (NULL); + decimal = base_2_decimal(nbr, base_from, &error); + if (error == 1) + return (NULL); + free(nbr); + return (decimal_2_base(decimal, base_to, length)); +} diff --git a/libs/libft/srcs/ft_foreach.c b/libs/libft/srcs/ft_foreach.c new file mode 100644 index 0000000..aaf7649 --- /dev/null +++ b/libs/libft/srcs/ft_foreach.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_foreach.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:16:10 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:16:11 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_foreach(int *tab, int length, void (*f)(int)) +{ + int i; + + i = 0; + while (i < length && tab && tab[i]) + (*f)(tab[i++]); +} diff --git a/libs/libft/srcs/ft_free_tab.c b/libs/libft/srcs/ft_free_tab.c new file mode 100644 index 0000000..cc9c4bb --- /dev/null +++ b/libs/libft/srcs/ft_free_tab.c @@ -0,0 +1,15 @@ + +#include "libft.h" + +void ft_free_tab(char **tab) +{ + int i; + + i = 0; + while (tab[i] != NULL) + { + free(tab[i]); + i++; + } + free(tab); +} diff --git a/libs/libft/srcs/ft_gnl.c b/libs/libft/srcs/ft_gnl.c new file mode 100644 index 0000000..ff3d635 --- /dev/null +++ b/libs/libft/srcs/ft_gnl.c @@ -0,0 +1,138 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_gnl.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/31 17:05:53 by hulamy #+# #+# */ +/* Updated: 2022/05/04 12:15:32 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +/* +** #include //for open +** +** int main(int ac, char **av) +** { +** int *fd; +** int i = 0; +** int j = 0; +** int ret; +** char *line = NULL; +** +** fd = (int *)ft_calloc(ac, sizeof(int)); +** while (++i <= ac - 1) +** fd[i - 1] = open(av[i], O_RDONLY); +** i = 0; +** while (j < ac - 1) +** { +** if ((ret = ft_gnl(fd[i], &line)) > 0) +** { +** ft_printf(" [fd%i-%i] %s\n", fd[i], ret, line); +** free(line); +** j = 0; +** } +** else if (ret == -1) +** { +** ft_printf("[fd%i-%i] *ERROR*\n", fd[i], ret); +** free(line); +** j++; +** } +** else if (*line != '\0') +** ft_printf(" [fd%i-%i] %s\n", fd[i], ret, line); +** else +** { +** ft_printf("[fd%i-%i] %s *FINI*\n", fd[i], ret, line); +** free(line); +** j++; +** } +** i++; +** if (i >= ac - 1) +** i = 0; +** } +** free(fd); +** //while (1); +** return (0); +** } +*/ + +int free_lst(t_gnlist **lst, int ret) +{ + t_gnlist *tmp; + + tmp = *lst; + while (tmp->next != *lst) + tmp = tmp->next; + tmp->next = (*lst)->next; + free((*lst)->str); + if (*lst == (*lst)->next) + { + free(*lst); + *lst = NULL; + } + else + { + free(*lst); + *lst = tmp; + } + return (ret); +} + +int multi_fd(int fd, t_gnlist **lst) +{ + t_gnlist *tmp; + + tmp = *lst; + while (*lst && (*lst)->lfd != fd && (*lst)->next != tmp) + *lst = (*lst)->next; + if (!tmp || ((*lst)->next == tmp && (*lst)->lfd != fd)) + { + tmp = (t_gnlist *)malloc(sizeof(*tmp)); + if (!tmp) + return (0); + tmp->lfd = fd; + tmp->str = ft_strdup(""); + if (!tmp->str) + return (0); + if (*lst) + { + tmp->next = (*lst)->next; + (*lst)->next = tmp; + } + else + tmp->next = tmp; + *lst = tmp; + } + return (1); +} + +int ft_gnl(const int fd, char **line) +{ + char buf[BUFFER_SIZE + 1]; + int ret; + static t_gnlist *lst = NULL; + char *str; + + ret = 1; + if (!(multi_fd(fd, &lst)) || !line || BUFFER_SIZE < 1) + return (free_lst(&lst, -1)); + while (!(str = ft_strchr(lst->str, '\n')) && ret != 0) + { + if ((ret = read(fd, buf, BUFFER_SIZE)) < 0) + return (free_lst(&lst, -1)); + buf[ret] = '\0'; + lst->str = ft_strjoinfree(lst->str, ft_strdup(buf)); + if (!lst->str) + return (free_lst(&lst, -1)); + } + if (str != NULL) + str[0] = '\0'; + if (!(*line = ft_strdup(lst->str))) + return (free_lst(&lst, -1)); + if (str != NULL) + return (ft_memmove(lst->str, str + 1, ft_strlen(str + 1) + 1) != NULL); + return (free_lst(&lst, 0)); +} diff --git a/libs/libft/srcs/ft_greater.c b/libs/libft/srcs/ft_greater.c new file mode 100644 index 0000000..1c1d526 --- /dev/null +++ b/libs/libft/srcs/ft_greater.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_greater(int a, int b) +{ + if (a < b) + return (b); + return (a); +} diff --git a/libs/libft/srcs/ft_isalnum.c b/libs/libft/srcs/ft_isalnum.c new file mode 100644 index 0000000..dc1bb03 --- /dev/null +++ b/libs/libft/srcs/ft_isalnum.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalnum.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:05 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:06 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isalnum(int c) +{ + return (ft_isalpha(c) || ft_isdigit(c)); +} diff --git a/libs/libft/srcs/ft_isalpha.c b/libs/libft/srcs/ft_isalpha.c new file mode 100644 index 0000000..e0ec883 --- /dev/null +++ b/libs/libft/srcs/ft_isalpha.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:15 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:17 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isalpha(int c) +{ + return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); +} diff --git a/libs/libft/srcs/ft_isascii.c b/libs/libft/srcs/ft_isascii.c new file mode 100644 index 0000000..f201880 --- /dev/null +++ b/libs/libft/srcs/ft_isascii.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isascii.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:24 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:25 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isascii(int c) +{ + return (c >= 0 && c <= 127); +} diff --git a/libs/libft/srcs/ft_isdigit.c b/libs/libft/srcs/ft_isdigit.c new file mode 100644 index 0000000..69e0809 --- /dev/null +++ b/libs/libft/srcs/ft_isdigit.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isdigit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:32 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:33 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isdigit(int c) +{ + return (c >= '0' && c <= '9'); +} diff --git a/libs/libft/srcs/ft_isnumber.c b/libs/libft/srcs/ft_isnumber.c new file mode 100644 index 0000000..6ecc6c5 --- /dev/null +++ b/libs/libft/srcs/ft_isnumber.c @@ -0,0 +1,19 @@ + +#include "libft.h" + +int ft_isnumber(char *nb) +{ + int i; + + i = 0; + if (nb[i] == '+' || nb[i] == '-') + i++; + while (nb[i] != '\0') + { + if (ft_isdigit(nb[i]) == 0) + return (0); + i++; + } + return (1); +} + diff --git a/libs/libft/srcs/ft_isprint.c b/libs/libft/srcs/ft_isprint.c new file mode 100644 index 0000000..21395ab --- /dev/null +++ b/libs/libft/srcs/ft_isprint.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isprint.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:43 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:44 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isprint(int c) +{ + return (c >= 32 && c < 127); +} diff --git a/libs/libft/srcs/ft_issort.c b/libs/libft/srcs/ft_issort.c new file mode 100644 index 0000000..842195b --- /dev/null +++ b/libs/libft/srcs/ft_issort.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_issort.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:18:14 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:18:15 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_issort(int *tab, int length, int (*f)(int, int)) +{ + int i; + + i = -1; + if (!tab) + return (0); + while (++i < length - 1) + if (f(tab[i], tab[i + 1]) > 0) + return (0); + return (1); +} diff --git a/libs/libft/srcs/ft_itoa.c b/libs/libft/srcs/ft_itoa.c new file mode 100644 index 0000000..9819d33 --- /dev/null +++ b/libs/libft/srcs/ft_itoa.c @@ -0,0 +1,91 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_itoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:59:01 by hulamy #+# #+# */ +/* Updated: 2020/02/19 15:44:04 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** take an integer and give a string +*/ + +/* +** #include // for printf +** #include // for atoi +** +** char *ft_itoa(long int n); +** +** int main(int ac, char **av) +** { +** if (ac == 0) +** return (0); +** else if (ac == 2) +** printf("%s\n",ft_itoa(atoi(av[1]))); +** else +** { +** long int i; +** i = 0; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 1234567; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = -1234567; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 237683; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 2147483647; +** printf("| %li\n| %s\n\n",i,ft_itoa(i)); +** i = i ^ 0; // create the opposite of a signed '0', which +** // is 0 followed by 31 '1', the signed int max +** printf("* %li\n* %s\n\n",i,ft_itoa(i)); +** i = i ^ 0; +** i = 1 << 31; // change the most lefted bit from '0' (positive) +** // to '1' (negative), the signed int min +** printf("* %li\n* %s\n\n",i,ft_itoa(i)); +** i = 2147483646; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = -2147483648; +** printf("| %li\n| %s\n\n",i,ft_itoa(i)); +** i = -2147483647; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 2147483648; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = -2147483649; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 9223372036854775807; +** printf("| %li\n| %s\n\n",i,ft_itoa(i)); +** i = -9223372036854775807; +** printf("| %li\n| %s\n\n",i,ft_itoa(i)); +** } +** return 0; +** } +*/ + +#include "libft.h" + +char *ft_itoa(long int n) +{ + char *str; + int len; + long int cpy; + char rgt; + + cpy = (n < 0) ? (n / 10) * -10 : (n / 10) * 10; + len = (n < 0) ? 2 : 1; + rgt = (n < 0) ? (n % 10) * -1 + '0' : n % 10 + '0'; + while (n /= 10) + len++; + if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) + return (NULL); + str[len] = '\0'; + str[--len] = rgt; + while (cpy /= 10) + str[--len] = cpy % 10 + '0'; + if (len) + str[0] = '-'; + return (str); +} diff --git a/libs/libft/srcs/ft_lstbegin.c b/libs/libft/srcs/ft_lstbegin.c new file mode 100644 index 0000000..375e816 --- /dev/null +++ b/libs/libft/srcs/ft_lstbegin.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstbegin.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 15:05:21 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:17:27 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * return a pointer to the first element of a two-way list + */ + +#include "libft.h" + +t_list *ft_lstbegin(t_list *lst) +{ + while (lst->prev) + lst = lst->prev; + return (lst); +} diff --git a/libs/libft/srcs/ft_lstcopy.c b/libs/libft/srcs/ft_lstcopy.c new file mode 100644 index 0000000..feb5482 --- /dev/null +++ b/libs/libft/srcs/ft_lstcopy.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstcopy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 16:26:27 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:17:37 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * copy a two-way list with the copy function for the content + * and return pointer to the begining of the new list + */ + +#include "libft.h" + +t_list *ft_lstcopy(t_list *lst, void *(*cpy)(void *)) +{ + t_list *lst_copy; + + if (!lst || !cpy) + return (NULL); + lst_copy = NULL; + while (lst) + { + ft_lstpush_back(&lst_copy, ft_lstcreate(cpy(lst->content))); + lst = lst->next; + } + return (ft_lstbegin(lst_copy)); +} diff --git a/libs/libft/srcs/ft_lstcreate.c b/libs/libft/srcs/ft_lstcreate.c new file mode 100644 index 0000000..5dee203 --- /dev/null +++ b/libs/libft/srcs/ft_lstcreate.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstcreate.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 13:12:50 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:17:46 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * create a new two-way list + */ + +#include "libft.h" + +t_list *ft_lstcreate(void *content) +{ + t_list *lst; + + lst = (t_list *)malloc(sizeof(*lst)); + if (!lst) + return (NULL); + lst->content = content; + lst->prev = NULL; + lst->next = NULL; + return (lst); +} diff --git a/libs/libft/srcs/ft_lstend.c b/libs/libft/srcs/ft_lstend.c new file mode 100644 index 0000000..bb04263 --- /dev/null +++ b/libs/libft/srcs/ft_lstend.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstend.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 15:11:41 by simplonco #+# #+# */ +/* Updated: 2022/03/24 15:12:17 by simplonco ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * return a pointer to the last element of a two-way list + */ + +#include "libft.h" + +t_list *ft_lstend(t_list *lst) +{ + while (lst->next) + lst = lst->next; + return (lst); +} diff --git a/libs/libft/srcs/ft_lsterase.c b/libs/libft/srcs/ft_lsterase.c new file mode 100644 index 0000000..ed0bad9 --- /dev/null +++ b/libs/libft/srcs/ft_lsterase.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lsterase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 15:31:16 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:17:57 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * erase an element in two-way list + * and rejoin the list + */ + +#include "libft.h" + +void ft_lsterase(t_list *lst, void (*del)(void *)) +{ + if (!lst || !del) + return ; + del(lst->content); + if (lst->prev) + lst->prev->next = lst->next; + if (lst->next) + lst->next->prev = lst->prev; + free(lst); + lst = NULL; +} diff --git a/libs/libft/srcs/ft_lstfind.c b/libs/libft/srcs/ft_lstfind.c new file mode 100644 index 0000000..297f6d0 --- /dev/null +++ b/libs/libft/srcs/ft_lstfind.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstfind.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/23 22:48:47 by simplonco #+# #+# */ +/* Updated: 2022/03/24 15:23:22 by simplonco ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * find an element in two-way list with the comp function + * return a pointer to it + */ + +#include "libft.h" + +t_list *ft_lstfind(t_list *lst, void *to_find, int (*comp)(void*, void *)) +{ + while (lst && (!comp(to_find, lst->content))) + lst = lst->next; + return (lst); +} diff --git a/libs/libft/srcs/ft_lstfree.c b/libs/libft/srcs/ft_lstfree.c new file mode 100644 index 0000000..ecc7043 --- /dev/null +++ b/libs/libft/srcs/ft_lstfree.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstfree.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 15:49:35 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:18:07 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * delete and free an element of a two-way list and all the followings + */ + +#include "libft.h" + +void ft_lstfree(t_list *lst, void (*del)(void *)) +{ + t_list *next; + + if (lst && lst->prev) + lst->prev->next = NULL; + while (lst != NULL) + { + next = lst->next; + del(lst->content); + free(lst); + lst = next; + } +} diff --git a/libs/libft/srcs/ft_lstinsert.c b/libs/libft/srcs/ft_lstinsert.c new file mode 100644 index 0000000..fe674df --- /dev/null +++ b/libs/libft/srcs/ft_lstinsert.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstinsert.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 15:22:46 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:18:19 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * insert an element in two-way list just after the one in parameter + * and rejoin the list + */ + +#include "libft.h" + +void ft_lstinsert(t_list *lst, t_list *new) +{ + new->next = lst->next; + lst->next = new; + new->next->prev = new; + new->prev = lst; +} diff --git a/libs/libft/srcs/ft_lstlen.c b/libs/libft/srcs/ft_lstlen.c new file mode 100644 index 0000000..c07b112 --- /dev/null +++ b/libs/libft/srcs/ft_lstlen.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 16:20:25 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:18:36 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * return the len of the two-way list + */ + +#include "libft.h" + +int ft_lstlen(t_list *lst) +{ + int size; + + size = 0; + while (lst) + { + size++; + lst = lst->next; + } + return (size); +} diff --git a/libs/libft/srcs/ft_lstloop.c b/libs/libft/srcs/ft_lstloop.c new file mode 100644 index 0000000..2eb1f46 --- /dev/null +++ b/libs/libft/srcs/ft_lstloop.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstloop.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 14:37:15 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:18:55 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * go forward through all elements of a two-way list + * and apply the function f to each of them + */ + +#include "libft.h" + +void ft_lstloop(t_list *lst, void (*f)(void *)) +{ + if (!f) + return ; + while (lst) + { + f(lst->content); + lst = lst->next; + } +} diff --git a/libs/libft/srcs/ft_lstloop_back.c b/libs/libft/srcs/ft_lstloop_back.c new file mode 100644 index 0000000..3b03fc0 --- /dev/null +++ b/libs/libft/srcs/ft_lstloop_back.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstloop_back.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 15:01:37 by simplonco #+# #+# */ +/* Updated: 2022/05/04 14:18:50 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * go backward through all elements of a two-way list + * and apply the function f to each of them + */ + +#include "libft.h" + +void ft_lstloop_back(t_list *lst, void (*f)(void *)) +{ + if (!f) + return ; + while (lst) + { + f(lst->content); + lst = lst->prev; + } +} diff --git a/libs/libft/srcs/ft_lstpush_back.c b/libs/libft/srcs/ft_lstpush_back.c new file mode 100644 index 0000000..3d819fb --- /dev/null +++ b/libs/libft/srcs/ft_lstpush_back.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstpush_back.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 13:37:11 by simplonco #+# #+# */ +/* Updated: 2022/03/24 14:28:49 by simplonco ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * add an element to the end of a two-way list, or first if list has no element + * return NULL if element is NULL (eg it returned from ft_lstcreate and failed) + * or else address to the element added + */ + +#include "libft.h" + +void *ft_lstpush_back(t_list **lst, t_list *new) +{ + t_list *tmp; + + if (!new) + return (NULL); + if (lst) + { + tmp = *lst; + if (!tmp) + *lst = new; + else + { + while (tmp->next) + tmp = tmp->next; + tmp->next = new; + new->prev = tmp; + } + } + return (new); +} diff --git a/libs/libft/srcs/ft_lstpush_front.c b/libs/libft/srcs/ft_lstpush_front.c new file mode 100644 index 0000000..453054f --- /dev/null +++ b/libs/libft/srcs/ft_lstpush_front.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstpush_front.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: simplonco +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/03/24 14:25:25 by simplonco #+# #+# */ +/* Updated: 2022/03/24 14:32:14 by simplonco ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* + * add an element to the begining of a two-way list + */ + +#include "libft.h" + +void ft_lstpush_front(t_list **alst, t_list *new) +{ + new->next = *alst; + (*alst)->prev = new; + *alst = new; +} diff --git a/libs/libft/srcs/ft_memalloc.c b/libs/libft/srcs/ft_memalloc.c new file mode 100644 index 0000000..e746ee2 --- /dev/null +++ b/libs/libft/srcs/ft_memalloc.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memalloc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/19 15:21:44 by hulamy #+# #+# */ +/* Updated: 2022/05/04 14:15:38 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** allocate size byte of memory and return a pointer to the allocated memory +*/ + +#include "libft.h" + +void *ft_memalloc(size_t size) +{ + void *tmp; + + tmp = malloc(size); + if (!size || !tmp) + return (NULL); + ft_bzero(tmp, size); + return (tmp); +} diff --git a/libs/libft/srcs/ft_memccpy.c b/libs/libft/srcs/ft_memccpy.c new file mode 100644 index 0000000..fee3c2f --- /dev/null +++ b/libs/libft/srcs/ft_memccpy.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memccpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 15:24:51 by hulamy #+# #+# */ +/* Updated: 2019/11/25 15:25:09 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy string until character is found and place cursor in dst +** after last byte copied +*/ + +#include "libft.h" + +void *ft_memccpy(void *dst, const void *src, int c, size_t n) +{ + unsigned char *dest; + unsigned char *sourc; + size_t i; + + i = -1; + dest = (unsigned char *)dst; + sourc = (unsigned char *)src; + while (++i < n) + { + dest[i] = sourc[i]; + if (sourc[i] == (unsigned char)c) + return (dst + i + 1); + } + return (NULL); +} diff --git a/libs/libft/srcs/ft_memchr.c b/libs/libft/srcs/ft_memchr.c new file mode 100644 index 0000000..6a1c359 --- /dev/null +++ b/libs/libft/srcs/ft_memchr.c @@ -0,0 +1,51 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:51 by hulamy #+# #+# */ +/* Updated: 2019/12/12 21:50:32 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate character in string and return its position +*/ + +/* +** #include +** +** void *ft_memchr(const void *s, int c, size_t n); +** +** int main(void) +** { +** const char *str; +** +** char *pouet = "z"; +** char *lolzer = (char *)&pouet[2]; +** lolzer = "aaaaaaaaaa"; +** str = ft_memchr(pouet, 'a', 50); +** if (!str) +** printf("NULL"); +** else +** printf("%s\n", str); +** return (0); +** } +*/ + +#include "libft.h" + +void *ft_memchr(const void *s, int c, size_t n) +{ + unsigned char *sbis; + size_t i; + + sbis = (unsigned char *)s; + i = -1; + while (++i < n) + if (sbis[i] == (unsigned char)c) + return ((void *)sbis + i); + return (NULL); +} diff --git a/libs/libft/srcs/ft_memcmp.c b/libs/libft/srcs/ft_memcmp.c new file mode 100644 index 0000000..c05a028 --- /dev/null +++ b/libs/libft/srcs/ft_memcmp.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:05 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:56:07 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** compare two bytes strings (doesnt recognize a null terminated string) +** and return value of difference between first two different character +*/ + +#include "libft.h" + +int ft_memcmp(const void *s1, const void *s2, size_t n) +{ + unsigned char *frst; + unsigned char *scnd; + size_t i; + + i = 0; + frst = (unsigned char *)s1; + scnd = (unsigned char *)s2; + while (i < n && frst[i] == scnd[i]) + i++; + return ((i == n) ? 0 : frst[i] - scnd[i]); +} diff --git a/libs/libft/srcs/ft_memcpy.c b/libs/libft/srcs/ft_memcpy.c new file mode 100644 index 0000000..b9f0b38 --- /dev/null +++ b/libs/libft/srcs/ft_memcpy.c @@ -0,0 +1,46 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:16 by hulamy #+# #+# */ +/* Updated: 2019/12/01 14:54:14 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy n characters from src to dst and return dst +*/ + +/* +** #include +** +** void *ft_memcpy(void *dst, const void *src, size_t n); +** +** int main(int ac, char **av) +** { +** if (ac == 4) +** printf("%s\n", ft_memcpy(av[1], av[2], atoi(av[3]))); +** return (0); +** } +*/ + +#include "libft.h" + +void *ft_memcpy(void *dst, const void *src, size_t n) +{ + int i; + char *ptr; + char *ptr2; + + i = -1; + ptr = (char *)dst; + ptr2 = (char *)src; + if (dst == src) + return (dst); + while (++i < (int)n) + ptr[i] = ptr2[i]; + return (dst); +} diff --git a/libs/libft/srcs/ft_memdel.c b/libs/libft/srcs/ft_memdel.c new file mode 100644 index 0000000..f057043 --- /dev/null +++ b/libs/libft/srcs/ft_memdel.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memdel.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:13:26 by hulamy #+# #+# */ +/* Updated: 2019/04/03 15:44:12 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** free memory +*/ + +#include "libft.h" + +void ft_memdel(void **ap) +{ + if (ap && *ap) + { + free(*ap); + *ap = 0; + } +} diff --git a/libs/libft/srcs/ft_memmove.c b/libs/libft/srcs/ft_memmove.c new file mode 100644 index 0000000..d005136 --- /dev/null +++ b/libs/libft/srcs/ft_memmove.c @@ -0,0 +1,68 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memmove.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:25 by hulamy #+# #+# */ +/* Updated: 2019/12/10 23:53:40 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy n characters from src to dst in a non destructive way and return dst +*/ + +/* +** #include +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** void *ft_memmove(void *dst, const void *src, size_t len); +** +** //int main(int ac, char **av) +** int main(void) +** { +** char *src = "this is a good nyancat !\r\n"; +** char dst[0xF0]; +** int size = strlen(src); +** +** // if (ac == 4) +** // printf("%s\n", ft_memmove(av[1], av[2], atoi(av[3]))); +** +** ft_memmove(dst, src, size); +** printf("%s", dst); +** return (0); +** } +*/ + +#include "libft.h" + +void *ft_memmove(void *dst, const void *src, size_t len) +{ + size_t i; + char *cpsrc; + char *cpdst; + + i = -1; + cpsrc = (char *)src; + cpdst = (char *)dst; + if (dst == src) + return (dst); + if (cpsrc < cpdst) + while (len--) + cpdst[len] = cpsrc[len]; + else + while (++i < len) + cpdst[i] = cpsrc[i]; + return (dst); +} diff --git a/libs/libft/srcs/ft_memset.c b/libs/libft/srcs/ft_memset.c new file mode 100644 index 0000000..10c2d7c --- /dev/null +++ b/libs/libft/srcs/ft_memset.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:37 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:56:38 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy n time a character in a string and return the string +*/ + +#include "libft.h" + +void *ft_memset(void *b, int c, size_t len) +{ + char *ptr; + size_t i; + + ptr = (char *)b; + i = 0; + while (i < len) + ptr[i++] = c; + return (b); +} diff --git a/libs/libft/srcs/ft_printf_files/ft_convert.c b/libs/libft/srcs/ft_printf_files/ft_convert.c new file mode 100644 index 0000000..644a270 --- /dev/null +++ b/libs/libft/srcs/ft_printf_files/ft_convert.c @@ -0,0 +1,105 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convert.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/03/12 22:30:05 by hulamy #+# #+# */ +/* Updated: 2020/06/30 00:40:49 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +/* +** -convert the next argument into a string according to the following +** correspondances for diuxXcspefgn : +** [char] [hhd, hhi, c] [int] [d i c] +** [short] [hd, hi] [int] +** [int] [d, i] [int] +** [long] [ld, li] [long] [ld li] +** [long long] [lld, lli] [long] +** [unsigned char] [hhu, hhx, hhX] [unsigned int] [u x X p s] +** [unsigned short] [hu, hx, hX] [unsigned int] +** [unsigned int] [u, x, X, p] [unsigned int] +** [unsigned long] [lu, lx, lX] [unsigned long] [lu lx lX] +** [unsigned long long][llu, llx, llX] [unsigned long] +** [char *] [s, hhn] +** [double] [e, le, f, lf, g, lg] +** [wint_t] [lc] +** [wchar_t] [ls] +** [short *] [hn] +** [int *] [n] +** [long *] [ln] +** [long long *] [lln] +** -'h' and 'hh', are traited just like regular size because of +** default promotion, that promote smaller type than int into int +*/ + +char *conv_i(char c, long int i) +{ + char *s; + + if (c == 'c') + { + s = ft_strdup("0"); + s[0] = i; + return (s); + } + if (c == 'd' || c == 'i') + return (ft_itoa(i)); + return (NULL); +} + +char *conv_u(char c, unsigned long int i) +{ + char *s; + + if (c == 's') + return (i == 0 ? ft_strdup("(null)") : ft_strdup((char *)i)); + s = ft_utoa(i); + if (c == 'u') + return (s); + if (c == 'x' || c == 'p') + return (ft_convertbase_free(s, "0123456789", "0123456789abcdef")); + if (c == 'X') + return (ft_convertbase_free(s, "0123456789", "0123456789ABCDEF")); + return (NULL); +} + +/* +** -first a loop to expand all the stars from width and .precision +** they always expand into int type +** it's done first because those are the first next args on the va_list +** -for each kind of specifier there is finally four kinds of conversion : +** int / long int / unsigned int / unsingned long int +** -the conversion 'uxX' associated with 'l' are converted with lu, but +** also are 'p' and 's', without an 'l' flag, that's why there is this little +** trick on line the line for unsigned int : +** -'uxXps' && 'lps' will make it looks for 'uxX' and for 'l' +** (because it will never find a 'p' or a 's' if there are 'uxX' already) +** or for 'p' and again for 'p', or 's' twice similarly +*/ + +char *ft_convert(va_list ap, char *type, char **s) +{ + char *tmp; + + while (ft_strchr(*s, '*')) + if (!(ft_expand_star(va_arg(ap, int), s))) + return (NULL); + if ((tmp = ft_strchrset(type, "dic")) && ft_strchr(type, 'l')) + return (conv_i(tmp[0], va_arg(ap, long int))); + if ((tmp = ft_strchrset(type, "dic"))) + return (conv_i(tmp[0], va_arg(ap, int))); + if ((tmp = ft_strchrset(type, "uxXps")) && ft_strchrset(type, "lps")) + return (conv_u(tmp[0], va_arg(ap, unsigned long int))); + if ((tmp = ft_strchrset(type, "uxX"))) + return (conv_u(tmp[0], va_arg(ap, unsigned int))); + if (ft_strchr(type, '%')) + return (ft_strdup("%")); + if (ft_strchrset(type, "efgn")) + return (NULL); + return (NULL); +} diff --git a/libs/libft/srcs/ft_printf_files/ft_flag_transform.c b/libs/libft/srcs/ft_printf_files/ft_flag_transform.c new file mode 100644 index 0000000..21a06fc --- /dev/null +++ b/libs/libft/srcs/ft_printf_files/ft_flag_transform.c @@ -0,0 +1,199 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_flag_transform.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/03/12 22:30:28 by hulamy #+# #+# */ +/* Updated: 2020/03/12 22:30:41 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +/* +** -function that modify the string 'print' according to the precision flag : +** if length(s) < precision, add x '0' bfr nbr, but after '-' if negative +*/ + +char *precision_int(char *print, int precision) +{ + int i; + char *tmp; + + i = ft_strlen(print); + if (print[0] == '-') + precision++; + if (precision > i) + { + if (!(tmp = (char *)malloc(sizeof(char) * (precision + 1)))) + return (NULL); + tmp[precision] = '\0'; + if (print[0] == '-') + tmp[0] = '-'; + while (i) + tmp[--precision] = print[--i]; + if (print[0] == '-') + precision++; + while (precision) + tmp[--precision] = '0'; + if (print[0] == '-') + tmp[0] = '-'; + free(print); + print = tmp; + } + return (print); +} + +/* +** -it first verify if there is a precision point, and if so, it execute a +** serie of action listed below, otherwise return print as it is +** ACTIONS : +** -look for a '.' +** -if followed by numbers, extract an int version of those numbers +** -if the '.' is alone, gives value '0' to the int +** -then removes the '.' and the numbers from the %string +** -if flag '0' is present in %string, removes it (actually turn each occurence +** in a '.') +** -and transform 'print' according to the precision : +** -0 if .precision is 0 && print is "0": print nothing +** -1 if type is s: if length(s) > precision, removes end of 'print' to print +** only x chars, with x = precision +** -2 if type is "diouxX": call fonction 'precision_int' that return : +** if length(s) < precision, add x '0' bfr nbr, but after '-' if negative +** -3 if type is "aAeEfF": not covered +** -4 if type is "gG": not covered +** -5 else: error +*/ + +char *ft_precision(char *s, char *print, char *type) +{ + char *tmp; + int precision; + int i; + + if ((tmp = ft_strchr(s, '.'))) + { + precision = ft_atoi(tmp + 1); + while (*s && ft_strchr("#- +'0", *(++s))) + if (*s == '0') + *s = '/'; + i = 0; + if (precision == 0 && !ft_strcmp(print, "0")) + print[0] = '\0'; + else if (ft_strchr(type, 's')) + { + while (i < precision && print[i]) + i++; + if (print[i]) + print[i] = '\0'; + } + else if (ft_strchrset(type, "diouxX")) + print = precision_int(print, precision); + } + return (print); +} + +/* +** -if flag '-' is present, put extra width as ' ' to right of 'print' +** -if flag '0' is present, put extra width as '0' to left of 'print' +** -else, put extra width as ' ' to left of 'print' +*/ + +char *width_flags(char *print, char *s, int width, int zero) +{ + char *tmp; + char *minus; + int len; + + len = ft_strlen(print) + zero; + if (!(tmp = ft_strnew(width))) + return (NULL); + if (ft_strchr(s, '-')) + { + ft_memmove(tmp, print, len); + ft_memset(tmp + len, ' ', width - len); + } + else + { + ft_memset(tmp, (ft_strchr(s, '0')) ? '0' : ' ', width - len); + ft_memmove(ft_strchr(tmp, '\0') + zero, print, ft_strlen(print)); + if (ft_strchr(s, '0') && (minus = ft_strchrset("+-", tmp))) + { + tmp[0] = (minus[0] == '+') ? '+' : '-'; + minus[0] = '0'; + } + } + free(print); + return (tmp); +} + +/* +** -if there is a minimal width field, calculate it and add it to print +** according to the flags '-' and '0' if present +** -in details : +** 0 if print[0] value 0, as it happens for type c with (char)0, save it for +** later in 'zero' +** 1 loop through s, the string starting by '%' and ending by a converter, +** until it has passed all the flags that are not a potentiel width field +** 2 then if it's the end of s, there is no width and print isn't changed, +** otherwise the int 'size' take the value returned by atoi +** in case print isn't changed, 'size' is the length of 'print' +** 3 then if the size of the width shield is bigger than the size of print +** (plus zero in case print is a (char)0), call 'width_flags' that will +** create a new char* to contain the string to print after transformation +** 4 otherwise 'size' is the length of print + zero +*/ + +char *ft_width(char *s, char *print, int *size, char *type) +{ + char *tmp; + int zero; + + tmp = s; + zero = 0; + if (print[0] == '\0' && ft_strchr(type, 'c')) + zero = 1; + while (*tmp != '\0' && ft_strchr("%#- +'0/", *tmp)) + tmp++; + if (*tmp == '\0' || *tmp == '.') + { + *size = ft_strlen(print) + zero; + return (print); + } + *size = ft_atoi(tmp); + tmp[0] = '\0'; + if ((unsigned int)*size > ft_strlen(print) + zero) + print = width_flags(print, s, *size, zero); + else + *size = ft_strlen(print) + zero; + tmp[0] = '1'; + return (print); +} + +/* +** -go through all the transformation flags needs +** -first the precision +** -then if type is int and nbr is positive, add a + to the left, it's flag '+' +** -third the flag "#" +** -fourth, the width +** -then p +** -the case of 'p' is treated without any subtelness because i don't care +*/ + +char *ft_flag_transform(char *s, char *print, char *type, int *size) +{ + print = ft_precision(s, print, type); + print = ft_plus(s, print, type); + print = ft_sharp(s, print, type); + if (ft_strchr(type, 'p')) + { + print = ft_concat_free(ft_strdup("0x"), print); + *size += 2; + } + print = ft_width(s, print, size, type); + print = ft_sharp_again(s, print, type); + print = ft_space(s, print, type, size); + return (print); +} diff --git a/libs/libft/srcs/ft_printf_files/ft_flag_transform_bonus.c b/libs/libft/srcs/ft_printf_files/ft_flag_transform_bonus.c new file mode 100644 index 0000000..f6d773a --- /dev/null +++ b/libs/libft/srcs/ft_printf_files/ft_flag_transform_bonus.c @@ -0,0 +1,75 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_flag_transform_bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/03/12 22:30:50 by hulamy #+# #+# */ +/* Updated: 2020/03/12 22:30:57 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_plus(char *s, char *print, char *type) +{ + if (!ft_strchrset(type, "di")) + return (print); + if (ft_strchr(s, '+') && !ft_strchr(print, '-')) + print = ft_concat_free(ft_strdup("+"), print); + return (print); +} + +char *ft_sharp(char *s, char *print, char *type) +{ + if (ft_strchr(s, '#')) + { + if (ft_strchr(type, 'x')) + print = ft_concat_free(ft_strdup("0x"), print); + else + print = ft_concat_free(ft_strdup("0X"), print); + } + return (print); +} + +char *ft_sharp_again(char *s, char *print, char *type) +{ + char *tmp; + + if (!ft_strchr(s, '#')) + return (print); + if (print[0] == '0' && print[1] == '0' && ft_strchrset(type, "xX")) + { + tmp = ft_strchrset("xX", print); + print[1] = tmp[0]; + tmp[0] = '0'; + } + return (print); +} + +char *ft_space(char *s, char *print, char *type, int *size) +{ + int i; + + i = 0; + if (print[0] == ' ' || !ft_strchr(s, ' ') || !ft_strchrset(type, "diuxX")) + return (print); + while (print[i] == ' ') + i++; + if (print[i] == '-' || print[i] == '+') + return (print); + if (ft_strchr(s, '.') || (i == 0 && print[i] != '0')) + { + print = ft_concat_free(ft_strdup(" "), print); + *size += 1; + } + else + print[i] = ' '; + if (ft_strchr(s, '-') && print[*size - 1] == ' ') + { + print[*size] = '\0'; + *size -= 1; + } + return (print); +} diff --git a/libs/libft/srcs/ft_printf_files/ft_next_word.c b/libs/libft/srcs/ft_printf_files/ft_next_word.c new file mode 100644 index 0000000..6980aac --- /dev/null +++ b/libs/libft/srcs/ft_printf_files/ft_next_word.c @@ -0,0 +1,98 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* next_word.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/10 13:58:30 by hulamy #+# #+# */ +/* Updated: 2020/02/26 18:24:04 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +/* +** -placed outside of "word_length" for lake of space +** -check if there is a '*' or a number +** -usefull as such for the 'width', and after a check +** for a '.' for the 'precision' flag +*/ + +int width_precision(char *s) +{ + int i; + + i = 0; + if (ft_strchr("*", s[i]) != NULL) + i++; + while (ft_strchr("0123456789", s[i]) != NULL) + i++; + return (i); +} + +/* +** -return the length of the next word to print +** -for that it got through the characters expecting +** in the following order : +** [%][flags][width][.precision][length][specifier] +** knowing that 'flags' can repeat themselves +** -a single '%' is treated as a word of length 1 +** (unlike the real printf) +** -it's written : +** i += width_precision(s + i + 1) + 1; +** instead of : +** i++; +** i += width_precision(s + i); +** to save a line (3 with the brackets) +*/ + +int word_length(char *s) +{ + int i; + + i = 1; + if (s[0] == '\0') + return (0); + if (s[0] != '%') + { + while (s[i] != '%' && s[i] != '\0') + i++; + return (i); + } + while (ft_strchr("#0- +'", s[i]) != NULL) + i++; + i += width_precision(s + i); + if (ft_strchr(".", s[i]) != NULL) + i += width_precision(s + i + 1) + 1; + while (ft_strchr("hl", s[i]) != NULL) + i++; + if (ft_strchr("diuxXcspefgn%", s[i]) != NULL) + i++; + return (i); +} + +/* +** -return the next sequence to be print +** (either a string, or a conversion) +** -a single '%' is an error in real printf +** but is treated as a '%' here +*/ + +char *next_word(char **string) +{ + char *s; + char *word; + int i; + + s = *string; + if (*s == '\0') + return (NULL); + if ((i = word_length(s)) < 0) + return (NULL); + word = (char *)malloc(sizeof(char) * (i + 1)); + word[i] = '\0'; + ft_memmove(word, s, i); + *string += i; + return (word); +} diff --git a/libs/libft/srcs/ft_printf_files/ft_printf.c b/libs/libft/srcs/ft_printf_files/ft_printf.c new file mode 100644 index 0000000..d96f663 --- /dev/null +++ b/libs/libft/srcs/ft_printf_files/ft_printf.c @@ -0,0 +1,162 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/03/12 22:31:29 by hulamy #+# #+# */ +/* Updated: 2020/06/30 00:41:35 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +/* +** SPECIFIER : +** receive a word as a string, check if it start by '%', and return the +** specifier (diuxXspefgn) and the length (h hh l ll) +** -if s is a string, or is a single '%' +** return NULL (to print is as a string) +** -if s is a double '%%', remove one '%', and +** return NULL (to print is as a string) +** -then s is a conversion, go to the length and specifier +** -copy them in 'string' +** -and remove them from s +** -return the length and specifier in a string +*/ + +char *specifier(char *s) +{ + char *string; + int i; + + if (s[0] != '%' || s[1] == '\0') + return (NULL); + if (s[1] == '%') + { + s[1] = '\0'; + return (NULL); + } + i = 1; + while (ft_strchr("#0- +'0123456789.*", s[i]) != NULL) + i++; + string = ft_strdup(s + i); + while (s[i] != '\0') + { + s[i] = '\0'; + i++; + } + return (string); +} + +/* +** -receive 'i' the number in which '*' will expand +** -turn it into a string +** -calculate the total lentgh of the string '%...' for nbr replacing '*' +** -allocate a new string with this length +** -copy the original str with first '*' expanded into it's corresponding nbr +*/ + +int ft_expand_star(int nbr, char **string) +{ + char *s; + char *n; + int i; + int j; + int k; + + n = ft_itoa(nbr); + if (!(s = ft_memalloc(sizeof(char) * (ft_strlen(n) + ft_strlen(*string))))) + return (0); + i = -1; + j = 0; + k = 0; + while ((*string)[++i] != '\0') + { + s[j] = (*string)[i]; + if (s[j] == '*') + while (n[k] != '\0') + s[j++] = n[k++]; + else + j++; + } + free(n); + free(*string); + *string = s; + return (1); +} + +/* +** print the string +** because of lake of space, it also free 'type' +*/ + +int ft_put_word(char *s, char *type, int size) +{ + int i; + + i = 0; + while (i < size) + write(1, &(s[i++]), 1); + free(type); + free(s); + return (i); +} + +/* +** because of lake of space... +** -1 expand the specifier according to its type and its length +** and put in a string 'print' +** -2 transform 'print' according to the flags +*/ + +char *convert_with_flags(char *s, va_list ap, char *type, int *size) +{ + char *print; + + if (!(print = ft_convert(ap, type, &s))) + return (NULL); + if (!(print = ft_flag_transform(s, print, type, size))) + return (NULL); + free(s); + return (print); +} + +/* +** -printf receive a string to print with a variadic number of arguments +** -it will go in a loop through each 'words' +** -a word is either a string containing no '%' or a conversion starting by '%' +** -if it's a string it's printed right away +** -if it's a conversion it will call convert_with_flags for some actions : +** -1 expand the specifier according to its type and its length +** and put in a string 'print' +** -2 transform 'print' according to the flags +*/ + +int ft_printf(char *string, ...) +{ + char *s; + char *type; + int length; + int size; + va_list ap; + + length = 0; + va_start(ap, string); + while ((s = next_word(&string)) != NULL) + { + if ((type = specifier(s)) == NULL) + length += ft_put_word(s, type, ft_strlen(s)); + else + { + size = 0; + if (!(s = convert_with_flags(s, ap, type, &size))) + return (-1); + length += ft_put_word(s, type, size); + } + } + free(s); + va_end(ap); + return (length); +} diff --git a/libs/libft/srcs/ft_putchar_fd.c b/libs/libft/srcs/ft_putchar_fd.c new file mode 100644 index 0000000..a48c1d5 --- /dev/null +++ b/libs/libft/srcs/ft_putchar_fd.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:59:40 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:59:42 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putchar_fd(char c, int fd) +{ + write(fd, &c, 1); +} diff --git a/libs/libft/srcs/ft_putnbr_fd.c b/libs/libft/srcs/ft_putnbr_fd.c new file mode 100644 index 0000000..afc9e85 --- /dev/null +++ b/libs/libft/srcs/ft_putnbr_fd.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:59:56 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:59:57 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putnbr_fd(int n, int fd) +{ + long l; + + l = n; + if (l < 0) + { + ft_putchar_fd('-', fd); + l *= -1; + } + if (l >= 10) + ft_putnbr_fd(l / 10, fd); + ft_putchar_fd((l % 10) + '0', fd); +} diff --git a/libs/libft/srcs/ft_putnbrbase.c b/libs/libft/srcs/ft_putnbrbase.c new file mode 100644 index 0000000..e98bac4 --- /dev/null +++ b/libs/libft/srcs/ft_putnbrbase.c @@ -0,0 +1,59 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbrbase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:17:00 by hulamy #+# #+# */ +/* Updated: 2022/03/24 17:01:57 by simplonco ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +static int check(char *base) +{ + int i; + int j; + + i = 0; + while (base[i]) + { + j = i + 1; + while (base[j]) + { + if (base[i] == base[j]) + return (0); + j++; + } + if (base[i] == '-' || base[i] == '+') + return (0); + i++; + } + if (i >= 2) + return (1); + return (0); +} + +void ft_putnbrbase(int nbr, char *base) +{ + int i; + long n; + + i = 0; + n = nbr; + if (check(base)) + { + if (n < 0) + { + ft_putchar_fd('-', 1); + n = -n; + } + while (base[i]) + i++; + if (n >= i) + ft_putnbrbase(n / i, base); + ft_putchar_fd(base[n % i], 1); + } +} diff --git a/libs/libft/srcs/ft_putstr_fd.c b/libs/libft/srcs/ft_putstr_fd.c new file mode 100644 index 0000000..cf6ad12 --- /dev/null +++ b/libs/libft/srcs/ft_putstr_fd.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:00:04 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:00:05 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** write the string s on the given file descritor fd +*/ + +#include "libft.h" + +void ft_putstr_fd(char *s, int fd) +{ + while (s && *s) + ft_putchar_fd(*s++, fd); +} diff --git a/libs/libft/srcs/ft_sign.c b/libs/libft/srcs/ft_sign.c new file mode 100644 index 0000000..3140d85 --- /dev/null +++ b/libs/libft/srcs/ft_sign.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sign.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 14:14:19 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 14:14:25 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_sign(int i) +{ + if (i < 0) + return (-1); + return (1); +} diff --git a/libs/libft/srcs/ft_smaller.c b/libs/libft/srcs/ft_smaller.c new file mode 100644 index 0000000..688f466 --- /dev/null +++ b/libs/libft/srcs/ft_smaller.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_smaller(int a, int b) +{ + if (a > b) + return (b); + return (a); +} diff --git a/libs/libft/srcs/ft_split.c b/libs/libft/srcs/ft_split.c new file mode 100644 index 0000000..06a7dd0 --- /dev/null +++ b/libs/libft/srcs/ft_split.c @@ -0,0 +1,139 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/12 22:41:54 by hulamy #+# #+# */ +/* Updated: 2022/05/04 14:11:07 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return an array of string with each word found in str, with c as separator +*/ + +/* +** #include +** #include +** #include +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** char *ft_substr(char const *s, unsigned int start, size_t len) +** { +** char *str; +** size_t i; +** +** if (!s) +** return (NULL); +** if (ft_strlen(s) < start) +** return (""); +** if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) +** return (NULL); +** i = 0; +** while (i < len && s[start]) +** str[i++] = s[start++]; +** str[i] = '\0'; +** return (str); +** } +** +** char **ft_split(char const *s, char c); +** char **ft_strsplit(char const *s, char c); +** +** int main(void) +** { +** char **str; +** int i; +** +** char *s; +** char c; +** +** i = -1; +** s = NULL; +** c = ' '; +** str = ft_split(s, c); +** //if (str) +** //{ +** printf("s : '%s'\n", s); +** printf("*str : '%p'\n", str[0]); +** while (str[++i]) +** printf("str[%i] : '%s'\n", i, str[i]); +** //} +** return (0); +** } +*/ + +#include "libft.h" + +static int count(char const *s, char c) +{ + int i; + int words; + + i = -1; + words = 0; + while (s[++i] != '\0') + if (s[i] != c && ++words) + while (s[i + 1] != '\0' && s[i + 1] != c) + i++; + return (words); +} + +void *ft_free(char **array, int w) +{ + int i; + + i = 0; + while (array[i] != NULL && i < w) + free(array[i++]); + free(array); + return (NULL); +} + +char **empty_s(char **empty) +{ + empty = (char **)malloc(sizeof(char *) * 1); + if (!empty) + return (NULL); + empty[0] = NULL; + return (empty); +} + +char **ft_split(char const *s, char c) +{ + char **array; + int w; + int len; + + if (!s) + return (empty_s(NULL)); + array = (char **)malloc(sizeof(char *) * (count(s, c) + 1)); + if (!array) + return (NULL); + w = 0; + while (*s != '\0') + { + len = 0; + if (*s != c) + { + while (s[len] != '\0' && s[len] != c) + len++; + if (!(array[w++] = ft_substr(s, 0, len))) + return (ft_free(array, w)); + s += len - 1; + } + s++; + } + array[w] = NULL; + return (array); +} diff --git a/libs/libft/srcs/ft_sqrt.c b/libs/libft/srcs/ft_sqrt.c new file mode 100644 index 0000000..04c1483 --- /dev/null +++ b/libs/libft/srcs/ft_sqrt.c @@ -0,0 +1,15 @@ +#include "libft.h" + +/* +** return the square root of nb +** or the integer value of it +*/ +int ft_sqrt(int nb) +{ + int i; + + i = 0; + while ((i*i) < nb) + i++; + return (i); +} diff --git a/libs/libft/srcs/ft_strcat.c b/libs/libft/srcs/ft_strcat.c new file mode 100644 index 0000000..d78543c --- /dev/null +++ b/libs/libft/srcs/ft_strcat.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:15:40 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:12:58 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** append src to dest (dest must have sufficient space) and return dest +*/ + +#include "libft.h" + +char *ft_strcat(char *dest, const char *src) +{ + int i; + int j; + + i = 0; + j = 0; + while (dest[i]) + i++; + while (src[j]) + dest[i++] = src[j++]; + dest[i] = '\0'; + return (dest); +} diff --git a/libs/libft/srcs/ft_strchr.c b/libs/libft/srcs/ft_strchr.c new file mode 100644 index 0000000..b220565 --- /dev/null +++ b/libs/libft/srcs/ft_strchr.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:46 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:56:47 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate the first occurence of character c in string s +** and return pointer to its location +*/ + +#include "libft.h" + +char *ft_strchr(const char *s, int c) +{ + int i; + int j; + + i = 0; + j = -1; + while (s[i]) + i++; + while (++j < i + 1) + if (s[j] == c) + return ((char *)s + j); + return (NULL); +} diff --git a/libs/libft/srcs/ft_strchrset.c b/libs/libft/srcs/ft_strchrset.c new file mode 100644 index 0000000..103e857 --- /dev/null +++ b/libs/libft/srcs/ft_strchrset.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchrset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/16 15:07:11 by hulamy #+# #+# */ +/* Updated: 2020/03/10 15:24:14 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** if any character of the character set is found in s +** return a pointer to the first found, else return 0 +*/ + +#include "libft.h" + +char *ft_strchrset(const char *s, const char *set) +{ + int i; + + i = 0; + while (set[i] != '\0') + { + if (ft_strchr(s, set[i]) != NULL) + return ((char *)set + i); + i++; + } + return (NULL); +} diff --git a/libs/libft/srcs/ft_strclr.c b/libs/libft/srcs/ft_strclr.c new file mode 100644 index 0000000..5e3952c --- /dev/null +++ b/libs/libft/srcs/ft_strclr.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strclr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:15:58 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:17:42 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** fill string with zeros +*/ + +#include "libft.h" + +void ft_strclr(char *s) +{ + if (s) + ft_bzero(s, ft_strlen(s)); +} diff --git a/libs/libft/srcs/ft_strcmp.c b/libs/libft/srcs/ft_strcmp.c new file mode 100644 index 0000000..3954e2c --- /dev/null +++ b/libs/libft/srcs/ft_strcmp.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:08 by hulamy #+# #+# */ +/* Updated: 2022/05/04 14:08:35 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** compare two null terminated strings and return value +** of difference between first two different character +*/ + +#include "libft.h" + +int ft_strcmp(const char *s1, const char *s2) +{ + int i; + + i = 0; + while (s1[i] && s1[i] == s2[i]) + i++; + return ((unsigned char)s1[i] - (unsigned char)s2[i]); +} diff --git a/libs/libft/srcs/ft_strcpy.c b/libs/libft/srcs/ft_strcpy.c new file mode 100644 index 0000000..7d2a45b --- /dev/null +++ b/libs/libft/srcs/ft_strcpy.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:17 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:19:19 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy string src to dst including '\0' and return dst +*/ + +#include "libft.h" + +char *ft_strcpy(char *dest, const char *src) +{ + int i; + + i = -1; + while (src[++i]) + dest[i] = src[i]; + dest[i] = '\0'; + return (dest); +} diff --git a/libs/libft/srcs/ft_strdel.c b/libs/libft/srcs/ft_strdel.c new file mode 100644 index 0000000..82cbc2e --- /dev/null +++ b/libs/libft/srcs/ft_strdel.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdel.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:25 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:19:54 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** free memory +*/ + +#include "libft.h" + +void ft_strdel(char **as) +{ + if (as && *as) + { + free(*as); + *as = 0; + } +} diff --git a/libs/libft/srcs/ft_strdup.c b/libs/libft/srcs/ft_strdup.c new file mode 100644 index 0000000..b80939c --- /dev/null +++ b/libs/libft/srcs/ft_strdup.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:54 by hulamy #+# #+# */ +/* Updated: 2022/05/04 14:05:57 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** save a copy of string src by allocating memory and return pointer to copy +*/ + +#include "libft.h" + +char *ft_strdup(const char *src) +{ + int i; + char *str; + + i = 0; + while (src[i] != '\0') + i++; + str = (char *)malloc(sizeof(*str) * (i + 1)); + if (!str) + return (NULL); + while (i-- >= 0) + str[i + 1] = src[i + 1]; + return (str); +} diff --git a/libs/libft/srcs/ft_strequ.c b/libs/libft/srcs/ft_strequ.c new file mode 100644 index 0000000..fa4d4e4 --- /dev/null +++ b/libs/libft/srcs/ft_strequ.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strequ.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:44 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:21:02 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return 0 if strings s1 and s2 are identical and 1 if not +*/ + +#include "libft.h" + +int ft_strequ(char const *s1, char const *s2) +{ + if (!s1 || !s2) + return (0); + return (ft_strcmp(s1, s2) == 0); +} diff --git a/libs/libft/srcs/ft_striter.c b/libs/libft/srcs/ft_striter.c new file mode 100644 index 0000000..9d3b21f --- /dev/null +++ b/libs/libft/srcs/ft_striter.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_striter.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:53 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:21:14 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** apply function f to each element of string s +*/ + +#include "libft.h" + +void ft_striter(char *s, void (*f)(char *)) +{ + while (s && *s && f) + f(s++); +} diff --git a/libs/libft/srcs/ft_striteri.c b/libs/libft/srcs/ft_striteri.c new file mode 100644 index 0000000..60fd7f6 --- /dev/null +++ b/libs/libft/srcs/ft_striteri.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_striteri.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:17:04 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:21:27 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** apply function f to each element of string s with index specified +*/ + +#include "libft.h" + +void ft_striteri(char *s, void (*f)(unsigned int, char *)) +{ + int i; + + i = 0; + while (s && *s && f) + f(i++, s++); +} diff --git a/libs/libft/srcs/ft_strjoin.c b/libs/libft/srcs/ft_strjoin.c new file mode 100644 index 0000000..0dfad46 --- /dev/null +++ b/libs/libft/srcs/ft_strjoin.c @@ -0,0 +1,79 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strjoin.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:01:26 by hulamy #+# #+# */ +/* Updated: 2019/12/09 21:38:35 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new string by concatenating the two strings s1 and s2 +*/ + +/* +** #include +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** char *ft_strjoin(char const *s1, char const *s2); +** +** int main(int ac, char **av) +** { +** char *s1; +** char *s2; +** char *str; +** +** if (ac == 0) +** return (0); +** else if (ac == 3) +** { +** s1 = strdup(av[1]); +** s2 = strdup(av[2]); +** } +** else +** { +** s1 = malloc(sizeof(char*) * 100); +** s1 = "sdf"; +** s2 = "tref"; +** } +** str = ft_strjoin(s1, s2); +** printf("%s\n", str); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_strjoin(char const *s1, char const *s2) +{ + char *str; + int len; + int i; + + if (!s1 || !s2) + return (NULL); + len = ft_strlen(s1) + ft_strlen(s2); + if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) + return (NULL); + len = 0; + i = 0; + while (s1[i] != '\0') + str[len++] = s1[i++]; + i = 0; + while (s2[i] != '\0') + str[len++] = s2[i++]; + str[len] = '\0'; + return (str); +} diff --git a/libs/libft/srcs/ft_strjoinfree.c b/libs/libft/srcs/ft_strjoinfree.c new file mode 100644 index 0000000..66c8b50 --- /dev/null +++ b/libs/libft/srcs/ft_strjoinfree.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strjoinfree.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/03/05 15:05:28 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:22:28 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new string by concatenating the two strings s1 and s2 +** then free s1 and s2 +*/ + +#include "libft.h" + +char *ft_strjoinfree(char *s1, char *s2) +{ + char *str; + + if (!(str = ft_strjoin(s1, s2))) + return (NULL); + free(s1); + free(s2); + return (str); +} diff --git a/libs/libft/srcs/ft_strlcat.c b/libs/libft/srcs/ft_strlcat.c new file mode 100644 index 0000000..91d14d8 --- /dev/null +++ b/libs/libft/srcs/ft_strlcat.c @@ -0,0 +1,108 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:57:02 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:23:18 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** append src to sized dest and return size of final dest +*/ + +/* +** #include +** +** size_t ft_strlcat(char *dest, const char *src, size_t size); +** +** size_t ft_strlcat2(char *dest, char *src, size_t size); +** +** int ft_strlen(char *str) +** { +** int i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** int main(int ac, char **av) +** { +** char tmp1[100]; +** char tmp2[100]; +** int i; +** +** i = atoi(av[3]); +** strcpy(tmp1, av[1]); +** strcpy(tmp2, av[2]); +** +** if (ac == 4) +** { +** printf("----strlcat: %zu - %s - %s\n", strlcat(tmp1, tmp2, i), +** tmp1, tmp2); +** +** strcpy(tmp1, av[1]); +** strcpy(tmp2, av[2]); +** +** printf("-ft_strlcat: %zu - %s - %s\n", ft_strlcat(tmp1, tmp2, i), +** tmp1, tmp2); +** +** strcpy(tmp1, av[1]); +** strcpy(tmp2, av[2]); +** +** printf("ft_strlcat2: %zu - %s - %s\n", ft_strlcat2(tmp1, tmp2, i), +** tmp1, tmp2); +** } +** } +** +** size_t ft_strlcat2(char *dest, char *src, size_t size) +** { +** size_t i; +** size_t dest_length; +** size_t src_length; +** +** i = 0; +** dest_length = ft_strlen(dest); +** src_length = ft_strlen(src); +** if (size > dest_length + 1) +** { +** while (i < (size - dest_length - 1)) +** { +** dest[i + dest_length] = src[i]; +** i++; +** } +** dest[dest_length + i] = '\0'; +** } +** if (size >= dest_length) +** return (dest_length + src_length); +** return (src_length + size); +** } +*/ + +#include "libft.h" + +size_t ft_strlcat(char *dest, const char *src, size_t size) +{ + size_t i; + size_t j; + + i = 0; + j = 0; + while (dest[i] && i < size) + i++; + while (src[j]) + { + if (j + i < size - 1 && size) + { + dest[i + j] = src[j]; + dest[i + j + 1] = '\0'; + } + j++; + } + return (i + j); +} diff --git a/libs/libft/srcs/ft_strlcpy.c b/libs/libft/srcs/ft_strlcpy.c new file mode 100644 index 0000000..48ef5b8 --- /dev/null +++ b/libs/libft/srcs/ft_strlcpy.c @@ -0,0 +1,70 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:57:19 by hulamy #+# #+# */ +/* Updated: 2019/12/01 16:12:57 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy size - 1 length of src into dest, +** terminate it with a '\0' +** and return size of src +** this way, if you try to copy a name in a variable with an available size +** of 5 for exemple, if you use ft_strlcpy(variable, name, sizeof(variable)) +** you will know if the name was too long for the variable by looking at the +** return value (which is size of name) +*/ + +/* +** #include +** +** size_t ft_strlcpy(char *dest, const char *src, size_t size); +** +** int main(int argc, char **argv) +** { +** char str[100]; +** int i; +** unsigned int u; +** unsigned int v; +** +** i = atoi(argv[3]); +** strcpy(str, argv[2]); +** if (argc > 3) +** { +** u = strlcpy(argv[2], argv[1], i); +** printf("strlcpy : %s - %s - %d",argv[1], argv[2], i); +** printf(" - return:%d\n",u); +** strcpy(argv[2], str); +** printf("(re-init : %s - %s - %d)\n",argv[1], argv[2], i); +** v = ft_strlcpy(argv[2], argv[1], i); +** printf("ft_strlcpy: %s - %s - %d",argv[1], argv[2], i); +** printf(" - return:%d\n",v); +** } +** return (0); +** } +*/ + +#include "libft.h" + +size_t ft_strlcpy(char *dest, const char *src, size_t size) +{ + size_t i; + size_t j; + + i = 0; + j = 0; + while (src[i] != '\0') + { + if (i + 1 < size) + dest[i] = src[j++]; + i++; + } + if (size > 0) + dest[j] = '\0'; + return (i); +} diff --git a/libs/libft/srcs/ft_strlen.c b/libs/libft/srcs/ft_strlen.c new file mode 100644 index 0000000..c95879f --- /dev/null +++ b/libs/libft/srcs/ft_strlen.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:57:48 by hulamy #+# #+# */ +/* Updated: 2022/05/04 14:06:31 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return length of of string +*/ + +#include "libft.h" + +size_t ft_strlen(const char *str) +{ + size_t i; + + i = 0; + while (str[i]) + i++; + return (i); +} diff --git a/libs/libft/srcs/ft_strmap.c b/libs/libft/srcs/ft_strmap.c new file mode 100644 index 0000000..ef82f97 --- /dev/null +++ b/libs/libft/srcs/ft_strmap.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:17:49 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:23:12 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new array with the result of function f on every element of s +*/ + +#include "libft.h" + +char *ft_strmap(char const *s, char (*f)(char)) +{ + char *str; + int i; + + if (!s) + return (NULL); + if (!(str = ft_strnew(ft_strlen(s)))) + return (NULL); + i = -1; + while (s[++i]) + str[i] = f(s[i]); + return (str); +} diff --git a/libs/libft/srcs/ft_strmapi.c b/libs/libft/srcs/ft_strmapi.c new file mode 100644 index 0000000..7fa1a06 --- /dev/null +++ b/libs/libft/srcs/ft_strmapi.c @@ -0,0 +1,75 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmapi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:01:40 by hulamy #+# #+# */ +/* Updated: 2019/12/09 21:44:07 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new array with the result of function f on every element of +** s by index i +*/ + +/* +** #include +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** char touppercase(unsigned int i, char c) +** { +** if (i < 3 && c >= 'a' && c <= 'z') +** c -= 32; +** return (c); +** } +** +** char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); +** +** int main(int ac, char **av) +** { +** char *str; +** char touppercase(unsigned int, char); +** +** if (ac > 2) +** return (0); +** if (ac == 2) +** str = strdup(av[1]); +** if (ac == 1) +** str = NULL; +** //str = ft_strmapi(str, touppercase); +** str = ft_strmapi(str, NULL); +** printf("%s\n",str); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) +{ + char *str; + int i; + int size; + + if (!s || !f) + return (NULL); + size = ft_strlen(s); + if (!(str = (char *)malloc(sizeof(char) * (size + 1)))) + return (NULL); + str[size] = '\0'; + i = -1; + while (s[++i]) + str[i] = f(i, s[i]); + return (str); +} diff --git a/libs/libft/srcs/ft_strmultisplit.c b/libs/libft/srcs/ft_strmultisplit.c new file mode 100644 index 0000000..ed2ed98 --- /dev/null +++ b/libs/libft/srcs/ft_strmultisplit.c @@ -0,0 +1,83 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmultisplit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:18:29 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:23:57 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return an array of string with each word found in str +** with any character of charset difining a separator +*/ + +#include "libft.h" + +static int ft_is_separator(char c, char *charset, int i) +{ + while (charset[i]) + { + if (c == charset[i]) + return (1); + i++; + } + c = charset[i]; + return (0); +} + +static int ft_count(char *str, int word, char **tab, char *charset) +{ + int i; + int j; + int k; + + k = 0; + i = 0; + while (ft_is_separator(str[k], charset, 0) == 1) + k++; + while (str[k] != '\0' && i != word) + { + j = 0; + while (!ft_is_separator(str[k + j], charset, 0) && str[k + j] != '\0') + { + if (word == -2) + tab[i][j] = str[k + j]; + j++; + } + k += j; + while (ft_is_separator(str[k], charset, 0)) + k++; + i++; + } + if (word == -1) + return (i); + return (j); +} + +char **ft_strmultisplit(char *str, char *charset) +{ + char **tab; + int i; + int j; + int k; + + k = 0; + tab = 0; + i = ft_count(str, -1, tab, charset); + if (!(tab = (char**)malloc(sizeof(tab) * (i + 1)))) + return (NULL); + tab[i] = 0; + while (k < i) + { + j = ft_count(str, k + 1, tab, charset); + tab[k] = (char*)malloc(sizeof(*tab) * (j + 1)); + tab[k][j] = '\0'; + k++; + } + ft_count(str, -2, tab, charset); + return (tab); +} diff --git a/libs/libft/srcs/ft_strncat.c b/libs/libft/srcs/ft_strncat.c new file mode 100644 index 0000000..cf52aae --- /dev/null +++ b/libs/libft/srcs/ft_strncat.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:18:24 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:24:11 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** append n character of src to dest and return dest +*/ + +#include "libft.h" + +char *ft_strncat(char *dest, const char *src, size_t nb) +{ + size_t i; + size_t j; + + i = 0; + j = 0; + while (dest[i]) + i++; + while (src[j] && j < nb) + dest[i++] = src[j++]; + dest[i] = '\0'; + return (dest); +} diff --git a/libs/libft/srcs/ft_strncmp.c b/libs/libft/srcs/ft_strncmp.c new file mode 100644 index 0000000..7022624 --- /dev/null +++ b/libs/libft/srcs/ft_strncmp.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:57:59 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:58:00 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** compare size first character of two null terminated strings +** and return value of difference between first two different character +*/ + +#include "libft.h" + +int ft_strncmp(const char *s1, const char *s2, size_t n) +{ + size_t i; + int res; + + i = 0; + res = 0; + while (s1[i] && s1[i] == s2[i] && i < n - 1) + i++; + if (n != 0) + res = (unsigned char)s1[i] - (unsigned char)s2[i]; + return (res); +} diff --git a/libs/libft/srcs/ft_strncpy.c b/libs/libft/srcs/ft_strncpy.c new file mode 100644 index 0000000..91ea1b3 --- /dev/null +++ b/libs/libft/srcs/ft_strncpy.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:18:44 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:24:59 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy n characters from string src to dst including '\0' +** if space remain it's filled zith '\0', and return dst +*/ + +#include "libft.h" + +char *ft_strncpy(char *dest, const char *src, size_t n) +{ + size_t i; + + i = -1; + while (++i < n && src[i]) + dest[i] = src[i]; + while (i < n) + dest[i++] = '\0'; + return (dest); +} diff --git a/libs/libft/srcs/ft_strnequ.c b/libs/libft/srcs/ft_strnequ.c new file mode 100644 index 0000000..668f3fa --- /dev/null +++ b/libs/libft/srcs/ft_strnequ.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnequ.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:18:55 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:25:20 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return 0 if n first character of strings s1 and s2 are identical +** and 1 if not +*/ + +#include "libft.h" + +int ft_strnequ(char const *s1, char const *s2, size_t n) +{ + if (!s1 || !s2) + return (0); + return (ft_strncmp(s1, s2, n) == 0); +} diff --git a/libs/libft/srcs/ft_strnew.c b/libs/libft/srcs/ft_strnew.c new file mode 100644 index 0000000..645feff --- /dev/null +++ b/libs/libft/srcs/ft_strnew.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:19:08 by hulamy #+# #+# */ +/* Updated: 2019/11/21 17:00:30 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new string of length size, fill with zero, and return pointer to it +*/ + +#include "libft.h" + +char *ft_strnew(size_t size) +{ + char *str; + + if (!(str = (char *)malloc(sizeof(char) * (size + 1)))) + return (NULL); + ft_bzero(str, size + 1); + return (str); +} diff --git a/libs/libft/srcs/ft_strnstr.c b/libs/libft/srcs/ft_strnstr.c new file mode 100644 index 0000000..6ab0282 --- /dev/null +++ b/libs/libft/srcs/ft_strnstr.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:58:10 by hulamy #+# #+# */ +/* Updated: 2022/05/04 14:07:50 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate the first occurence of the string little in len first characters +** of big and return a pointer to this occurence if found +*/ + +#include "libft.h" + +char *ft_strnstr(const char *big, const char *little, size_t len) +{ + size_t i; + size_t j; + + j = 0; + i = 0; + if (!ft_strlen(little)) + return ((char *)big); + while (i == 0 && j <= len) + { + while (little[i] == big[j + i] && little[i] && j + i <= len) + i++; + if (little[i]) + { + j++; + if (!big[j] || j >= len) + return (0); + i = 0; + } + } + return ((char *)big + j); +} diff --git a/libs/libft/srcs/ft_strrchr.c b/libs/libft/srcs/ft_strrchr.c new file mode 100644 index 0000000..1c8faa8 --- /dev/null +++ b/libs/libft/srcs/ft_strrchr.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strrchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:58:20 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:58:21 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate the last occurence of character c in string s +** and return pointer to its location +*/ + +#include "libft.h" + +char *ft_strrchr(const char *s, int c) +{ + int i; + + i = 0; + while (s[i]) + i++; + i++; + while (i--) + if (s[i] == c) + return ((char *)s + i); + return (NULL); +} diff --git a/libs/libft/srcs/ft_strstr.c b/libs/libft/srcs/ft_strstr.c new file mode 100644 index 0000000..c7a3535 --- /dev/null +++ b/libs/libft/srcs/ft_strstr.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:19:45 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:26:59 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate the first occurence of the string little in big +** and return a pointer to this occurence if found +*/ + +#include "libft.h" + +char *ft_strstr(const char *str, const char *to_find) +{ + int i; + int j; + + j = 0; + i = 0; + if (!ft_strlen(to_find)) + return ((char *)str); + while (i == 0) + { + while (to_find[i] && to_find[i] == str[j + i]) + i++; + if (to_find[i]) + { + j++; + if (str[j] == '\0' && to_find[i]) + return (0); + i = 0; + } + } + return ((char *)str + j); +} diff --git a/libs/libft/srcs/ft_strtrim.c b/libs/libft/srcs/ft_strtrim.c new file mode 100644 index 0000000..0e9ede9 --- /dev/null +++ b/libs/libft/srcs/ft_strtrim.c @@ -0,0 +1,101 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strtrim.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:01:49 by hulamy #+# #+# */ +/* Updated: 2019/12/09 21:46:54 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a copy of s without the firsts and lasts set of characters +*/ + +/* +** #include +** +** char *ft_substr(char const *s, unsigned int start, size_t len) +** { +** char *str; +** size_t i; +** +** if (!s) +** return (NULL); +** if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) +** return (NULL); +** str[len] = '\0'; +** i = 0; +** while (i < len) +** str[i++] = s[start++]; +** return (str); +** } +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** char *ft_strchr(const char *s, int c) +** { +** int i; +** int j; +** +** i = 0; +** j = -1; +** while (s[i]) +** i++; +** while (++j < i + 1) +** if (s[j] == c) +** return ((char *)s + j); +** return (NULL); +** } +** +** char *ft_strtrim(char const *s1, char const *set); +** +** int main(int ac, char **av) +** { +** char *s1; +** char *s2; +** +** if (ac == 3) +** { +** s1 = strdup(av[1]); +** s2 = strdup(av[2]); +** } +** if (ac == 1) +** { +** s1 = "fuehf"; +** s2 = NULL; +** } +** printf("%s\n",ft_strtrim(s1, s2)); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_strtrim(char const *s1, char const *set) +{ + int len; + char *str; + + if (!s1 || !set) + return (NULL); + while (s1[0] && ft_strchr(set, s1[0])) + s1++; + len = ft_strlen(s1) - 1; + while (len >= 0 && ft_strchr(set, s1[len])) + len--; + len++; + if (!(str = ft_substr(s1, 0, len))) + return (NULL); + return (str); +} diff --git a/libs/libft/srcs/ft_substr.c b/libs/libft/srcs/ft_substr.c new file mode 100644 index 0000000..bd92f36 --- /dev/null +++ b/libs/libft/srcs/ft_substr.c @@ -0,0 +1,105 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_substr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/01 16:00:10 by hulamy #+# #+# */ +/* Updated: 2022/05/04 14:07:05 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a copy of a portion of s, begining at start and of length len +*/ + +/* +** #include +** #include +** #include +** +** char *ft_substr(char const *s, unsigned int start, size_t len); +** +** char *ft_strdup(const char *src) +** { +** int i; +** char *str; +** +** i = 0; +** while (src[i] != '\0') +** i++; +** if (!(str = (char*)malloc(sizeof(*str) * (i + 1)))) +** return (NULL); +** while (i-- >= 0) +** str[i + 1] = src[i + 1]; +** return (str); +** } +** +** int ft_strncmp(const char *s1, const char *s2, size_t n) +** { +** size_t i; +** int res; +** +** i = 0; +** res = 0; +** while (s1[i] && s1[i] == s2[i] && i < n - 1) +** i++; +** if (n != 0) +** res = (unsigned char)s1[i] - (unsigned char)s2[i]; +** return (res); +** } +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** int main(int ac, char **av) +** { +** char *str; +** size_t size; +** int start; +** +** str = "frgehr"; +** start = 2; +** size = 5; +** if (ac == 4) +** { +** str = strdup(av[1]); +** start = atoi(av[2]); +** size = atoi(av[3]); +** } +** char *ret = ft_substr(str, start, size); +** printf("%s, %i, %zu\n", str, start, size); +** printf("%s\n", ret); +** free(ret); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_substr(char const *s, unsigned int start, size_t len) +{ + char *str; + size_t i; + + if (!s) + return (NULL); + if (ft_strlen(s) < start) + return (ft_strdup("")); + str = (char *)malloc(sizeof(char) * (len + 1)); + if (!str) + return (NULL); + i = 0; + while (i < len && s[start]) + str[i++] = s[start++]; + str[i] = '\0'; + return (str); +} diff --git a/libs/libft/srcs/ft_tolower.c b/libs/libft/srcs/ft_tolower.c new file mode 100644 index 0000000..2cd5cb6 --- /dev/null +++ b/libs/libft/srcs/ft_tolower.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_tolower.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:58:30 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:58:32 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_tolower(int c) +{ + if (c >= 'A' && c <= 'Z') + return (c + 32); + return (c); +} diff --git a/libs/libft/srcs/ft_toupper.c b/libs/libft/srcs/ft_toupper.c new file mode 100644 index 0000000..cc842a5 --- /dev/null +++ b/libs/libft/srcs/ft_toupper.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_toupper.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:58:39 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:58:43 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_toupper(int c) +{ + if (c >= 'a' && c <= 'z') + return (c - 32); + return (c); +} diff --git a/libs/libft/srcs/ft_utoa.c b/libs/libft/srcs/ft_utoa.c new file mode 100644 index 0000000..e47f898 --- /dev/null +++ b/libs/libft/srcs/ft_utoa.c @@ -0,0 +1,74 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_utoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/03/12 22:36:50 by hulamy #+# #+# */ +/* Updated: 2020/03/12 22:36:56 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** take an unsigned integer and give a string +*/ + +/* +** #include // for printf +** #include // for atoi +** +** char *ft_utoa(unsigned long int n); +** +** int main(int ac, char **av) +** { +** if (ac == 0) +** return (0); +** else if (ac == 2) +** printf("%s\n",ft_utoa(atoi(av[1]))); +** else +** { +** unsigned long int i; +** i = 0; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 237683; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 1234567; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 12345678; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 2147483646; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 2147483647; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 2147483648; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 2147483649; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 9223372036854775807; +** printf("| %lu\n| %s\n\n",i,ft_utoa(i)); +** } +** return 0; +** } +*/ + +#include "libft.h" + +char *ft_utoa(unsigned long int n) +{ + char *str; + int len; + unsigned long int cpy; + + cpy = n; + len = 1; + while (n /= 10) + len++; + if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) + return (NULL); + str[len] = '\0'; + str[--len] = cpy % 10 + '0'; + while (cpy /= 10) + str[--len] = cpy % 10 + '0'; + return (str); +} diff --git a/libs/libft/testing/Makefile b/libs/libft/testing/Makefile new file mode 100644 index 0000000..ca66b05 --- /dev/null +++ b/libs/libft/testing/Makefile @@ -0,0 +1,154 @@ +# - - - - - - - - - - - - - - # name = value \ +# variables names # value +# - - - - - - - - - - - - - - # ! name is case sensitive + +NAME = libftest + +CC = gcc + +VPATH = srcs + +DEPS = ../includes/libft.h \ + ./includes/libftest.h +IDIR = $(dir $(DEPS)) +# $(dir PATH/TO/FILE) expands to "PATH/TO/" -> the directory of a file + +LDIR = ../ +_LIBS = libft.a +LIBS = $(_LIBS:lib%.a=%) + +SRCS = main.c \ + test_memset.c \ + test_bzero.c \ + test_memcpy.c \ + test_memccpy.c \ + test_memmove.c \ + test_memchr.c \ + test_memcmp.c \ + test_strlen.c \ + test_isalpha.c \ + test_isdigit.c \ + test_isalnum.c \ + test_isascii.c \ + test_isprint.c \ + test_toupper.c \ + test_tolower.c \ + test_strchr.c \ + test_strrchr.c \ + test_strchrset.c \ + test_strncmp.c \ + test_strlcpy.c \ + test_strlcat.c \ + test_strnstr.c \ + test_atoi.c \ + test_calloc.c \ + test_strdup.c \ + test_substr.c \ + test_strjoin.c \ + test_strtrim.c \ + test_split.c \ + test_itoa.c \ + test_utoa.c \ + test_strmapi.c \ + test_putchar_fd.c \ + test_putstr_fd.c \ + test_putendl_fd.c \ + test_putnbr_fd.c \ + test_lstnew.c \ + test_lstadd_front.c \ + test_lstsize.c \ + test_lstlast.c \ + test_lstadd_back.c \ + test_lstdelone.c \ + test_lstclear.c \ + test_lstiter.c \ + test_lstmap.c \ + test_strcat.c \ + test_strcmp.c \ + test_strcpy.c \ + test_strncat.c \ + test_strncpy.c \ + test_strstr.c \ + test_strjoinfree.c \ + test_strclr.c \ + test_strdel.c \ + test_strequ.c \ + test_striter.c \ + test_striteri.c \ + test_strmap.c \ + test_strnequ.c \ + test_strnew.c \ + test_memalloc.c \ + test_memdel.c \ + test_putchar.c \ + test_putendl.c \ + test_putnbr.c \ + test_putnbrendl.c \ + test_putnbrendl_fd.c \ + test_putnbrbase.c \ + test_putstr.c \ + test_any.c \ + test_atoibase.c \ + test_convertbase.c \ + test_convertbase_free.c \ + test_foreach.c \ + test_issort.c \ + test_arraymap.c \ + test_strmultisplit.c \ + test_gnl.c \ + test_concat_free.c \ + test_printf.c \ + test_abs.c \ + test_greater.c \ + test_smaller.c \ + test_sign.c \ + test_sqrt.c + +ODIR = ./builds +OBJS = $(SRCS:%.c=$(ODIR)/%.o) + +CFLAGS = $(IDIR:%=-I%) +# flag -g generates debug informations, g3 is maximal version +CFLAGS += -g3 -Wall -Wextra -Werror +LFLAGS = -L$(LDIR) -l$(LIBS) + + +# - - - - - - - - - - - - - - # target: prerequisites | $@ : target +# rules to execute # recipe | $< : 1st prerequisite +# - - - - - - - - - - - - - - # recipe | $^ : all prerequisites + +all: $(NAME) + +$(NAME): $(ODIR) $(OBJS) $(DEPS) + make -C $(LDIR) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) + +$(ODIR): + mkdir -p $@ + +$(ODIR)/%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +debug: CFLAGS += -fsanitize=address +debug: clean $(NAME) + +leaks: $(NAME) + valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) maps/42_color.fdf + +clean: + /bin/rm -f $(OBJS) $(OBJS_B) + +fclean: clean + /bin/rm -rf $(ODIR) + /bin/rm -f $(NAME) + /bin/rm -rf a.out a.out.dSYM + +libfclean: + make fclean -C $(LDIR) + +re: fclean all + +relib: libfclean re + +.PHONY: all clean fclean re gcc + diff --git a/libs/libft/testing/includes/libftest.h b/libs/libft/testing/includes/libftest.h new file mode 100644 index 0000000..d7d271c --- /dev/null +++ b/libs/libft/testing/includes/libftest.h @@ -0,0 +1,104 @@ +#ifndef LIBFTEST_H +# define LIBFTEST_H +# include "libft.h" +# include // for write +# include // for printf +# include // for malloc +# include // for strdup and strlen and strcmp +# include // for characters like isalpha or isdigit etc + +# define RED write(1, "\033[91m", 5); +# define GREEN write(1, "\033[92m", 5); +# define COLOREND write(1, "\033[0m", 4); + +void test_memset(void); +void test_bzero(void); +void test_memcpy(void); +void test_memccpy(void); +void test_memmove(void); +void test_memchr(void); +void test_memcmp(void); +void test_strlen(void); +void test_isalpha(void); +void test_isdigit(void); +void test_isalnum(void); +void test_isascii(void); +void test_isprint(void); +void test_toupper(void); +void test_tolower(void); +void test_strchr(void); +void test_strrchr(void); +void test_strchrset(void); +void test_strncmp(void); +void test_strlcpy(void); +void test_strlcat(void); +void test_strnstr(void); +void test_atoi(void); +void test_calloc(void); +void test_strdup(void); +void test_substr(void); +void test_strjoin(void); +void test_strtrim(void); +void test_split(void); +void test_itoa(void); +void test_utoa(void); +void test_strmapi(void); +void test_putchar_fd(void); +void test_putstr_fd(void); +void test_putendl_fd(void); +void test_putnbr_fd(void); +void test_lstnew(void); +void test_lstadd_front(void); +void test_lstsize(void); +void test_lstlast(void); +void test_lstadd_back(void); +void test_lstdelone(void); +void test_lstclear(void); +void test_lstiter(void); +void test_lstmap(void); +void test_strcat(void); +void test_strcmp(void); +void test_strcpy(void); +void test_strncat(void); +void test_strncpy(void); +void test_strstr(void); +void test_strjoinfree(void); +void test_strclr(void); +void test_strdel(void); +void test_strequ(void); +void test_striter(void); +void test_striteri(void); +void test_strmap(void); +void test_strnequ(void); +void test_strnew(void); +void test_memalloc(void); +void test_memdel(void); +void test_putchar(void); +void test_putendl(void); +void test_putnbr(void); +void test_putnbrendl(void); +void test_putnbrendl_fd(void); +void test_putnbrbase(void); +void test_putstr(void); +void test_any(void); +void test_atoibase(void); +void test_convertbase(void); +void test_convertbase_free(void); +void test_foreach(void); +void test_issort(void); +void test_arraymap(void); +void test_strmultisplit(void); +void test_gnl(void); +void test_concat_free(void); +void test_printf(void); +void test_next_word(void); +void test_convert(void); +void test_flag_transform(void); +void test_flag_transform_bonus(void); +void test_abs(void); +void test_greater(void); +void test_smaller(void); +void test_sign(void); +void test_sqrt(void); + +#endif diff --git a/libs/libft/testing/libftest b/libs/libft/testing/libftest new file mode 100755 index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6ihsE8mHV&o;TqU4`f zPS($Zt}SPYBV^)*Z_BIj1-yAfhmFn+cuF`{Qc;~(SY29HoLgF~v>TW8RE*8L(p;>NiuZ<&V@@KI%1K*_T@a2^ixN_>b0FzitB=)n+5KI<-&=LHL_ z2g6y#$V9~Kq_!FD6yg{qc*;wQP$#;H<)QN_dFZd@c*X?gEvznqrl+C=53d}>5ZWh> zJ%xo;-U~&nthB-_j$tKnSnesR^6``NpA#*SoF27#dNa6hSM1;AX`Wyq;;~!+G`-~t zOE32K3Yj4kSsGDsT8;=$FZKZo$9W#eQKSMg2|Afu~P{`O)+T zrU--AFZLA+If*Yg4mxxw(x>5=ezbg{^~NA4=IKHqV0Ds&K(P@zu2cNWOV&S zIYQ1x`lDg##eQZX#k_cQ{Y91Lh1|`G(e@M9e;KDA#(H9Zw2VH$d$pA_5n{XVXof(t$_$nKZMALpOB)y zHX5qGz;DEf@bqF`L&zVeij=k#+=M(NFAKS;!O7(fT4T zP-m*sp%&e>453NK4!k>BYYGm7M;2YFzvTKSjBs9oOR=sfhGq|NFuPlnU2l zg`q&C7xFMpg{Kd$w{k*Jj>tiz6Y=kHK$s|B%$p}Jv^D-y`hP%;%I{{Y2SbrQJBZi^ zYz`|8AvDh{Fk8b8`!2NQc}d}DP2Gk_94r0xtL${M|8o5F%^lJkjqF?t1|C0sM~C$N z$J*)7xx|(tm&ll+^yKu>_FMm=-J^cqEmGQ2q!)4!r;pT9lx4Jm6~Bwcf+Q=5bR4y8 zC;G0yNG3jP_taT@1IYwNzE1E*_;2zrf;%`2{^q`7r+*Fe^5MVe@~L@ar62vFou17Y J%pyAde*sy0q1gZc literal 0 HcmV?d00001 diff --git a/libs/libft/testing/main.c b/libs/libft/testing/main.c new file mode 100644 index 0000000..8405d33 --- /dev/null +++ b/libs/libft/testing/main.c @@ -0,0 +1,95 @@ +#include "libftest.h" + +// the functions precedes by # already exists in the system +int main() +{ + test_abs(); + test_any(); + /* + test_arraymap.c + test_atoibase.c + # test_atoi.c + # test_bzero.c + # test_calloc.c + test_concat_free.c + test_convertbase.c + test_convertbase_free.c + test_foreach.c + test_gnl.c + test_greater.c + # test_isalnum.c + # test_isalpha.c + # test_isascii.c + # test_isdigit.c + # test_isprint.c + test_issort.c + test_itoa.c + test_lstadd_back.c + test_lstadd_front.c + test_lstclear.c + test_lstdelone.c + test_lstiter.c + test_lstlast.c + test_lstmap.c + test_lstnew.c + test_lstsize.c + test_memalloc.c + # test_memccpy.c + # test_memchr.c + # test_memcmp.c + # test_memcpy.c + test_memdel.c + # test_memmove.c + # test_memset.c + test_printf.c + test_putchar.c + test_putchar_fd.c + test_putendl.c + test_putendl_fd.c + test_putnbrbase.c + test_putnbr.c + test_putnbrendl.c + test_putnbrendl_fd.c + test_putnbr_fd.c + test_putstr.c + test_putstr_fd.c + test_sign.c + test_smaller.c + test_split.c + test_sqrt.c + test_strcat.c + # test_strchr.c + test_strchrset.c + test_strclr.c + test_strcmp.c + test_strcpy.c + test_strdel.c + # test_strdup.c + test_strequ.c + test_striter.c + test_striteri.c + test_strjoin.c + test_strjoinfree.c + # test_strlcat.c + # test_strlcpy.c + # test_strlen.c + test_strmap.c + test_strmapi.c + test_strmultisplit.c + test_strncat.c + # test_strncmp.c + test_strncpy.c + test_strnequ.c + test_strnew.c + # test_strnstr.c + # test_strrchr.c + test_strstr.c + test_strtrim.c + test_substr.c + # test_tolower.c + # test_toupper.c + test_utoa.c + */ + + return 0; +} diff --git a/libs/libft/testing/srcs/test_abs.c b/libs/libft/testing/srcs/test_abs.c new file mode 100644 index 0000000..f9c944e --- /dev/null +++ b/libs/libft/testing/srcs/test_abs.c @@ -0,0 +1,23 @@ +#include "libftest.h" + +void compare_abs(int i, int ans) +{ + if (ft_abs(i) != ans) + { + RED ft_printf("error: "); COLOREND + ft_printf("ft_abs(%i)", i); + RED ft_printf(" gives "); COLOREND + ft_printf("%i", ft_abs(i)); + RED ft_printf(" instead of "); COLOREND + ft_printf("%i\n", ans); + } +} + +void test_abs(void) +{ + compare_abs(-1, 1); + compare_abs(0, 0); + compare_abs(-0, 0); + compare_abs(-1000, 1000); + compare_abs(-2147483647, 2147483647); +} diff --git a/libs/libft/testing/srcs/test_any.c b/libs/libft/testing/srcs/test_any.c new file mode 100644 index 0000000..05b7692 --- /dev/null +++ b/libs/libft/testing/srcs/test_any.c @@ -0,0 +1,131 @@ +#include "libftest.h" + +char **create_tab(void) +{ + char **tab; + + tab = (char **)malloc(sizeof(char *) * (6 + 1)); + tab[0] = strdup("premiere ligne de test"); + tab[1] = strdup("deuxieme ligne de test"); + tab[2] = strdup("troisieme ligne pour le fun"); + tab[3] = strdup("quatrieme linge avec une erreur"); + tab[4] = strdup("cinquieme peche a la ligne"); + tab[5] = strdup("sixieme et derniere ligne"); + return (tab); +} + +void free_tab(char **tab) +{ + free(tab[0]); + free(tab[1]); + free(tab[2]); + free(tab[3]); + free(tab[4]); + free(tab[5]); + free(tab); +} + +int contain_a(char *s) +{ + int i; + + i = -1; + while (s[++i]) + if (s[i] == 'a') + return (1); + return (0); +} + +int contain_y(char *s) +{ + int i; + + i = -1; + while (s[++i]) + if (s[i] == 'y') + return (1); + return (0); +} + +int contain_z(char *s) +{ + int i; + + i = -1; + while (s[++i]) + if (s[i] == 'z') + return (1); + return (0); +} + +int contain_x(char *s) +{ + int i; + + i = -1; + while (s[++i]) + if (s[i] == 'x') + return (1); + return (0); +} + +int contain_u(char *s) +{ + int i; + + i = -1; + while (s[++i]) + if (s[i] == 'u') + return (1); + return (0); +} + +int contain_1(char *s) +{ + int i; + + i = -1; + while (s[++i]) + if (s[i] == '1') + return (1); + return (0); +} + +void compare_any(char **tab, int (*f)(char *), char *s, int solution) +{ + int i; + + i = ft_any(tab, f); + if (i != solution) + { + write(1, "\033[91m", 5); + printf("error: "); + write(1, "\033[0m", 4); + printf("ft_any(tab, %s) returned", s); + printf(" %i ", i); + printf("in tab :\n"); + printf(" %s:\n", tab[0]); + printf(" %s:\n", tab[1]); + printf(" %s:\n", tab[2]); + printf(" %s:\n", tab[3]); + printf(" %s:\n", tab[4]); + printf(" %s:\n", tab[5]); + } +} + +void test_any(void) +{ + char **tab; + + tab = create_tab(); + + compare_any(tab, contain_a, "contain_a", 1); + compare_any(tab, contain_y, "contain_y", 0); + compare_any(tab, contain_z, "contain_z", 0); + compare_any(tab, contain_x, "contain_x", 1); + compare_any(tab, contain_u, "contain_u", 1); + compare_any(tab, contain_1, "contain_1", 0); + + free_tab(tab); +} + diff --git a/libs/libft/testing/srcs/test_arraymap.c b/libs/libft/testing/srcs/test_arraymap.c new file mode 100644 index 0000000..267510a --- /dev/null +++ b/libs/libft/testing/srcs/test_arraymap.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_arraymap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:17:24 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:17:27 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int *ft_arraymap(int *tab, int length, int (*f)(int)) +{ + int i; + int *newtab; + + i = -1; + if (!tab) + return (NULL); + if (!(newtab = (int*)malloc(sizeof(*newtab) * (length + 1)))) + return (NULL); + while (++i < length) + newtab[i] = (*f)(tab[i]); + return (newtab); +} diff --git a/libs/libft/testing/srcs/test_atoi.c b/libs/libft/testing/srcs/test_atoi.c new file mode 100644 index 0000000..01660a9 --- /dev/null +++ b/libs/libft/testing/srcs/test_atoi.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:54:29 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:54:35 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_atoi(const char *str) +{ + long long nbr; + int i; + int n; + + i = 0; + n = 1; + nbr = 0; + while ((str[i] == ' ') || (str[i] > 8 && str[i] < 14)) + i++; + if (str[i] == '-') + n = -1; + if (str[i] == '+' || str[i] == '-') + i++; + while (str[i] >= '0' && str[i] <= '9') + { + if ((nbr >= 922337203685477580 + && ((str[i] > 8 && n < 0) || (str[i] > 7 && n > 0)))) + return ((n > 0) ? -1 : 0); + else + nbr = nbr * 10 + (str[i++] - '0'); + } + return (nbr * n); +} diff --git a/libs/libft/testing/srcs/test_atoibase.c b/libs/libft/testing/srcs/test_atoibase.c new file mode 100644 index 0000000..fdb92d1 --- /dev/null +++ b/libs/libft/testing/srcs/test_atoibase.c @@ -0,0 +1,75 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoibase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:15:31 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:22:34 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +static int is_valid_base(char *base, int i, int j) +{ + while (base[i]) + { + j = i + 1; + while (base[j]) + { + if (base[i] == base[j]) + return (0); + j++; + } + if (base[i] == '-' || base[i] == '+') + return (0); + i++; + } + if (i >= 2) + return (1); + return (0); +} + +static int skip(int i, char *str, int *n) +{ + while ((str[i] == 32) || (str[i] > 8 && str[i] < 14)) + i++; + if (str[i] == '+' || str[i] == '-') + { + if (str[i] == '-') + *n = -1; + i++; + } + return (i); +} + +int ft_atoibase(char *str, char *base) +{ + int i; + int j; + int length; + int res; + int n; + + length = 0; + res = 0; + n = 1; + if (!is_valid_base(base, 0, 0)) + return (0); + while (base[length]) + length++; + i = skip(0, str, &n); + while (str[i] && str[i] > 32 && str[i] != '-' && str[i] != '+') + { + j = 0; + while (str[i] != base[j] && base[j]) + j++; + if (base[j] == '\0') + return (0); + res = (res * length) + j; + i++; + } + return (res * n); +} diff --git a/libs/libft/testing/srcs/test_bzero.c b/libs/libft/testing/srcs/test_bzero.c new file mode 100644 index 0000000..f66336a --- /dev/null +++ b/libs/libft/testing/srcs/test_bzero.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_bzero.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:54:43 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:54:44 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_bzero(void *s, size_t n) +{ + size_t i; + unsigned char *ptr; + + if (n) + { + ptr = (unsigned char *)s; + i = 0; + while (i < n) + ptr[i++] = '\0'; + } +} diff --git a/libs/libft/testing/srcs/test_calloc.c b/libs/libft/testing/srcs/test_calloc.c new file mode 100644 index 0000000..b84f0ee --- /dev/null +++ b/libs/libft/testing/srcs/test_calloc.c @@ -0,0 +1,64 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_calloc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:54:53 by hulamy #+# #+# */ +/* Updated: 2019/12/01 16:04:12 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** allocate count * size byte of memory and +** return a pointer to the allocated memory +** +** exemple allocation for 5 integers with malloc then calloc : +** a = (int *)malloc(5 * sizeof(int)); //5*4bytes = 20 bytes +** free(a); +** a = (int *)calloc(5, sizeof(int)); +*/ + +/* +** #include +** +** void ft_bzero(void *s, size_t n) +** { +** size_t i; +** unsigned char *ptr; +** +** if (n) +** { +** ptr = (unsigned char *)s; +** i = 0; +** while (i < n) +** ptr[i++] = '\0'; +** } +** } +** +** void *ft_calloc(size_t count, size_t size); +** +** int main(void) +** { +** void *str; +** +** str = ft_calloc(0, 0); +** if (str == ((void *)0)) +** printf("failed\n"); +** free(str); +** return (0); +** } +*/ + +#include "libft.h" + +void *ft_calloc(size_t count, size_t size) +{ + void *tmp; + + if (!(tmp = malloc(count * size))) + return (NULL); + ft_bzero(tmp, count * size); + return (tmp); +} diff --git a/libs/libft/testing/srcs/test_concat_free.c b/libs/libft/testing/srcs/test_concat_free.c new file mode 100644 index 0000000..d31a4cd --- /dev/null +++ b/libs/libft/testing/srcs/test_concat_free.c @@ -0,0 +1,53 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_concat_free.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/27 18:04:09 by hulamy #+# #+# */ +/* Updated: 2020/02/27 18:06:44 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new string size of str1 + str2 +** fill it with concated str1 and str2m as "str1str2" +** free the received strings str1 and str2 +** return the new string +*/ + +/* +** #include +** #include "libft.h" +** +** char *ft_concat_free(char *str1, char *str2); +** +** int main(int ac, char **av) +** { +** if (ac != 3) +** return (0); +** printf("%s\n", ft_concat_free(ft_strdup(av[1]), ft_strdup(av[2]))); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_concat_free(char *str1, char *str2) +{ + char *cat; + int i; + int j; + + cat = ft_memalloc(sizeof(char) * (ft_strlen(str1) + ft_strlen(str2) + 1)); + i = -1; + j = 0; + while (str1[++i]) + cat[i] = str1[i]; + while (str2[j]) + cat[i++] = str2[j++]; + free(str1); + free(str2); + return (cat); +} diff --git a/libs/libft/testing/srcs/test_convertbase.c b/libs/libft/testing/srcs/test_convertbase.c new file mode 100644 index 0000000..43f6ec4 --- /dev/null +++ b/libs/libft/testing/srcs/test_convertbase.c @@ -0,0 +1,196 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convertbase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/26 20:19:54 by hulamy #+# #+# */ +/* Updated: 2020/02/26 20:20:14 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** take a string that is a number in a certain base +** and convert it in another base +** it works with unsigned long int +** return the new string +*/ + +/* +** #include // for printf +** #include // for atoi +** +** char *ft_convertbase(char *nbr, char *base_from, char *base_to); +** +** int main(int ac, char **av) +** { +** if (ac != 4) +** { +** printf("usage:\nchar *nbr, char *base_from, char *base_to\n"); +** printf("try the max long unsigned int : 18446744073709551615\n"); +** } +** else +** printf("[%s]\n",ft_convertbase(av[1], av[2], av[3])); +** return (0); +** } +*/ + +#include "libft.h" + +/* +** check : +** -if the base has no characters that appear more than one time +** -if the signes '-' and '+' are not part of the set +** -if there are no invisible characters (inferior to 32 or equal to 127) +*/ + +int + is_valid_base(char *base) +{ + int i; + int j; + + i = 0; + while (base[i]) + { + j = i + 1; + while (base[j]) + if (base[i] == base[j++]) + return (0); + if (base[i] == '-' || base[i] == '+' || base[i] < 33 || base[i] == 127) + return (0); + i++; + } + if (i >= 2) + return (1); + return (0); +} + +/* +** check : +** -if base is valid +** -if nbr contain characters +** -if nbr is made of elements of base only +*/ + +int + is_valid_nbr(char *nbr, char *base) +{ + int i; + int j; + + i = 0; + if (!is_valid_base(base)) + return (0); + while (nbr[i]) + { + j = 0; + while (base[j] && nbr[i] != base[j]) + j++; + if (base[j] == '\0') + return (0); + i++; + } + if (i == 0) + return (0); + return (1); +} + +/* +** -transform a nbr written as a string into a decimal nbr +** -it's an unsigned nbr because the negativity is managed elsewhere +** -if the number is bigger than the max unsigned long int it's false +** as it's impossible to verify if a number is bigger than the biggest +** unsigned, we verify the difference before the multiplication +*/ + +unsigned long int + base_to_decimal(char *nbr, char *base, int *error) +{ + unsigned long int decimal; + int i; + int j; + int length; + + decimal = 0; + i = 0; + length = 0; + while (base[length]) + length++; + while (nbr[i]) + { + j = 0; + while (nbr[i] != base[j] && base[j]) + j++; + if ((18446744073709551615U - j) / length < decimal) + return (*error = 1); + decimal = (decimal * length) + j; + i++; + } + return (decimal); +} + +/* +** -it counts the size needed to be allocated +** -if the given nbr was a negative one it add the place for the '-' +** -then convert the nbr from decimal base to destination base +** into the string allocated +*/ + +char + *decimal_to_base(unsigned long int decimal, char *base, int malloc_size) +{ + int base_size; + int neg; + char *result; + unsigned long int nb; + + neg = malloc_size; + base_size = 0; + while (base[base_size]) + base_size++; + nb = decimal; + while (nb /= base_size) + malloc_size++; + result = (char *)malloc(sizeof(char) * (malloc_size + 2)); + result[malloc_size + 1] = '\0'; + if (neg) + result[0] = '-'; + while (malloc_size >= 0) + { + result[malloc_size--] = base[decimal % base_size]; + decimal /= base_size; + } + return (result); +} + +/* +** -main function to convert from one base to another +** -function base_to_decimal has an awfull int *error because it cannot +** return -1 in case of error, since it's an unsigned, and it cannot +** return 0 to check the error since it would be confusing with an actual +** return of 0 if the number to convert is 0 +*/ + +char + *ft_convertbase(char *nbr, char *base_from, char *base_to) +{ + int length; + unsigned long int decimal; + int error; + + error = 0; + length = 0; + if (nbr[0] == '-') + { + nbr++; + length = 1; + } + if (!is_valid_nbr(nbr, base_from) || !is_valid_base(base_to)) + return (NULL); + decimal = base_to_decimal(nbr, base_from, &error); + if (error == 1) + return (NULL); + return (decimal_to_base(decimal, base_to, length)); +} diff --git a/libs/libft/testing/srcs/test_convertbase_free.c b/libs/libft/testing/srcs/test_convertbase_free.c new file mode 100644 index 0000000..1f2bae7 --- /dev/null +++ b/libs/libft/testing/srcs/test_convertbase_free.c @@ -0,0 +1,198 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convertbase_free.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/26 20:19:54 by hulamy #+# #+# */ +/* Updated: 2020/02/27 20:23:22 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** (just like ft_convert, but free the string it receive) +** take a string that is a number in a certain base +** and convert it in another base +** it works with unsigned long int +** return the new string +*/ + +/* +** #include // for printf +** #include // for atoi +** +** char *ft_convertbase_free(char *nbr, char *base_from, char *base_to); +** +** int main(int ac, char **av) +** { +** if (ac != 4) +** { +** printf("usage:\nchar *nbr, char *base_from, char *base_to\n"); +** printf("try the max long unsigned int : 18446744073709551615\n"); +** } +** else +** printf("[%s]\n",ft_convertbase_free(av[1], av[2], av[3])); +** return (0); +** } +*/ + +#include "libft.h" + +/* +** check : +** -if the base has no characters that appear more than one time +** -if the signes '-' and '+' are not part of the set +** -if there are no invisible characters (inferior to 32 or equal to 127) +*/ + +int + is_base_valid(char *base) +{ + int i; + int j; + + i = 0; + while (base[i]) + { + j = i + 1; + while (base[j]) + if (base[i] == base[j++]) + return (0); + if (base[i] == '-' || base[i] == '+' || base[i] < 33 || base[i] == 127) + return (0); + i++; + } + if (i >= 2) + return (1); + return (0); +} + +/* +** check : +** -if base is valid +** -if nbr contain characters +** -if nbr is made of elements of base only +*/ + +int + is_nbr_valid(char *nbr, char *base) +{ + int i; + int j; + + i = 0; + if (!is_base_valid(base)) + return (0); + while (nbr[i]) + { + j = 0; + while (base[j] && nbr[i] != base[j]) + j++; + if (base[j] == '\0') + return (0); + i++; + } + if (i == 0) + return (0); + return (1); +} + +/* +** -transform a nbr written as a string into a decimal nbr +** -it's an unsigned nbr because the negativity is managed elsewhere +** -if the number is bigger than the max unsigned long int it's false +** as it's impossible to verify if a number is bigger than the biggest +** unsigned, we verify the difference before the multiplication +*/ + +unsigned long int + base_2_decimal(char *nbr, char *base, int *error) +{ + unsigned long int decimal; + int i; + int j; + int length; + + decimal = 0; + i = 0; + length = 0; + while (base[length]) + length++; + while (nbr[i]) + { + j = 0; + while (nbr[i] != base[j] && base[j]) + j++; + if ((18446744073709551615U - j) / length < decimal) + return (*error = 1); + decimal = (decimal * length) + j; + i++; + } + return (decimal); +} + +/* +** -it counts the size needed to be allocated +** -if the given nbr was a negative one it add the place for the '-' +** -then convert the nbr from decimal base to destination base +** into the string allocated +*/ + +char + *decimal_2_base(unsigned long int decimal, char *base, int malloc_size) +{ + int base_size; + int neg; + char *result; + unsigned long int nb; + + neg = malloc_size; + base_size = 0; + while (base[base_size]) + base_size++; + nb = decimal; + while (nb /= base_size) + malloc_size++; + result = (char *)malloc(sizeof(char) * (malloc_size + 2)); + result[malloc_size + 1] = '\0'; + if (neg) + result[0] = '-'; + while (malloc_size >= 0) + { + result[malloc_size--] = base[decimal % base_size]; + decimal /= base_size; + } + return (result); +} + +/* +** -main function to convert from one base to another +** -function base_to_decimal has an awfull int *error because it cannot +** return -1 in case of error, since it's an unsigned, and it cannot +** return 0 to check the error since it would be confusing with an actual +** return of 0 if the number to convert is 0 +*/ + +char + *ft_convertbase_free(char *nbr, char *base_from, char *base_to) +{ + int length; + unsigned long int decimal; + int error; + + error = 0; + length = 0; + if (nbr[0] == '-') + { + nbr++; + length = 1; + } + if (!is_nbr_valid(nbr, base_from) || !is_base_valid(base_to)) + return (NULL); + decimal = base_2_decimal(nbr, base_from, &error); + if (error == 1) + return (NULL); + free(nbr); + return (decimal_2_base(decimal, base_to, length)); +} diff --git a/libs/libft/testing/srcs/test_foreach.c b/libs/libft/testing/srcs/test_foreach.c new file mode 100644 index 0000000..aaf7649 --- /dev/null +++ b/libs/libft/testing/srcs/test_foreach.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_foreach.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:16:10 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:16:11 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_foreach(int *tab, int length, void (*f)(int)) +{ + int i; + + i = 0; + while (i < length && tab && tab[i]) + (*f)(tab[i++]); +} diff --git a/libs/libft/testing/srcs/test_gnl.c b/libs/libft/testing/srcs/test_gnl.c new file mode 100644 index 0000000..d13051b --- /dev/null +++ b/libs/libft/testing/srcs/test_gnl.c @@ -0,0 +1,135 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/31 17:05:53 by hulamy #+# #+# */ +/* Updated: 2020/02/25 18:48:55 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +/* +** #include //for open +** +** int main(int ac, char **av) +** { +** int *fd; +** int i = 0; +** int j = 0; +** int ret; +** char *line = NULL; +** +** fd = (int *)ft_calloc(ac, sizeof(int)); +** while (++i <= ac - 1) +** fd[i - 1] = open(av[i], O_RDONLY); +** i = 0; +** while (j < ac - 1) +** { +** if ((ret = ft_gnl(fd[i], &line)) > 0) +** { +** ft_printf(" [fd%i-%i] %s\n", fd[i], ret, line); +** free(line); +** j = 0; +** } +** else if (ret == -1) +** { +** ft_printf("[fd%i-%i] *ERROR*\n", fd[i], ret); +** free(line); +** j++; +** } +** else if (*line != '\0') +** ft_printf(" [fd%i-%i] %s\n", fd[i], ret, line); +** else +** { +** ft_printf("[fd%i-%i] %s *FINI*\n", fd[i], ret, line); +** free(line); +** j++; +** } +** i++; +** if (i >= ac - 1) +** i = 0; +** } +** free(fd); +** //while (1); +** return (0); +** } +*/ + +int free_lst(t_gnlist **lst, int ret) +{ + t_gnlist *tmp; + + tmp = *lst; + while (tmp->next != *lst) + tmp = tmp->next; + tmp->next = (*lst)->next; + free((*lst)->str); + if (*lst == (*lst)->next) + { + free(*lst); + *lst = NULL; + } + else + { + free(*lst); + *lst = tmp; + } + return (ret); +} + +int multi_fd(int fd, t_gnlist **lst) +{ + t_gnlist *tmp; + + tmp = *lst; + while (*lst && (*lst)->lfd != fd && (*lst)->next != tmp) + *lst = (*lst)->next; + if (!tmp || ((*lst)->next == tmp && (*lst)->lfd != fd)) + { + if (!(tmp = (t_gnlist*)malloc(sizeof(*tmp)))) + return (0); + tmp->lfd = fd; + if (!(tmp->str = ft_strdup(""))) + return (0); + if (*lst) + { + tmp->next = (*lst)->next; + (*lst)->next = tmp; + } + else + tmp->next = tmp; + *lst = tmp; + } + return (1); +} + +int ft_gnl(const int fd, char **line) +{ + char buf[BUFFER_SIZE + 1]; + int ret; + static t_gnlist *lst = NULL; + char *str; + + ret = 1; + if (!(multi_fd(fd, &lst)) || !line || BUFFER_SIZE < 1) + return (free_lst(&lst, -1)); + while (!(str = ft_strchr(lst->str, '\n')) && ret != 0) + { + if ((ret = read(fd, buf, BUFFER_SIZE)) < 0) + return (free_lst(&lst, -1)); + buf[ret] = '\0'; + if (!(lst->str = ft_strjoinfree(lst->str, ft_strdup(buf)))) + return (free_lst(&lst, -1)); + } + if (str != NULL) + str[0] = '\0'; + if (!(*line = ft_strdup(lst->str))) + return (free_lst(&lst, -1)); + if (str != NULL) + return (ft_memmove(lst->str, str + 1, ft_strlen(str + 1) + 1) != NULL); + return (free_lst(&lst, 0)); +} diff --git a/libs/libft/testing/srcs/test_greater.c b/libs/libft/testing/srcs/test_greater.c new file mode 100644 index 0000000..1c1d526 --- /dev/null +++ b/libs/libft/testing/srcs/test_greater.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_greater(int a, int b) +{ + if (a < b) + return (b); + return (a); +} diff --git a/libs/libft/testing/srcs/test_isalnum.c b/libs/libft/testing/srcs/test_isalnum.c new file mode 100644 index 0000000..dc1bb03 --- /dev/null +++ b/libs/libft/testing/srcs/test_isalnum.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalnum.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:05 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:06 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isalnum(int c) +{ + return (ft_isalpha(c) || ft_isdigit(c)); +} diff --git a/libs/libft/testing/srcs/test_isalpha.c b/libs/libft/testing/srcs/test_isalpha.c new file mode 100644 index 0000000..e0ec883 --- /dev/null +++ b/libs/libft/testing/srcs/test_isalpha.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:15 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:17 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isalpha(int c) +{ + return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); +} diff --git a/libs/libft/testing/srcs/test_isascii.c b/libs/libft/testing/srcs/test_isascii.c new file mode 100644 index 0000000..f201880 --- /dev/null +++ b/libs/libft/testing/srcs/test_isascii.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isascii.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:24 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:25 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isascii(int c) +{ + return (c >= 0 && c <= 127); +} diff --git a/libs/libft/testing/srcs/test_isdigit.c b/libs/libft/testing/srcs/test_isdigit.c new file mode 100644 index 0000000..69e0809 --- /dev/null +++ b/libs/libft/testing/srcs/test_isdigit.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isdigit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:32 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:33 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isdigit(int c) +{ + return (c >= '0' && c <= '9'); +} diff --git a/libs/libft/testing/srcs/test_isprint.c b/libs/libft/testing/srcs/test_isprint.c new file mode 100644 index 0000000..21395ab --- /dev/null +++ b/libs/libft/testing/srcs/test_isprint.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isprint.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:43 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:55:44 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isprint(int c) +{ + return (c >= 32 && c < 127); +} diff --git a/libs/libft/testing/srcs/test_issort.c b/libs/libft/testing/srcs/test_issort.c new file mode 100644 index 0000000..842195b --- /dev/null +++ b/libs/libft/testing/srcs/test_issort.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_issort.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:18:14 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:18:15 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_issort(int *tab, int length, int (*f)(int, int)) +{ + int i; + + i = -1; + if (!tab) + return (0); + while (++i < length - 1) + if (f(tab[i], tab[i + 1]) > 0) + return (0); + return (1); +} diff --git a/libs/libft/testing/srcs/test_itoa.c b/libs/libft/testing/srcs/test_itoa.c new file mode 100644 index 0000000..9819d33 --- /dev/null +++ b/libs/libft/testing/srcs/test_itoa.c @@ -0,0 +1,91 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_itoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:59:01 by hulamy #+# #+# */ +/* Updated: 2020/02/19 15:44:04 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** take an integer and give a string +*/ + +/* +** #include // for printf +** #include // for atoi +** +** char *ft_itoa(long int n); +** +** int main(int ac, char **av) +** { +** if (ac == 0) +** return (0); +** else if (ac == 2) +** printf("%s\n",ft_itoa(atoi(av[1]))); +** else +** { +** long int i; +** i = 0; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 1234567; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = -1234567; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 237683; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 2147483647; +** printf("| %li\n| %s\n\n",i,ft_itoa(i)); +** i = i ^ 0; // create the opposite of a signed '0', which +** // is 0 followed by 31 '1', the signed int max +** printf("* %li\n* %s\n\n",i,ft_itoa(i)); +** i = i ^ 0; +** i = 1 << 31; // change the most lefted bit from '0' (positive) +** // to '1' (negative), the signed int min +** printf("* %li\n* %s\n\n",i,ft_itoa(i)); +** i = 2147483646; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = -2147483648; +** printf("| %li\n| %s\n\n",i,ft_itoa(i)); +** i = -2147483647; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 2147483648; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = -2147483649; +** printf(" %li\n %s\n\n",i,ft_itoa(i)); +** i = 9223372036854775807; +** printf("| %li\n| %s\n\n",i,ft_itoa(i)); +** i = -9223372036854775807; +** printf("| %li\n| %s\n\n",i,ft_itoa(i)); +** } +** return 0; +** } +*/ + +#include "libft.h" + +char *ft_itoa(long int n) +{ + char *str; + int len; + long int cpy; + char rgt; + + cpy = (n < 0) ? (n / 10) * -10 : (n / 10) * 10; + len = (n < 0) ? 2 : 1; + rgt = (n < 0) ? (n % 10) * -1 + '0' : n % 10 + '0'; + while (n /= 10) + len++; + if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) + return (NULL); + str[len] = '\0'; + str[--len] = rgt; + while (cpy /= 10) + str[--len] = cpy % 10 + '0'; + if (len) + str[0] = '-'; + return (str); +} diff --git a/libs/libft/testing/srcs/test_lstadd_back.c b/libs/libft/testing/srcs/test_lstadd_back.c new file mode 100644 index 0000000..315119b --- /dev/null +++ b/libs/libft/testing/srcs/test_lstadd_back.c @@ -0,0 +1,90 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_back.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:11:53 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:36:12 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** add an element to the end of a list +** or first if list has no element so far +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_back(t_list **alst, t_list *new); +** +** int main(void) +** { +** char tresor; +** char matos; +** char friends; +** t_list *toto; +** t_list *tmp; +** +** tresor = 'a'; +** matos = 'b'; +** friends = 'c'; +** toto = ft_lstnew(&tresor); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** tmp = ft_lstnew(&matos); +** ft_lstadd_back(&toto, tmp); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** tmp = ft_lstnew(&friends); +** ft_lstadd_back(&toto, tmp); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +void ft_lstadd_back(t_list **alst, t_list *new) +{ + t_list *tmp; + + if (alst) + { + tmp = *alst; + if (!tmp) + *alst = new; + else + { + while (tmp->next) + tmp = tmp->next; + tmp->next = new; + } + } +} diff --git a/libs/libft/testing/srcs/test_lstadd_front.c b/libs/libft/testing/srcs/test_lstadd_front.c new file mode 100644 index 0000000..3f90569 --- /dev/null +++ b/libs/libft/testing/srcs/test_lstadd_front.c @@ -0,0 +1,94 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_front.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:12:02 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:36:54 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** add an element to the begining of a list +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** void *ft_memcpy(void *dst, const void *src, size_t n) +** { +** size_t i; +** char *ptr; +** char *ptr2; +** +** ptr = (char *)dst; +** ptr2 = (char *)src; +** i = -1; +** while (++i < n) +** ptr[i] = ptr2[i]; +** return (dst); +** } +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** { +** if (!(lst->content = malloc(sizeof(content)))) +** return (NULL); +** ft_memcpy(lst->content, content, sizeof(content)); +** } +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_front(t_list **alst, t_list *new); +** +** int main(void) +** { +** char tresor; +** char matos; +** char friends; +** t_list *toto; +** t_list *tmp; +** +** tresor = 'a'; +** matos = 'b'; +** friends = 'c'; +** toto = ft_lstnew(&tresor); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** tmp = ft_lstnew(&matos); +** ft_lstadd_front(&toto, tmp); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** tmp = ft_lstnew(&friends); +** ft_lstadd_front(&toto, tmp); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->dqta:%c\n",*(char*)(toto->next->next->content)); +** return (0); +** } +*/ + +#include "libft.h" + +void ft_lstadd_front(t_list **alst, t_list *new) +{ + new->next = *alst; + *alst = new; +} diff --git a/libs/libft/testing/srcs/test_lstclear.c b/libs/libft/testing/srcs/test_lstclear.c new file mode 100644 index 0000000..a28d366 --- /dev/null +++ b/libs/libft/testing/srcs/test_lstclear.c @@ -0,0 +1,107 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstclear.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:13:30 by hulamy #+# #+# */ +/* Updated: 2019/11/28 17:06:48 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** delete and free an element of the list and all the followings +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_back(t_list **alst, t_list *new) +** { +** t_list *tmp; +** +** if (alst) +** { +** tmp = *alst; +** if (!tmp) +** *alst = new; +** else +** { +** while (tmp->next) +** tmp = tmp->next; +** tmp->next = new; +** } +** new->next = NULL; +** } +** } +** +** void ft_delete(void *element) +** { +** *(char*)element = '\0'; +** } +** +** void ft_lstdelone(t_list *lst, void (*del)(void *)) +** { +** del(lst->content); +** free(lst); +** lst = NULL; +** } +** +** void ft_lstclear(t_list **lst, void (*del)(void *)); +** +** int main(void) +** { +** t_list *toto; +** void (ft_delete)(void*); +** +** printf("sizeof(t_list)%lu\n",sizeof(t_list)); +** toto = ft_lstnew("a"); +** toto->next = ft_lstnew("b"); +** toto->next->next = ft_lstnew("c"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** ft_lstclear(&(toto->next), ft_delete); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt :%s\n",(char*)(toto->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +void ft_lstclear(t_list **lst, void (*del)(void *)) +{ + t_list *next; + + while (*lst != NULL) + { + next = (*lst)->next; + ft_lstdelone(*lst, del); + *lst = next; + } +} diff --git a/libs/libft/testing/srcs/test_lstdelone.c b/libs/libft/testing/srcs/test_lstdelone.c new file mode 100644 index 0000000..0cf925a --- /dev/null +++ b/libs/libft/testing/srcs/test_lstdelone.c @@ -0,0 +1,97 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstdelone.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:14:03 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:35:53 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** free an element and delete its content with del +** next is not free +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_back(t_list **alst, t_list *new) +** { +** t_list *tmp; +** +** if (alst) +** { +** tmp = *alst; +** if (!tmp) +** *alst = new; +** else +** { +** while (tmp->next) +** tmp = tmp->next; +** tmp->next = new; +** } +** new->next = NULL; +** } +** } +** +** void ft_delete(void *element) +** { +** *(char*)element = '\0'; +** } +** +** void ft_lstdelone(t_list *lst, void (*del)(void *)); +** +** int main(void) +** { +** t_list *toto; +** void (ft_delete)(void*); +** +** toto = ft_lstnew("a"); +** toto->next = ft_lstnew("b"); +** toto->next->next = ft_lstnew("c"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** ft_lstdelone(toto->next, ft_delete); +** printf("----------------------\n"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +void ft_lstdelone(t_list *lst, void (*del)(void *)) +{ + if (lst->content && del) + del(lst->content); + free(lst); + lst = NULL; +} diff --git a/libs/libft/testing/srcs/test_lstiter.c b/libs/libft/testing/srcs/test_lstiter.c new file mode 100644 index 0000000..ee67de6 --- /dev/null +++ b/libs/libft/testing/srcs/test_lstiter.c @@ -0,0 +1,85 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstiter.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:14:11 by hulamy #+# #+# */ +/* Updated: 2019/12/01 16:03:40 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** go through all elements of the list and apply the function f to each of them +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstiter(t_list *lst, void (*f)(void*)); +** +** void to_uppercase(void *element) +** { +** // *(char*)(((t_list*)element)->content) -= 32; +** // or : +** t_list *tmp; +** +** tmp = (t_list*)element; +** *(char*)(tmp->content) -= 32; +** } +** +** int main(void) +** { +** t_list *toto; +** void to_uppercase(void*); +** +** toto = ft_lstnew("a"); +** toto->next = ft_lstnew("b"); +** toto->next->next = ft_lstnew("c"); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** printf("---------------------------\n"); +** ft_lstiter(toto, to_uppercase); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +void ft_lstiter(t_list *lst, void (*f)(void *)) +{ + if (!f) + return ; + while (lst) + { + f(lst->content); + lst = lst->next; + } +} diff --git a/libs/libft/testing/srcs/test_lstlast.c b/libs/libft/testing/srcs/test_lstlast.c new file mode 100644 index 0000000..e6173f2 --- /dev/null +++ b/libs/libft/testing/srcs/test_lstlast.c @@ -0,0 +1,100 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstlast.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:14:49 by hulamy #+# #+# */ +/* Updated: 2019/11/28 16:43:18 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return a pointer to the last element of a list +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** void *ft_memcpy(void *dst, const void *src, size_t n) +** { +** size_t i; +** char *ptr; +** char *ptr2; +** +** ptr = (char *)dst; +** ptr2 = (char *)src; +** i = -1; +** while (++i < n) +** ptr[i] = ptr2[i]; +** return (dst); +** } +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** { +** if (!(lst->content = malloc(sizeof(content)))) +** return (NULL); +** ft_memcpy(lst->content, content, sizeof(content)); +** } +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_front(t_list **alst, t_list *new) +** { +** new->next = *alst; +** *alst = new; +** } +** +** t_list *ft_lstlast(t_list *lst); +** +** int main(void) +** { +** char tresor; +** t_list *toto; +** t_list *tmp; +** +** tresor = 'a'; +** toto = ft_lstnew(&tresor); +** tresor = 'b'; +** tmp = ft_lstnew(&tresor); +** ft_lstadd_front(&toto, tmp); +** tresor = 'c'; +** tmp = ft_lstnew(&tresor); +** ft_lstadd_front(&toto, tmp); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** tmp = ft_lstlast(toto); +** printf("%c\n",*(char*)(tmp->content)); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content)); +** return (0); +** } +*/ + +#include "libft.h" + +t_list *ft_lstlast(t_list *lst) +{ + if (lst) + while (lst->next) + lst = lst->next; + return (lst); +} diff --git a/libs/libft/testing/srcs/test_lstmap.c b/libs/libft/testing/srcs/test_lstmap.c new file mode 100644 index 0000000..41e7a25 --- /dev/null +++ b/libs/libft/testing/srcs/test_lstmap.c @@ -0,0 +1,145 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstmap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:15:42 by hulamy #+# #+# */ +/* Updated: 2019/12/01 16:02:13 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** iterate trhough linked list and apply to each element a function f +** if necessary the function del is used to delete an element +*/ + +/* +** #include +** #include +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_back(t_list **alst, t_list *new) +** { +** t_list *tmp; +** +** if (alst) +** { +** tmp = *alst; +** if (!tmp) +** *alst = new; +** else +** { +** while (tmp->next) +** tmp = tmp->next; +** tmp->next = new; +** } +** new->next = NULL; +** } +** } +** +** char *ft_strdup(const char *src) +** { +** int i; +** char *str; +** +** i = 0; +** while (src[i] != '\0') +** i++; +** if (!(str = (char*)malloc(sizeof(*str) * (i + 1)))) +** return (NULL); +** while (i-- >= 0) +** str[i + 1] = src[i + 1]; +** return (str); +** } +** +** void *to_uppercase(void *element) +** { +** char *i; +** +** if (!(i = ft_strdup((char*)element))) +** return (NULL); +** *i -= 32; +** return ((void *)i); +** } +** +** void ft_delete(void *element) +** { +** *(char*)element = '\0'; +** } +** +** t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)); +** +** int main(void) +** { +** t_list *toto; +** void *(to_uppercase)(void *); +** void (ft_delete)(void*); +** +** toto = ft_lstnew("aa"); +** toto->next = ft_lstnew("b"); +** toto->next->next = ft_lstnew("c"); +** printf("toto->data :%s\n",(char*)(toto->content)); +** printf("toto->nxt->data :%s\n",(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%s\n",(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** toto = ft_lstmap(toto, to_uppercase, ft_delete); +** printf("----------------------\n"); +** printf("toto->data :%s\n",(char*)(toto->content)); +** printf("toto->nxt->data :%s\n",(char*)(toto->next->content)); +** printf("toto->nxt->nxt->data:%s\n",(char*)(toto->next->next->content)); +** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next)); +** return (0); +** } +*/ + +#include "libft.h" + +t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) +{ + t_list *new; + t_list *tmp; + + if (!lst) + return (NULL); + if (!(tmp = ft_lstnew(f(lst->content)))) + { + del(tmp->content); + free(tmp); + return (NULL); + } + new = tmp; + while (lst->next) + { + lst = lst->next; + if (!(tmp->next = ft_lstnew(f(lst->content)))) + { + del(tmp->next->content); + free(tmp->next); + return (NULL); + } + tmp = tmp->next; + } + return (new); +} diff --git a/libs/libft/testing/srcs/test_lstnew.c b/libs/libft/testing/srcs/test_lstnew.c new file mode 100644 index 0000000..401f6c9 --- /dev/null +++ b/libs/libft/testing/srcs/test_lstnew.c @@ -0,0 +1,59 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:16:20 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:29:46 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new list +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content); +** +** int main(void) +** { +** char tresor; +** t_list *toto; +** +** tresor = 'd'; +** printf("tresor : %c\n",tresor); +** toto = ft_lstnew(&tresor); +** //toto->content was alocated as void* so it need cast +** printf("toto->content : %c\n",*(char*)(toto->content)); +** tresor = 'D'; +** printf("transform tresor : %c\n",tresor); +** printf("and also toto->content: %c\n",*(char*)(toto->content)); +** return (0); +** } +*/ + +#include "libft.h" + +t_list *ft_lstnew(void *content) +{ + t_list *lst; + + if (!(lst = (t_list *)malloc(sizeof(*lst)))) + return (NULL); + if (!content) + lst->content = NULL; + else + lst->content = content; + lst->next = NULL; + return (lst); +} diff --git a/libs/libft/testing/srcs/test_lstsize.c b/libs/libft/testing/srcs/test_lstsize.c new file mode 100644 index 0000000..5ff5f2d --- /dev/null +++ b/libs/libft/testing/srcs/test_lstsize.c @@ -0,0 +1,86 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstsize.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:31:48 by hulamy #+# #+# */ +/* Updated: 2019/11/25 16:06:41 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return the size of the linked list +*/ + +/* +** #include +** +** typedef struct s_list +** { +** void *content; +** struct s_list *next; +** } t_list; +** +** t_list *ft_lstnew(void *content) +** { +** t_list *lst; +** +** if (!(lst = (t_list *)malloc(sizeof(*lst)))) +** return (NULL); +** if (!content) +** lst->content = NULL; +** else +** lst->content = content; +** lst->next = NULL; +** return (lst); +** } +** +** void ft_lstadd_front(t_list **alst, t_list *new) +** { +** new->next = *alst; +** *alst = new; +** } +** +** int ft_lstsize(t_list *lst); +** +** int main(void) +** { +** char tresor; +** t_list *toto; +** t_list *tmp; +** +** tresor = 'a'; +** toto = ft_lstnew(&tresor); +** tresor = 'b'; +** tmp = ft_lstnew(&tresor); +** ft_lstadd_front(&toto, tmp); +** tresor = 'c'; +** tmp = ft_lstnew(&tresor); +** ft_lstadd_front(&toto, tmp); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->dqta:%c\n",*(char*)(toto->next->next->content)); +** printf("%i\n",ft_lstsize(toto)); +** printf("toto->data :%c\n",*(char*)(toto->content)); +** printf("toto->nxt->data :%c\n",*(char*)(toto->next->content)); +** printf("toto->nxt->nxt->dqta:%c\n",*(char*)(toto->next->next->content)); +** return (0); +** } +*/ + +#include "libft.h" + +int ft_lstsize(t_list *lst) +{ + int size; + + size = 0; + while (lst) + { + size++; + lst = lst->next; + } + return (size); +} diff --git a/libs/libft/testing/srcs/test_memalloc.c b/libs/libft/testing/srcs/test_memalloc.c new file mode 100644 index 0000000..072e7f1 --- /dev/null +++ b/libs/libft/testing/srcs/test_memalloc.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memalloc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/19 15:21:44 by hulamy #+# #+# */ +/* Updated: 2019/11/19 15:23:17 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** allocate size byte of memory and return a pointer to the allocated memory +*/ + +#include "libft.h" + +void *ft_memalloc(size_t size) +{ + void *tmp; + + if (!size || !(tmp = malloc(size))) + return (NULL); + ft_bzero(tmp, size); + return (tmp); +} diff --git a/libs/libft/testing/srcs/test_memccpy.c b/libs/libft/testing/srcs/test_memccpy.c new file mode 100644 index 0000000..fee3c2f --- /dev/null +++ b/libs/libft/testing/srcs/test_memccpy.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memccpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 15:24:51 by hulamy #+# #+# */ +/* Updated: 2019/11/25 15:25:09 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy string until character is found and place cursor in dst +** after last byte copied +*/ + +#include "libft.h" + +void *ft_memccpy(void *dst, const void *src, int c, size_t n) +{ + unsigned char *dest; + unsigned char *sourc; + size_t i; + + i = -1; + dest = (unsigned char *)dst; + sourc = (unsigned char *)src; + while (++i < n) + { + dest[i] = sourc[i]; + if (sourc[i] == (unsigned char)c) + return (dst + i + 1); + } + return (NULL); +} diff --git a/libs/libft/testing/srcs/test_memchr.c b/libs/libft/testing/srcs/test_memchr.c new file mode 100644 index 0000000..6a1c359 --- /dev/null +++ b/libs/libft/testing/srcs/test_memchr.c @@ -0,0 +1,51 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:55:51 by hulamy #+# #+# */ +/* Updated: 2019/12/12 21:50:32 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate character in string and return its position +*/ + +/* +** #include +** +** void *ft_memchr(const void *s, int c, size_t n); +** +** int main(void) +** { +** const char *str; +** +** char *pouet = "z"; +** char *lolzer = (char *)&pouet[2]; +** lolzer = "aaaaaaaaaa"; +** str = ft_memchr(pouet, 'a', 50); +** if (!str) +** printf("NULL"); +** else +** printf("%s\n", str); +** return (0); +** } +*/ + +#include "libft.h" + +void *ft_memchr(const void *s, int c, size_t n) +{ + unsigned char *sbis; + size_t i; + + sbis = (unsigned char *)s; + i = -1; + while (++i < n) + if (sbis[i] == (unsigned char)c) + return ((void *)sbis + i); + return (NULL); +} diff --git a/libs/libft/testing/srcs/test_memcmp.c b/libs/libft/testing/srcs/test_memcmp.c new file mode 100644 index 0000000..c05a028 --- /dev/null +++ b/libs/libft/testing/srcs/test_memcmp.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:05 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:56:07 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** compare two bytes strings (doesnt recognize a null terminated string) +** and return value of difference between first two different character +*/ + +#include "libft.h" + +int ft_memcmp(const void *s1, const void *s2, size_t n) +{ + unsigned char *frst; + unsigned char *scnd; + size_t i; + + i = 0; + frst = (unsigned char *)s1; + scnd = (unsigned char *)s2; + while (i < n && frst[i] == scnd[i]) + i++; + return ((i == n) ? 0 : frst[i] - scnd[i]); +} diff --git a/libs/libft/testing/srcs/test_memcpy.c b/libs/libft/testing/srcs/test_memcpy.c new file mode 100644 index 0000000..b9f0b38 --- /dev/null +++ b/libs/libft/testing/srcs/test_memcpy.c @@ -0,0 +1,46 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:16 by hulamy #+# #+# */ +/* Updated: 2019/12/01 14:54:14 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy n characters from src to dst and return dst +*/ + +/* +** #include +** +** void *ft_memcpy(void *dst, const void *src, size_t n); +** +** int main(int ac, char **av) +** { +** if (ac == 4) +** printf("%s\n", ft_memcpy(av[1], av[2], atoi(av[3]))); +** return (0); +** } +*/ + +#include "libft.h" + +void *ft_memcpy(void *dst, const void *src, size_t n) +{ + int i; + char *ptr; + char *ptr2; + + i = -1; + ptr = (char *)dst; + ptr2 = (char *)src; + if (dst == src) + return (dst); + while (++i < (int)n) + ptr[i] = ptr2[i]; + return (dst); +} diff --git a/libs/libft/testing/srcs/test_memdel.c b/libs/libft/testing/srcs/test_memdel.c new file mode 100644 index 0000000..f057043 --- /dev/null +++ b/libs/libft/testing/srcs/test_memdel.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memdel.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:13:26 by hulamy #+# #+# */ +/* Updated: 2019/04/03 15:44:12 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** free memory +*/ + +#include "libft.h" + +void ft_memdel(void **ap) +{ + if (ap && *ap) + { + free(*ap); + *ap = 0; + } +} diff --git a/libs/libft/testing/srcs/test_memmove.c b/libs/libft/testing/srcs/test_memmove.c new file mode 100644 index 0000000..d005136 --- /dev/null +++ b/libs/libft/testing/srcs/test_memmove.c @@ -0,0 +1,68 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memmove.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:25 by hulamy #+# #+# */ +/* Updated: 2019/12/10 23:53:40 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy n characters from src to dst in a non destructive way and return dst +*/ + +/* +** #include +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** void *ft_memmove(void *dst, const void *src, size_t len); +** +** //int main(int ac, char **av) +** int main(void) +** { +** char *src = "this is a good nyancat !\r\n"; +** char dst[0xF0]; +** int size = strlen(src); +** +** // if (ac == 4) +** // printf("%s\n", ft_memmove(av[1], av[2], atoi(av[3]))); +** +** ft_memmove(dst, src, size); +** printf("%s", dst); +** return (0); +** } +*/ + +#include "libft.h" + +void *ft_memmove(void *dst, const void *src, size_t len) +{ + size_t i; + char *cpsrc; + char *cpdst; + + i = -1; + cpsrc = (char *)src; + cpdst = (char *)dst; + if (dst == src) + return (dst); + if (cpsrc < cpdst) + while (len--) + cpdst[len] = cpsrc[len]; + else + while (++i < len) + cpdst[i] = cpsrc[i]; + return (dst); +} diff --git a/libs/libft/testing/srcs/test_memset.c b/libs/libft/testing/srcs/test_memset.c new file mode 100644 index 0000000..10c2d7c --- /dev/null +++ b/libs/libft/testing/srcs/test_memset.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:37 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:56:38 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy n time a character in a string and return the string +*/ + +#include "libft.h" + +void *ft_memset(void *b, int c, size_t len) +{ + char *ptr; + size_t i; + + ptr = (char *)b; + i = 0; + while (i < len) + ptr[i++] = c; + return (b); +} diff --git a/libs/libft/testing/srcs/test_printf.c b/libs/libft/testing/srcs/test_printf.c new file mode 100644 index 0000000..e69de29 diff --git a/libs/libft/testing/srcs/test_putchar.c b/libs/libft/testing/srcs/test_putchar.c new file mode 100644 index 0000000..b0aa9cb --- /dev/null +++ b/libs/libft/testing/srcs/test_putchar.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:14:00 by hulamy #+# #+# */ +/* Updated: 2018/11/14 21:14:01 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putchar(char c) +{ + write(1, &c, 1); +} diff --git a/libs/libft/testing/srcs/test_putchar_fd.c b/libs/libft/testing/srcs/test_putchar_fd.c new file mode 100644 index 0000000..a48c1d5 --- /dev/null +++ b/libs/libft/testing/srcs/test_putchar_fd.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:59:40 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:59:42 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putchar_fd(char c, int fd) +{ + write(fd, &c, 1); +} diff --git a/libs/libft/testing/srcs/test_putendl.c b/libs/libft/testing/srcs/test_putendl.c new file mode 100644 index 0000000..c1d9a6a --- /dev/null +++ b/libs/libft/testing/srcs/test_putendl.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putendl.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:14:32 by hulamy #+# #+# */ +/* Updated: 2018/11/14 21:14:33 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putendl(char const *s) +{ + ft_putstr(s); + ft_putchar('\n'); +} diff --git a/libs/libft/testing/srcs/test_putendl_fd.c b/libs/libft/testing/srcs/test_putendl_fd.c new file mode 100644 index 0000000..5a0ef44 --- /dev/null +++ b/libs/libft/testing/srcs/test_putendl_fd.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putendl_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:59:47 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:59:48 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** write the string s on the given file descriptor fd, followed by a newline +*/ + +#include "libft.h" + +void ft_putendl_fd(char *s, int fd) +{ + ft_putstr_fd(s, fd); + ft_putchar_fd('\n', fd); +} diff --git a/libs/libft/testing/srcs/test_putnbr.c b/libs/libft/testing/srcs/test_putnbr.c new file mode 100644 index 0000000..bb8e2d7 --- /dev/null +++ b/libs/libft/testing/srcs/test_putnbr.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:14:57 by hulamy #+# #+# */ +/* Updated: 2018/11/14 21:14:58 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putnbr(int n) +{ + ft_putnbr_fd(n, 1); +} diff --git a/libs/libft/testing/srcs/test_putnbr_fd.c b/libs/libft/testing/srcs/test_putnbr_fd.c new file mode 100644 index 0000000..afc9e85 --- /dev/null +++ b/libs/libft/testing/srcs/test_putnbr_fd.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:59:56 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:59:57 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putnbr_fd(int n, int fd) +{ + long l; + + l = n; + if (l < 0) + { + ft_putchar_fd('-', fd); + l *= -1; + } + if (l >= 10) + ft_putnbr_fd(l / 10, fd); + ft_putchar_fd((l % 10) + '0', fd); +} diff --git a/libs/libft/testing/srcs/test_putnbrbase.c b/libs/libft/testing/srcs/test_putnbrbase.c new file mode 100644 index 0000000..bf0d627 --- /dev/null +++ b/libs/libft/testing/srcs/test_putnbrbase.c @@ -0,0 +1,59 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbrbase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:17:00 by hulamy #+# #+# */ +/* Updated: 2018/11/16 15:23:43 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +static int check(char *base) +{ + int i; + int j; + + i = 0; + while (base[i]) + { + j = i + 1; + while (base[j]) + { + if (base[i] == base[j]) + return (0); + j++; + } + if (base[i] == '-' || base[i] == '+') + return (0); + i++; + } + if (i >= 2) + return (1); + return (0); +} + +void ft_putnbrbase(int nbr, char *base) +{ + int i; + long n; + + i = 0; + n = nbr; + if (check(base)) + { + if (n < 0) + { + ft_putchar('-'); + n = -n; + } + while (base[i]) + i++; + if (n >= i) + ft_putnbrbase(n / i, base); + ft_putchar(base[n % i]); + } +} diff --git a/libs/libft/testing/srcs/test_putnbrendl.c b/libs/libft/testing/srcs/test_putnbrendl.c new file mode 100644 index 0000000..ddd05f6 --- /dev/null +++ b/libs/libft/testing/srcs/test_putnbrendl.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbrendl.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/02/19 10:38:07 by hulamy #+# #+# */ +/* Updated: 2019/02/19 10:42:46 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putnbrendl(int n) +{ + ft_putnbrendl_fd(n, 1); +} diff --git a/libs/libft/testing/srcs/test_putnbrendl_fd.c b/libs/libft/testing/srcs/test_putnbrendl_fd.c new file mode 100644 index 0000000..266dc55 --- /dev/null +++ b/libs/libft/testing/srcs/test_putnbrendl_fd.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbrendl_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/02/19 10:37:58 by hulamy #+# #+# */ +/* Updated: 2019/02/19 10:42:48 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putnbrendl_fd(int n, int fd) +{ + long l; + + l = n; + if (l < 0) + { + ft_putchar_fd('-', fd); + l *= -1; + } + if (l >= 10) + ft_putnbr_fd(l / 10, fd); + ft_putchar_fd((l % 10) + '0', fd); + ft_putchar_fd('\n', fd); +} diff --git a/libs/libft/testing/srcs/test_putstr.c b/libs/libft/testing/srcs/test_putstr.c new file mode 100644 index 0000000..78617eb --- /dev/null +++ b/libs/libft/testing/srcs/test_putstr.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:15:19 by hulamy #+# #+# */ +/* Updated: 2018/11/14 21:15:19 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putstr(char const *s) +{ + int i; + + i = 0; + while (s && s[i]) + ft_putchar(s[i++]); +} diff --git a/libs/libft/testing/srcs/test_putstr_fd.c b/libs/libft/testing/srcs/test_putstr_fd.c new file mode 100644 index 0000000..cf6ad12 --- /dev/null +++ b/libs/libft/testing/srcs/test_putstr_fd.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:00:04 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:00:05 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** write the string s on the given file descritor fd +*/ + +#include "libft.h" + +void ft_putstr_fd(char *s, int fd) +{ + while (s && *s) + ft_putchar_fd(*s++, fd); +} diff --git a/libs/libft/testing/srcs/test_sign.c b/libs/libft/testing/srcs/test_sign.c new file mode 100644 index 0000000..b665855 --- /dev/null +++ b/libs/libft/testing/srcs/test_sign.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_sign(int i) +{ + if (i < 0) + return (-1); + return (1); +} diff --git a/libs/libft/testing/srcs/test_smaller.c b/libs/libft/testing/srcs/test_smaller.c new file mode 100644 index 0000000..688f466 --- /dev/null +++ b/libs/libft/testing/srcs/test_smaller.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_smaller(int a, int b) +{ + if (a > b) + return (b); + return (a); +} diff --git a/libs/libft/testing/srcs/test_split.c b/libs/libft/testing/srcs/test_split.c new file mode 100644 index 0000000..4a27b9a --- /dev/null +++ b/libs/libft/testing/srcs/test_split.c @@ -0,0 +1,137 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/12 22:41:54 by hulamy #+# #+# */ +/* Updated: 2019/12/13 01:35:15 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return an array of string with each word found in str, with c as separator +*/ + +/* +** #include +** #include +** #include +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** char *ft_substr(char const *s, unsigned int start, size_t len) +** { +** char *str; +** size_t i; +** +** if (!s) +** return (NULL); +** if (ft_strlen(s) < start) +** return (""); +** if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) +** return (NULL); +** i = 0; +** while (i < len && s[start]) +** str[i++] = s[start++]; +** str[i] = '\0'; +** return (str); +** } +** +** char **ft_split(char const *s, char c); +** char **ft_strsplit(char const *s, char c); +** +** int main(void) +** { +** char **str; +** int i; +** +** char *s; +** char c; +** +** i = -1; +** s = NULL; +** c = ' '; +** str = ft_split(s, c); +** //if (str) +** //{ +** printf("s : '%s'\n", s); +** printf("*str : '%p'\n", str[0]); +** while (str[++i]) +** printf("str[%i] : '%s'\n", i, str[i]); +** //} +** return (0); +** } +*/ + +#include "libft.h" + +static int count(char const *s, char c) +{ + int i; + int words; + + i = -1; + words = 0; + while (s[++i] != '\0') + if (s[i] != c && ++words) + while (s[i + 1] != '\0' && s[i + 1] != c) + i++; + return (words); +} + +void *ft_free(char **array, int w) +{ + int i; + + i = 0; + while (array[i] != NULL && i < w) + free(array[i++]); + free(array); + return (NULL); +} + +char **empty_s(char **empty) +{ + if (!(empty = (char **)malloc(sizeof(char *) * 1))) + return (NULL); + empty[0] = NULL; + return (empty); +} + +char **ft_split(char const *s, char c) +{ + char **array; + int w; + int len; + + if (!s) + return (empty_s(NULL)); + if (!(array = (char **)malloc(sizeof(char *) * (count(s, c) + 1)))) + return (NULL); + w = 0; + while (*s != '\0') + { + len = 0; + if (*s != c) + { + while (s[len] != '\0' && s[len] != c) + len++; + if (!(array[w++] = ft_substr(s, 0, len))) + return (ft_free(array, w)); + s += len - 1; + } + s++; + } + array[w] = NULL; + return (array); +} diff --git a/libs/libft/testing/srcs/test_sqrt.c b/libs/libft/testing/srcs/test_sqrt.c new file mode 100644 index 0000000..04c1483 --- /dev/null +++ b/libs/libft/testing/srcs/test_sqrt.c @@ -0,0 +1,15 @@ +#include "libft.h" + +/* +** return the square root of nb +** or the integer value of it +*/ +int ft_sqrt(int nb) +{ + int i; + + i = 0; + while ((i*i) < nb) + i++; + return (i); +} diff --git a/libs/libft/testing/srcs/test_strcat.c b/libs/libft/testing/srcs/test_strcat.c new file mode 100644 index 0000000..d78543c --- /dev/null +++ b/libs/libft/testing/srcs/test_strcat.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:15:40 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:12:58 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** append src to dest (dest must have sufficient space) and return dest +*/ + +#include "libft.h" + +char *ft_strcat(char *dest, const char *src) +{ + int i; + int j; + + i = 0; + j = 0; + while (dest[i]) + i++; + while (src[j]) + dest[i++] = src[j++]; + dest[i] = '\0'; + return (dest); +} diff --git a/libs/libft/testing/srcs/test_strchr.c b/libs/libft/testing/srcs/test_strchr.c new file mode 100644 index 0000000..b220565 --- /dev/null +++ b/libs/libft/testing/srcs/test_strchr.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:46 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:56:47 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate the first occurence of character c in string s +** and return pointer to its location +*/ + +#include "libft.h" + +char *ft_strchr(const char *s, int c) +{ + int i; + int j; + + i = 0; + j = -1; + while (s[i]) + i++; + while (++j < i + 1) + if (s[j] == c) + return ((char *)s + j); + return (NULL); +} diff --git a/libs/libft/testing/srcs/test_strchrset.c b/libs/libft/testing/srcs/test_strchrset.c new file mode 100644 index 0000000..103e857 --- /dev/null +++ b/libs/libft/testing/srcs/test_strchrset.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchrset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/16 15:07:11 by hulamy #+# #+# */ +/* Updated: 2020/03/10 15:24:14 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** if any character of the character set is found in s +** return a pointer to the first found, else return 0 +*/ + +#include "libft.h" + +char *ft_strchrset(const char *s, const char *set) +{ + int i; + + i = 0; + while (set[i] != '\0') + { + if (ft_strchr(s, set[i]) != NULL) + return ((char *)set + i); + i++; + } + return (NULL); +} diff --git a/libs/libft/testing/srcs/test_strclr.c b/libs/libft/testing/srcs/test_strclr.c new file mode 100644 index 0000000..5e3952c --- /dev/null +++ b/libs/libft/testing/srcs/test_strclr.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strclr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:15:58 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:17:42 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** fill string with zeros +*/ + +#include "libft.h" + +void ft_strclr(char *s) +{ + if (s) + ft_bzero(s, ft_strlen(s)); +} diff --git a/libs/libft/testing/srcs/test_strcmp.c b/libs/libft/testing/srcs/test_strcmp.c new file mode 100644 index 0000000..f6603c3 --- /dev/null +++ b/libs/libft/testing/srcs/test_strcmp.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:08 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:18:30 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** compare two null terminated strings and return value +** of difference between first two different character +*/ + +#include "libft.h" + +int ft_strcmp(const char *s1, const char *s2) +{ + int i; + + i = 0; + while (s1[i] && s1[i] == s2[i]) + i++; + return ((unsigned char)s1[i] - (unsigned char)s2[i]); +} diff --git a/libs/libft/testing/srcs/test_strcpy.c b/libs/libft/testing/srcs/test_strcpy.c new file mode 100644 index 0000000..7d2a45b --- /dev/null +++ b/libs/libft/testing/srcs/test_strcpy.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:17 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:19:19 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy string src to dst including '\0' and return dst +*/ + +#include "libft.h" + +char *ft_strcpy(char *dest, const char *src) +{ + int i; + + i = -1; + while (src[++i]) + dest[i] = src[i]; + dest[i] = '\0'; + return (dest); +} diff --git a/libs/libft/testing/srcs/test_strdel.c b/libs/libft/testing/srcs/test_strdel.c new file mode 100644 index 0000000..82cbc2e --- /dev/null +++ b/libs/libft/testing/srcs/test_strdel.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdel.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:25 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:19:54 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** free memory +*/ + +#include "libft.h" + +void ft_strdel(char **as) +{ + if (as && *as) + { + free(*as); + *as = 0; + } +} diff --git a/libs/libft/testing/srcs/test_strdup.c b/libs/libft/testing/srcs/test_strdup.c new file mode 100644 index 0000000..b917ac9 --- /dev/null +++ b/libs/libft/testing/srcs/test_strdup.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:56:54 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:56:55 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** save a copy of string src by allocating memory and return pointer to copy +*/ + +#include "libft.h" + +char *ft_strdup(const char *src) +{ + int i; + char *str; + + i = 0; + while (src[i] != '\0') + i++; + if (!(str = (char*)malloc(sizeof(*str) * (i + 1)))) + return (NULL); + while (i-- >= 0) + str[i + 1] = src[i + 1]; + return (str); +} diff --git a/libs/libft/testing/srcs/test_strequ.c b/libs/libft/testing/srcs/test_strequ.c new file mode 100644 index 0000000..fa4d4e4 --- /dev/null +++ b/libs/libft/testing/srcs/test_strequ.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strequ.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:44 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:21:02 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return 0 if strings s1 and s2 are identical and 1 if not +*/ + +#include "libft.h" + +int ft_strequ(char const *s1, char const *s2) +{ + if (!s1 || !s2) + return (0); + return (ft_strcmp(s1, s2) == 0); +} diff --git a/libs/libft/testing/srcs/test_striter.c b/libs/libft/testing/srcs/test_striter.c new file mode 100644 index 0000000..9d3b21f --- /dev/null +++ b/libs/libft/testing/srcs/test_striter.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_striter.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:16:53 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:21:14 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** apply function f to each element of string s +*/ + +#include "libft.h" + +void ft_striter(char *s, void (*f)(char *)) +{ + while (s && *s && f) + f(s++); +} diff --git a/libs/libft/testing/srcs/test_striteri.c b/libs/libft/testing/srcs/test_striteri.c new file mode 100644 index 0000000..60fd7f6 --- /dev/null +++ b/libs/libft/testing/srcs/test_striteri.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_striteri.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:17:04 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:21:27 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** apply function f to each element of string s with index specified +*/ + +#include "libft.h" + +void ft_striteri(char *s, void (*f)(unsigned int, char *)) +{ + int i; + + i = 0; + while (s && *s && f) + f(i++, s++); +} diff --git a/libs/libft/testing/srcs/test_strjoin.c b/libs/libft/testing/srcs/test_strjoin.c new file mode 100644 index 0000000..0dfad46 --- /dev/null +++ b/libs/libft/testing/srcs/test_strjoin.c @@ -0,0 +1,79 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strjoin.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:01:26 by hulamy #+# #+# */ +/* Updated: 2019/12/09 21:38:35 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new string by concatenating the two strings s1 and s2 +*/ + +/* +** #include +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** char *ft_strjoin(char const *s1, char const *s2); +** +** int main(int ac, char **av) +** { +** char *s1; +** char *s2; +** char *str; +** +** if (ac == 0) +** return (0); +** else if (ac == 3) +** { +** s1 = strdup(av[1]); +** s2 = strdup(av[2]); +** } +** else +** { +** s1 = malloc(sizeof(char*) * 100); +** s1 = "sdf"; +** s2 = "tref"; +** } +** str = ft_strjoin(s1, s2); +** printf("%s\n", str); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_strjoin(char const *s1, char const *s2) +{ + char *str; + int len; + int i; + + if (!s1 || !s2) + return (NULL); + len = ft_strlen(s1) + ft_strlen(s2); + if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) + return (NULL); + len = 0; + i = 0; + while (s1[i] != '\0') + str[len++] = s1[i++]; + i = 0; + while (s2[i] != '\0') + str[len++] = s2[i++]; + str[len] = '\0'; + return (str); +} diff --git a/libs/libft/testing/srcs/test_strjoinfree.c b/libs/libft/testing/srcs/test_strjoinfree.c new file mode 100644 index 0000000..66c8b50 --- /dev/null +++ b/libs/libft/testing/srcs/test_strjoinfree.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strjoinfree.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/03/05 15:05:28 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:22:28 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new string by concatenating the two strings s1 and s2 +** then free s1 and s2 +*/ + +#include "libft.h" + +char *ft_strjoinfree(char *s1, char *s2) +{ + char *str; + + if (!(str = ft_strjoin(s1, s2))) + return (NULL); + free(s1); + free(s2); + return (str); +} diff --git a/libs/libft/testing/srcs/test_strlcat.c b/libs/libft/testing/srcs/test_strlcat.c new file mode 100644 index 0000000..91d14d8 --- /dev/null +++ b/libs/libft/testing/srcs/test_strlcat.c @@ -0,0 +1,108 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:57:02 by hulamy #+# #+# */ +/* Updated: 2019/11/25 14:23:18 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** append src to sized dest and return size of final dest +*/ + +/* +** #include +** +** size_t ft_strlcat(char *dest, const char *src, size_t size); +** +** size_t ft_strlcat2(char *dest, char *src, size_t size); +** +** int ft_strlen(char *str) +** { +** int i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** int main(int ac, char **av) +** { +** char tmp1[100]; +** char tmp2[100]; +** int i; +** +** i = atoi(av[3]); +** strcpy(tmp1, av[1]); +** strcpy(tmp2, av[2]); +** +** if (ac == 4) +** { +** printf("----strlcat: %zu - %s - %s\n", strlcat(tmp1, tmp2, i), +** tmp1, tmp2); +** +** strcpy(tmp1, av[1]); +** strcpy(tmp2, av[2]); +** +** printf("-ft_strlcat: %zu - %s - %s\n", ft_strlcat(tmp1, tmp2, i), +** tmp1, tmp2); +** +** strcpy(tmp1, av[1]); +** strcpy(tmp2, av[2]); +** +** printf("ft_strlcat2: %zu - %s - %s\n", ft_strlcat2(tmp1, tmp2, i), +** tmp1, tmp2); +** } +** } +** +** size_t ft_strlcat2(char *dest, char *src, size_t size) +** { +** size_t i; +** size_t dest_length; +** size_t src_length; +** +** i = 0; +** dest_length = ft_strlen(dest); +** src_length = ft_strlen(src); +** if (size > dest_length + 1) +** { +** while (i < (size - dest_length - 1)) +** { +** dest[i + dest_length] = src[i]; +** i++; +** } +** dest[dest_length + i] = '\0'; +** } +** if (size >= dest_length) +** return (dest_length + src_length); +** return (src_length + size); +** } +*/ + +#include "libft.h" + +size_t ft_strlcat(char *dest, const char *src, size_t size) +{ + size_t i; + size_t j; + + i = 0; + j = 0; + while (dest[i] && i < size) + i++; + while (src[j]) + { + if (j + i < size - 1 && size) + { + dest[i + j] = src[j]; + dest[i + j + 1] = '\0'; + } + j++; + } + return (i + j); +} diff --git a/libs/libft/testing/srcs/test_strlcpy.c b/libs/libft/testing/srcs/test_strlcpy.c new file mode 100644 index 0000000..48ef5b8 --- /dev/null +++ b/libs/libft/testing/srcs/test_strlcpy.c @@ -0,0 +1,70 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:57:19 by hulamy #+# #+# */ +/* Updated: 2019/12/01 16:12:57 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy size - 1 length of src into dest, +** terminate it with a '\0' +** and return size of src +** this way, if you try to copy a name in a variable with an available size +** of 5 for exemple, if you use ft_strlcpy(variable, name, sizeof(variable)) +** you will know if the name was too long for the variable by looking at the +** return value (which is size of name) +*/ + +/* +** #include +** +** size_t ft_strlcpy(char *dest, const char *src, size_t size); +** +** int main(int argc, char **argv) +** { +** char str[100]; +** int i; +** unsigned int u; +** unsigned int v; +** +** i = atoi(argv[3]); +** strcpy(str, argv[2]); +** if (argc > 3) +** { +** u = strlcpy(argv[2], argv[1], i); +** printf("strlcpy : %s - %s - %d",argv[1], argv[2], i); +** printf(" - return:%d\n",u); +** strcpy(argv[2], str); +** printf("(re-init : %s - %s - %d)\n",argv[1], argv[2], i); +** v = ft_strlcpy(argv[2], argv[1], i); +** printf("ft_strlcpy: %s - %s - %d",argv[1], argv[2], i); +** printf(" - return:%d\n",v); +** } +** return (0); +** } +*/ + +#include "libft.h" + +size_t ft_strlcpy(char *dest, const char *src, size_t size) +{ + size_t i; + size_t j; + + i = 0; + j = 0; + while (src[i] != '\0') + { + if (i + 1 < size) + dest[i] = src[j++]; + i++; + } + if (size > 0) + dest[j] = '\0'; + return (i); +} diff --git a/libs/libft/testing/srcs/test_strlen.c b/libs/libft/testing/srcs/test_strlen.c new file mode 100644 index 0000000..8af143b --- /dev/null +++ b/libs/libft/testing/srcs/test_strlen.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:57:48 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:57:49 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return length of of string +*/ + +#include "libft.h" + +size_t ft_strlen(const char *str) +{ + size_t i; + + i = 0; + while (str[i]) + i++; + return (i); +} diff --git a/libs/libft/testing/srcs/test_strmap.c b/libs/libft/testing/srcs/test_strmap.c new file mode 100644 index 0000000..ef82f97 --- /dev/null +++ b/libs/libft/testing/srcs/test_strmap.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:17:49 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:23:12 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new array with the result of function f on every element of s +*/ + +#include "libft.h" + +char *ft_strmap(char const *s, char (*f)(char)) +{ + char *str; + int i; + + if (!s) + return (NULL); + if (!(str = ft_strnew(ft_strlen(s)))) + return (NULL); + i = -1; + while (s[++i]) + str[i] = f(s[i]); + return (str); +} diff --git a/libs/libft/testing/srcs/test_strmapi.c b/libs/libft/testing/srcs/test_strmapi.c new file mode 100644 index 0000000..7fa1a06 --- /dev/null +++ b/libs/libft/testing/srcs/test_strmapi.c @@ -0,0 +1,75 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmapi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:01:40 by hulamy #+# #+# */ +/* Updated: 2019/12/09 21:44:07 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new array with the result of function f on every element of +** s by index i +*/ + +/* +** #include +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** char touppercase(unsigned int i, char c) +** { +** if (i < 3 && c >= 'a' && c <= 'z') +** c -= 32; +** return (c); +** } +** +** char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); +** +** int main(int ac, char **av) +** { +** char *str; +** char touppercase(unsigned int, char); +** +** if (ac > 2) +** return (0); +** if (ac == 2) +** str = strdup(av[1]); +** if (ac == 1) +** str = NULL; +** //str = ft_strmapi(str, touppercase); +** str = ft_strmapi(str, NULL); +** printf("%s\n",str); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) +{ + char *str; + int i; + int size; + + if (!s || !f) + return (NULL); + size = ft_strlen(s); + if (!(str = (char *)malloc(sizeof(char) * (size + 1)))) + return (NULL); + str[size] = '\0'; + i = -1; + while (s[++i]) + str[i] = f(i, s[i]); + return (str); +} diff --git a/libs/libft/testing/srcs/test_strmultisplit.c b/libs/libft/testing/srcs/test_strmultisplit.c new file mode 100644 index 0000000..ed2ed98 --- /dev/null +++ b/libs/libft/testing/srcs/test_strmultisplit.c @@ -0,0 +1,83 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmultisplit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/16 15:18:29 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:23:57 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return an array of string with each word found in str +** with any character of charset difining a separator +*/ + +#include "libft.h" + +static int ft_is_separator(char c, char *charset, int i) +{ + while (charset[i]) + { + if (c == charset[i]) + return (1); + i++; + } + c = charset[i]; + return (0); +} + +static int ft_count(char *str, int word, char **tab, char *charset) +{ + int i; + int j; + int k; + + k = 0; + i = 0; + while (ft_is_separator(str[k], charset, 0) == 1) + k++; + while (str[k] != '\0' && i != word) + { + j = 0; + while (!ft_is_separator(str[k + j], charset, 0) && str[k + j] != '\0') + { + if (word == -2) + tab[i][j] = str[k + j]; + j++; + } + k += j; + while (ft_is_separator(str[k], charset, 0)) + k++; + i++; + } + if (word == -1) + return (i); + return (j); +} + +char **ft_strmultisplit(char *str, char *charset) +{ + char **tab; + int i; + int j; + int k; + + k = 0; + tab = 0; + i = ft_count(str, -1, tab, charset); + if (!(tab = (char**)malloc(sizeof(tab) * (i + 1)))) + return (NULL); + tab[i] = 0; + while (k < i) + { + j = ft_count(str, k + 1, tab, charset); + tab[k] = (char*)malloc(sizeof(*tab) * (j + 1)); + tab[k][j] = '\0'; + k++; + } + ft_count(str, -2, tab, charset); + return (tab); +} diff --git a/libs/libft/testing/srcs/test_strncat.c b/libs/libft/testing/srcs/test_strncat.c new file mode 100644 index 0000000..cf52aae --- /dev/null +++ b/libs/libft/testing/srcs/test_strncat.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:18:24 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:24:11 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** append n character of src to dest and return dest +*/ + +#include "libft.h" + +char *ft_strncat(char *dest, const char *src, size_t nb) +{ + size_t i; + size_t j; + + i = 0; + j = 0; + while (dest[i]) + i++; + while (src[j] && j < nb) + dest[i++] = src[j++]; + dest[i] = '\0'; + return (dest); +} diff --git a/libs/libft/testing/srcs/test_strncmp.c b/libs/libft/testing/srcs/test_strncmp.c new file mode 100644 index 0000000..7022624 --- /dev/null +++ b/libs/libft/testing/srcs/test_strncmp.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:57:59 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:58:00 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** compare size first character of two null terminated strings +** and return value of difference between first two different character +*/ + +#include "libft.h" + +int ft_strncmp(const char *s1, const char *s2, size_t n) +{ + size_t i; + int res; + + i = 0; + res = 0; + while (s1[i] && s1[i] == s2[i] && i < n - 1) + i++; + if (n != 0) + res = (unsigned char)s1[i] - (unsigned char)s2[i]; + return (res); +} diff --git a/libs/libft/testing/srcs/test_strncpy.c b/libs/libft/testing/srcs/test_strncpy.c new file mode 100644 index 0000000..91ea1b3 --- /dev/null +++ b/libs/libft/testing/srcs/test_strncpy.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:18:44 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:24:59 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** copy n characters from string src to dst including '\0' +** if space remain it's filled zith '\0', and return dst +*/ + +#include "libft.h" + +char *ft_strncpy(char *dest, const char *src, size_t n) +{ + size_t i; + + i = -1; + while (++i < n && src[i]) + dest[i] = src[i]; + while (i < n) + dest[i++] = '\0'; + return (dest); +} diff --git a/libs/libft/testing/srcs/test_strnequ.c b/libs/libft/testing/srcs/test_strnequ.c new file mode 100644 index 0000000..668f3fa --- /dev/null +++ b/libs/libft/testing/srcs/test_strnequ.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnequ.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:18:55 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:25:20 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return 0 if n first character of strings s1 and s2 are identical +** and 1 if not +*/ + +#include "libft.h" + +int ft_strnequ(char const *s1, char const *s2, size_t n) +{ + if (!s1 || !s2) + return (0); + return (ft_strncmp(s1, s2, n) == 0); +} diff --git a/libs/libft/testing/srcs/test_strnew.c b/libs/libft/testing/srcs/test_strnew.c new file mode 100644 index 0000000..645feff --- /dev/null +++ b/libs/libft/testing/srcs/test_strnew.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:19:08 by hulamy #+# #+# */ +/* Updated: 2019/11/21 17:00:30 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a new string of length size, fill with zero, and return pointer to it +*/ + +#include "libft.h" + +char *ft_strnew(size_t size) +{ + char *str; + + if (!(str = (char *)malloc(sizeof(char) * (size + 1)))) + return (NULL); + ft_bzero(str, size + 1); + return (str); +} diff --git a/libs/libft/testing/srcs/test_strnstr.c b/libs/libft/testing/srcs/test_strnstr.c new file mode 100644 index 0000000..52ff0d2 --- /dev/null +++ b/libs/libft/testing/srcs/test_strnstr.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:58:10 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:58:11 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate the first occurence of the string little in len first characters +** of big and return a pointer to this occurence if found +*/ + +#include "libft.h" + +char *ft_strnstr(const char *big, const char *little, size_t len) +{ + size_t i; + size_t j; + + j = 0; + i = 0; + if (!ft_strlen(little)) + return ((char *)big); + while (i == 0 && j <= len) + { + while (little[i] == big[j + i] && little[i] && j + i <= len) + i++; + if (little[i]) + { + j++; + if (!big[j] || j >= len) + return (0); + i = 0; + } + } + return ((char *)big + j); +} diff --git a/libs/libft/testing/srcs/test_strrchr.c b/libs/libft/testing/srcs/test_strrchr.c new file mode 100644 index 0000000..1c8faa8 --- /dev/null +++ b/libs/libft/testing/srcs/test_strrchr.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strrchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:58:20 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:58:21 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate the last occurence of character c in string s +** and return pointer to its location +*/ + +#include "libft.h" + +char *ft_strrchr(const char *s, int c) +{ + int i; + + i = 0; + while (s[i]) + i++; + i++; + while (i--) + if (s[i] == c) + return ((char *)s + i); + return (NULL); +} diff --git a/libs/libft/testing/srcs/test_strstr.c b/libs/libft/testing/srcs/test_strstr.c new file mode 100644 index 0000000..c7a3535 --- /dev/null +++ b/libs/libft/testing/srcs/test_strstr.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/11/14 21:19:45 by hulamy #+# #+# */ +/* Updated: 2019/03/25 15:26:59 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** locate the first occurence of the string little in big +** and return a pointer to this occurence if found +*/ + +#include "libft.h" + +char *ft_strstr(const char *str, const char *to_find) +{ + int i; + int j; + + j = 0; + i = 0; + if (!ft_strlen(to_find)) + return ((char *)str); + while (i == 0) + { + while (to_find[i] && to_find[i] == str[j + i]) + i++; + if (to_find[i]) + { + j++; + if (str[j] == '\0' && to_find[i]) + return (0); + i = 0; + } + } + return ((char *)str + j); +} diff --git a/libs/libft/testing/srcs/test_strtrim.c b/libs/libft/testing/srcs/test_strtrim.c new file mode 100644 index 0000000..0e9ede9 --- /dev/null +++ b/libs/libft/testing/srcs/test_strtrim.c @@ -0,0 +1,101 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strtrim.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 14:01:49 by hulamy #+# #+# */ +/* Updated: 2019/12/09 21:46:54 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a copy of s without the firsts and lasts set of characters +*/ + +/* +** #include +** +** char *ft_substr(char const *s, unsigned int start, size_t len) +** { +** char *str; +** size_t i; +** +** if (!s) +** return (NULL); +** if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) +** return (NULL); +** str[len] = '\0'; +** i = 0; +** while (i < len) +** str[i++] = s[start++]; +** return (str); +** } +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** char *ft_strchr(const char *s, int c) +** { +** int i; +** int j; +** +** i = 0; +** j = -1; +** while (s[i]) +** i++; +** while (++j < i + 1) +** if (s[j] == c) +** return ((char *)s + j); +** return (NULL); +** } +** +** char *ft_strtrim(char const *s1, char const *set); +** +** int main(int ac, char **av) +** { +** char *s1; +** char *s2; +** +** if (ac == 3) +** { +** s1 = strdup(av[1]); +** s2 = strdup(av[2]); +** } +** if (ac == 1) +** { +** s1 = "fuehf"; +** s2 = NULL; +** } +** printf("%s\n",ft_strtrim(s1, s2)); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_strtrim(char const *s1, char const *set) +{ + int len; + char *str; + + if (!s1 || !set) + return (NULL); + while (s1[0] && ft_strchr(set, s1[0])) + s1++; + len = ft_strlen(s1) - 1; + while (len >= 0 && ft_strchr(set, s1[len])) + len--; + len++; + if (!(str = ft_substr(s1, 0, len))) + return (NULL); + return (str); +} diff --git a/libs/libft/testing/srcs/test_substr.c b/libs/libft/testing/srcs/test_substr.c new file mode 100644 index 0000000..4ffd069 --- /dev/null +++ b/libs/libft/testing/srcs/test_substr.c @@ -0,0 +1,104 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_substr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/01 16:00:10 by hulamy #+# #+# */ +/* Updated: 2019/12/09 22:04:26 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** create a copy of a portion of s, begining at start and of length len +*/ + +/* +** #include +** #include +** #include +** +** char *ft_substr(char const *s, unsigned int start, size_t len); +** +** char *ft_strdup(const char *src) +** { +** int i; +** char *str; +** +** i = 0; +** while (src[i] != '\0') +** i++; +** if (!(str = (char*)malloc(sizeof(*str) * (i + 1)))) +** return (NULL); +** while (i-- >= 0) +** str[i + 1] = src[i + 1]; +** return (str); +** } +** +** int ft_strncmp(const char *s1, const char *s2, size_t n) +** { +** size_t i; +** int res; +** +** i = 0; +** res = 0; +** while (s1[i] && s1[i] == s2[i] && i < n - 1) +** i++; +** if (n != 0) +** res = (unsigned char)s1[i] - (unsigned char)s2[i]; +** return (res); +** } +** +** size_t ft_strlen(const char *str) +** { +** size_t i; +** +** i = 0; +** while (str[i]) +** i++; +** return (i); +** } +** +** int main(int ac, char **av) +** { +** char *str; +** size_t size; +** int start; +** +** str = "frgehr"; +** start = 2; +** size = 5; +** if (ac == 4) +** { +** str = strdup(av[1]); +** start = atoi(av[2]); +** size = atoi(av[3]); +** } +** char *ret = ft_substr(str, start, size); +** printf("%s, %i, %zu\n", str, start, size); +** printf("%s\n", ret); +** free(ret); +** return (0); +** } +*/ + +#include "libft.h" + +char *ft_substr(char const *s, unsigned int start, size_t len) +{ + char *str; + size_t i; + + if (!s) + return (NULL); + if (ft_strlen(s) < start) + return (ft_strdup("")); + if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) + return (NULL); + i = 0; + while (i < len && s[start]) + str[i++] = s[start++]; + str[i] = '\0'; + return (str); +} diff --git a/libs/libft/testing/srcs/test_tolower.c b/libs/libft/testing/srcs/test_tolower.c new file mode 100644 index 0000000..2cd5cb6 --- /dev/null +++ b/libs/libft/testing/srcs/test_tolower.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_tolower.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/11/25 13:58:30 by hulamy #+# #+# */ +/* Updated: 2019/11/25 13:58:32 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_tolower(int c) +{ + if (c >= 'A' && c <= 'Z') + return (c + 32); + return (c); +} diff --git a/libs/libft/testing/srcs/test_toupper.c b/libs/libft/testing/srcs/test_toupper.c new file mode 100644 index 0000000..cb6f5c8 --- /dev/null +++ b/libs/libft/testing/srcs/test_toupper.c @@ -0,0 +1,7 @@ + +char touppercase(unsigned int i, char c) +{ + if (i < 3 && c >= 'a' && c <= 'z') + c -= 32; + return (c); +} diff --git a/libs/libft/testing/srcs/test_utoa.c b/libs/libft/testing/srcs/test_utoa.c new file mode 100644 index 0000000..e47f898 --- /dev/null +++ b/libs/libft/testing/srcs/test_utoa.c @@ -0,0 +1,74 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_utoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/03/12 22:36:50 by hulamy #+# #+# */ +/* Updated: 2020/03/12 22:36:56 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** take an unsigned integer and give a string +*/ + +/* +** #include // for printf +** #include // for atoi +** +** char *ft_utoa(unsigned long int n); +** +** int main(int ac, char **av) +** { +** if (ac == 0) +** return (0); +** else if (ac == 2) +** printf("%s\n",ft_utoa(atoi(av[1]))); +** else +** { +** unsigned long int i; +** i = 0; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 237683; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 1234567; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 12345678; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 2147483646; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 2147483647; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 2147483648; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 2147483649; +** printf(" %lu\n %s\n\n",i,ft_utoa(i)); +** i = 9223372036854775807; +** printf("| %lu\n| %s\n\n",i,ft_utoa(i)); +** } +** return 0; +** } +*/ + +#include "libft.h" + +char *ft_utoa(unsigned long int n) +{ + char *str; + int len; + unsigned long int cpy; + + cpy = n; + len = 1; + while (n /= 10) + len++; + if (!(str = (char *)malloc(sizeof(char) * (len + 1)))) + return (NULL); + str[len] = '\0'; + str[--len] = cpy % 10 + '0'; + while (cpy /= 10) + str[--len] = cpy % 10 + '0'; + return (str); +} diff --git a/maps/map_valid_03.cub b/maps/map_valid_03.cub index b8b7ded..706c7a0 100644 --- a/maps/map_valid_03.cub +++ b/maps/map_valid_03.cub @@ -1,12 +1,10 @@ -R 801 597 -NO ./texture/grey.xpm -SO ./texture/brick.xpm -WE ./texture/wood.xpm -EA ./texture/blue.xpm +NO ./textures/grey.xpm +SO ./textures/brick.xpm +WE ./textures/wood.xpm +EA ./textures/blue.xpm -S ./texture/kinkss/perso_base.xpm -F 66,66,66 -C 33,33,33 +F 66, 66 , 66 +C 33,33 ,33 111111111111111111111111 100000000000000000000001 @@ -15,19 +13,19 @@ C 33,33,33 100000111110000101010001 100000100010000000000001 100000100010000100010001 -100000100010000E00020001 -100200110110000101010001 +100000100010000E00000001 +100000110110000101010001 +100000000000000000000001 +100000000000000000000001 100000000000000000000001 100000000000000000000001 100000000000000000000001 -100000000200000000020001 -100000002000020000000001 100000001100000000000001 100000001100000000000001 111111001100000000000011 110100001100000000000001 110000101100000000000011 -110102001100000000000001 +110100001100000000000001 110111111100000000000011 110000000000000000000111 111111111100000000001111 diff --git a/srcs/cube3d.c b/srcs/cube3d.c index 62defc2..6e0df90 100644 --- a/srcs/cube3d.c +++ b/srcs/cube3d.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* cube3d.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:42:00 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:43:02 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" void destroy_mlx(void *param) @@ -28,7 +40,7 @@ int shut_down(void) return (0); } -int main(int ac, char **av) +int main(int ac, char **av) { t_game *game; @@ -37,23 +49,15 @@ int main(int ac, char **av) return (EXIT_FAILURE); game = init_struct(); mb_init(destroy_mlx, game); - - if (init_parsing(game, av[1]) && write(2, "The .cub file is invalid.\n", 26)) + if (init_parsing(game, av[1])) return (EXIT_FAILURE); - - if (check_map(&(game->map)) && write(2, "The map is invalid.\n", 20)) + if (check_map(&(game->map))) return (EXIT_FAILURE); init_game(game); - - // draw game a first time before it start draw(game); - // receive a keypress event mlx_hook(game->win.ptr, 2, 1L << 0, keypress, game); - // receive a keyprelease event mlx_hook(game->win.ptr, 3, 1L << 1, keyrelease, game); - // receive event when clicking the red button to close the window mlx_hook(game->win.ptr, 17, 1L << 17, shut_down, NULL); - // infinite loop that waits for events to occurs mlx_loop_hook(game->mlx_ptr, hook_action, game); mlx_loop(game->mlx_ptr); return (0); diff --git a/srcs/draw/draw.c b/srcs/draw/draw.c index 73e0aa4..4b06df5 100644 --- a/srcs/draw/draw.c +++ b/srcs/draw/draw.c @@ -1,65 +1,16 @@ -#include "cube3d.h" +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* draw.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:55:29 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:55:31 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ -// tmp draw map -// static void draw_square(t_game *game, t_coord pos, int border, int fill, int size, int rotation) -// { -// int i; -// int j; -// t_coord new; -// -// i = 0; -// while (i < size) -// { -// j = 0; -// while (j < size) -// { -// new.x = pos.x + j; -// new.y = pos.y + i; -// if (rotation) -// rotate(&(game->plr), &(new)); -// if (!i || i == size - 1) -// draw_pixel(&game->map_img, new.x, new.y, border); -// else if (!j || j == size - 1) -// draw_pixel(&game->map_img, new.x, new.y, border); -// else -// draw_pixel(&game->map_img, new.x, new.y, fill); -// j++; -// } -// i++; -// } -// } -// -// static void draw_map(t_game *game) -// { -// t_coord incr; -// t_coord pos; -// int cell; -// -// cell = game->map.cell; -// incr.x = 0; -// pos.x = 0; -// pos.y = 0; -// while ((game->map.content)[incr.x]) -// { -// incr.y = 0; -// while ((game->map.content)[incr.x][incr.y]) -// { -// if ((game->map.content)[incr.x][incr.y] == '1' ) -// draw_square(game, pos, 0x00999999, 0x00000000, cell, 0); -// else -// draw_square(game, pos, 0x00555555, 0x00333333, cell, 0); -// (incr.y)++; -// pos.x += cell; -// } -// (incr.x)++; -// pos.x = 0; -// pos.y += cell; -// } -// pos.x = game->plr.pos.x - cell / 2; -// pos.y = game->plr.pos.y - cell / 2; -// draw_square(game, pos, 0x00999900, 0x00330033, cell, 1); -// } -// tmp end +#include "cube3d.h" static int pxl_out_limits(t_img *img, int x, int y) { @@ -80,7 +31,7 @@ void draw_pixel(t_img *img, int x, int y, int color) if (pxl_out_limits(img, x, y)) return ; position = y * img->szl + x * (img->bpp / 8); - *(unsigned int*)(img->data + position) = color; + *(unsigned int *)(img->data + position) = color; } void draw_line(t_img *img, t_vec *vec, int color) @@ -105,16 +56,6 @@ void draw_line(t_img *img, t_vec *vec, int color) void draw(t_game *game) { - // tmp draw map - // draw_map(game); - // tmp end - raycast(game, &(game->rcast)); - - // tmp draw map - // draw_screen(game, &(game->rcast)); - // mlx_put_image_to_window(game->mlx_ptr, game->map_win.ptr, game->map_img.ptr, 0, SCREEN_HEIGHT); - // tmp end - mlx_put_image_to_window(game->mlx_ptr, game->win.ptr, game->img.ptr, 0, 0); } diff --git a/srcs/draw/draw_column.c b/srcs/draw/draw_column.c index 244066f..25379f9 100644 --- a/srcs/draw/draw_column.c +++ b/srcs/draw/draw_column.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* draw_column.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:51:59 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:52:01 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" static void draw_floor_ceiling(t_game *game, t_rcast *rcast, t_txt *txt) @@ -40,16 +52,6 @@ static void draw_txt_column(t_game *game, t_wall *wall, t_img *txt_img) int j; img_x = (wall->posx * txt_img->width) / game->rcast.cell; - - // tmp draw map - // if (game->ray_activ) - // { - // printf("img_x:%i ", img_x); - // draw_line(&game->img, &wall->vec, 0x00FF00FF); - // return ; - // } - // tmp end - j = wall->limit; i = 0; while (j < wall->height - wall->limit) diff --git a/srcs/draw/ray_intersect.c b/srcs/draw/ray_intersect.c index cd8c786..5b45420 100644 --- a/srcs/draw/ray_intersect.c +++ b/srcs/draw/ray_intersect.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ray_intersect.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:52:25 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:52:27 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" static void init_ray_params(t_rcast *rcast, t_vec *ray) diff --git a/srcs/draw/raycast.c b/srcs/draw/raycast.c index 8412032..85edb58 100644 --- a/srcs/draw/raycast.c +++ b/srcs/draw/raycast.c @@ -1,34 +1,16 @@ -#include "cube3d.h" +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* raycast.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:54:22 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:54:23 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ -// tmp draw map -// static void calcul_ray_end(t_rcast *rcast, t_vec *ray) -// { -// if (rcast->is_x) -// { -// ray->end.x = rcast->cell_x * rcast->cell; -// if (rcast->ray_sign_x == 1) -// ray->end.x += rcast->cell; -// if (rcast->slope_x) -// { -// rcast->ratio = (double)(ray->end.x - ray->start.x); -// rcast->ratio /= (double)rcast->slope_x; -// ray->end.y = ray->start.y + (double)rcast->slope_y * rcast->ratio; -// } -// } -// else -// { -// ray->end.y = rcast->cell_y * rcast->cell; -// if (rcast->ray_sign_y == 1) -// ray->end.y += rcast->cell; -// if (rcast->slope_y) -// { -// rcast->ratio = (double)(ray->end.y - ray->start.y); -// rcast->ratio /= (double)rcast->slope_y; -// ray->end.x = ray->start.x + (double)rcast->slope_x * rcast->ratio; -// } -// } -// } -// tmp end +#include "cube3d.h" static void calcul_img_column(t_game *game, t_rcast *rcast, t_wall *wall) { @@ -37,42 +19,22 @@ static void calcul_img_column(t_game *game, t_rcast *rcast, t_wall *wall) if (rcast->is_x == 1) { tmp = wall->delta; -// tmp += rcast->slope_y; tmp *= -rcast->ray_sign_y; tmp /= ft_abs(rcast->slope_x); tmp += game->plr.pos.y; - - // tmp draw map - // if (game->ray_activ) - // printf("tmp:%i ", tmp); - // tmp end - wall->posx = tmp % rcast->cell; } else { tmp = wall->delta; -// tmp += rcast->slope_x; tmp *= -rcast->ray_sign_x; tmp /= ft_abs(rcast->slope_y); tmp += game->plr.pos.x; - - // tmp draw map - // if (game->ray_activ) - // printf("tmp:%i ", tmp); - // tmp end - wall->posx = tmp % rcast->cell; } - - // tmp draw map - // if (game->ray_activ) - // printf("wall->posx:%i ", wall->posx); - // tmp end - } -static void fill_wall_vector(t_rcast *rcast, t_wall *wall) +static void fill_wall_vector(t_rcast *rcast, t_wall *wall) { int height; @@ -117,35 +79,10 @@ void raycast(t_game *game, t_rcast *rcast) rcast->ray_nb = 0; while (rcast->ray_nb <= rcast->screen_width) { - - // tmp draw map - // // rays - // game->ray_activ = 0; - // if (rcast->ray_nb == game->ray_highlight) - // { - // game->ray_activ = 1; - // game->ray = ray; - // } - // tmp end - ray_intersect_wall(game, rcast, &ray); - - // tmp draw map - // calcul_ray_end(rcast, &ray); - // if (game->ray_activ) - // draw_line(&game->map_img, &ray, 0x00FF00FF); - // else if (rcast->ray_nb % 10 == 0) - // draw_line(&game->map_img, &ray, 0x00FFFFFF); - // tmp end - calcul_wall(rcast); calcul_img_column(game, rcast, &rcast->wall); draw_column(game, rcast, &rcast->wall, &game->txt); (rcast->ray_nb)++; } - - // tmp draw map - // printf("\n\n"); - // tmp end - } diff --git a/srcs/hook/key_action_1.c b/srcs/hook/key_action_1.c index f1a86dd..4f0deef 100644 --- a/srcs/hook/key_action_1.c +++ b/srcs/hook/key_action_1.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* key_action_1.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:48:28 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:49:27 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" int is_esc(int *k_hook, int *is_action) @@ -5,9 +17,9 @@ int is_esc(int *k_hook, int *is_action) if (!ft_arrint(k_hook, KEY_ESC, MAX_NB_KEY)) { *is_action = 1; - return 1; + return (1); } - return 0; + return (0); } int is_go_left(int *k_hook, int *is_action) @@ -15,14 +27,14 @@ int is_go_left(int *k_hook, int *is_action) if (!ft_arrint(k_hook, KEY_A, MAX_NB_KEY)) { *is_action = 1; - return 1; + return (1); } if (!ft_arrint(k_hook, KEY_Q, MAX_NB_KEY)) { *is_action = 1; - return 1; + return (1); } - return 0; + return (0); } int is_go_right(int *k_hook, int *is_action) @@ -30,9 +42,9 @@ int is_go_right(int *k_hook, int *is_action) if (!ft_arrint(k_hook, KEY_D, MAX_NB_KEY)) { *is_action = 1; - return 1; + return (1); } - return 0; + return (0); } int is_go_forward(int *k_hook, int *is_action) @@ -40,14 +52,14 @@ int is_go_forward(int *k_hook, int *is_action) if (!ft_arrint(k_hook, KEY_W, MAX_NB_KEY)) { *is_action = 1; - return 1; + return (1); } if (!ft_arrint(k_hook, KEY_Z, MAX_NB_KEY)) { *is_action = 1; - return 1; + return (1); } - return 0; + return (0); } int is_go_backward(int *k_hook, int *is_action) @@ -55,7 +67,7 @@ int is_go_backward(int *k_hook, int *is_action) if (!ft_arrint(k_hook, KEY_S, MAX_NB_KEY)) { *is_action = 1; - return 1; + return (1); } - return 0; + return (0); } diff --git a/srcs/hook/key_action_2.c b/srcs/hook/key_action_2.c index 6f8cbab..0289c81 100644 --- a/srcs/hook/key_action_2.c +++ b/srcs/hook/key_action_2.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* key_action_2.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:48:54 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:48:56 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" int is_turn_left(int *k_hook, int *is_action) @@ -5,9 +17,9 @@ int is_turn_left(int *k_hook, int *is_action) if (!ft_arrint(k_hook, ARROW_LEFT, MAX_NB_KEY)) { *is_action = 1; - return 1; + return (1); } - return 0; + return (0); } int is_turn_right(int *k_hook, int *is_action) @@ -15,7 +27,7 @@ int is_turn_right(int *k_hook, int *is_action) if (!ft_arrint(k_hook, ARROW_RIGHT, MAX_NB_KEY)) { *is_action = 1; - return 1; + return (1); } - return 0; + return (0); } diff --git a/srcs/hook/keyhook.c b/srcs/hook/keyhook.c index ae29798..fe856b7 100644 --- a/srcs/hook/keyhook.c +++ b/srcs/hook/keyhook.c @@ -1,15 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* keyhook.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:45:52 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:47:13 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" -// temp, to map all the keys on linux and mac - static int print_keycode(int keycode, t_plr *plr) - { - ft_putnbr_fd(keycode, 1); - ft_putchar_fd(' ', 1); - ft_putnbr_fd(plr->rot, 1); - ft_putchar_fd('\n', 1); - return(0); - } -// temp end +static int print_keycode(int keycode, t_plr *plr) +{ + ft_putnbr_fd(keycode, 1); + ft_putchar_fd(' ', 1); + ft_putnbr_fd(plr->rot, 1); + ft_putchar_fd('\n', 1); + return (0); +} int hook_action(t_game *game) { @@ -30,40 +40,16 @@ int hook_action(t_game *game) plr_turn_left(&(game->plr)); if (is_turn_right(game->k_hook, &is_action)) plr_turn_right(&(game->plr)); - - // tmp draw map - // // ray - // if (!ft_arrint(game->k_hook, 65364, MAX_NB_KEY)) - // { - // if (game->ray_highlight <= SCREEN_WIDTH) - // game->ray_highlight++; - // else - // game->ray_highlight = -1; - // is_action = 1; - // } - // if (!ft_arrint(game->k_hook, 65362, MAX_NB_KEY)) - // { - // if (game->ray_highlight >= 0) - // game->ray_highlight--; - // else - // game->ray_highlight = SCREEN_WIDTH; - // is_action = 1; - // } - // tmp end - if (is_action) draw(game); - return(0); + return (0); } -int keypress(int keycode, t_game *game) +int keypress(int keycode, t_game *game) { unsigned i; - // temp - print_keycode(keycode, &game->plr); - // temp end - + print_keycode(keycode, &game->plr); i = 0; while (i < MAX_NB_KEY && game->k_hook[i] != 0 && game->k_hook[i] != keycode) i++; @@ -71,11 +57,10 @@ int keypress(int keycode, t_game *game) game->k_hook[i] = 0; else if (i < MAX_NB_KEY) game->k_hook[i] = keycode; -// hook_action(game); return (0); } -int keyrelease(int keycode, t_game *game) +int keyrelease(int keycode, t_game *game) { unsigned i; diff --git a/srcs/init/init_game.c b/srcs/init/init_game.c index d216e53..e2ff82c 100644 --- a/srcs/init/init_game.c +++ b/srcs/init/init_game.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* init_game.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:58:13 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:59:14 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" static void init_img(t_img *img, void *mlx_ptr, t_win *win) @@ -16,12 +28,10 @@ static void init_raycast(t_rcast *rcast) rcast->screen_dist = dist; rcast->screen_width = SCREEN_WIDTH; rcast->screen_height = SCREEN_HEIGHT; - // screen size rcast->screen_size.start.x = -SCREEN_WIDTH / 2; rcast->screen_size.start.y = -dist; rcast->screen_size.end.x = SCREEN_WIDTH / 2; rcast->screen_size.end.y = -dist; - // first ray rcast->ray.start.x = 0; rcast->ray.start.y = 0; rcast->ray.end.x = -SCREEN_WIDTH / 2; @@ -30,12 +40,10 @@ static void init_raycast(t_rcast *rcast) static void init_plr(t_plr *plr, t_map *map) { - // player first position plr->exact.x = map->plr_x * CELL + CELL / 2; plr->exact.y = map->plr_y * CELL + CELL / 2; plr->pos.x = plr->exact.x; plr->pos.y = plr->exact.y; - // rotation plr->deg = PLR_ROT; plr->rot = 0; plr->cosi = 0; @@ -52,33 +60,16 @@ static void init_plr(t_plr *plr, t_map *map) void init_game(t_game *game) { - // plr init_plr(&(game->plr), &(game->map)); - // init connexion to server game->mlx_ptr = mlx_init(); mb_add(game->mlx_ptr); - - // tmp draw map - // game->map_win.size_x = game->map.size_x * CELL; - // game->map_win.size_y = game->map.size_y * CELL + SCREEN_HEIGHT; - // game->map_win.ptr = mlx_new_window(game->mlx_ptr, game->map_win.size_x, game->map_win.size_y, "map"); - // init_img(&(game->map_img), game->mlx_ptr, &(game->map_win)); - // // ray - // game->ray_highlight = -1; - // game->ray_activ = 0; - // tmp end - - // create window game->win.size_x = SCREEN_WIDTH; game->win.size_y = SCREEN_HEIGHT; - game->win.ptr = mlx_new_window(game->mlx_ptr, game->win.size_x, game->win.size_y, "cub3d"); - // create img + game->win.ptr = mlx_new_window(game->mlx_ptr, game->win.size_x, \ + game->win.size_y, "cub3d"); init_img(&(game->img), game->mlx_ptr, &game->win); - // create textures img init_txtr(&game->txt, game->mlx_ptr); - // k(ey)_hook is the array containing the values of key press events ft_bzero(&game->k_hook, sizeof(game->k_hook)); - // raycasting init_raycast(&(game->rcast)); game->rcast.cell = game->map.cell; } diff --git a/srcs/init/init_struct.c b/srcs/init/init_struct.c index b5846a2..4ae4b82 100644 --- a/srcs/init/init_struct.c +++ b/srcs/init/init_struct.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* init_struct.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:57:22 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:57:28 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" static void init_null_mlx_ptr(t_game *game) @@ -35,11 +47,8 @@ t_game *init_struct(void) t_game *game; game = mb_alloc(sizeof(t_game)); - // map init_map(&(game->map)); - // init textures and floor/ceiling colors init_txt_null(&(game->txt)); - // put all mlx allocated pointer to null init_null_mlx_ptr(game); return (game); } diff --git a/srcs/init/init_textures.c b/srcs/init/init_textures.c index 2e17423..34dab61 100644 --- a/srcs/init/init_textures.c +++ b/srcs/init/init_textures.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* init_textures.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:57:11 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:57:13 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" static void init_txtr_img(t_img *img, void *mlx_ptr, char *path) diff --git a/srcs/mem/memorybook.c b/srcs/mem/memorybook.c index 3eebf50..b59c53e 100644 --- a/srcs/mem/memorybook.c +++ b/srcs/mem/memorybook.c @@ -1,7 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* memorybook.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:56:30 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:58:58 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" void mb_set_params_exit(void (*f)(void *), void *param); -void mb_exec_exit_func(); +void mb_exec_exit_func(void); t_list **mb_get_lst(void); int mb_comp_addr(void *to_find, void *to_compare); diff --git a/srcs/mem/memorybook_2d.c b/srcs/mem/memorybook_2d.c index d663985..0789c64 100644 --- a/srcs/mem/memorybook_2d.c +++ b/srcs/mem/memorybook_2d.c @@ -1,19 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* memorybook_2d.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:55:48 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:55:51 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" void mb_add_2d(void **addr, int nb) { - while (nb) + int i; + + i = 0; + while (i < nb) { - mb_add(addr[nb]); - nb--; + mb_add(addr[i]); + i++; } } void mb_free_2d(void **addr, int nb) { - while (nb) + int i; + + i = 0; + while (i < nb) { - mb_free(addr[nb]); - nb--; + mb_free(addr[i]); + i++; } } diff --git a/srcs/mem/memorybook_utils.c b/srcs/mem/memorybook_utils.c index 90e4f9a..bfdc6e7 100644 --- a/srcs/mem/memorybook_utils.c +++ b/srcs/mem/memorybook_utils.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* memorybook_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:56:23 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:56:25 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" /* private struct definition : diff --git a/srcs/parsing/check_map_borders.c b/srcs/parsing/check_map_borders.c new file mode 100644 index 0000000..266e41f --- /dev/null +++ b/srcs/parsing/check_map_borders.c @@ -0,0 +1,44 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* check_map.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/18 12:37:48 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:05:47 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "cube3d.h" + +int check_borders(t_map *map) +{ + int x; + int y; + + y = 0; + while (map->content[y] != NULL) + { + x = 0; + while (map->content[y][x] != '\0' && map->content[y][x] != '\n') + { + if (y == 0 || y == map->size_y - 1) + if (map->content[y][x] != '1' && map->content[y][x] != ' ') + mb_exit("Error\nInvalid map borders.\n", EXIT_FAILURE); + if (x == 0 || x == map->size_x - 1) + if (map->content[y][x] != '1' && map->content[y][x] != ' ') + mb_exit("Error\nInvalid map borders.\n", EXIT_FAILURE); + x++; + } + y++; + } + return (EXIT_SUCCESS); +} + +int check_map(t_map *map) +{ + if (check_borders(map) || check_content(map)) + mb_exit("Error\nInvalid map content.\n", EXIT_FAILURE); + return (EXIT_SUCCESS); +} diff --git a/srcs/parsing/check_map.c b/srcs/parsing/check_map_content.c similarity index 65% rename from srcs/parsing/check_map.c rename to srcs/parsing/check_map_content.c index 31061af..2456fbd 100644 --- a/srcs/parsing/check_map.c +++ b/srcs/parsing/check_map_content.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* check_map.c :+: :+: :+: */ +/* check_map_content.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: pblagoje +#+ +:+ +#+ */ +/* By: pblagoje +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2022/04/18 12:37:48 by pblagoje #+# #+# */ -/* Updated: 2022/05/04 00:51:54 by simplonco ### ########.fr */ +/* Created: 2022/05/04 13:04:44 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:05:34 by pblagoje ### ########.fr */ /* */ /* ************************************************************************** */ @@ -73,9 +73,9 @@ int check_content(t_map *map) while (map->content[y][x] != '\0' && map->content[y][x] != '\n') { if (map->content[y][x] == ' ' && check_spaces(map, y, x)) - return (EXIT_FAILURE); + mb_exit("Error\nInvalid space positions.\n", EXIT_FAILURE); else if (!ft_strchr(" 01SNWE", map->content[y][x])) - return (EXIT_FAILURE); + mb_exit("Error\nInvalid map characters.\n", EXIT_FAILURE); else if (ft_strchr("SNWE", map->content[y][x]) \ && set_player(map, y, x, map->content[y][x])) count++; @@ -84,40 +84,6 @@ int check_content(t_map *map) y++; } if (count != 1) - return (EXIT_FAILURE); - return (EXIT_SUCCESS); -} - -int check_borders(t_map *map) -{ - int x; - int y; - - y = 0; - while (map->content[y] != NULL) - { - x = 0; - while (map->content[y][x] != '\0' && map->content[y][x] != '\n') - { - if (y == 0 || y == map->size_y - 1) - if (map->content[y][x] != '1' && map->content[y][x] != ' ') - return (EXIT_FAILURE); - if (x == 0 || x == map->size_x - 1) - if (map->content[y][x] != '1' && map->content[y][x] != ' ') - return (EXIT_FAILURE); - x++; - } - y++; - } - return (EXIT_SUCCESS); -} - -int check_map(t_map *map) -{ - if (check_borders(map) || check_content(map)) - { - ft_putstr_fd("Error\nThe map characters are invalid.\n", 2); - return (EXIT_FAILURE); - } + mb_exit("Error\nToo many player starting positions.\n", EXIT_FAILURE); return (EXIT_SUCCESS); } diff --git a/srcs/parsing/check_path.c b/srcs/parsing/check_path.c index 3fd3d1a..4b6ff62 100644 --- a/srcs/parsing/check_path.c +++ b/srcs/parsing/check_path.c @@ -6,7 +6,7 @@ /* By: pblagoje +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/04/16 20:54:37 by pblagoje #+# #+# */ -/* Updated: 2022/05/02 15:45:01 by simplonco ### ########.fr */ +/* Updated: 2022/05/04 13:01:16 by pblagoje ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,21 +17,25 @@ int set_path(t_txt *txt, char *path, char identifier) if (identifier == 'N' && txt->txt_north == NULL) { txt->txt_north = ft_strdup(path); + mb_add(txt->txt_north); return (EXIT_SUCCESS); } else if (identifier == 'S' && txt->txt_south == NULL) { txt->txt_south = ft_strdup(path); + mb_add(txt->txt_south); return (EXIT_SUCCESS); } else if (identifier == 'W' && txt->txt_west == NULL) { txt->txt_west = ft_strdup(path); + mb_add(txt->txt_west); return (EXIT_SUCCESS); } else if (identifier == 'E' && txt->txt_east == NULL) { txt->txt_east = ft_strdup(path); + mb_add(txt->txt_east); return (EXIT_SUCCESS); } return (EXIT_FAILURE); @@ -45,21 +49,21 @@ static int check_path(t_txt *txt, char *element, char identifier) while (element && *element && ft_strchr(" \t\r", *element)) element++; path = ft_substr(element, 0, ft_strlen(element)); + mb_add(path); fd = open(path, O_RDONLY); if (fd == -1 || check_extension(path, ".xpm")) { - ft_putstr_fd("Error\nInvalid texture file.\n", 2); - free(path); + mb_free(path); close(fd); - return (EXIT_FAILURE); + mb_exit("Error\nInvalid texture file.\n", EXIT_FAILURE); } if (set_path(txt, path, identifier) == EXIT_FAILURE) { - free(path); + mb_free(path); close(fd); - return (EXIT_FAILURE); + mb_exit("Error\nCouldn't save texture paths.\n", EXIT_FAILURE); } - free(path); + mb_free(path); close(fd); return (EXIT_SUCCESS); } @@ -81,6 +85,7 @@ static int check_element(t_game *game, char *element) if (ft_strnstr("F C ", identifier, 5) && \ !check_rgb(&(game->txt), element, identifier[0])) return (EXIT_SUCCESS); + mb_exit("Error\nInvalid textures and/or RGB elements.\n", EXIT_FAILURE); return (EXIT_FAILURE); } @@ -98,15 +103,16 @@ int check_elements(t_game *game, char *file) while (count < TOTAL_ELEMENTS) { get_next_line(fd, &line); + mb_add(line); if (line && *line != '\n' && !check_element(game, line)) count++; else if (!line || (*line != '\n' && *line != '\0')) { - free(line); + mb_free(line); close(fd); return (-1); } - free(line); + mb_free(line); line = NULL; } return (fd); diff --git a/srcs/parsing/check_rgb.c b/srcs/parsing/check_rgb.c index d9eedec..09d6b90 100644 --- a/srcs/parsing/check_rgb.c +++ b/srcs/parsing/check_rgb.c @@ -6,7 +6,7 @@ /* By: pblagoje +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/04/15 16:11:24 by pblagoje #+# #+# */ -/* Updated: 2022/05/01 22:53:25 by simplonco ### ########.fr */ +/* Updated: 2022/05/04 12:58:13 by pblagoje ### ########.fr */ /* */ /* ************************************************************************** */ @@ -51,7 +51,7 @@ static void set_rgb(int *plan, char **rgb) *plan = 0 << 24 | r << 16 | g << 8 | b; } -void ft_free_2d(char **str) +/*void ft_free_2d(char **str) { int i; @@ -62,14 +62,14 @@ void ft_free_2d(char **str) i++; } free(str); -} +}*/ int check_rgb(t_txt *txt, char *elem, char identifier) { char **rgb; rgb = ft_split(elem, ','); - mb_add_2d((void**)rgb, ft_strlen_2d(rgb)); + mb_add_2d((void **)rgb, ft_strlen_2d(rgb)); if (!rgb || ft_strlen_2d(rgb) != 3 || elem[ft_strlen(elem) - 1] == ',') mb_exit("Error\nInvalid RGB code.\n", EXIT_FAILURE); if ((identifier != 'F' && identifier != 'C') || check_colors(rgb)) diff --git a/srcs/parsing/init_parsing.c b/srcs/parsing/init_parsing.c index 6b34a03..3335f29 100644 --- a/srcs/parsing/init_parsing.c +++ b/srcs/parsing/init_parsing.c @@ -6,7 +6,7 @@ /* By: pblagoje +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/04/15 16:03:50 by pblagoje #+# #+# */ -/* Updated: 2022/04/23 18:57:37 by pblagoje ### ########.fr */ +/* Updated: 2022/05/04 13:14:21 by pblagoje ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,11 +17,12 @@ int size_map(t_map *map, int fd) char *line; get_next_line(fd, &line); + mb_add(line); while (line) { if ((*line == '\n' || *line == '\0') && map->size_x) { - free(line); + mb_free(line); return (EXIT_FAILURE); } else if (*line != '\n' && (int)ft_strlen(line) > map->size_x) @@ -32,9 +33,10 @@ int size_map(t_map *map, int fd) } if (*line != '\n' && *line != '\0') map->size_y++; - free(line); + mb_free(line); line = NULL; get_next_line(fd, &line); + mb_add(line); } return (EXIT_SUCCESS); } @@ -50,8 +52,8 @@ int find_map(t_map *map, char *file) return (-1); while (count < TOTAL_ELEMENTS + 1) { - free(map->tmp_str); get_next_line(fd, &map->tmp_str); + mb_add(map->tmp_str); if (!map->tmp_str) { close(fd); @@ -88,22 +90,25 @@ int fill_map(t_map *map, int fd) map->content = (char **)mb_alloc((map->size_y + 1) * sizeof(char *)); if (!map->content) { - free(map->tmp_str); + mb_free(map->tmp_str); return (EXIT_FAILURE); } i = -1; while (++i < map->size_y) { if (i > 0) + { get_next_line(fd, &map->tmp_str); + mb_add(map->tmp_str); + } map->content[i] = (char *)mb_alloc((map->size_x + 1) * sizeof(char)); if (!map->content[i]) { - free(map->tmp_str); + mb_free(map->tmp_str); return (EXIT_FAILURE); } fill_row(map->content[i], map->tmp_str, map->size_x); - free(map->tmp_str); + mb_free(map->tmp_str); map->tmp_str = NULL; } map->content[i] = NULL; @@ -116,20 +121,20 @@ int init_parsing(t_game *game, char *file) fd = check_elements(game, file); if (fd == -1) - return (EXIT_FAILURE); + mb_exit("Error\nInvalid .cub file.\n", EXIT_FAILURE); if (size_map(&(game->map), fd)) { close(fd); - return (EXIT_FAILURE); + mb_exit("Error\nInvalid map format.\n", EXIT_FAILURE); } close(fd); fd = find_map(&(game->map), file); if (fd == -1) - return (EXIT_FAILURE); + mb_exit("Error\nCouldn't locate the map.\n", EXIT_FAILURE); if (fill_map(&(game->map), fd) == EXIT_FAILURE) { close(fd); - return (EXIT_FAILURE); + mb_exit("Error\nCouldn't save the map.\n", EXIT_FAILURE); } close(fd); return (EXIT_SUCCESS); diff --git a/srcs/player/player_limits.c b/srcs/player/player_limits.c index c03a235..e3d74cc 100644 --- a/srcs/player/player_limits.c +++ b/srcs/player/player_limits.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* player_limits.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:50:31 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:50:37 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" int is_wall(t_game *game, int cell_x, int cell_y) diff --git a/srcs/player/player_moves.c b/srcs/player/player_moves.c index 1a62c4c..c455f86 100644 --- a/srcs/player/player_moves.c +++ b/srcs/player/player_moves.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* player_moves.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:50:18 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:50:21 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" void plr_posx_decrement(t_game *game, t_plr *plr) diff --git a/srcs/player/player_rotates.c b/srcs/player/player_rotates.c index 7bc2b09..7b966d1 100644 --- a/srcs/player/player_rotates.c +++ b/srcs/player/player_rotates.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* player_rotates.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: pblagoje +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/05/04 13:49:40 by pblagoje #+# #+# */ +/* Updated: 2022/05/04 13:49:57 by pblagoje ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "cube3d.h" void rotate(t_plr *plr, t_coord *coord) @@ -5,17 +17,13 @@ void rotate(t_plr *plr, t_coord *coord) int old_x; t_coord tmp; - // do nothing if not rotating if (plr->rot == 0) return ; - // offset center tmp.x = coord->x - plr->pos.x; tmp.y = coord->y - plr->pos.y; - // calculate new coordinates old_x = tmp.x; tmp.x = tmp.x * plr->cosi + tmp.y * plr->cosj; tmp.y = old_x * plr->sini + tmp.y * plr->sinj; - // de-offset center coord->x = tmp.x + plr->pos.x; coord->y = tmp.y + plr->pos.y; } @@ -25,17 +33,13 @@ void rotate_double(t_plr *plr, t_d_coord *coord) double old_x; t_d_coord tmp; - // do nothing if not rotating if (plr->rot == 0) return ; - // offset center tmp.x = coord->x - plr->exact.x; tmp.y = coord->y - plr->exact.y; - // calculate new coordinates old_x = tmp.x; tmp.x = tmp.x * plr->cosi + tmp.y * plr->cosj; tmp.y = old_x * plr->sini + tmp.y * plr->sinj; - // de-offset center coord->x = tmp.x + plr->exact.x; coord->y = tmp.y + plr->exact.y; } @@ -48,7 +52,6 @@ void plr_turn(t_plr *plr, int deg) if (plr->rot == -180) (plr->rot) *= -1; plr->rot += deg; - // calculate trigo for rotations radi = plr->rot * M_PI / 180; radj = radi + (M_PI / 2); plr->cosi = cos(radi);