merged ok

This commit is contained in:
Antoine Riard 2017-03-07 14:29:14 +01:00
commit 1fa81ff1be
11 changed files with 96 additions and 24 deletions

View file

@ -6,7 +6,7 @@
# By: jhalford <jack@crans.org> +#+ +:+ +#+ # # By: jhalford <jack@crans.org> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2017/02/07 16:09:36 by jhalford #+# #+# # # Created: 2017/02/07 16:09:36 by jhalford #+# #+# #
# Updated: 2017/03/07 11:37:58 by ariard ### ########.fr # # Updated: 2017/03/07 14:28:55 by ariard ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -17,7 +17,7 @@ AR = ar -rc
MKDIR = mkdir -p MKDIR = mkdir -p
RM = /bin/rm -rf RM = /bin/rm -rf
W_FLAGS = -Wall -Wextra -Werror W_FLAGS = -Wall -Wextra
D_FLAGS = D_FLAGS =
V_FLAGS = -fvisibility=hidden V_FLAGS = -fvisibility=hidden
FLAGS = $(W_FLAGS) $(D_FLAGS) $(V_FLAGS) FLAGS = $(W_FLAGS) $(D_FLAGS) $(V_FLAGS)
@ -38,6 +38,7 @@ btree/btree_del.c\
btree/btree_delone.c\ btree/btree_delone.c\
btree/btree_insert_data.c\ btree/btree_insert_data.c\
btree/btree_level_count.c\ btree/btree_level_count.c\
btree/btree_map.c\
btree/btree_print.c\ btree/btree_print.c\
btree/btree_search_item.c\ btree/btree_search_item.c\
char/ft_isalnum.c\ char/ft_isalnum.c\
@ -114,6 +115,7 @@ math/ft_lltoa_base.c\
math/ft_uilen.c\ math/ft_uilen.c\
math/ft_uitoa_base.c\ math/ft_uitoa_base.c\
math/ft_ulltoa_base.c\ math/ft_ulltoa_base.c\
math/id.c\
mem/ft_bzero.c\ mem/ft_bzero.c\
mem/ft_memalloc.c\ mem/ft_memalloc.c\
mem/ft_memccpy.c\ mem/ft_memccpy.c\
@ -203,14 +205,14 @@ $(NAME): $(OBJ_DIR) $(OBJS)
@$(AR) $(NAME) $(OBJS) @$(AR) $(NAME) $(OBJS)
@ranlib $(NAME) @ranlib $(NAME)
@strip -x $(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) $(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJ_DIR)
@$(eval DONE=$(shell echo $$(($(INDEX)*20/$(NB))))) @$(eval DONE=$(shell echo $$(($(INDEX)*20/$(NB)))))
@$(eval PERCENT=$(shell echo $$(($(INDEX)*100/$(NB))))) @$(eval PERCENT=$(shell echo $$(($(INDEX)*100/$(NB)))))
@$(eval COLOR=$(shell echo $$(($(PERCENT)%35+196)))) @$(eval COLOR=$(shell echo $$(($(PERCENT)%35+196))))
@$(eval TO_DO=$(shell echo $$((20-$(INDEX)*20/$(NB))))) @$(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) $(DELTA) "$@"
@$(CC) $(FLAGS) -MMD -c $< -o $@\ @$(CC) $(FLAGS) -MMD -c $< -o $@\
-I $(INC_DIR) -I $(INC_DIR)
@$(eval INDEX=$(shell echo $$(($(INDEX)+1)))) @$(eval INDEX=$(shell echo $$(($(INDEX)+1))))
@ -221,11 +223,11 @@ $(OBJ_DIR):
clean: clean:
@$(RM) $(OBJ_DIR) @$(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 fclean: clean
@$(RM) $(NAME) @$(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 re: fclean all

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/16 11:13:15 by jhalford #+# #+# */ /* Created: 2016/11/16 11:13:15 by jhalford #+# #+# */
/* Updated: 2016/12/05 11:53:30 by jhalford ### ########.fr */ /* Updated: 2017/03/07 12:16:03 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -36,6 +36,7 @@ typedef struct s_btree t_btree;
typedef struct s_printdata t_printdata; typedef struct s_printdata t_printdata;
t_btree *btree_create_node(void const *item, size_t content_size); t_btree *btree_create_node(void const *item, size_t content_size);
t_btree *btree_map(t_btree *root, void *(*f)(void *));
void btree_insert_data( void btree_insert_data(
t_btree **root, t_btree **root,
void *item, void *item,

View file

@ -1,5 +1,4 @@
/* ************************************************************************** */ /* ************************************************************************** */ /* */
/* */
/* ::: :::::::: */ /* ::: :::::::: */
/* math.h :+: :+: :+: */ /* math.h :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
@ -33,5 +32,6 @@ size_t ft_lllen(long long n);
size_t ft_lllen_base(long long n, int base); size_t ft_lllen_base(long long n, int base);
int ft_addrcmp(void *a, void *b); int ft_addrcmp(void *a, void *b);
void *id(void *data);
#endif #endif

View file

@ -0,0 +1,14 @@
#include "btree.h"
t_btree *btree_map(t_btree *root, void *(*f)(void *))
{
t_btree *new;
if (!root)
return (NULL);
new = btree_create_node(root->item, root->content_size);
new->item = (*f)(new->item);
new->left = btree_map(root->left, f);
new->right = btree_map(root->right, f);
return (new);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 16:53:07 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) void ft_fmt_validate_flags(t_fmt *fmt)
{ {
int i;
i = 0;
ft_fmt_validate_flag_conv(fmt); ft_fmt_validate_flag_conv(fmt);
ft_fmt_validate_flag_flag(fmt); ft_fmt_validate_flag_flag(fmt);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:48 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) void ft_pad_sharp_xb(char *str, t_fmt *fmt)
{ {
char start[3] = {'0',fmt->conversion, 0}; char start[3] = {'0',fmt->conversion, 0};
int i;
i = 0;
if (str[0] == '0') if (str[0] == '0')
{ {
if (str[1] == '0') if (str[1] == '0')

6
libft/src/math/id.c Normal file
View file

@ -0,0 +1,6 @@
#include "libft.h"
void *id(void *data)
{
return (data);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 18:03:58 by jhalford #+# #+# */ /* Created: 2016/11/03 18:03:58 by jhalford #+# #+# */
/* Updated: 2017/03/07 11:32:39 by ariard ### ########.fr */ /* Updated: 2017/03/07 14:28:29 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,11 +14,9 @@
char **ft_sstradd(char **sstr, char *new) char **ft_sstradd(char **sstr, char *new)
{ {
int i;
int size; int size;
char **newlist; char **newlist;
i = 0;
size = 0; size = 0;
if (sstr) if (sstr)
while (sstr[size]) while (sstr[size])

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/07 14:25:41 by jhalford #+# #+# */ /* Created: 2016/12/07 14:25:41 by jhalford #+# #+# */
/* Updated: 2017/03/07 11:05:48 by ariard ### ########.fr */ /* Updated: 2017/03/07 14:27:58 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,9 +15,7 @@
char *ft_strdup(const char *s1) char *ft_strdup(const char *s1)
{ {
char *dup; char *dup;
int i;
i = 0;
if (!s1 || !(dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1)))) if (!s1 || !(dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1))))
return (NULL); return (NULL);
ft_strcpy(dup, s1); ft_strcpy(dup, s1);

View file

@ -6,12 +6,14 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 18:00:52 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 16:48:29 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"
#if defined __APPLE__
int ft_xattr_count(char *path) int ft_xattr_count(char *path)
{ {
ssize_t listlen; ssize_t listlen;
@ -32,3 +34,28 @@ int ft_xattr_count(char *path)
} }
return (count); 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

View file

@ -6,12 +6,14 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 18:00:43 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 16:48:20 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"
#if defined __APPLE__
int ft_xattr_print(char *path) int ft_xattr_print(char *path)
{ {
ssize_t listlen; ssize_t listlen;
@ -36,3 +38,32 @@ int ft_xattr_print(char *path)
} }
return (0); 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