diff --git a/libft/Makefile b/libft/Makefile index 68bcfb3a..6ad2e058 100644 --- a/libft/Makefile +++ b/libft/Makefile @@ -6,7 +6,7 @@ # By: jhalford +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2017/02/07 16:09:36 by jhalford #+# #+# # -# Updated: 2017/03/02 16:21:52 by jhalford ### ########.fr # +#* Updated: 2017/03/05 15:19:07 by wescande ### ########.fr *# # # # **************************************************************************** # @@ -17,7 +17,7 @@ AR = ar -rc MKDIR = mkdir -p RM = /bin/rm -rf -W_FLAGS = -Wall -Wextra -Werror +W_FLAGS = -Wall -Wextra D_FLAGS = V_FLAGS = -fvisibility=hidden FLAGS = $(W_FLAGS) $(D_FLAGS) $(V_FLAGS) @@ -198,14 +198,14 @@ $(NAME): $(OBJ_DIR) $(OBJS) @$(AR) $(NAME) $(OBJS) @ranlib $(NAME) @strip -x $(NAME) - @printf "\r\e[48;5;15;38;5;25m✅ MAKE $(NAME)\e[0m\e[K\n" + @printf "\r\033[48;5;15;38;5;25m✅ MAKE $(NAME)\033[0m\033[K\n" $(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJ_DIR) @$(eval DONE=$(shell echo $$(($(INDEX)*20/$(NB))))) @$(eval PERCENT=$(shell echo $$(($(INDEX)*100/$(NB))))) @$(eval COLOR=$(shell echo $$(($(PERCENT)%35+196)))) @$(eval TO_DO=$(shell echo $$((20-$(INDEX)*20/$(NB))))) - @printf "\r\e[38;5;11m⌛ MAKE %10.10s : %2d%% \e[48;5;%dm%*s\e[0m%*s\e[48;5;255m \e[0m \e[38;5;11m %*s\e[0m\e[K" $(NAME) $(PERCENT) $(COLOR) $(DONE) "" $(TO_DO) "" $(DELTA) "$@" + @printf "\r\033[38;5;11m⌛ MAKE %10.10s : %2d%% \033[48;5;%dm%*s\033[0m%*s\033[48;5;255m \033[0m \033[38;5;11m %*s\033[0m\033[K" $(NAME) $(PERCENT) $(COLOR) $(DONE) "" $(TO_DO) "" $(DELTA) "$@" @$(CC) $(FLAGS) -MMD -c $< -o $@\ -I $(INC_DIR) @$(eval INDEX=$(shell echo $$(($(INDEX)+1)))) @@ -216,11 +216,11 @@ $(OBJ_DIR): clean: @$(RM) $(OBJ_DIR) - @printf "\r\e[38;5;202m✖ clean $(NAME).\e[0m\e[K\n" + @printf "\r\033[38;5;202m✖ clean $(NAME).\033[0m\033[K\n" fclean: clean @$(RM) $(NAME) - @printf "\r\e[38;5;196m❌ fclean $(NAME).\e[0m\e[K\n" + @printf "\r\033[38;5;196m❌ fclean $(NAME).\033[0m\033[K\n" re: fclean all diff --git a/libft/src/ft_printf/ft_fmt_validate_flags.c b/libft/src/ft_printf/ft_fmt_validate_flags.c index 3f5892e1..709e3c19 100644 --- a/libft/src/ft_printf/ft_fmt_validate_flags.c +++ b/libft/src/ft_printf/ft_fmt_validate_flags.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 16:53:07 by jhalford #+# #+# */ -/* Updated: 2016/11/16 11:15:55 by jhalford ### ########.fr */ +/* Updated: 2017/03/05 15:19:35 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,9 +55,6 @@ static void ft_fmt_validate_flag_conv(t_fmt *fmt) void ft_fmt_validate_flags(t_fmt *fmt) { - int i; - - i = 0; ft_fmt_validate_flag_conv(fmt); ft_fmt_validate_flag_flag(fmt); } diff --git a/libft/src/ft_printf/lib_pad_sharp.c b/libft/src/ft_printf/lib_pad_sharp.c index 526fcd1e..db6fd9c9 100644 --- a/libft/src/ft_printf/lib_pad_sharp.c +++ b/libft/src/ft_printf/lib_pad_sharp.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:33:48 by jhalford #+# #+# */ -/* Updated: 2016/12/09 19:07:55 by jhalford ### ########.fr */ +/* Updated: 2017/03/05 15:19:49 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,9 +25,7 @@ void ft_pad_sharp_o(char *str, t_fmt *fmt) void ft_pad_sharp_xb(char *str, t_fmt *fmt) { char start[3] = {'0',fmt->conversion, 0}; - int i; - i = 0; if (str[0] == '0') { if (str[1] == '0') diff --git a/libft/src/sstr/ft_sstradd.c b/libft/src/sstr/ft_sstradd.c index fef02c2b..4e5cec45 100644 --- a/libft/src/sstr/ft_sstradd.c +++ b/libft/src/sstr/ft_sstradd.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 18:03:58 by jhalford #+# #+# */ -/* Updated: 2016/12/07 17:39:37 by jhalford ### ########.fr */ +/* Updated: 2017/03/05 15:20:02 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,11 +14,9 @@ char **ft_sstradd(char **sstr, char *new) { - int i; int size; char **newlist; - i = 0; size = 0; if (sstr) while (sstr[size]) diff --git a/libft/src/str/ft_strdup.c b/libft/src/str/ft_strdup.c index d1064ad8..b2986931 100644 --- a/libft/src/str/ft_strdup.c +++ b/libft/src/str/ft_strdup.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 14:25:41 by jhalford #+# #+# */ -/* Updated: 2017/01/10 10:56:33 by jhalford ### ########.fr */ +/* Updated: 2017/03/05 15:20:36 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,9 +15,7 @@ char *ft_strdup(const char *s1) { char *dup; - int i; - i = 0; if (!s1 || !(dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1)))) return (NULL); ft_strcpy(dup, s1); diff --git a/libft/src/sys/ft_xattr_count.c b/libft/src/sys/ft_xattr_count.c index 01b96eb5..6f928f88 100644 --- a/libft/src/sys/ft_xattr_count.c +++ b/libft/src/sys/ft_xattr_count.c @@ -6,12 +6,14 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 18:00:52 by jhalford #+# #+# */ -/* Updated: 2016/11/25 17:22:07 by jhalford ### ########.fr */ +/* Updated: 2017/03/05 15:17:57 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +#if defined __DARWIN__ + int ft_xattr_count(char *path) { ssize_t listlen; @@ -32,3 +34,28 @@ int ft_xattr_count(char *path) } return (count); } + +#else + +int ft_xattr_count(char *path) +{ + ssize_t listlen; + char list[FT_XATTR_SIZE]; + int i; + int count; + + i = 0; + ft_bzero(list, FT_XATTR_SIZE); + listlen = listxattr(path, list, FT_XATTR_SIZE); + if (listlen == -1) + return (-1); + count = 0; + while (i < listlen) + { + i += ft_strlen(list) + 1; + count++; + } + return (count); +} + +#endif diff --git a/libft/src/sys/ft_xattr_print.c b/libft/src/sys/ft_xattr_print.c index de7a009f..a1e6955f 100644 --- a/libft/src/sys/ft_xattr_print.c +++ b/libft/src/sys/ft_xattr_print.c @@ -6,12 +6,14 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 18:00:43 by jhalford #+# #+# */ -/* Updated: 2016/11/03 18:00:44 by jhalford ### ########.fr */ +/* Updated: 2017/03/05 15:17:05 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +#if defined __DARWIN__ + int ft_xattr_print(char *path) { ssize_t listlen; @@ -36,3 +38,32 @@ int ft_xattr_print(char *path) } return (0); } + +#else + +int ft_xattr_print(char *path) +{ + ssize_t listlen; + ssize_t valuelen; + char list[FT_XATTR_SIZE]; + char value[FT_XATTR_SIZE]; + int i; + + i = 0; + listlen = listxattr(path, list, FT_XATTR_SIZE); + if (listlen == -1) + return (1); + while (i < listlen) + { + valuelen = getxattr(path, list + i, value, + FT_XATTR_SIZE); + if (valuelen == -1) + ft_printf("couldn't get value\n"); + else + ft_printf("%s:\n%s\n", list + i, value); + i += ft_strlen(list) + 1; + } + return (0); +} + +#endif