diff --git a/libftasm/Makefile b/libftasm/Makefile index 80bba6c0..3df2d403 100644 --- a/libftasm/Makefile +++ b/libftasm/Makefile @@ -10,10 +10,19 @@ #* *# #* ************************************************************************** *# -NAME = libft.a +SHELL := bash + +NAME = libfts.a +NASM = nasm + +UNAME_S = $(shell uname -s) +ifeq ($(UNAME_S),Linux) + FLAGS_ASM = -f elf64 +endif +ifeq ($(UNAME_S),Darwin) + FLAGS_ASM = -f macho64 +endif -CC = gcc -FLAGS = -Wall -Wextra -Werror -O3 LEN_NAME = `printf "%s" $(NAME) |wc -c` DELTA = $$(echo "$$(tput cols)-31-$(LEN_NAME)"|bc) @@ -23,201 +32,23 @@ INC_DIR = includes/ OBJ_DIR = objs/ SRC_BASE = \ -rs/rs.c\ -btree/btree_apply_by_level.c\ -btree/btree_apply_infix.c\ -btree/btree_apply_prefix.c\ -btree/btree_apply_suffix.c\ -btree/btree_create_node.c\ -btree/btree_del.c\ -btree/btree_delone.c\ -btree/btree_insert_data.c\ -btree/btree_level_count.c\ -btree/btree_map.c\ -btree/btree_print.c\ -btree/btree_search_item.c\ -char/ft_isalnum.c\ -char/ft_isalpha.c\ -char/ft_isascii.c\ -char/ft_isdigit.c\ -char/ft_isprint.c\ -char/ft_tolower.c\ -char/ft_toupper.c\ -cliopts/cliopts_get.c\ -cliopts/cliopts_getmap.c\ -color/ft_color_mk.c\ -color/ft_color_mkif.c\ -color/ft_color_reset.c\ -color/ft_color_set.c\ -dlst/ft_dlstadd_after.c\ -dlst/ft_dlstadd_before.c\ -dlst/ft_dlstdel.c\ -dlst/ft_dlstdelone.c\ -dlst/ft_dlstlast.c\ -dlst/ft_dlstnew.c\ -dlst/ft_dlstrtostr.c\ -dlst/ft_dlstsize.c\ -error/error.c\ -error/ft_usage.c\ -ft_printf/ft_conversion.c\ -ft_printf/ft_fmt_simplify.c\ -ft_printf/ft_fmt_validate_conv.c\ -ft_printf/ft_fmt_validate_flags.c\ -ft_printf/ft_fmt_validate_mod.c\ -ft_printf/ft_printf.c\ -ft_printf/ft_printf_color.c\ -ft_printf/ft_printf_parse.c\ -ft_printf/ft_transform.c\ -ft_printf/ft_vprintf.c\ -ft_printf/lib_fmt.c\ -ft_printf/lib_fmt_error.c\ -ft_printf/lib_pad.c\ -ft_printf/lib_pad_sharp.c\ -get_next_line/get_next_line.c\ -lst/ft_id.c\ -lst/ft_lst_at.c\ -lst/ft_lst_bfree.c\ -lst/ft_lst_cfree.c\ -lst/ft_lst_delif.c\ -lst/ft_lst_delsub.c\ -lst/ft_lst_filter.c\ -lst/ft_lst_filterout.c\ -lst/ft_lst_find.c\ -lst/ft_lst_merge.c\ -lst/ft_lst_order_delsub.c\ -lst/ft_lst_print.c\ -lst/ft_lst_print2.c\ -lst/ft_lst_removeif.c\ -lst/ft_lst_reverse.c\ -lst/ft_lst_size.c\ -lst/ft_lst_sorted_insert.c\ -lst/ft_lst_sorted_merge.c\ -lst/ft_lstadd.c\ -lst/ft_lstdel.c\ -lst/ft_lstdelone.c\ -lst/ft_lsteadd.c\ -lst/ft_lstiter.c\ -lst/ft_lstlast.c\ -lst/ft_lstmap.c\ -lst/ft_lstnadd.c\ -lst/ft_lstnew.c\ -lst/ft_lstnew_range.c\ -lst/ft_lstsort.c\ -lst/lst_insert_sort.c\ -lst/ft_lst_pop.c\ -lst/pop.c\ -lst/push.c\ -lst/top.c\ -lst/ft_lst2str.c\ -math/ft_addrcmp.c\ -math/ft_ilen.c\ -math/ft_ilen_base.c\ -math/ft_itoa.c\ -math/ft_itoa_base.c\ -math/ft_lllen.c\ -math/ft_lllen_base.c\ -math/ft_lltoa_base.c\ -math/ft_uilen.c\ -math/ft_uitoa_base.c\ -math/ft_ulltoa_base.c\ -math/id.c\ -mem/ft_bzero.c\ -mem/ft_malloc.c\ -mem/ft_memalloc.c\ -mem/ft_memccpy.c\ -mem/ft_memchr.c\ -mem/ft_memcmp.c\ -mem/ft_memcpy.c\ -mem/ft_memdel.c\ -mem/ft_memmove.c\ -mem/ft_memset.c\ -mem/ft_realloc.c\ -net/create_client.c\ -net/create_server.c\ -net/net_get.c\ -net/net_send.c\ -path/ft_path_notdir.c\ -printing/ft_putchar.c\ -printing/ft_putendl.c\ -printing/ft_putnbr.c\ -printing/ft_putstr.c\ -printing/hexdump.c\ -sstr/ft_sstradd.c\ -sstr/ft_sstrcat.c\ -sstr/ft_sstrdel.c\ -sstr/ft_sstrdup.c\ -sstr/ft_sstrfree.c\ -sstr/ft_sstrmerge.c\ -sstr/ft_sstrprint.c\ -sstr/ft_sstrprint_fd.c\ -sstr/ft_sstrsort.c\ -sstr/ft_sstrstr.c\ -str/ft_strsepjoin.c\ -str/ft_atoi.c\ -str/ft_convert_base.c\ -str/ft_putaddr_fd.c\ -str/ft_split_whitespaces.c\ -str/ft_str3join.c\ -str/ft_strappend.c\ -str/ft_strbetween.c\ -str/ft_strcat.c\ -str/ft_strcatf.c\ -str/ft_strchr.c\ -str/ft_strchrcpy.c\ -str/ft_strclr.c\ -str/ft_strcmp.c\ -str/ft_strcpy.c\ -str/ft_strcspn.c\ -str/ft_strcut.c\ -str/ft_strdel.c\ -str/ft_strdup.c\ -str/ft_strndup.c\ -str/ft_strdupchr.c\ -str/ft_strduptr.c\ -str/ft_strequ.c\ -str/ft_strinsert.c\ -str/ft_stris.c\ -str/ft_striter.c\ -str/ft_striteri.c\ -str/ft_strjoin.c\ -str/ft_strlcat.c\ -str/ft_strlen.c\ -str/ft_strlenchr.c\ -str/ft_strmap.c\ -str/ft_strmapi.c\ -str/ft_strncat.c\ -str/ft_strncmp.c\ -str/ft_strncpy.c\ -str/ft_strnequ.c\ -str/ft_strnew.c\ -str/ft_strnstr.c\ -str/ft_strrchr.c\ -str/ft_strreplace.c\ -str/ft_strrev.c\ -str/ft_strsplit.c\ -str/ft_strstr.c\ -str/ft_strsub.c\ -str/ft_strtok.c\ -str/ft_strtrim.c\ -time/ft_mytime_free.c\ -time/ft_mytime_get.c\ -time/ft_time_isrecent.c\ -sys/open_new.c\ -htb/ft_hash_string.c\ -htb/hashtab_init.c\ -htb/hashtab_insert.c\ -htb/hashtab_lookup.c\ -htb/hashtab_remove.c\ -htb/hashtab_destroy.c\ -htb/hashtab_print.c\ -htb/hashtab_generator.c\ -htb/hashtab_del.c\ +ft_bzero.s\ +ft_isdigit.s\ +ft_isalnum.s\ +ft_isprint.s\ +ft_isalpha.s\ +ft_isascii.s\ +ft_strcat.s\ +ft_toupper.s\ +ft_tolower.s\ +\ +ft_islower.s\ +ft_isupper.s\ SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE)) -OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o)) +OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.s=.o)) NB = $(words $(SRC_BASE)) INDEX = 0 -SHELL := /bin/bash all : @$(MAKE) -j $(NAME) @@ -230,14 +61,13 @@ $(OBJ_DIR) : @mkdir -p $(OBJ_DIR) @mkdir -p $(dir $(OBJS)) -$(OBJ_DIR)%.o : $(SRC_DIR)%.c | $(OBJ_DIR) +$(OBJ_DIR)%.o : $(SRC_DIR)%.s | $(OBJ_DIR) @$(eval DONE=$(shell echo $$(($(INDEX)*20/$(NB))))) @$(eval PERCENT=$(shell echo $$(($(INDEX)*100/$(NB))))) @$(eval TO_DO=$(shell echo $$((20-$(INDEX)*20/$(NB) - 1)))) @$(eval COLOR=$(shell list=(160 196 202 208 215 221 226 227 190 154 118 82 46); index=$$(($(PERCENT) * $${#list[@]} / 100)); echo "$${list[$$index]}")) @printf "\r\033[38;5;%dm⌛ [%s]: %2d%% `printf '█%.0s' {0..$(DONE)}`%*s❙%*.*s\033[0m\033[K" $(COLOR) $(NAME) $(PERCENT) $(TO_DO) "" $(DELTA) $(DELTA) "$(shell echo "$@" | sed 's/^.*\///')" - @$(CC) $(FLAGS) -MMD -c $< -o $@\ - -I $(INC_DIR) -lm + @$(NASM) $(FLAGS_ASM) $< -o $@ @$(eval INDEX=$(shell echo $$(($(INDEX)+1)))) clean : @@ -256,6 +86,10 @@ fclean : clean re : fclean all +main: $(NAME) main.c + @gcc main.c -I $(INC_DIR) -L. -lfts -o main -Wall -Wextra -Werror -L. -lfts -o main + @printf "\r\033[38;5;117m✓ MAKE main\033[0m\033[K\n" + .PHONY : fclean clean re -include $(OBJS:.o=.d) diff --git a/libftasm/STDBUG b/libftasm/STDBUG deleted file mode 100644 index e69de29b..00000000 diff --git a/libftasm/includes/btree.h b/libftasm/includes/btree.h deleted file mode 100644 index eede027a..00000000 --- a/libftasm/includes/btree.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/16 11:13:15 by jhalford #+# #+# */ -/* Updated: 2017/05/16 17:31:13 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef BTREE_H -# define BTREE_H - -# include "libft.h" - -struct s_btree -{ - void *item; - size_t content_size; - struct s_btree *left; - struct s_btree *right; -}; - -struct s_printdata -{ - int is_left; - int offset; - int depth; - int left; - int right; -}; - -typedef struct s_btree t_btree; -typedef struct s_printdata t_printdata; - -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( - t_btree **root, - void *item, - size_t content_size, - int (*cmpf)(void *, void *)); -void *btree_search_item(t_btree *root, - void *data_ref, int (*cmpf)(void *, void *)); -int btree_level_count(t_btree *root); -void btree_apply_prefix(t_btree *root, void (*applyf)(void *)); -void btree_apply_infix(t_btree *root, void (*applyf)(void *)); -void btree_apply_suffix(t_btree *root, void (*applyf)(void *)); -void btree_print(int fd, t_btree *tree, char *(*printer)(void *)); -void btree_del(t_btree **root, void (*del)(void *, size_t)); -void btree_delone(t_btree **root, void (*del)(void *, size_t)); - -#endif diff --git a/libftasm/includes/cliopts.h b/libftasm/includes/cliopts.h deleted file mode 100644 index 9ea82890..00000000 --- a/libftasm/includes/cliopts.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* cliopts.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/14 20:22:56 by jhalford #+# #+# */ -/* Updated: 2017/03/25 14:59:53 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef CLIOPTS_H -# define CLIOPTS_H - -# include "libft.h" -# include "error.h" - -typedef struct s_cliopts t_cliopts; -typedef struct s_data_template t_data_template; -typedef long long t_flag; - -struct s_cliopts -{ - char c; - char *str; - t_flag flag_on; - t_flag flag_off; - int (*get)(); - int arg_required:1; -}; - -struct s_data_template -{ - t_flag flag; - char **av_data; -}; - -int cliopts_get(char **av, t_cliopts opt_map[], void *data); -t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], char *arg); -t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], char arg); -int cliopts_has(char **av, char c); - -#endif diff --git a/libftasm/includes/color.h b/libftasm/includes/color.h deleted file mode 100644 index 698e6c51..00000000 --- a/libftasm/includes/color.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* color.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/25 13:36:48 by jhalford #+# #+# */ -/* Updated: 2017/02/18 20:01:33 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef COLOR_H -# define COLOR_H -# include "libft.h" - -struct s_color -{ - char fg[7]; - char bg[7]; -}; - -typedef struct s_color t_color; - -# define FG_DEFAULT "\e[0m" -# define ON_BOLD "\e[1m" - -# define ON_UNDERLINED "\e[4m" -# define ON_INVERTED "\e[7m" - -# define FG_BLACK "\e[30m" -# define FG_RED "\e[31m" -# define FG_GREEN "\e[32m" -# define FG_YELLOW "\e[33m" -# define FG_BLUE "\e[34m" -# define FG_MAGENTA "\e[35m" -# define FG_CYAN "\e[36m" - -# define BG_BLACK "\e[40m" -# define BG_RED "\e[41m" -# define BG_GREEN "\e[42m" -# define BG_YELLOW "\e[43m" -# define BG_BLUE "\e[44m" -# define BG_MAGENTA "\e[45m" -# define BG_CYAN "\e[46m" -# define BG_DEFAULT "\e[49m" - -# define FBG_DEFAULT FG_DEFAULT BG_DEFAULT - -void ft_color_reset(void); -void ft_color_set(t_color color); - -void ft_color_mk(t_color *color, char fg[7], char bg[7]); -void ft_color_mkif(t_color *color, int cond, char fg[7], char bg[7]); - -#endif diff --git a/libftasm/includes/dlst.h b/libftasm/includes/dlst.h deleted file mode 100644 index 79470a87..00000000 --- a/libftasm/includes/dlst.h +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* dlst.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:21:04 by jhalford #+# #+# */ -/* Updated: 2017/05/16 17:30:42 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef DLST_H -# define DLST_H - -struct s_dlist -{ - void *content; - size_t content_size; - struct s_dlist *next; - struct s_dlist *prev; -}; - -typedef struct s_dlist t_dlist; - -void ft_dlstadd_after(t_dlist **alst, t_dlist *new); -void ft_dlstadd_before(t_dlist **alst, t_dlist *new); -void ft_dlstdel(t_dlist **alst, void (*del)(void *, size_t)); -void ft_dlstdelone(t_dlist **alst, void (*del)(void *, size_t)); -int ft_dlstsize(t_dlist *list); -t_dlist *ft_dlstnew(void const *content, size_t content_size); -t_dlist *ft_dlstlast(t_dlist *list); -char *ft_dlsttostr(t_dlist *list); - -#endif diff --git a/libftasm/includes/error.h b/libftasm/includes/error.h deleted file mode 100644 index 3780ad8f..00000000 --- a/libftasm/includes/error.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* error.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/14 15:34:21 by jhalford #+# #+# */ -/* Updated: 2017/05/15 17:37:29 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef ERROR_H -# define ERROR_H - -# include "libft.h" -# include - -/* -** DEBUG with malloc -*/ -# define DG_MSG "{inv}{ran}%5i{yel}%21s {bol}{blu}%-3d{eoc}" -# define DG_ARGS getpid(), getpid(), ft_path_notdir(__FILE__), __LINE__ -# define DG(s, ...) ft_dprintf(STDBUG,DG_MSG s "{eoc}\n",DG_ARGS,##__VA_ARGS__) - -/* -** DEBUG with no malloc -*/ -# define DG2 ft_putstr(__FILE__"\t");ft_putnbr(__LINE__) -# define DGW(d) DG2;d;ft_putchar('\n') -# define DGS(s) DGW(ft_putstr(": "s"=")) -# define DGSN(s, n) DGW(ft_putstr(": "s"=");ft_putnbr(n)) -# define DGSH(s, n) DGW(ft_putstr(": "s"=");ft_putnbr_hex(n)) - -# define ERR_PROTO(u, m) "{red}%s: %s{eoc}\n", u, m -# define ERR_MSG(u, m) ft_dprintf(2, ERR_PROTO(u, m)) -# define ERR_SET(n, ...) error_set(n, ##__VA_ARGS__) -# define ERRMSG_MAX_SIZE 150 - -enum e_errors -{ - E_NOERR, - E_CO_INV, - E_CO_INVL, - E_CO_MULT, - E_CO_MISS, - E_CO_MISSL, - E_SYS_NOFILE, - E_SYS_ISDIR, - E_SYS_NOPERM, - E_MAX, -}; - -extern char g_error_msg[E_MAX][ERRMSG_MAX_SIZE]; -extern char *g_errmsg; -extern int g_errnum; -extern char **g_argv; - -int error_set(int n, ...); -int ft_perror(char *utility); -void ft_usage(char *format, ...); - -#endif diff --git a/libftasm/includes/ft_printf.h b/libftasm/includes/ft_printf.h deleted file mode 100644 index e9299538..00000000 --- a/libftasm/includes/ft_printf.h +++ /dev/null @@ -1,80 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ftprintf.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:22:54 by jhalford #+# #+# */ -/* Updated: 2017/03/20 09:23:06 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef FT_PRINTF_H -# define FT_PRINTF_H - -# include "libft.h" -# include - -# define ALL_FLAGS "#0- +" -# define ALL_CONVERSIONS "sSpdDioOuUxXcCb" - -typedef struct s_fmt t_fmt; -typedef struct s_conv t_conv; -typedef char *(t_converter)(t_fmt *fmt, va_list ap); -typedef void (t_pad_func)(char *str, t_fmt *fmt); - -struct s_conv -{ - char id; - char allowed_flags[6]; - char base[20]; - t_converter *converter; - t_pad_func *sharp_func; -}; - -struct s_fmt -{ - char flags[6]; - int width; - int precision; - char modifier[3]; - char conversion; - int valid; - t_conv conv; - -}; - -int ft_vdprintf(int fd, const char *format, va_list ap); -int ft_fmtcalc(char **final, char **str, va_list ap); - -extern t_conv g_convs[]; - -t_fmt *ft_fmt_init(void); -void ft_fmt_print(t_fmt *fmt); -void ft_printf_color(char **final, char **str, va_list ap); -t_fmt *ft_printf_parse(char **format, va_list ap); - -char *ft_transform(t_fmt *fmt, va_list ap); - -void ft_fmt_error_conv(char conv); -void ft_fmt_error_mod_conv(char *mod, char conv); -void ft_fmt_error_flag_conv(char flag, char conv); -void ft_fmt_error_flag_flag(char flag1, char flag2); - -void ft_fmt_simplify(t_fmt *fmt); -int ft_fmt_validate_conv(t_fmt *fmt); -void ft_fmt_validate_flags(t_fmt *fmt); -void ft_fmt_validate_mod(t_fmt *fmt); - -char *ft_signed_conversion(t_fmt *fmt, va_list ap); -char *ft_unsigned_conversion(t_fmt *fmt, va_list ap); -char *ft_str_conversion(t_fmt *fmt, va_list ap); -char *ft_char_conversion(t_fmt *fmt, va_list ap); - -void ft_pad_sharp_o(char *str, t_fmt *fmt); -void ft_pad_sharp_xb(char *str, t_fmt *fmt); -void ft_pad_left(char *str, t_fmt *fmt); -void ft_pad_right(char *str, t_fmt *fmt); - -#endif diff --git a/libftasm/includes/ft_types.h b/libftasm/includes/ft_types.h deleted file mode 100644 index a8f001cc..00000000 --- a/libftasm/includes/ft_types.h +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_types.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/25 01:56:58 by jhalford #+# #+# */ -/* Updated: 2017/03/25 02:02:06 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef FT_TYPES_H -# define FT_TYPES_H - -typedef struct s_stos t_stos; -typedef struct s_stof t_stof; -typedef struct s_itof t_itof; -typedef long long int t_flag; -typedef long long int t_type; - -#endif diff --git a/libftasm/includes/get_next_line.h b/libftasm/includes/get_next_line.h deleted file mode 100644 index b63d0ac2..00000000 --- a/libftasm/includes/get_next_line.h +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* get_next_line.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/05 12:21:36 by jhalford #+# #+# */ -/* Updated: 2016/12/15 13:07:58 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef GET_NEXT_LINE_H -# define GET_NEXT_LINE_H -# define BUFF_SIZE 32 - -# include "libft.h" -# include -# include - -typedef struct s_save t_save; - -struct s_save -{ - int fd; - char *str; -}; - -int get_next_line(int const fd, char **line); - -#endif diff --git a/libftasm/includes/hashtab.h b/libftasm/includes/hashtab.h deleted file mode 100644 index 0cb7c7a7..00000000 --- a/libftasm/includes/hashtab.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hashtab.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/05/15 19:16:49 by ariard #+# #+# */ -/* Updated: 2017/06/22 20:25:20 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef HASHTAB_H -# define HASHTAB_H - -# include "libft.h" - -struct s_hashtab -{ - int capacity; - int size; - int (*hashfunc)(const void *key, int capacity); - struct s_list **head; -}; - -typedef struct s_hashtab t_hashtab; - -void hashtab_init(t_hashtab *htb, int capacity, - int (*hashfunc)(const void *key, int size)); - -int hashtab_insert(t_hashtab *htb, struct s_list *new, void *key, - int (*match)(const void *data_ref, const void *key)); - -struct s_list *hashtab_lookup(t_hashtab *htb, void *key, - int (*match)(const void *data_ref, const void *key)); - -struct s_list *hashtab_remove(t_hashtab *htb, void *key, - int (*match)(const void *data_ref, const void *key)); - -void hashtab_destroy(t_hashtab *htb, void (*destroy)()); - -void hashtab_print(t_hashtab *htb, int (*printer)()); - -int ft_hash_string(const void *key, int size); - -struct s_list *hashtab_iterator(t_hashtab *htb, char init); - -void hashtab_del(t_hashtab *htb, void *key, - int (*match)(const void *, const void *), - void (*del)(void *, size_t)); - -#endif diff --git a/libftasm/includes/libft.h b/libftasm/includes/libft.h deleted file mode 100644 index 27c04598..00000000 --- a/libftasm/includes/libft.h +++ /dev/null @@ -1,97 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* libft.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */ -/* Updated: 2017/05/16 17:47:18 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef LIBFT_H -# define LIBFT_H - -# define FT_TRY(a,b) ((a) ? (a) : (b)) - -# include -# include -# include -# include -# include -# include - -# include "ft_types.h" -# include "error.h" -# include "color.h" -# include "cliopts.h" -# include "rs.h" - -# include "lst.h" -# include "dlst.h" -# include "btree.h" -# include "hashtab.h" - -# include "str.h" -# include "sstr.h" -# include "math.h" -# include "mytime.h" -# include "get_next_line.h" -# include "net.h" -# include "sys.h" - -struct s_stos -{ - char *key; - char *val; -}; - -struct s_stof -{ - char *key; - int (*f)(); -}; - -struct s_itof -{ - int id; - int (*f)(); -}; - -int ft_printf(const char *format, ...); -int ft_dprintf(int fd, const char *format, ...); -int ft_vdprintf(int fd, const char *format, va_list ap); -int ft_asprintf(char **ret, const char *format, ...); -int ft_vasprintf(char **ret, const char *format, va_list ap); - -void *ft_malloc(size_t size); -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); -void *ft_memalloc(size_t size); -void ft_memdel(void **ap); - -int ft_putchar(int c); -int ft_putstr(char const *s); -int ft_putendl(char const *s); -int ft_putnbr(long n); -int ft_putnbr_hex(long n); - -int ft_error_message(char *message); - -int ft_putchar_fd(int c, int fd); -int ft_putstr_fd(char const *s, int fd); -int ft_putendl_fd(char const *s, int fd); -int ft_putnbr_fd(long n, int fd); -int ft_putnbr_hex_fd(long n, int fd); - -void hexdump(void *pAddressIn, long lSize); - -void *ft_realloc(void *data, int size); - -#endif diff --git a/libftasm/includes/lst.h b/libftasm/includes/lst.h deleted file mode 100644 index 17b91150..00000000 --- a/libftasm/includes/lst.h +++ /dev/null @@ -1,94 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lst.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */ -/* Updated: 2017/05/20 20:01:20 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef LST_H -# define LST_H - -# include "libft.h" - -struct s_list -{ - void *content; - size_t content_size; - struct s_list *next; -}; - -typedef struct s_list t_list; - -int pop(t_list **lst); -t_list *push(t_list **stack, int elem); - -t_list *ft_lstnew(void const *content, size_t content_size); -void ft_lstdel(t_list **alst, void (*del)(void *, size_t)); -void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)); -void ft_lstadd(t_list **alst, t_list *new); -int ft_lstiter(t_list *lst, int (*f)(), void *data); -t_list *ft_lstmap(t_list *lst, void *(*f)(void *)); - -t_list *ft_lstnew_range(int a, int b); -void ft_lsteadd(t_list **alst, t_list *new); -void ft_lstnadd(t_list **alst, t_list *new, int n); -void ft_lstsort(t_list **begin_list, int (*cmp)()); -void ft_lst_print(t_list *list, void (*printer)()); -int ft_lstsize(t_list *lst); -t_list *ft_lstlast(t_list *lst); -void ft_lst_sorted_merge( - t_list **begin_list1, - t_list *begin_list2, - int (*cmp)()); -void ft_lst_sorted_insert( - t_list **begin_list, - t_list *insert, - int (*cmp)()); -void ft_lst_delif( - t_list **alist, - void *data_ref, - int (*cmp)(), - void (*del)(void *, size_t)); -void ft_lst_delsub( - t_list **alst, - t_list *sub, int (*cmp)(), - void (*del)(void *, size_t)); -void ft_lst_cfree(void *ptr, size_t size); -void ft_lst_bfree(void *ptr, size_t size); -t_list *ft_lst_filter( - t_list *lst, - void const *data_ref, - t_list *(*f)(t_list *elem, void const *)); -t_list *ft_lst_removeif( - t_list **alst, - void *data_ref, - int (*cmp)()); -t_list *ft_lst_find( - t_list *begin_list, - void *data_ref, - int (*cmp)()); -t_list *ft_lstpop(t_list **lst); -void ft_lst_merge(t_list **begin_list1, t_list *begin_list2); -void ft_lst_reverse(t_list **begin_list); -void ft_lst_filterout( - t_list **alst, - void *data_ref, - int (*cmp)(), - void (*del)(void *, size_t)); - -int ft_diff(void *a, void *b); -t_list *ft_id(t_list *a); -t_list *ft_lst_at(t_list *list, unsigned int nbr); - -void lst_insert_sort(t_list **head, - int (cmp)()); - -t_list *ft_lst_pop(t_list **lst); -char *ft_lst2str(t_list *list); - -#endif diff --git a/libftasm/includes/math.h b/libftasm/includes/math.h deleted file mode 100644 index 4b87935e..00000000 --- a/libftasm/includes/math.h +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* math.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/20 15:41:59 by jhalford #+# #+# */ -/* Updated: 2017/05/16 17:30:35 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef MATH_H -# define MATH_H - -# define FT_WS(x) (x == ' ' || x == '\t' || x == '\n') -# define FT_ABS(x) (((x) < 0) ? -(x) : (x)) -# define FT_NEG(x) ((x) < 0) -# define FT_POS(x) ((x) > 0) -# define FT_MIN(a, b) ((a) < (b) ? (a) : (b)) -# define FT_MAX(a, b) ((a) > (b) ? (a) : (b)) -# define FT_DIST(a, b) FT_ABS((a) - (b)) - -char *ft_itoa(int n); -char *ft_itoa_base(int nbr, char *base, char *flags); -char *ft_lltoa_base(long long nbr, char *base, char *flags); -char *ft_ulltoa_base(unsigned long long nbr, char *base); -char *ft_uitoa_base(unsigned int nbr, char *base); -size_t ft_ilen(int n); -size_t ft_ilen_base(int n, int base); -size_t ft_uilen(unsigned int n); -size_t ft_lllen(long long n); -size_t ft_lllen_base(long long n, int base); - -int ft_addrcmp(void *a, void *b); -void *id(void *data); - -#endif diff --git a/libftasm/includes/mytime.h b/libftasm/includes/mytime.h deleted file mode 100644 index 61444457..00000000 --- a/libftasm/includes/mytime.h +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* mytime.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/25 11:43:12 by jhalford #+# #+# */ -/* Updated: 2017/02/18 13:11:26 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef MYTIME_H -# define MYTIME_H -# include "libft.h" - -struct s_mytime -{ - char *year; - char *month; - char *day; - char *hour; - char *min; - char *sec; -}; - -typedef struct s_mytime t_mytime; - -int ft_time_isrecent(time_t event); - -t_mytime *ft_mytime_get(time_t epoch); -void ft_mytime_free(t_mytime **time); - -#endif diff --git a/libftasm/includes/net.h b/libftasm/includes/net.h deleted file mode 100644 index 91698c7f..00000000 --- a/libftasm/includes/net.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef NET_H -# define NET_H - -# define ACK 2 -# define NACK 3 -# define NET_MAXSIZE 512 - -# include -# include -# include -# include - -int create_server(int port, int backlog, char *protoname); -int create_client(char *addr, int port, char *protoname); -void listener(int domain, int sock, int proto, void (*handler)(void *buf, int bytes, struct sockaddr_in *addr)); - -int net_send(int sock, char *msg, int size); -int net_send_large(int sock, char *msg, int size); -int net_get(int sock, char *msg, int size); -int net_get_fd(int sock, int fd, int size); -int net_get_large(int sock, int fd); - -#endif diff --git a/libftasm/includes/rs.h b/libftasm/includes/rs.h deleted file mode 100644 index c5b716e4..00000000 --- a/libftasm/includes/rs.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef LIBFT_RS_H -# define LIBFT_RS_H - -#include -#include - -extern struct s_stats { - int count; - double min; - double max; - double avg; - double m; - double stdev; - double var; -} g_rs; - -void rs_clear(); -void rs_push(double n); -void rs_calcmore(); - -#endif diff --git a/libftasm/includes/sstr.h b/libftasm/includes/sstr.h deleted file mode 100644 index b1f10bc2..00000000 --- a/libftasm/includes/sstr.h +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* sstr.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/02/18 13:16:25 by jhalford #+# #+# */ -/* Updated: 2017/03/24 17:46:36 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef SSTR_H -# define SSTR_H - -char **ft_sstradd(char **list, char *new); -void ft_sstrsort(char **list, int (*cmp)()); -void ft_sstrprint(char **list, char sep); -void ft_sstrprint_fd(int fd, char **list, char sep); -char **ft_sstrdup(char **list); -char **ft_sstrmerge(char **s1, char **s2); -void ft_sstrdel(char **sstr, int index); -void ft_sstrfree(char **sstr); -char *ft_sstrcat(char **sstr, char sep); -char *ft_sstrstr(char **sstr, char *find); - -#endif diff --git a/libftasm/includes/str.h b/libftasm/includes/str.h deleted file mode 100644 index 0d08a4b6..00000000 --- a/libftasm/includes/str.h +++ /dev/null @@ -1,78 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* str.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/02/18 13:05:53 by jhalford #+# #+# */ -/* Updated: 2017/03/07 11:36:58 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef STR_H -# define STR_H - -int ft_isalpha(int c); -int ft_isdigit(int c); -int ft_isalnum(int c); -int ft_isascii(int c); -int ft_isprint(int c); -int ft_toupper(int c); -int ft_tolower(int c); - -size_t ft_strlen(const char *s); -size_t ft_strlenchr(const char *s, char c); -char *ft_strdup(const char *s1); -char *ft_strdupchr(const char *str, char c); -char *ft_strduptr(char *str, int (*is)(int c)); -char *ft_strcpy(char *dst, const char *src); -char *ft_strncpy(char *dst, const char *src, size_t len); -char *ft_strchrcpy(char *dst, const char *str, char c); -char *ft_strcat(char *s1, const char *s2); -char *ft_strncat(char *s1, const char *s2, size_t n); -size_t ft_strlcat(char *dst, const char *src, size_t size); -char *ft_strchr(const char *s, int c); -char *ft_strrchr(const char *s, int c); -char *ft_strstr(const char *big, const char *little); -char *ft_strnstr(const char *big, const char *little, size_t len); -int ft_strcmp(const char *s1, const char *s2); -int ft_strncmp(const char *s1, const char *s2, size_t n); -int ft_atoi(const char *str); - -char *ft_strnew(size_t size); -void ft_strdel(char **as); -void ft_strclr(char *s); -void ft_striter(char *s, void (*f)(char *)); -void ft_striteri(char *s, void (*f)(unsigned int, char *)); -char *ft_strmap(char const *s, char (*f)(char)); -char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); -int ft_strequ(char const *s1, char const *s2); -int ft_strnequ(char const *s1, char const *s2, size_t n); -char *ft_strsub(char const *s, unsigned int start, size_t len); -char *ft_strjoin(char const *s1, char const *s2); -char *ft_strsepjoin(char **tab, char sep); -char *ft_strtrim(char const *s); -char **ft_strsplit(char const *s, char c); - -char *ft_strrev(char *str); -char **ft_strsplit(char const *s, char c); -char *ft_str3join(char const *s1, char const *s2, char const *s3); -char *ft_strcut(char *str, char *cut); -char **ft_split_whitespaces(char const *str); -char *ft_convert_base( - char *str, char *base_from, char *base_to, char *flags); -char *ft_strcatf(char *s1, const char *s2); -char *ft_strinsert(char *str, char c, int n); -int ft_strappend(char **dst, char *src); -char *ft_strbetween(char *start, char *end); -char *ft_strreplace(char **str, char *start, char *end, char *new); -char *ft_strtok(char *s, const char *delim); -size_t ft_strcspn(char *s, const char *delim); - -char *ft_path_notdir(char *path); -int ft_stris(char *str, int (*f)()); - -char *ft_strndup(const char *s1, size_t n); - -#endif diff --git a/libftasm/includes/sys.h b/libftasm/includes/sys.h deleted file mode 100644 index c945ead7..00000000 --- a/libftasm/includes/sys.h +++ /dev/null @@ -1,46 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* sys.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/14 17:24:23 by jhalford #+# #+# */ -/* Updated: 2017/05/16 17:30:50 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef SYS_H -# define SYS_H - -# define FT_XATTR_SIZE 10000 -# define STDIN STDIN_FILENO -# define STDOUT STDOUT_FILENO -# define STDERR STDERR_FILENO -# define STDBUG 9 - -# define PIPE_READ 0 -# define PIPE_WRITE 1 - -# include -# include -/* # if HAVE_SYS_ACL_H */ -/* # include */ -/* # endif */ -# include -# include - -/* int ft_xattr_print(char *path); */ -/* int ft_xattr_count(char *path); */ - -/* char *ft_getenv(char **env, char *key); */ - -/* int open_access(char *file, t_flag a_flag, t_flag o_flag, t_flag o_perm); */ -int open_new(char *filename, int oflag); -/* int is_directory(const char *path); */ -/* char *create_directory(const char *path, const char *old_pathnames); */ - -/* int dup2_close(int fd1, int fd2); */ -/* int fd_replace(int fd1, int fd2); */ - -#endif diff --git a/libftasm/libft.h b/libftasm/libft.h new file mode 100644 index 00000000..4ecd06d6 --- /dev/null +++ b/libftasm/libft.h @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include +#include + +/* +** PART_1 +*/ +void ft_bzero(void *i, size_t t); +char *ft_strcat(char *c, char *d); +int ft_isalpha(int i); +int ft_isdigit(int i); +int ft_isalnum(int i); +int ft_isascii(int i); +int ft_isprint(int i); +int ft_toupper(int i); +int ft_tolower(int i); +int ft_puts(char *s); +/* +** PART_2 +*/ +int ft_strlen(char *s); +void *ft_memset(void *b, int c, size_t len); +void *ft_memcpy(void *dest, const void *src, size_t n); +char *ft_strdup(const char *s1); +/* +** PART_3 +*/ +void ft_cat(int fd); +/* +** PART_BONUS +*/ +int ft_isupper(int i); +int ft_islower(int i); +int ft_putchar(int i); + diff --git a/libftasm/main.c b/libftasm/main.c new file mode 100644 index 00000000..2bda6a5c --- /dev/null +++ b/libftasm/main.c @@ -0,0 +1,502 @@ + +#include "libft.h" +#include + +int ft_putstr(const char *str) +{ + return (write(1, str, strlen(str))); +} + +/* int ft_putchar(const char c) */ +/* { */ +/* return (write(1, &c, 1)); */ +/* } */ + +int ft_putnstr(const char *str, size_t n) +{ + return (write(1, str, n)); +} + +int test_bzero() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char str[] = "Bonjour je suis une chaine de char!\n"; + char str_cmp[] = "Bonjour je suis une chaine de char!\n"; + int len = strlen(str); + int result = 0; + int i; + + ft_bzero(NULL, 250); + + bzero(str_cmp, 1); + ft_bzero(str, 1); + i = -1; + ++result; + while (++i < len) + { + if (str[i] != str_cmp[i]) + { + printf("Failed[%d]: %c vs %c at pos: %d\n", result, str[i], str_cmp[i], i); + ft_putnstr(str, len); + ft_putnstr(str_cmp, len); + return(1); + } + } + bzero(str_cmp + 5, 4); + ft_bzero(str + 5, 4); + ++result; + i = -1; + while (++i < len) + { + if (str[i] != str_cmp[i]) + { + printf("Failed[%d]: %c vs %c at pos: %d\n", result, str[i], str_cmp[i], i); + ft_putnstr(str, len); + ft_putnstr(str_cmp, len); + return(1); + } + } + bzero(str_cmp + 2, len - 3); + ft_bzero(str + 2, len - 3); + ++result; + i = -1; + while (++i < len) + { + if (str[i] != str_cmp[i]) + { + printf("Failed[%d]: %c vs %c at pos: %d\n", result, str[i], str_cmp[i], i); + ft_putnstr(str, len); + ft_putnstr(str_cmp, len); + return(1); + } + } + return (0); +} + +int test_strcat() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char str[20] = "first_"; + char str2[] = "second\n"; + char str_cmp[20] = "first_"; + char str_cmp2[] = "second\n"; + int len = 20; + int i; + + strcat(str_cmp, str_cmp2); + ft_strcat(str, str2); + i = -1; + while (++i < len) + { + if (str[i] != str_cmp[i]) + { + printf("Failed: %c vs %c at pos: %d\n", str[i], str_cmp[i], i); + ft_putnstr(str, len); + ft_putnstr(str_cmp, len); + return(1); + } + } + return (0); +} + +int test_isalpha() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char a = -1; + int ret, ret_cmp; + while (++a < 127) + { + if ((ret = ft_isalpha(a) == 0) != (ret_cmp = isalpha(a) == 0)) + { + printf("FAILED: %c [%d] => %d vs %d\n", a, a, ret, ret_cmp); + return (1); + } + } + return (0); +} + +int test_isdigit() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char a = -1; + int ret, ret_cmp; + while (++a < 127) + { + if ((ret = ft_isdigit(a) == 0) != (ret_cmp = isdigit(a) == 0)) + { + printf("FAILED: %c [%d] => %d vs %d\n", a, a, ret, ret_cmp); + return(1); + } + } + return (0); +} + +int test_isascii() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char a = -1; + int ret, ret_cmp; + while (++a < 127) + { + if ((ret = ft_isascii(a) == 0) != (ret_cmp = isascii(a) == 0)) + { + printf("FAILED: %c [%d] => %d vs %d\n", a, a, ret, ret_cmp); + return(1); + } + } + return (0); +} + +int test_isalnum() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char a = -1; + int ret, ret_cmp; + while (++a < 127) + { + if ((ret = ft_isalnum(a) == 0) != (ret_cmp = isalnum(a) == 0)) + { + printf("FAILED: %c [%d] => %d vs %d\n", a, a, ret, ret_cmp); + return(1); + } + } + return (0); +} + +int test_isprint() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char a = -1; + int ret, ret_cmp; + while (++a < 127) + { + if ((ret = ft_isprint(a) == 0) != (ret_cmp = isprint(a) == 0)) + { + printf("FAILED: %c [%d] => %d vs %d\n", a, a, ret, ret_cmp); + return(1); + } + } + return (0); +} + +int test_toupper() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char a = -1; + while (++a < 127) + { + if (ft_toupper(a) != toupper(a)) + { + printf("FAILED: %c [%d]\n", a, a); + return(1); + } + } + return (0); +} + +int test_tolower() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char a = -1; + while (++a < 127) + { + if (ft_tolower(a) != tolower(a)) + { + printf("FAILED: %c [%d]\n", a, a); + return(1); + } + } + return (0); +} + +/* int test_puts() */ +/* { */ +/* ft_putstr(__func__); ft_putstr(":\n"); */ +/* char str[] = "It's a char line you have to print. Not this one"; */ +/* str[35] = 0; */ +/* int ret, ret_cmp; */ +/* /1* ft_putstr("Original:"); ret_cmp = puts(str); *1/ */ +/* ft_putstr("Notre___:|"); ft_puts(NULL);ft_putstr("|\n"); */ +/* ft_putstr("Notre___:|"); ret = ft_puts(str);ft_putstr("|\n"); */ +/* ft_putstr("Original:|"); ret_cmp = puts(str);ft_putstr("|\n"); */ +/* if (ret != ret_cmp) */ +/* { */ +/* printf("FAILED: %d vs %d\n", ret, ret_cmp); */ +/* return (1); */ +/* } */ +/* return (0); */ +/* } */ + +/* int test_strlen() */ +/* { */ +/* ft_putstr(__func__); ft_putstr(":\n"); */ +/* char str[] = "zagaga"; */ +/* int ret, ret_cmp; */ +/* ret = ft_strlen(str); */ +/* ret_cmp = strlen(str); */ +/* if (ret != ret_cmp) */ +/* { */ +/* printf("FAILED: %d vs %d (on %s)", ret, ret_cmp, str); */ +/* return (1); */ +/* } */ +/* ret = ft_strlen(NULL); */ +/* ret_cmp = 0; */ +/* if (ret != ret_cmp) */ +/* { */ +/* printf("FAILED: %d vs %d (on nullptr)", ret, ret_cmp); */ +/* return (1); */ +/* } */ +/* return (0); */ +/* } */ + +/* int test_memset() */ +/* { */ +/* ft_putstr(__func__); ft_putstr(":\n"); */ +/* char a = -1; */ +/* char str[] = "Bonjour je suis une chaine de char!\n"; */ +/* char str_cmp[] = "Bonjour je suis une chaine de char!\n"; */ +/* char *ret, *ret_cmp; */ +/* int len = strlen(str); */ +/* int result = 0; */ +/* int i; */ + +/* while (++a < 127) */ +/* { */ +/* ++result; */ +/* if (ft_memset(NULL, a, 250) != NULL) */ +/* { */ +/* printf("Failed[%d]: memset on NULL\n", result); */ +/* return (1); */ +/* } */ +/* ret_cmp = memset(str_cmp, a, 1); */ +/* ret = ft_memset(str, a, 1); */ +/* i = -1; */ +/* ++result; */ +/* while (++i < len) */ +/* { */ +/* if (ret[i] != ret_cmp[i]) */ +/* { */ +/* ft_putnstr(ret, len); */ +/* ft_putnstr(ret_cmp, len); */ +/* printf("Failed[%d]: %c vs %c at pos: %d/%d\n", result, ret[i], ret_cmp[i], i, len); */ +/* return(1); */ +/* } */ +/* } */ +/* ret_cmp = memset(str_cmp + 5, a, 4); */ +/* ret = ft_memset(str + 5, a, 4); */ +/* ++result; */ +/* i = -1; */ +/* while (++i < (len - 5)) */ +/* { */ +/* if (ret[i] != ret_cmp[i]) */ +/* { */ +/* ft_putnstr(ret, len); */ +/* ft_putnstr(ret_cmp, len); */ +/* printf("Failed[%d]: %c vs %c at pos: %d/%d\n", result, ret[i], ret_cmp[i], i, len); */ +/* return(1); */ +/* } */ +/* } */ +/* ret_cmp = memset(str_cmp + 2, a, len - 3); */ +/* ret = ft_memset(str + 2, a, len - 3); */ +/* ++result; */ +/* i = -1; */ +/* while (++i < (len - 2)) */ +/* { */ +/* if (ret[i] != ret_cmp[i]) */ +/* { */ +/* ft_putnstr(ret, len); */ +/* ft_putnstr(ret_cmp, len); */ +/* printf("Failed[%d]: %c vs %c at pos: %d/%d\n", result, ret[i], ret_cmp[i], i, len); */ +/* return(1); */ +/* } */ +/* } */ +/* } */ +/* return (0); */ +/* } */ + +/* int test_memcpy() */ +/* { */ +/* ft_putstr(__func__); ft_putstr(":\n"); */ +/* char str[] = "Bonjour je suis une chaine de char!\n"; */ +/* char str_cmp[] = "Bonjour je suis une chaine de char!\n"; */ +/* char ret[100], ret_cmp[100]; */ +/* char *me, *cmp; */ +/* int len = strlen(str); */ +/* int result = 0; */ +/* int i; */ + +/* ++result; */ +/* if (ft_memcpy(NULL, str, 250) != NULL) */ +/* { */ +/* printf("Failed[%d]: memcpy on NULL\n", result); */ +/* return (1); */ +/* } */ +/* ++result; */ +/* if (ft_memcpy(ret, NULL, 250) != NULL) */ +/* { */ +/* printf("Failed[%d]: memcpy on NULL\n", result); */ +/* return (1); */ +/* } */ +/* cmp = memcpy(ret_cmp, str_cmp, len); */ +/* me = ft_memcpy(ret, str, len); */ +/* i = -1; */ +/* ++result; */ +/* while (++i < len) */ +/* { */ +/* if (me[i] != cmp[i]) */ +/* { */ +/* ft_putnstr(ret, len); */ +/* ft_putnstr(ret_cmp, len); */ +/* printf("Failed[%d]: %c vs %c at pos: %d/%d\n", result, me[i], cmp[i], i, len); */ +/* return(1); */ +/* } */ +/* } */ +/* memcpy(ret_cmp + len, str_cmp, len); */ +/* ft_memcpy(ret + len, str, len); */ +/* i = -1; */ +/* ++result; */ +/* while (++i < 2 * len) */ +/* { */ +/* if (me[i] != cmp[i]) */ +/* { */ +/* ft_putnstr(ret, 2 * len); */ +/* ft_putnstr(ret_cmp, 2 * len); */ +/* printf("Failed[%d]: %c vs %c at pos: %d/%d\n", result, me[i], cmp[i], i, 2 * len); */ +/* return(1); */ +/* } */ +/* } */ +/* return (0); */ +/* } */ + +/* int test_strdup() */ +/* { */ +/* ft_putstr(__func__); ft_putstr(":\n"); */ +/* char *str; */ +/* char *str_cmp; */ +/* int len, len_cmp; */ +/* int i; */ +/* if ((str = ft_strdup(NULL)) != NULL) */ +/* { */ +/* printf("FAILED: not support NULL\n"); */ +/* return (1); */ +/* } */ +/* str = ft_strdup("Coucou"); */ +/* str_cmp = strdup("Coucou"); */ +/* len = strlen(str); */ +/* len_cmp = strlen(str_cmp); */ +/* if (len != len_cmp) */ +/* { */ +/* printf("FAILED: len is %d vs %d\n", len, len_cmp); */ +/* return (1); */ +/* } */ +/* i = -1; */ +/* while (++i < len) */ +/* { */ +/* if (str[i] != str_cmp[i]) */ +/* { */ +/* ft_putnstr(str, len); */ +/* ft_putnstr(str_cmp, len); */ +/* printf("FAILED: %c vs %c\n", str[i], str_cmp[i]); */ +/* return (1); */ +/* } */ +/* } */ +/* free(str); */ +/* free(str_cmp); */ + +/* return (0); */ +/* } */ + +/* int test_cat(char ** argv) */ +/* { */ +/* ft_putstr(__func__); ft_putstr(":\n"); */ +/* ft_putstr("Wait for a user input:\n"); */ +/* ft_cat(0); */ +/* ft_cat(open(__FILE__, O_RDONLY)); */ +/* ft_cat(open(argv[0], O_RDONLY)); */ +/* ft_cat(-42); */ +/* return (0); */ +/* } */ + +int test_isupper() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char a = -1; + int ret, ret_cmp; + while (++a < 127) + { + if ((ret = ft_isupper(a) == 0) != (ret_cmp = isupper(a) == 0)) + { + printf("FAILED: %c [%d] => %d vs %d\n", a, a, ret, ret_cmp); + return(1); + } + } + return (0); +} + +int test_islower() +{ + ft_putstr(__func__); ft_putstr(":\n"); + char a = -1; + int ret, ret_cmp; + while (++a < 127) + { + if ((ret = ft_islower(a) == 0) != (ret_cmp = islower(a) == 0)) + { + printf("FAILED: %c [%d] => %d vs %d\n", a, a, ret, ret_cmp); + return(1); + } + } + return (0); +} + +/* int test_putchar() */ +/* { */ +/* ft_putstr(__func__); ft_putstr(":\n"); */ +/* int a = -500; */ +/* int ret, ret_cmp; */ +/* while (++a < 500) */ +/* { */ +/* if ((ret = ft_putchar(a)) != (ret_cmp = putchar(a))) */ +/* { */ +/* printf("FAILED: %c [%d] => %d vs %d\n", a, a, ret, ret_cmp); */ +/* return(1); */ +/* } */ +/* } */ + +/* return (0); */ +/* } */ + + +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + ft_putstr("PART 1:\n_______\n"); + if (test_bzero() || + test_isdigit() || + test_isalpha() || + test_strcat() || + test_isascii() || + test_isalnum() || + test_isprint() || + test_toupper() || + test_tolower()) + /* test_puts()) */ + return (1); + /* ft_putstr("\nPART 2:\n_______\n"); */ + /* if (test_strlen() || */ + /* test_memset() || */ + /* test_memcpy() || */ + /* test_strdup()) */ + /* return (1); */ + /* ft_putstr("\nPART 3:\n_______\n"); */ + /* /1* if (test_cat(argv)) *1/ */ + /* /1* return (1); *1/ */ + ft_putstr("\nPART BONUS:\n_______\n"); + if (test_isupper() || + test_islower()) + /* test_putchar()) */ + /* return (1); */ + puts("\033c\n\033[38;5;117mALL PASSED:\n___________\n\033[0m"); + return (0); +} diff --git a/libftasm/srcs/btree/btree_apply_by_level.c b/libftasm/srcs/btree/btree_apply_by_level.c deleted file mode 100644 index 14e537f7..00000000 --- a/libftasm/srcs/btree/btree_apply_by_level.c +++ /dev/null @@ -1,46 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_apply_by_level.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/19 12:06:15 by jhalford #+# #+# */ -/* Updated: 2017/03/14 17:25:46 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -int g_level = 0; - -static void btree_apply_to_level( - t_btree *root, - int level, - int is_first_elem, - void (*applyf)(void *item, int current_level, int is_first_elem)) -{ - if (level == g_level) - { - (*applyf)(root->item, level, is_first_elem); - return ; - } - if (root->left) - btree_apply_to_level(root->left, level + 1, is_first_elem, applyf); - if (root->right) - btree_apply_to_level(root->right, level + 1, 0, applyf); -} - -void btree_apply_by_level( - t_btree *root, - void (*applyf)(void *item, int current_level, int is_first_elem)) -{ - int height; - - height = btree_level_count(root); - while (g_level < height) - { - btree_apply_to_level(root, 0, 1, applyf); - g_level++; - } -} diff --git a/libftasm/srcs/btree/btree_apply_infix.c b/libftasm/srcs/btree/btree_apply_infix.c deleted file mode 100644 index 93a18b7d..00000000 --- a/libftasm/srcs/btree/btree_apply_infix.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_create_node.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */ -/* Updated: 2017/03/06 18:22:31 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -void btree_apply_infix(t_btree *root, void (*applyf)(void *)) -{ - if (root->left) - btree_apply_infix(root->left, applyf); - (*applyf)(root->item); - if (root->right) - btree_apply_infix(root->right, applyf); - return ; -} diff --git a/libftasm/srcs/btree/btree_apply_prefix.c b/libftasm/srcs/btree/btree_apply_prefix.c deleted file mode 100644 index e7e4332c..00000000 --- a/libftasm/srcs/btree/btree_apply_prefix.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_create_node.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */ -/* Updated: 2016/08/18 21:06:44 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -void btree_apply_prefix(t_btree *root, void (*applyf)(void *)) -{ - (*applyf)(root->item); - if (root->left) - btree_apply_prefix(root->left, applyf); - if (root->right) - btree_apply_prefix(root->right, applyf); -} diff --git a/libftasm/srcs/btree/btree_apply_suffix.c b/libftasm/srcs/btree/btree_apply_suffix.c deleted file mode 100644 index ae103242..00000000 --- a/libftasm/srcs/btree/btree_apply_suffix.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_apply_suffix.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/05 11:43:08 by jhalford #+# #+# */ -/* Updated: 2016/12/05 11:43:13 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -void btree_apply_suffix(t_btree *root, void (*applyf)(void *)) -{ - if (root->left) - btree_apply_suffix(root->left, applyf); - if (root->right) - btree_apply_suffix(root->right, applyf); - (*applyf)(root->item); - return ; -} diff --git a/libftasm/srcs/btree/btree_create_node.c b/libftasm/srcs/btree/btree_create_node.c deleted file mode 100644 index cc365537..00000000 --- a/libftasm/srcs/btree/btree_create_node.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_create_node.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:43:50 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -t_btree *btree_create_node(void const *item, size_t content_size) -{ - t_btree *new; - - if (!(new = (t_btree *)ft_malloc(sizeof(t_btree)))) - return (NULL); - new->left = 0; - new->right = 0; - if (!item) - { - new->content_size = 0; - new->item = NULL; - } - else - { - new->content_size = content_size; - new->item = ft_memalloc(content_size + 1); - ft_memcpy(new->item, item, content_size); - } - return (new); -} diff --git a/libftasm/srcs/btree/btree_del.c b/libftasm/srcs/btree/btree_del.c deleted file mode 100644 index 8b72f78a..00000000 --- a/libftasm/srcs/btree/btree_del.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_del.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/05 11:43:03 by jhalford #+# #+# */ -/* Updated: 2017/03/21 19:43:51 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -void btree_del(t_btree **root, void (*del)(void *, size_t)) -{ - if (root && *root && del) - { - btree_del(&(*root)->left, del); - btree_del(&(*root)->right, del); - btree_delone(root, del); - } -} diff --git a/libftasm/srcs/btree/btree_delone.c b/libftasm/srcs/btree/btree_delone.c deleted file mode 100644 index 17ce1c4a..00000000 --- a/libftasm/srcs/btree/btree_delone.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_delone.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/05 11:45:51 by jhalford #+# #+# */ -/* Updated: 2016/12/15 12:48:55 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -void btree_delone(t_btree **root, void (*del)(void *, size_t)) -{ - if (root && *root) - { - if (del) - (*del)((*root)->item, (*root)->content_size); - free(*root); - *root = NULL; - } -} diff --git a/libftasm/srcs/btree/btree_insert_data.c b/libftasm/srcs/btree/btree_insert_data.c deleted file mode 100644 index a6e262fc..00000000 --- a/libftasm/srcs/btree/btree_insert_data.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_create_node.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */ -/* Updated: 2016/11/14 16:12:47 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -void btree_insert_data( - t_btree **root, - void *item, - size_t content_size, - int (*cmpf)(void *, void *)) -{ - t_btree *node; - - if (!*root) - { - *root = btree_create_node(item, content_size); - return ; - } - node = *root; - if ((*cmpf)(item, node->item) < 0) - { - if (node->left) - btree_insert_data(&node->left, item, content_size, cmpf); - else - node->left = btree_create_node(item, content_size); - } - else - { - if (node->right) - btree_insert_data(&node->right, item, content_size, cmpf); - else - node->right = btree_create_node(item, content_size); - } -} diff --git a/libftasm/srcs/btree/btree_level_count.c b/libftasm/srcs/btree/btree_level_count.c deleted file mode 100644 index 41248654..00000000 --- a/libftasm/srcs/btree/btree_level_count.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_create_node.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */ -/* Updated: 2016/08/25 17:46:00 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -int btree_level_count(t_btree *root) -{ - return (root - ? 1 + FT_MAX(btree_level_count(root->left), - btree_level_count(root->right)) - : 0); -} diff --git a/libftasm/srcs/btree/btree_map.c b/libftasm/srcs/btree/btree_map.c deleted file mode 100644 index 47b92852..00000000 --- a/libftasm/srcs/btree/btree_map.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_map.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/08 11:50:46 by jhalford #+# #+# */ -/* Updated: 2017/03/24 15:49:42 by gwojda ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -t_btree *btree_map(t_btree *root, void *(*f)(void *)) -{ - t_btree *new; - - if (!root) - return (NULL); - if (!(new = (t_btree *)ft_malloc(sizeof(*new)))) - return (NULL); - new->item = (*f)(root->item); - new->left = btree_map(root->left, f); - new->right = btree_map(root->right, f); - return (new); -} diff --git a/libftasm/srcs/btree/btree_print.c b/libftasm/srcs/btree/btree_print.c deleted file mode 100644 index 10b46735..00000000 --- a/libftasm/srcs/btree/btree_print.c +++ /dev/null @@ -1,82 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_print.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/14 18:06:24 by jhalford #+# #+# */ -/* Updated: 2017/05/15 19:08:35 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -static int print_t2(t_printdata data, char s[20][255], char b[20]) -{ - int width; - int i; - - width = 5; - i = -1; - while (++i < width) - s[2 * data.depth][data.offset + data.left + i] = b[i]; - i = -1; - if (data.depth && data.is_left) - { - while (++i < width + data.right) - s[2 * data.depth - 1] - [data.offset + data.left + width / 2 + i] = '-'; - s[2 * data.depth - 1][data.offset + data.left + width / 2] = '+'; - s[2 * data.depth - 1] - [data.offset + data.left + data.right + 3 * width / 2] = '+'; - } - else if (data.depth && !data.is_left) - { - while (++i < width + data.left) - s[2 * data.depth - 1][data.offset - width / 2 + i] = '-'; - s[2 * data.depth - 1][data.offset + data.left + width / 2] = '+'; - s[2 * data.depth - 1][data.offset - width / 2 - 1] = '+'; - } - return (data.left + width + data.right); -} - -static int print_t(t_btree *tree, - t_printdata data, char s[20][255], char *(*printer)(void *)) -{ - char b[20]; - int width; - - width = 5; - if (!tree) - return (0); - sprintf(b, "%5s", printer(tree->item)); - data.left = print_t(tree->left, (t_printdata){ - 1, data.offset, data.depth + 1, data.left, data.right}, s, printer); - data.right = print_t(tree->right, (t_printdata){ - 0, data.offset + data.left + width, data.depth + 1, - data.left, data.right}, s, printer); - return (print_t2(data, s, b)); -} - -void btree_print(int fd, t_btree *tree, char *(*printer)(void *)) -{ - char s[20][255]; - char empty[255]; - int i; - - i = -1; - while (++i < 20) - sprintf(s[i], "%80s", " "); - sprintf(empty, "%80s", " "); - print_t(tree, (t_printdata){0, 0, 0, 0, 0}, s, printer); - i = -1; - while (++i < 20) - { - if (ft_strcmp(s[i], empty) == 0) - break ; - if (i == 0 && ft_strcmp(s[1], empty) == 0) - break ; - ft_dprintf(fd, "%s\n", s[i]); - } -} diff --git a/libftasm/srcs/btree/btree_search_item.c b/libftasm/srcs/btree/btree_search_item.c deleted file mode 100644 index a7a1eb68..00000000 --- a/libftasm/srcs/btree/btree_search_item.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* btree_create_node.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */ -/* Updated: 2016/08/23 19:04:56 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "btree.h" - -void *btree_search_item(t_btree *root, - void *data_ref, int (*cmpf)(void *, void *)) -{ - void *out; - - out = NULL; - if (root) - { - out = btree_search_item(root->left, data_ref, cmpf); - if (!out && ((*cmpf)(root->item, data_ref) == 0)) - out = root->item; - if (!out) - out = btree_search_item(root->right, data_ref, cmpf); - } - return (out); -} diff --git a/libftasm/srcs/char/ft_isalnum.c b/libftasm/srcs/char/ft_isalnum.c deleted file mode 100644 index 673b6e89..00000000 --- a/libftasm/srcs/char/ft_isalnum.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isalnum.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:56:18 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:31:33 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isalnum(int c) -{ - if ((c >= 'a' && c <= 'z') - || (c >= 'A' && c <= 'Z') - || (c >= '0' && c <= '9')) - return (c); - return (0); -} diff --git a/libftasm/srcs/char/ft_isalpha.c b/libftasm/srcs/char/ft_isalpha.c deleted file mode 100644 index ac5d276e..00000000 --- a/libftasm/srcs/char/ft_isalpha.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isalpha.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:56:24 by jhalford #+# #+# */ -/* Updated: 2017/03/07 11:59:16 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isalpha(int c) -{ - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) - return (c); - return (0); -} diff --git a/libftasm/srcs/char/ft_isascii.c b/libftasm/srcs/char/ft_isascii.c deleted file mode 100644 index 52a85067..00000000 --- a/libftasm/srcs/char/ft_isascii.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isascii.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:56:28 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:35:42 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isascii(int c) -{ - if (c >= 0 && c <= 127) - return (1); - return (0); -} diff --git a/libftasm/srcs/char/ft_isdigit.c b/libftasm/srcs/char/ft_isdigit.c deleted file mode 100644 index 510371c2..00000000 --- a/libftasm/srcs/char/ft_isdigit.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isdigit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:56:33 by jhalford #+# #+# */ -/* Updated: 2016/11/03 14:56:34 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isdigit(int c) -{ - unsigned char a; - - a = (unsigned char)c; - if (a >= '0' && a <= '9') - return (a); - return (0); -} diff --git a/libftasm/srcs/char/ft_isprint.c b/libftasm/srcs/char/ft_isprint.c deleted file mode 100644 index 74a46640..00000000 --- a/libftasm/srcs/char/ft_isprint.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isprint.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:56:38 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:32:40 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isprint(int c) -{ - if (c >= 32 && c <= 126) - return (c); - return (0); -} diff --git a/libftasm/srcs/char/ft_tolower.c b/libftasm/srcs/char/ft_tolower.c deleted file mode 100644 index 3992c4c9..00000000 --- a/libftasm/srcs/char/ft_tolower.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_tolower.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:46 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:24:09 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_tolower(int c) -{ - if (c >= 'A' && c <= 'Z') - return (c + 32); - return (c); -} diff --git a/libftasm/srcs/char/ft_toupper.c b/libftasm/srcs/char/ft_toupper.c deleted file mode 100644 index 3aa9ea10..00000000 --- a/libftasm/srcs/char/ft_toupper.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_toupper.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:53:58 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:24:40 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_toupper(int c) -{ - if (c >= 'a' && c <= 'z') - return (c - 32); - return (c); -} diff --git a/libftasm/srcs/cliopts/cliopts_get.c b/libftasm/srcs/cliopts/cliopts_get.c deleted file mode 100644 index f226e6f3..00000000 --- a/libftasm/srcs/cliopts/cliopts_get.c +++ /dev/null @@ -1,110 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* cliopts_get.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/14 20:04:04 by jhalford #+# #+# */ -/* Updated: 2017/04/02 20:45:11 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -/* -** void *data must be a structure starting with `int flag` -** to do polymorphism with t_data_template ! -*/ - -#include "cliopts.h" - -static char *check_required(char ***av, char *arg) -{ - char *ret; - - if (!av || !*av) - return (NULL); - if (!arg || !*arg || !*(arg + 1)) - return (*++(*av)); - ret = arg + 1; - return (ret); -} - -static int cliopts_parse_short( - char ***av, t_cliopts opt_map[], void *data) -{ - t_cliopts *map; - char *arg; - int i; - char *tmp; - - arg = **av + 1; - i = -1; - while (arg[++i] && !(tmp = NULL)) - { - if (!(map = cliopts_getmap_short(opt_map, arg[i]))) - return (ERR_SET(E_CO_INV, arg[i])); - ((t_data_template*)data)->flag |= map->flag_on; - ((t_data_template*)data)->flag &= ~map->flag_off; - if (map->get) - { - if (map->arg_required && !(tmp = check_required(av, arg + i))) - return (ERR_SET(E_CO_MISS, *arg)); - tmp = tmp ? tmp : **av; - if ((map->get)(tmp, data)) - return (ERR_SET(E_CO_MISS, *arg)); - if (map->arg_required) - break ; - } - } - return (++(*av) ? 0 : 0); -} - -static int cliopts_parse_long( - char ***av, t_cliopts opt_map[], void *data) -{ - t_cliopts *map; - char *arg; - char *tmp; - - arg = **av + 2; - tmp = NULL; - if (!(map = cliopts_getmap_long(opt_map, arg))) - return (ERR_SET(E_CO_INVL, arg)); - ((t_data_template*)data)->flag |= map->flag_on; - ((t_data_template*)data)->flag &= ~map->flag_off; - if (map->get) - { - if (map->arg_required && !(tmp = check_required(av, NULL))) - return (ERR_SET(E_CO_MISS, *arg)); - if ((map->get)(tmp, data)) - return (ERR_SET(E_CO_MISSL, arg)); - } - ++(*av); - return (0); -} - -int cliopts_get(char **av, t_cliopts opt_map[], void *data) -{ - if (!av) - return (1); - av++; - while (av && *av) - { - if (ft_strcmp(*av, "-") == 0 || (ft_strcmp(*av, "--") == 0 && av++)) - break ; - else if ((*av)[0] == '-' && (*av)[1] == '-') - { - if (cliopts_parse_long(&av, opt_map, data)) - return (1); - } - else if ((*av)[0] == '-') - { - if (cliopts_parse_short(&av, opt_map, data)) - return (1); - } - else - break ; - } - ((t_data_template*)data)->av_data = av; - return (0); -} diff --git a/libftasm/srcs/cliopts/cliopts_getmap.c b/libftasm/srcs/cliopts/cliopts_getmap.c deleted file mode 100644 index 189e22ba..00000000 --- a/libftasm/srcs/cliopts/cliopts_getmap.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* cliopts_getmap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/25 14:59:03 by jhalford #+# #+# */ -/* Updated: 2017/03/25 15:01:10 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "cliopts.h" - -t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], char *arg) -{ - int i; - - i = -1; - while (opt_map[++i].c) - if (!ft_strcmp(opt_map[i].str, arg)) - return (&opt_map[i]); - return (NULL); -} - -t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], char arg) -{ - int i; - - i = -1; - while (opt_map[++i].c) - if (opt_map[i].c == arg) - return (&opt_map[i]); - return (NULL); -} diff --git a/libftasm/srcs/color/ft_color_mk.c b/libftasm/srcs/color/ft_color_mk.c deleted file mode 100644 index db75d7cc..00000000 --- a/libftasm/srcs/color/ft_color_mk.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_color_mk.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/27 11:35:18 by jhalford #+# #+# */ -/* Updated: 2016/12/12 11:54:49 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_color_mk(t_color *color, char fg[7], char bg[7]) -{ - ft_strcpy(color->fg, fg); - ft_strcpy(color->bg, bg); -} diff --git a/libftasm/srcs/color/ft_color_mkif.c b/libftasm/srcs/color/ft_color_mkif.c deleted file mode 100644 index 707a5c8c..00000000 --- a/libftasm/srcs/color/ft_color_mkif.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_color_mk.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/27 11:35:18 by jhalford #+# #+# */ -/* Updated: 2016/12/03 12:17:14 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_color_mkif(t_color *color, int cond, char fg[7], char bg[7]) -{ - if (cond) - ft_color_mk(color, fg, bg); -} diff --git a/libftasm/srcs/color/ft_color_reset.c b/libftasm/srcs/color/ft_color_reset.c deleted file mode 100644 index 4b557bff..00000000 --- a/libftasm/srcs/color/ft_color_reset.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_color_reset.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/25 13:48:05 by jhalford #+# #+# */ -/* Updated: 2016/11/25 14:06:26 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_color_reset(void) -{ - ft_putstr(FG_DEFAULT); - ft_putstr(BG_DEFAULT); -} diff --git a/libftasm/srcs/color/ft_color_set.c b/libftasm/srcs/color/ft_color_set.c deleted file mode 100644 index 99d9c0d0..00000000 --- a/libftasm/srcs/color/ft_color_set.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_color_set.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/25 13:53:46 by jhalford #+# #+# */ -/* Updated: 2016/12/12 11:55:03 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_color_set(t_color color) -{ - char out[20]; - - ft_strcpy(out, color.fg); - ft_strcat(out, color.bg); - ft_putstr(out); -} diff --git a/libftasm/srcs/dlst/ft_dlstadd_after.c b/libftasm/srcs/dlst/ft_dlstadd_after.c deleted file mode 100644 index 19dc852a..00000000 --- a/libftasm/srcs/dlst/ft_dlstadd_after.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_dlst_add_after.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:27:04 by jhalford #+# #+# */ -/* Updated: 2016/11/07 13:27:36 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_dlstadd_after(t_dlist **alst, t_dlist *new) -{ - if (new) - { - new->prev = (*alst); - if (*alst) - new->next = (*alst)->next; - else - new->next = NULL; - if (new->next) - new->next->prev = new; - if (new->prev) - new->prev->next = new; - *alst = new; - } -} diff --git a/libftasm/srcs/dlst/ft_dlstadd_before.c b/libftasm/srcs/dlst/ft_dlstadd_before.c deleted file mode 100644 index e2d6b2e8..00000000 --- a/libftasm/srcs/dlst/ft_dlstadd_before.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_dlst_add_before.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:27:09 by jhalford #+# #+# */ -/* Updated: 2016/11/07 13:27:10 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_dlstadd_before(t_dlist **alst, t_dlist *new) -{ - if (new) - { - new->next = (*alst); - if (*alst) - new->prev = (*alst)->prev; - if (new->next) - new->next->prev = new; - if (new->prev) - new->prev->next = new; - *alst = new; - } -} diff --git a/libftasm/srcs/dlst/ft_dlstdel.c b/libftasm/srcs/dlst/ft_dlstdel.c deleted file mode 100644 index 94b43f6b..00000000 --- a/libftasm/srcs/dlst/ft_dlstdel.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_dlstdel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/14 17:55:40 by jhalford #+# #+# */ -/* Updated: 2016/12/07 17:29:54 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static void ft_dlstdelback(t_dlist **alst, void (*del)(void *, size_t)) -{ - if (alst && *alst && del) - { - ft_dlstdelback(&(*alst)->prev, del); - ft_dlstdelone(alst, del); - } -} - -static void ft_dlstdelfront(t_dlist **alst, void (*del)(void *, size_t)) -{ - if (alst && *alst && del) - { - ft_dlstdelfront(&(*alst)->next, del); - ft_dlstdelone(alst, del); - } -} - -void ft_dlstdel(t_dlist **alst, void (*del)(void *, size_t)) -{ - if (alst && *alst && del) - { - ft_dlstdelback(&(*alst)->prev, del); - ft_dlstdelfront(&(*alst)->next, del); - ft_dlstdelone(alst, del); - } -} diff --git a/libftasm/srcs/dlst/ft_dlstdelone.c b/libftasm/srcs/dlst/ft_dlstdelone.c deleted file mode 100644 index 55826853..00000000 --- a/libftasm/srcs/dlst/ft_dlstdelone.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_dlst_delone.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:27:13 by jhalford #+# #+# */ -/* Updated: 2016/11/14 17:52:58 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_dlstdelone(t_dlist **alst, void (*del)(void *, size_t)) -{ - t_dlist *tmp; - - tmp = *alst; - if (tmp) - { - if (del) - (*del)(tmp->content, tmp->content_size); - if (tmp->next) - tmp->next->prev = tmp->prev; - if (tmp->prev) - tmp->prev->next = tmp->next; - if (tmp->prev) - *alst = tmp->prev; - else - *alst = tmp->next; - free(tmp); - } -} diff --git a/libftasm/srcs/dlst/ft_dlstlast.c b/libftasm/srcs/dlst/ft_dlstlast.c deleted file mode 100644 index 1286c32c..00000000 --- a/libftasm/srcs/dlst/ft_dlstlast.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_dlst_last.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:27:15 by jhalford #+# #+# */ -/* Updated: 2016/11/07 13:27:15 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_dlist *ft_dlstlast(t_dlist *list) -{ - while (list && list->next) - list = list->next; - return (list); -} diff --git a/libftasm/srcs/dlst/ft_dlstnew.c b/libftasm/srcs/dlst/ft_dlstnew.c deleted file mode 100644 index 411bffca..00000000 --- a/libftasm/srcs/dlst/ft_dlstnew.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_dlst_new.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:27:20 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:43:50 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_dlist *ft_dlstnew(void const *content, size_t content_size) -{ - t_dlist *new; - - if (!content) - { - new = ft_malloc(sizeof(*new)); - if (!new) - return (NULL); - new->content_size = 0; - new->content = NULL; - } - else - { - new = (t_dlist *)ft_malloc(sizeof(*new)); - if (!new) - return (NULL); - new->content_size = content_size; - new->content = ft_memalloc(content_size + 1); - ft_memcpy(new->content, content, content_size); - } - new->next = NULL; - new->prev = NULL; - return (new); -} diff --git a/libftasm/srcs/dlst/ft_dlstrtostr.c b/libftasm/srcs/dlst/ft_dlstrtostr.c deleted file mode 100644 index e92e4d8a..00000000 --- a/libftasm/srcs/dlst/ft_dlstrtostr.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_dlstrtostr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:27:29 by jhalford #+# #+# */ -/* Updated: 2016/11/14 16:13:24 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_dlsttostr(t_dlist *list) -{ - char *str; - - if (!list) - return (NULL); - while (list->prev) - list = list->prev; - str = (char *)ft_strnew(sizeof(char) * (ft_dlstsize(list) + 2)); - while (list) - { - ft_strcat(str, (char *)list->content); - list = list->next; - } - return (str); -} diff --git a/libftasm/srcs/dlst/ft_dlstsize.c b/libftasm/srcs/dlst/ft_dlstsize.c deleted file mode 100644 index b536efa2..00000000 --- a/libftasm/srcs/dlst/ft_dlstsize.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_dlst_size.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:27:23 by jhalford #+# #+# */ -/* Updated: 2016/11/07 13:27:23 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_dlstsize(t_dlist *list) -{ - int size; - t_dlist *tmp; - - size = 0; - if (list) - size++; - tmp = list; - while (tmp->next) - { - size++; - tmp = tmp->next; - } - tmp = list; - while (tmp->prev) - { - size++; - tmp = tmp->prev; - } - return (size); -} diff --git a/libftasm/srcs/error/error.c b/libftasm/srcs/error/error.c deleted file mode 100644 index 6900c094..00000000 --- a/libftasm/srcs/error/error.c +++ /dev/null @@ -1,48 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* error.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/14 16:47:00 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:53:25 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "error.h" - -char g_error_msglist[E_MAX][ERRMSG_MAX_SIZE] = -{ - "unknown error 0", - "invalid option -%c", - "invalid option --%s", - "option '%c' awaits argument(s): please don't combine", - "option '%c': missing argument", - "option '%s': missing argument", - "%s: no such file or directory", - "%s: Is a directory", - "%s: Permission denied", -}; - -int g_errnum = 0; -char *g_errmsg = NULL; -char **g_argv; - -int error_set(int n, ...) -{ - va_list ap; - - g_errnum = n; - va_start(ap, n); - ft_strdel(&g_errmsg); - ft_vasprintf(&g_errmsg, g_error_msglist[n], ap); - return (g_errnum); -} - -int ft_perror(char *utility) -{ - utility = utility ? utility : g_argv[0]; - ERR_MSG(utility, g_errmsg); - return (g_errnum); -} diff --git a/libftasm/srcs/error/ft_usage.c b/libftasm/srcs/error/ft_usage.c deleted file mode 100644 index 42add078..00000000 --- a/libftasm/srcs/error/ft_usage.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_usage.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/04/02 15:08:56 by jhalford #+# #+# */ -/* Updated: 2017/04/02 20:05:28 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_usage(char *format, ...) -{ - va_list ap; - char *usage; - - va_start(ap, format); - usage = NULL; - ft_vasprintf(&usage, format, ap); - ft_dprintf(2, "usage: %s\n", usage); - ft_strdel(&usage); - exit(-1); -} diff --git a/libftasm/srcs/ft_bzero.s b/libftasm/srcs/ft_bzero.s new file mode 100644 index 00000000..1351d09b --- /dev/null +++ b/libftasm/srcs/ft_bzero.s @@ -0,0 +1,19 @@ +global _ft_bzero +global ft_bzero +section .text + +_ft_bzero: +ft_bzero: + cmp rdi, 0 + je end + cmp rsi, 0 + je end +start_loop: + mov BYTE [rdi], 0 + inc rdi + dec rsi + jnz start_loop +; loop start_loop + +end: + ret diff --git a/libftasm/srcs/ft_isalnum.s b/libftasm/srcs/ft_isalnum.s new file mode 100644 index 00000000..0476505a --- /dev/null +++ b/libftasm/srcs/ft_isalnum.s @@ -0,0 +1,14 @@ +global _ft_isalnum +global ft_isalnum + +extern ft_isalpha +extern ft_isdigit + +_ft_isalnum: +ft_isalnum: + mov rax, 0 + call ft_isalpha + cmp rax, 0 + jne end + call ft_isdigit +end: ret diff --git a/libftasm/srcs/ft_isalpha.s b/libftasm/srcs/ft_isalpha.s new file mode 100644 index 00000000..bd091f00 --- /dev/null +++ b/libftasm/srcs/ft_isalpha.s @@ -0,0 +1,15 @@ +global _ft_isalpha +global ft_isalpha + +extern ft_islower +extern ft_isupper + +_ft_isalpha: +ft_isalpha: + mov rax, 0 + call ft_isupper + cmp rax, 0 + jne end + call ft_islower + +end: ret diff --git a/libftasm/srcs/ft_isascii.s b/libftasm/srcs/ft_isascii.s new file mode 100644 index 00000000..75901217 --- /dev/null +++ b/libftasm/srcs/ft_isascii.s @@ -0,0 +1,11 @@ +global _ft_isascii +global ft_isascii + +_ft_isascii: +ft_isascii: + mov rax, 0 + and rdi, 128 + jne end + mov rax, 1 +end: + ret diff --git a/libftasm/srcs/ft_isdigit.s b/libftasm/srcs/ft_isdigit.s new file mode 100644 index 00000000..9108750e --- /dev/null +++ b/libftasm/srcs/ft_isdigit.s @@ -0,0 +1,13 @@ +global _ft_isdigit +global ft_isdigit + +_ft_isdigit: +ft_isdigit: + mov rax, 0 + cmp rdi, '0' + jl end + cmp rdi, '9' + jg end + mov rax, rdi +end: + ret diff --git a/libftasm/srcs/ft_islower.s b/libftasm/srcs/ft_islower.s new file mode 100644 index 00000000..231e2e07 --- /dev/null +++ b/libftasm/srcs/ft_islower.s @@ -0,0 +1,12 @@ +global _ft_islower +global ft_islower + +_ft_islower: +ft_islower: + mov rax, 0 + cmp rdi, 'a' + jl end + cmp rdi, 'z' + jg end + mov rax, rdi +end: ret diff --git a/libftasm/srcs/ft_isprint.s b/libftasm/srcs/ft_isprint.s new file mode 100644 index 00000000..7655346d --- /dev/null +++ b/libftasm/srcs/ft_isprint.s @@ -0,0 +1,13 @@ +global _ft_isprint +global ft_isprint + +_ft_isprint: +ft_isprint: + mov rax, 0 + cmp rdi, ' ' + jl end + cmp rdi, '~' + jg end + mov rax, rdi +end: + ret diff --git a/libftasm/srcs/ft_isupper.s b/libftasm/srcs/ft_isupper.s new file mode 100644 index 00000000..74dc3401 --- /dev/null +++ b/libftasm/srcs/ft_isupper.s @@ -0,0 +1,12 @@ +global _ft_isupper +global ft_isupper + +_ft_isupper: +ft_isupper: + mov rax, 0 + cmp rdi, 'A' + jl end + cmp rdi, 'Z' + jg end + mov rax, rdi +end: ret diff --git a/libftasm/srcs/ft_printf/ft_conversion.c b/libftasm/srcs/ft_printf/ft_conversion.c deleted file mode 100644 index 99f0cc08..00000000 --- a/libftasm/srcs/ft_printf/ft_conversion.c +++ /dev/null @@ -1,69 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_conversion.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:31:48 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -char *ft_signed_conversion(t_fmt *fmt, va_list ap) -{ - static char base10[] = "0123456789"; - long long arg; - - arg = va_arg(ap, int); - (void)fmt; - return (ft_lltoa_base(arg, base10, fmt->flags)); -} - -char *ft_unsigned_conversion(t_fmt *fmt, va_list ap) -{ - unsigned int uiarg; - unsigned long long ullarg; - int i; - - i = 0; - while (fmt->conversion != g_convs[i].id) - i++; - if (!*fmt->modifier - || ft_strequ(fmt->modifier, "hh") - || ft_strequ(fmt->modifier, "h") - || ft_strequ(fmt->modifier, "z")) - { - uiarg = va_arg(ap, int); - return (ft_uitoa_base(uiarg, g_convs[i].base)); - } - ullarg = va_arg(ap, long long); - return (ft_ulltoa_base(ullarg, g_convs[i].base)); -} - -char *ft_char_conversion(t_fmt *fmt, va_list ap) -{ - char *ret; - - (void)fmt; - ret = (char *)ft_malloc(sizeof(char) + 1); - ret[0] = (char)va_arg(ap, int); - ret[1] = '\0'; - return (ret); -} - -char *ft_str_conversion(t_fmt *fmt, va_list ap) -{ - char *ret; - - (void)fmt; - ret = va_arg(ap, char *); - if (ret == NULL) - return (ft_strdup("NULL")); - ret = ft_strdup(ret); - if (fmt->precision && fmt->precision < (int)ft_strlen(ret)) - ret[fmt->precision] = '\0'; - return (ret); -} diff --git a/libftasm/srcs/ft_printf/ft_fmt_simplify.c b/libftasm/srcs/ft_printf/ft_fmt_simplify.c deleted file mode 100644 index f35d2ffa..00000000 --- a/libftasm/srcs/ft_printf/ft_fmt_simplify.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lib_fmt_validate.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:33:43 by jhalford #+# #+# */ -/* Updated: 2016/11/07 16:53:54 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -void ft_fmt_simplify(t_fmt *fmt) -{ - char hashtag; - - hashtag = '#'; - if (fmt->conversion == 'p') - { - fmt->conversion = 'x'; - if (!ft_strchr(fmt->flags, '#')) - ft_strncat(fmt->flags, &hashtag, 1); - } - if (ft_strchr("DOUCS", fmt->conversion)) - { - fmt->conversion += 32; - ft_strcpy(fmt->modifier, "l"); - } -} diff --git a/libftasm/srcs/ft_printf/ft_fmt_validate_conv.c b/libftasm/srcs/ft_printf/ft_fmt_validate_conv.c deleted file mode 100644 index a10b619c..00000000 --- a/libftasm/srcs/ft_printf/ft_fmt_validate_conv.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_fmt_validate_conv.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 16:55:36 by jhalford #+# #+# */ -/* Updated: 2016/11/07 16:55:37 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -int ft_fmt_validate_conv(t_fmt *fmt) -{ - if (!ft_strchr(ALL_CONVERSIONS, fmt->conversion)) - { - if (fmt->conversion != '%') - ft_fmt_error_conv(fmt->conversion); - return (1); - } - return (0); -} diff --git a/libftasm/srcs/ft_printf/ft_fmt_validate_flags.c b/libftasm/srcs/ft_printf/ft_fmt_validate_flags.c deleted file mode 100644 index 709e3c19..00000000 --- a/libftasm/srcs/ft_printf/ft_fmt_validate_flags.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_fmt_validate_flags.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 16:53:07 by jhalford #+# #+# */ -/* Updated: 2017/03/05 15:19:35 by wescande ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -static void ft_fmt_validate_flag_flag(t_fmt *fmt) -{ - char *flag_ptr; - - if (ft_strchr(fmt->flags, '+') && (flag_ptr = ft_strchr(fmt->flags, ' '))) - { - ft_fmt_error_flag_flag(' ', '+'); - *flag_ptr = '.'; - } - if (ft_strchr(fmt->flags, '-') && (flag_ptr = ft_strchr(fmt->flags, '0'))) - { - ft_fmt_error_flag_flag('0', '-'); - *flag_ptr = '.'; - } - if (fmt->precision && (flag_ptr = ft_strchr(fmt->flags, '0'))) - *flag_ptr = '.'; -} - -static void ft_fmt_validate_flag_conv(t_fmt *fmt) -{ - char *flag_ptr; - char flag; - int i; - - i = 0; - flag_ptr = fmt->flags; - while (fmt->conversion != g_convs[i].id) - i++; - while (*flag_ptr) - { - flag = *flag_ptr; - if (!ft_strchr(g_convs[i].allowed_flags, flag)) - { - ft_fmt_error_flag_conv(flag, fmt->conversion); - if (flag == '#') - *flag_ptr = '.'; - } - flag_ptr++; - } -} - -void ft_fmt_validate_flags(t_fmt *fmt) -{ - ft_fmt_validate_flag_conv(fmt); - ft_fmt_validate_flag_flag(fmt); -} diff --git a/libftasm/srcs/ft_printf/ft_fmt_validate_mod.c b/libftasm/srcs/ft_printf/ft_fmt_validate_mod.c deleted file mode 100644 index e5cdb60e..00000000 --- a/libftasm/srcs/ft_printf/ft_fmt_validate_mod.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_fmt_validate_conv.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 16:53:42 by jhalford #+# #+# */ -/* Updated: 2016/11/07 16:53:52 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -void ft_fmt_validate_mod(t_fmt *fmt) -{ - if (fmt->conversion == 's' || fmt->conversion == 'c') - if (fmt->modifier[0] && ft_strcmp(fmt->modifier, "l")) - ft_fmt_error_mod_conv(fmt->modifier, fmt->conversion); -} diff --git a/libftasm/srcs/ft_printf/ft_printf.c b/libftasm/srcs/ft_printf/ft_printf.c deleted file mode 100644 index 53b60560..00000000 --- a/libftasm/srcs/ft_printf/ft_printf.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_printf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */ -/* Updated: 2017/04/02 15:22:13 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -int ft_printf(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - return (ft_vdprintf(1, format, ap)); -} - -int ft_dprintf(int fd, const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - return (ft_vdprintf(fd, format, ap)); -} - -int ft_asprintf(char **ret, const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - return (ft_vasprintf(ret, format, ap)); -} diff --git a/libftasm/srcs/ft_printf/ft_printf_color.c b/libftasm/srcs/ft_printf/ft_printf_color.c deleted file mode 100644 index 85995f46..00000000 --- a/libftasm/srcs/ft_printf/ft_printf_color.c +++ /dev/null @@ -1,53 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_printf_color.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/06 18:07:39 by jhalford #+# #+# */ -/* Updated: 2017/03/20 15:51:32 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -t_stos g_colors[] = -{ - {"{red}", FG_RED}, - {"{gre}", FG_GREEN}, - {"{yel}", FG_YELLOW}, - {"{blu}", FG_BLUE}, - {"{mag}", FG_MAGENTA}, - {"{cya}", FG_CYAN}, - {"{bla}", FG_BLACK}, - {"{eoc}", FG_DEFAULT}, - {"{bol}", ON_BOLD}, - {"{und}", ON_UNDERLINED}, - {"{inv}", ON_INVERTED}, - {NULL, NULL}, -}; - -void ft_printf_color(char **final, char **str, va_list ap) -{ - int i; - - i = 0; - if (ft_strncmp(*str, "{ran}", 5) == 0) - { - i = va_arg(ap, int) % 6; - *final = ft_strjoin(*final, g_colors[i].val); - *str += 5; - return ; - } - while (g_colors[i].key) - { - if (ft_strncmp(*str, g_colors[i].key, 5) == 0) - { - *final = ft_strjoin(*final, g_colors[i].val); - *str += 5; - return ; - } - i++; - } -} diff --git a/libftasm/srcs/ft_printf/ft_printf_parse.c b/libftasm/srcs/ft_printf/ft_printf_parse.c deleted file mode 100644 index 14797fbf..00000000 --- a/libftasm/srcs/ft_printf/ft_printf_parse.c +++ /dev/null @@ -1,123 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_parse.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:33:24 by jhalford #+# #+# */ -/* Updated: 2017/03/20 15:55:08 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -static void ft_printf_parse_flags(t_fmt *fmt, char **format) -{ - int i; - char *str; - - i = 0; - str = *format; - while (str[i]) - { - if (ft_strchr(ALL_FLAGS, (int)str[i])) - { - if (!ft_strchr(fmt->flags, (int)str[i])) - ft_strncat(fmt->flags, str + i, 1); - } - else - break ; - i++; - } - *format += i; -} - -static void ft_printf_parse_width(t_fmt *fmt, char **format, va_list ap) -{ - int i; - char buf[10]; - char *str; - - i = 0; - str = *format; - if (str[i] == '*') - { - i++; - fmt->width = va_arg(ap, int); - } - else - { - ft_strcpy(buf, "0"); - while (ft_isdigit((int)(str[i]))) - ft_strncat(buf, str + i++, 1); - fmt->width = ft_atoi(buf); - } - *format += i; -} - -static void ft_printf_parse_precision(t_fmt *fmt, char **format, va_list ap) -{ - int i; - char buf[10]; - char *str; - - i = 0; - str = *format; - if (str[i] == '.') - { - if (str[++i] == '*') - { - i++; - fmt->precision = va_arg(ap, int); - } - else - { - ft_strcpy(buf, "0"); - while (ft_isdigit(str[i])) - ft_strncat(buf, str + i++, 1); - fmt->precision = ft_atoi(buf); - } - } - *format += i; -} - -static void ft_printf_parse_modifiers(t_fmt *fmt, char **format) -{ - char *str; - - str = *format; - if (str[0] == 'h' && str[1] == 'h') - ft_strcpy(fmt->modifier, "hh"); - else if (str[0] == 'h' && str[1] != 'h') - ft_strcpy(fmt->modifier, "h"); - else if (str[0] == 'l' && str[1] == 'l') - ft_strcpy(fmt->modifier, "ll"); - else if (str[0] == 'l' && str[1] != 'l') - ft_strcpy(fmt->modifier, "l"); - else if (str[0] == 'j') - ft_strcpy(fmt->modifier, "j"); - else if (str[0] == 'z') - ft_strcpy(fmt->modifier, "z"); - else - ft_strcpy(fmt->modifier, ""); - *format += ft_strlen(fmt->modifier); -} - -t_fmt *ft_printf_parse(char **format, va_list ap) -{ - t_fmt *fmt; - - fmt = ft_fmt_init(); - ft_printf_parse_flags(fmt, format); - ft_printf_parse_width(fmt, format, ap); - ft_printf_parse_precision(fmt, format, ap); - ft_printf_parse_modifiers(fmt, format); - fmt->conversion = **format; - (*format)++; - ft_fmt_validate_mod(fmt); - ft_fmt_validate_flags(fmt); - ft_fmt_simplify(fmt); - fmt->valid = ft_fmt_validate_conv(fmt) ? 0 : 1; - return (fmt); -} diff --git a/libftasm/srcs/ft_printf/ft_transform.c b/libftasm/srcs/ft_printf/ft_transform.c deleted file mode 100644 index 67abd6e1..00000000 --- a/libftasm/srcs/ft_printf/ft_transform.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_transform.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:33:32 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:26:37 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -char *ft_transform(t_fmt *fmt, va_list ap) -{ - char *ret; - int i; - - i = 0; - while (fmt->conversion != g_convs[i].id) - i++; - fmt->conv = g_convs[i]; - ret = (*fmt->conv.converter)(fmt, ap); - if (fmt->width > (int)ft_strlen(ret)) - ret = ft_realloc(ret, fmt->width + 5); - else - ret = ft_realloc(ret, ft_strlen(ret) + 3); - if (ft_strchr(fmt->flags, '-')) - ft_pad_right(ret, fmt); - else - ft_pad_left(ret, fmt); - return (ret); -} diff --git a/libftasm/srcs/ft_printf/ft_vprintf.c b/libftasm/srcs/ft_printf/ft_vprintf.c deleted file mode 100644 index a2b8a96a..00000000 --- a/libftasm/srcs/ft_printf/ft_vprintf.c +++ /dev/null @@ -1,85 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_vprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/20 15:52:57 by jhalford #+# #+# */ -/* Updated: 2017/04/02 15:22:20 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -t_conv g_convs[] = -{ - {'d', "0- +", "0123456789", &ft_signed_conversion, NULL}, - {'i', "0- +", "0123456789", &ft_signed_conversion, NULL}, - {'u', "0-", "0123456789", &ft_unsigned_conversion, NULL}, - {'o', "#0-", "01234567", &ft_unsigned_conversion, &ft_pad_sharp_o}, - {'x', "#0-", "0123456789abcdef", &ft_unsigned_conversion, &ft_pad_sharp_xb}, - {'X', "#0-", "0123456789ABCDEF", &ft_unsigned_conversion, &ft_pad_sharp_xb}, - {'b', "#0-", "01", &ft_unsigned_conversion, &ft_pad_sharp_xb}, - {'s', "-", "", &ft_str_conversion, NULL}, - {'c', "-", "", &ft_char_conversion, NULL}, -}; - -int ft_vdprintf(int fd, const char *format, va_list ap) -{ - char *ret; - char size; - - ret = NULL; - size = ft_vasprintf(&ret, format, ap); - if (size != -1) - ft_putstr_fd(ret, fd); - ft_strdel(&ret); - return (size); -} - -int ft_vasprintf(char **ret, const char *format, va_list ap) -{ - char *str; - char *tmp; - char *final; - - str = (char *)format; - final = ft_strnew(1); - while (*str) - { - tmp = final; - if (*str == '{') - ft_printf_color(&final, &str, ap); - else if (*str == '%') - { - if (ft_fmtcalc(&final, &str, ap)) - return (-1); - } - else if (!(final = ft_strjoin(final, (char[]){*str++, 0}))) - return (-1); - ft_strdel(&tmp); - } - *ret = final; - return (ft_strlen(final)); -} - -int ft_fmtcalc(char **final, char **str, va_list ap) -{ - t_fmt *fmt; - char *transform; - - *str += 1; - if (!(fmt = ft_printf_parse(str, ap))) - return (1); - if (!fmt->valid) - ft_strncat(*final, &fmt->conversion, 1); - else - { - transform = ft_transform(fmt, ap); - *final = ft_strjoin(*final, transform); - ft_strdel(&transform); - } - free(fmt); - return (0); -} diff --git a/libftasm/srcs/ft_printf/lib_fmt.c b/libftasm/srcs/ft_printf/lib_fmt.c deleted file mode 100644 index 28b7313d..00000000 --- a/libftasm/srcs/ft_printf/lib_fmt.c +++ /dev/null @@ -1,49 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lib_fmt.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:33:35 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -t_fmt *ft_fmt_init(void) -{ - t_fmt *fmt; - - fmt = (t_fmt *)ft_malloc(sizeof(t_fmt) + 1); - ft_bzero(fmt->flags, 6); - ft_bzero(fmt->modifier, 3); - fmt->conversion = '\0'; - fmt->width = 0; - fmt->precision = 0; - fmt->valid = 0; - return (fmt); -} - -void ft_fmt_print(t_fmt *fmt) -{ - ft_putendl("\n---"); - ft_putstr("valid: "); - ft_putnbr(fmt->valid); - ft_putendl(""); - ft_putstr("conv.: "); - ft_putchar(fmt->conversion); - ft_putendl(""); - ft_putstr("flags: "); - ft_putendl(fmt->flags); - ft_putstr("width: "); - ft_putnbr(fmt->width); - ft_putendl(""); - ft_putstr("prec.: "); - ft_putnbr(fmt->precision); - ft_putendl(""); - ft_putstr("modifier: "); - ft_putendl(fmt->modifier); - ft_putendl("---"); -} diff --git a/libftasm/srcs/ft_printf/lib_fmt_error.c b/libftasm/srcs/ft_printf/lib_fmt_error.c deleted file mode 100644 index a10954ff..00000000 --- a/libftasm/srcs/ft_printf/lib_fmt_error.c +++ /dev/null @@ -1,47 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lib_fmt_error.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:33:38 by jhalford #+# #+# */ -/* Updated: 2016/11/07 17:22:41 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -void ft_fmt_error_conv(char conv) -{ - ft_putstr("Warning: invalid or unsupported conversion specifier '"); - ft_putchar(conv); - ft_putendl("'"); -} - -void ft_fmt_error_mod_conv(char *mod, char conv) -{ - ft_putstr("warning: length modifier '"); - ft_putstr(mod); - ft_putstr("' results in undefined behaviour or no effect with '"); - ft_putchar(conv); - ft_putendl("' conversion specifier"); -} - -void ft_fmt_error_flag_conv(char flag, char conv) -{ - ft_putstr("warning: flag '"); - ft_putchar(flag); - ft_putstr("' results in undefined behaviour with '"); - ft_putchar(conv); - ft_putendl("' conversion specifier"); -} - -void ft_fmt_error_flag_flag(char flag1, char flag2) -{ - ft_putstr("warning: flag '"); - ft_putchar(flag1); - ft_putstr("' is ignored when flag '"); - ft_putchar(flag2); - ft_putendl("' is present"); -} diff --git a/libftasm/srcs/ft_printf/lib_pad.c b/libftasm/srcs/ft_printf/lib_pad.c deleted file mode 100644 index 57da1c1b..00000000 --- a/libftasm/srcs/ft_printf/lib_pad.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lib_pad.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:33:45 by jhalford #+# #+# */ -/* Updated: 2017/02/18 13:14:30 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -void ft_pad_right(char *str, t_fmt *fmt) -{ - if (ft_strchr(fmt->flags, '#')) - (fmt->conv.sharp_func)(str, fmt); - while ((int)ft_strlen(str) < fmt->width) - ft_strcat(str, " "); -} - -void ft_pad_left(char *str, t_fmt *fmt) -{ - char sign; - - sign = 0; - if (str[0] == '-' || str[0] == '+' || str[0] == ' ') - { - sign = str[0]; - str++; - } - if (ft_strchr(fmt->flags, '0')) - while ((int)ft_strlen(str) < fmt->width - (sign ? 1 : 0)) - ft_strcatf(str, "0"); - if (sign) - str--; - if (ft_strchr(fmt->flags, '#')) - (fmt->conv.sharp_func)(str, fmt); - while ((int)ft_strlen(str) < fmt->width) - ft_strcatf(str, " "); -} diff --git a/libftasm/srcs/ft_printf/lib_pad_sharp.c b/libftasm/srcs/ft_printf/lib_pad_sharp.c deleted file mode 100644 index 5d065581..00000000 --- a/libftasm/srcs/ft_printf/lib_pad_sharp.c +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lib_pad_sharp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:33:48 by jhalford #+# #+# */ -/* Updated: 2017/03/20 15:54:47 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_printf.h" - -void ft_pad_sharp_o(char *str, t_fmt *fmt) -{ - char buf[100]; - - (void)fmt; - ft_bzero(buf, 100); - if (str[0] != '0') - ft_strcatf(buf, "0"); -} - -void ft_pad_sharp_xb(char *str, t_fmt *fmt) -{ - char start[3]; - - start[0] = '0'; - start[1] = fmt->conversion; - start[2] = 0; - if (str[0] == '0') - { - if (str[1] == '0') - str[1] = fmt->conversion; - else - { - str[0] = fmt->conversion; - ft_strcatf(str, "0"); - } - } - else - ft_strcatf(str, start); -} diff --git a/libftasm/srcs/ft_puts.s b/libftasm/srcs/ft_puts.s new file mode 100644 index 00000000..61f9f5dd --- /dev/null +++ b/libftasm/srcs/ft_puts.s @@ -0,0 +1,12 @@ +global _ft_puts +global ft_puts + +_ft_puts: +ft_puts: + cmp rdi, 0 + je end + WRITE rdi + inc rdi + jmp ft_puts +end: + ret diff --git a/libftasm/srcs/ft_strcat.s b/libftasm/srcs/ft_strcat.s new file mode 100644 index 00000000..603d49d0 --- /dev/null +++ b/libftasm/srcs/ft_strcat.s @@ -0,0 +1,21 @@ +global _ft_strcat +global ft_strcat + +_ft_strcat: +ft_strcat: + mov rax, rdi +rloop: + cmp byte [rdi], 0 + je wloop + inc rdi + jmp rloop + +wloop: + mov cl, [rsi] + mov [rdi], cl + cmp byte [rdi], 0 + je end + inc rdi + inc rsi + jmp wloop +end: ret diff --git a/libftasm/srcs/ft_tolower.s b/libftasm/srcs/ft_tolower.s new file mode 100644 index 00000000..7ad14cfe --- /dev/null +++ b/libftasm/srcs/ft_tolower.s @@ -0,0 +1,13 @@ +global _ft_tolower +global ft_tolower + +_ft_tolower: +ft_tolower: + mov rax, rdi + cmp rdi, 'A' + jl end + cmp rdi, 'Z' + jg end + add rax, 32 +end: + ret diff --git a/libftasm/srcs/ft_toupper.s b/libftasm/srcs/ft_toupper.s new file mode 100644 index 00000000..8079cde1 --- /dev/null +++ b/libftasm/srcs/ft_toupper.s @@ -0,0 +1,13 @@ +global _ft_toupper +global ft_toupper + +_ft_toupper: +ft_toupper: + mov rax, rdi + cmp rdi, 'a' + jl end + cmp rdi, 'z' + jg end + sub rax, 32 +end: + ret diff --git a/libftasm/srcs/get_next_line/get_next_line.c b/libftasm/srcs/get_next_line/get_next_line.c deleted file mode 100644 index 3eed0dee..00000000 --- a/libftasm/srcs/get_next_line/get_next_line.c +++ /dev/null @@ -1,89 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* get_next_line.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/15 13:12:06 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "get_next_line.h" - -static int ft_fdcmp(t_save *a, int *b) -{ - return (a->fd - *b); -} - -static void ft_gnlfree(void *a, size_t size) -{ - (void)size; - ft_strdel(&((t_save*)a)->str); - free(a); -} - -static t_list *ft_newfd(t_list **head, int fd) -{ - t_save new; - - new.fd = fd; - new.str = ft_memalloc((BUFF_SIZE > 0 ? BUFF_SIZE : 0) + 1); - ft_lstadd(head, ft_lstnew(&new, sizeof(t_save))); - return (*head); -} - -static int ft_loop_read(int fd, char **line, char *save) -{ - char buf[BUFF_SIZE + 1]; - char *pos; - char *tmp; - int ret; - - while ((ret = read(fd, buf, BUFF_SIZE)) > 0) - { - buf[ret] = 0; - tmp = *line; - if ((pos = ft_strchr(buf, '\n'))) - { - ft_strcpy(save, pos + 1); - *pos = 0; - } - if (!(*line = ft_strjoin(*line, buf))) - return (-1); - ft_strdel(&tmp); - if (pos) - return (1); - } - if (ret < 0) - return (-1); - return (**line ? 1 : 0); -} - -int get_next_line(int const fd, char **line) -{ - static t_list *head; - t_list *tmp; - char *pos; - char *save; - int ret; - - if (fd < 0 || !line) - return (-1); - if (!(tmp = ft_lst_find(head, (void *)&fd, &ft_fdcmp))) - tmp = ft_newfd(&head, fd); - save = ((t_save*)tmp->content)->str; - if (!(*line = ft_strdup(save))) - return (-1); - ft_bzero(save, BUFF_SIZE + 1); - if ((pos = ft_strchr(*line, '\n'))) - { - ft_strcpy(save, pos + 1); - *pos = 0; - return (1); - } - if (!(ret = ft_loop_read(fd, line, save))) - ft_lst_delif(&head, (int *)&fd, ft_fdcmp, &ft_gnlfree); - return (ret); -} diff --git a/libftasm/srcs/htb/ft_hash_string.c b/libftasm/srcs/htb/ft_hash_string.c deleted file mode 100644 index 55640299..00000000 --- a/libftasm/srcs/htb/ft_hash_string.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hash.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/02 16:35:24 by ariard #+# #+# */ -/* Updated: 2017/05/16 17:33:47 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "hashtab.h" - -int ft_hash_string(const void *key, int size) -{ - const char *ptr; - unsigned int tmp; - unsigned int val; - - val = 0; - ptr = key; - while (*ptr != '\0') - { - val = (val << 4) + (*ptr); - if ((tmp = (val & 0xf0000000))) - { - val = val ^ (tmp >> 24); - val = val ^ tmp; - } - ptr++; - } - return (val % size); -} diff --git a/libftasm/srcs/htb/hashtab_del.c b/libftasm/srcs/htb/hashtab_del.c deleted file mode 100644 index 33aa1480..00000000 --- a/libftasm/srcs/htb/hashtab_del.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hashtab_del.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/06/22 17:04:24 by ariard #+# #+# */ -/* Updated: 2017/06/22 22:45:04 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "hashtab.h" - -void hashtab_del(t_hashtab *htb, void *key, - int (*match)(const void *, const void *), - void (*del)(void *, size_t)) -{ - int bucket; - - if ((bucket = htb->hashfunc(key, htb->capacity))) - ft_lst_delif(&htb->head[bucket], key, match, del); -} diff --git a/libftasm/srcs/htb/hashtab_destroy.c b/libftasm/srcs/htb/hashtab_destroy.c deleted file mode 100644 index 0ab4bfc2..00000000 --- a/libftasm/srcs/htb/hashtab_destroy.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hashtab_destroy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/05/15 21:35:07 by ariard #+# #+# */ -/* Updated: 2017/05/16 20:42:05 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "hashtab.h" - -void hashtab_destroy(t_hashtab *htb, void (*destroy)()) -{ - int bucket; - - bucket = -1; - while (++bucket < htb->capacity) - ft_lstdel(&htb->head[bucket], destroy); -} diff --git a/libftasm/srcs/htb/hashtab_generator.c b/libftasm/srcs/htb/hashtab_generator.c deleted file mode 100644 index d2f1ab73..00000000 --- a/libftasm/srcs/htb/hashtab_generator.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hashtab_generator.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/06/21 18:21:30 by ariard #+# #+# */ -/* Updated: 2017/06/22 22:43:01 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "hashtab.h" - -struct s_list *hashtab_iterator(t_hashtab *htb, char init) -{ - static int bucket; - static t_list *tmp; - static t_list *prev; - - if (init) - { - bucket = 0; - tmp = htb->head[bucket]; - return (NULL); - } - while (!tmp && ++bucket < htb->capacity) - tmp = htb->head[bucket]; - prev = tmp; - if (tmp) - tmp = tmp->next; - return (prev); -} diff --git a/libftasm/srcs/htb/hashtab_init.c b/libftasm/srcs/htb/hashtab_init.c deleted file mode 100644 index 51673ad1..00000000 --- a/libftasm/srcs/htb/hashtab_init.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hashtab_init.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/05/15 19:13:06 by ariard #+# #+# */ -/* Updated: 2017/06/21 19:48:34 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "hashtab.h" - -void hashtab_init(t_hashtab *htb, int capacity, - int (*hashfunc)(const void *key, int capacity)) -{ - htb->head = (t_list **)ft_memalloc(capacity * sizeof(*htb->head)); - htb->capacity = capacity; - htb->size = 0; - htb->hashfunc = hashfunc; -} diff --git a/libftasm/srcs/htb/hashtab_insert.c b/libftasm/srcs/htb/hashtab_insert.c deleted file mode 100644 index 9d2135c1..00000000 --- a/libftasm/srcs/htb/hashtab_insert.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hashtab_insert.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/05/15 19:30:39 by ariard #+# #+# */ -/* Updated: 2017/06/22 22:42:56 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "hashtab.h" - -int hashtab_insert(t_hashtab *htb, t_list *new, void *key, - int (*match)(const void *data_ref, const void *key)) -{ - int bucket; - - if (hashtab_lookup(htb, key, match)) - return (-1); - bucket = htb->hashfunc(key, htb->capacity); - ft_lsteadd(&htb->head[bucket], new); - htb->size++; - return (bucket); -} diff --git a/libftasm/srcs/htb/hashtab_lookup.c b/libftasm/srcs/htb/hashtab_lookup.c deleted file mode 100644 index 97a1bd58..00000000 --- a/libftasm/srcs/htb/hashtab_lookup.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hashtab_lookup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/05/15 19:38:41 by ariard #+# #+# */ -/* Updated: 2017/06/22 22:43:14 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *hashtab_lookup(t_hashtab *htb, void *key, - int (*match)(const void *data_ref, const void *key)) - -{ - int bucket; - - if ((bucket = htb->hashfunc(key, htb->capacity))) - return (ft_lst_find(htb->head[bucket], key, match)); - return (NULL); -} diff --git a/libftasm/srcs/htb/hashtab_print.c b/libftasm/srcs/htb/hashtab_print.c deleted file mode 100644 index 5040f894..00000000 --- a/libftasm/srcs/htb/hashtab_print.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hashtab_print.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/05/16 20:38:14 by ariard #+# #+# */ -/* Updated: 2017/06/22 22:24:23 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void hashtab_print(t_hashtab *htb, int (*printer)()) -{ - int bucket; - - bucket = -1; - while (++bucket != htb->capacity) - ft_lstiter(htb->head[bucket], printer, &bucket); -} diff --git a/libftasm/srcs/htb/hashtab_remove.c b/libftasm/srcs/htb/hashtab_remove.c deleted file mode 100644 index 80c7a619..00000000 --- a/libftasm/srcs/htb/hashtab_remove.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* hashtab_remove.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/05/15 19:46:48 by ariard #+# #+# */ -/* Updated: 2017/06/22 18:15:01 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *hashtab_remove(t_hashtab *htb, void *key, - int (*match)(const void *data_ref, const void *key)) -{ - t_list *data; - - if ((data = hashtab_lookup(htb, key, match))) - return(ft_lst_removeif(&data, key, match)); - return (NULL); -} diff --git a/libftasm/srcs/lst/ft_id.c b/libftasm/srcs/lst/ft_id.c deleted file mode 100644 index d5bac3fb..00000000 --- a/libftasm/srcs/lst/ft_id.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_id.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:08:55 by jhalford #+# #+# */ -/* Updated: 2017/03/07 22:43:40 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_id(t_list *a) -{ - return (a); -} diff --git a/libftasm/srcs/lst/ft_lst2str.c b/libftasm/srcs/lst/ft_lst2str.c deleted file mode 100644 index 4654dc7f..00000000 --- a/libftasm/srcs/lst/ft_lst2str.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "libft.h" - -char *ft_lst2str(t_list *list) -{ - size_t size; - t_list *tmp; - char *new; - - size = 0; - tmp = list; - while (tmp) - { - size += ft_strlen((char *)tmp->content) + 1; - tmp = tmp->next; - } - new = ft_memalloc(size); - while (list) - { - ft_strcat(new, (char *)list->content); - if (list->next) - ft_strcat(new, " "); - list = list->next; - } - return (new); -} diff --git a/libftasm/srcs/lst/ft_lst_at.c b/libftasm/srcs/lst/ft_lst_at.c deleted file mode 100644 index 516c0147..00000000 --- a/libftasm/srcs/lst/ft_lst_at.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_at.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/14 13:18:48 by jhalford #+# #+# */ -/* Updated: 2017/06/21 18:33:52 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "lst.h" - -t_list *ft_lst_at(t_list *list, unsigned int nbr) -{ - unsigned int i; - - if (!list) - return (NULL); - i = 0; - while (i < nbr && list) - { - list = list->next; - i++; - } - return (list); -} diff --git a/libftasm/srcs/lst/ft_lst_bfree.c b/libftasm/srcs/lst/ft_lst_bfree.c deleted file mode 100644 index 82c6dec4..00000000 --- a/libftasm/srcs/lst/ft_lst_bfree.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_bfree.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/07 16:55:04 by jhalford #+# #+# */ -/* Updated: 2017/05/15 21:35:59 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_bfree(void *ptr, size_t size) -{ - t_list *lst; - - lst = ptr; - (void)size; - if (lst) - { - ft_strdel((char **)&lst->content); - free(lst); - } -} diff --git a/libftasm/srcs/lst/ft_lst_cfree.c b/libftasm/srcs/lst/ft_lst_cfree.c deleted file mode 100644 index d70068ac..00000000 --- a/libftasm/srcs/lst/ft_lst_cfree.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_cfree.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:10 by jhalford #+# #+# */ -/* Updated: 2017/05/15 21:36:03 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_cfree(void *ptr, size_t size) -{ - (void)size; - if (ptr) - free(ptr); -} diff --git a/libftasm/srcs/lst/ft_lst_delif.c b/libftasm/srcs/lst/ft_lst_delif.c deleted file mode 100644 index b14fcd85..00000000 --- a/libftasm/srcs/lst/ft_lst_delif.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_delif.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */ -/* Updated: 2017/06/22 17:16:50 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_delif( - t_list **alst, - void *data_ref, - int (*cmp)(), - void (*del)(void *, size_t)) -{ - t_list *tmp; - t_list **indirect; - - indirect = alst; - while (*indirect) - { - if ((*cmp)((*indirect)->content, data_ref) == 0) - { - tmp = (*indirect); - (*indirect) = (*indirect)->next; - ft_lstdelone(&tmp, del); - } - else - indirect = &(*indirect)->next; - } -} diff --git a/libftasm/srcs/lst/ft_lst_delsub.c b/libftasm/srcs/lst/ft_lst_delsub.c deleted file mode 100644 index b3912fc2..00000000 --- a/libftasm/srcs/lst/ft_lst_delsub.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_delsub.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:15 by jhalford #+# #+# */ -/* Updated: 2017/01/12 14:33:28 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_delsub( - t_list **alst, - t_list *sub, - int (*cmp)(), - void (*del)(void *, size_t)) -{ - t_list *tmp; - t_list **indirect; - - indirect = alst; - while (*indirect) - { - if ((*cmp)((*indirect)->content, sub->content) == 0) - { - tmp = *indirect; - (*indirect) = (*indirect)->next; - sub = sub->next; - ft_lstdelone(&tmp, del); - } - indirect = &(*indirect)->next; - } -} diff --git a/libftasm/srcs/lst/ft_lst_filter.c b/libftasm/srcs/lst/ft_lst_filter.c deleted file mode 100644 index cc528142..00000000 --- a/libftasm/srcs/lst/ft_lst_filter.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_filter.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:17 by jhalford #+# #+# */ -/* Updated: 2017/05/16 17:34:15 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lst_filter( - t_list *lst, - void const *data_ref, - t_list *(*f)(t_list *elem, void const *)) -{ - t_list *out; - t_list *elem; - - out = NULL; - while (lst) - { - if (f) - elem = (*f)(lst, data_ref); - else - elem = lst; - elem = ft_lstnew(elem->content, elem->content_size); - ft_lsteadd(&out, elem); - lst = lst->next; - } - return (out); -} diff --git a/libftasm/srcs/lst/ft_lst_filterout.c b/libftasm/srcs/lst/ft_lst_filterout.c deleted file mode 100644 index 9a97c09d..00000000 --- a/libftasm/srcs/lst/ft_lst_filterout.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_filterout.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/26 16:56:02 by jhalford #+# #+# */ -/* Updated: 2017/03/26 19:10:03 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_filterout( - t_list **alst, - void *data_ref, - int (*cmp)(), - void (*del)(void *, size_t)) -{ - t_list *tmp; - t_list **indirect; - - indirect = alst; - while (*indirect) - { - if ((*cmp)((*indirect)->content, data_ref) == 0) - { - tmp = *indirect; - (*indirect) = (*indirect)->next; - ft_lstdelone(&tmp, del); - } - else - indirect = &(*indirect)->next; - } -} diff --git a/libftasm/srcs/lst/ft_lst_find.c b/libftasm/srcs/lst/ft_lst_find.c deleted file mode 100644 index da738ceb..00000000 --- a/libftasm/srcs/lst/ft_lst_find.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_find.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:20 by jhalford #+# #+# */ -/* Updated: 2017/06/21 18:20:30 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lst_find(t_list *begin_list, void *data_ref, int (*cmp)()) -{ - t_list *list_ptr; - - list_ptr = begin_list; - while (list_ptr) - { - if ((cmp)(list_ptr->content, data_ref) == 0) - return (list_ptr); - list_ptr = list_ptr->next; - } - return (NULL); -} diff --git a/libftasm/srcs/lst/ft_lst_merge.c b/libftasm/srcs/lst/ft_lst_merge.c deleted file mode 100644 index f8160381..00000000 --- a/libftasm/srcs/lst/ft_lst_merge.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_merge.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/14 13:50:32 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:24 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_merge(t_list **begin_list1, t_list *begin_list2) -{ - t_list *list_ptr; - - if (*begin_list1) - { - list_ptr = *begin_list1; - while (list_ptr->next) - list_ptr = list_ptr->next; - list_ptr->next = begin_list2; - } - else - *begin_list1 = begin_list2; -} diff --git a/libftasm/srcs/lst/ft_lst_order_delsub.c b/libftasm/srcs/lst/ft_lst_order_delsub.c deleted file mode 100644 index 5bf2067c..00000000 --- a/libftasm/srcs/lst/ft_lst_order_delsub.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_order_delsub.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:25 by jhalford #+# #+# */ -/* Updated: 2016/11/04 12:01:47 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_order_delsub( - t_list **alst, - t_list *sub, - int (*cmp)(), - void (*del)(void *, size_t)) -{ - t_list *tmp; - t_list **indirect; - - indirect = alst; - while (*indirect) - { - if ((*cmp)((*indirect)->content, sub->content) > 0) - { - sub = sub->next; - continue ; - } - if ((*cmp)((*indirect)->content, sub->content) == 0) - { - tmp = *indirect; - (*indirect) = (*indirect)->next; - ft_lstdelone(&tmp, del); - sub = sub->next; - } - indirect = &(*indirect)->next; - } -} diff --git a/libftasm/srcs/lst/ft_lst_pop.c b/libftasm/srcs/lst/ft_lst_pop.c deleted file mode 100644 index 47d8f606..00000000 --- a/libftasm/srcs/lst/ft_lst_pop.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "libft.h" - -t_list *ft_lst_pop(t_list **lst) -{ - t_list *top; - - top = *lst; - if (lst && *lst) - *lst = (*lst)->next; - return (top); -} diff --git a/libftasm/srcs/lst/ft_lst_print.c b/libftasm/srcs/lst/ft_lst_print.c deleted file mode 100644 index 18493eb3..00000000 --- a/libftasm/srcs/lst/ft_lst_print.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_print.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:27 by jhalford #+# #+# */ -/* Updated: 2017/05/16 21:00:09 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_print(t_list *list, void (*printer)()) -{ - while (list) - { - ft_putstr("["); - (*printer)(list->content); - ft_putstr("]->"); - list = list->next; - } - ft_putendl("X\n"); -} diff --git a/libftasm/srcs/lst/ft_lst_print2.c b/libftasm/srcs/lst/ft_lst_print2.c deleted file mode 100644 index 2016c78c..00000000 --- a/libftasm/srcs/lst/ft_lst_print2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_print2.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:29 by jhalford #+# #+# */ -/* Updated: 2017/05/16 21:00:19 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_print2(t_list *list, void (*printer)()) -{ - t_list *list2; - - while (list) - { - ft_putendl("---"); - list2 = *(t_list**)list->content; - while (list2) - { - ft_putstr("["); - (*printer)(*(int *)list2->content); - ft_putstr("]->"); - list2 = list2->next; - } - ft_putendl("X"); - ft_putendl("---"); - ft_putendl(" |"); - ft_putendl(" V"); - list = list->next; - } - ft_putendl(" X\n"); -} diff --git a/libftasm/srcs/lst/ft_lst_removeif.c b/libftasm/srcs/lst/ft_lst_removeif.c deleted file mode 100644 index e27041d2..00000000 --- a/libftasm/srcs/lst/ft_lst_removeif.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_removeif.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:30 by jhalford #+# #+# */ -/* Updated: 2017/06/22 22:04:23 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lst_removeif(t_list **alst, void *data_ref, int (*cmp)()) -{ - t_list *tmp; - t_list **indirect; - - indirect = alst; - while (*indirect) - { - if ((*cmp)((*indirect)->content, data_ref) == 0) - { - tmp = (*indirect); - (*indirect) = (*indirect)->next; - tmp->next = NULL; - return (tmp); - } - indirect = &(*indirect)->next; - } - return (NULL); -} diff --git a/libftasm/srcs/lst/ft_lst_reverse.c b/libftasm/srcs/lst/ft_lst_reverse.c deleted file mode 100644 index 7765d598..00000000 --- a/libftasm/srcs/lst/ft_lst_reverse.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_reverse.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/14 13:20:13 by jhalford #+# #+# */ -/* Updated: 2017/03/08 00:31:33 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_reverse(t_list **begin_list) -{ - t_list *new_start; - t_list *tmp; - - new_start = NULL; - while (*begin_list) - { - tmp = (*begin_list)->next; - (*begin_list)->next = new_start; - new_start = *begin_list; - *begin_list = tmp; - } - *begin_list = new_start; -} diff --git a/libftasm/srcs/lst/ft_lst_size.c b/libftasm/srcs/lst/ft_lst_size.c deleted file mode 100644 index 1f8c03b8..00000000 --- a/libftasm/srcs/lst/ft_lst_size.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_size.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:35 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:36 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_lstsize(t_list *lst) -{ - int i; - - i = 0; - if (lst) - { - i = 1; - while (lst->next) - { - lst = lst->next; - i++; - } - } - return (i); -} diff --git a/libftasm/srcs/lst/ft_lst_sorted_insert.c b/libftasm/srcs/lst/ft_lst_sorted_insert.c deleted file mode 100644 index f4821326..00000000 --- a/libftasm/srcs/lst/ft_lst_sorted_insert.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_sorted_insert.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:39 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:39 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_sorted_insert(t_list **begin_list, t_list *insert, int (*cmp)()) -{ - t_list *link; - - link = *begin_list; - if (!link || (*cmp)(insert->content, link->content) < 0) - { - *begin_list = insert; - insert->next = link ? link : NULL; - return ; - } - while (link->next) - { - if ((*cmp)(insert->content, link->content) > 0 - && (*cmp)(insert->content, link->next->content) <= 0) - { - insert->next = link->next; - link->next = insert; - return ; - } - link = link->next; - } - link->next = insert; - insert->next = NULL; -} diff --git a/libftasm/srcs/lst/ft_lst_sorted_merge.c b/libftasm/srcs/lst/ft_lst_sorted_merge.c deleted file mode 100644 index 38308849..00000000 --- a/libftasm/srcs/lst/ft_lst_sorted_merge.c +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lst_sorted_merge.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:40 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:40 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lst_sorted_merge( - t_list **begin_list1, - t_list *begin_list2, - int (*cmp)()) -{ - t_list *tail; - t_list *head1; - t_list *head2; - int comp; - - if (!*begin_list1 || !begin_list2) - { - *begin_list1 = begin_list2 ? begin_list2 : *begin_list1; - return ; - } - comp = (*cmp)(begin_list2->content, (*begin_list1)->content); - head1 = (comp < 0) ? *begin_list1 : (*begin_list1)->next; - head2 = (comp < 0) ? begin_list2->next : begin_list2; - *begin_list1 = (comp < 0) ? begin_list2 : *begin_list1; - tail = *begin_list1; - while (head1 && head2) - { - comp = (*cmp)(head2->content, head1->content); - tail->next = (comp < 0 ? head2 : head1); - head1 = comp < 0 ? head1 : head1->next; - head2 = comp < 0 ? head2->next : head2; - tail = tail->next; - } - tail->next = head2 ? head2 : head1; -} diff --git a/libftasm/srcs/lst/ft_lstadd.c b/libftasm/srcs/lst/ft_lstadd.c deleted file mode 100644 index 94d32d0d..00000000 --- a/libftasm/srcs/lst/ft_lstadd.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstadd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:13 by jhalford #+# #+# */ -/* Updated: 2017/05/15 19:31:42 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstadd(t_list **alst, t_list *new) -{ - if (new) - { - new->next = *alst; - *alst = new; - } -} diff --git a/libftasm/srcs/lst/ft_lstdel.c b/libftasm/srcs/lst/ft_lstdel.c deleted file mode 100644 index f63c3f6b..00000000 --- a/libftasm/srcs/lst/ft_lstdel.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstdel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 15:18:57 by jhalford #+# #+# */ -/* Updated: 2017/06/22 16:57:53 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstdel(t_list **alst, void (*del)(void *, size_t)) -{ - if (alst && *alst && del) - { - ft_lstdel(&(*alst)->next, del); - ft_lstdelone(alst, del); - } -} diff --git a/libftasm/srcs/lst/ft_lstdelone.c b/libftasm/srcs/lst/ft_lstdelone.c deleted file mode 100644 index 7b950442..00000000 --- a/libftasm/srcs/lst/ft_lstdelone.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstdelone.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/05 13:39:33 by jhalford #+# #+# */ -/* Updated: 2017/06/22 22:36:02 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)) -{ - if (alst && *alst) - { - if (del) - (*del)((*alst)->content, (*alst)->content_size); - free(*alst); - *alst = NULL; - } -} diff --git a/libftasm/srcs/lst/ft_lsteadd.c b/libftasm/srcs/lst/ft_lsteadd.c deleted file mode 100644 index 142f9660..00000000 --- a/libftasm/srcs/lst/ft_lsteadd.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lsteadd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:17 by jhalford #+# #+# */ -/* Updated: 2017/03/13 15:37:23 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lsteadd(t_list **alst, t_list *new) -{ - t_list *lst; - - lst = *alst; - if (lst) - { - while (lst->next) - lst = lst->next; - lst->next = new; - } - else - *alst = new; -} diff --git a/libftasm/srcs/lst/ft_lstiter.c b/libftasm/srcs/lst/ft_lstiter.c deleted file mode 100644 index 40ebc9c3..00000000 --- a/libftasm/srcs/lst/ft_lstiter.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstiter.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:19 by jhalford #+# #+# */ -/* Updated: 2017/05/16 17:18:12 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_lstiter(t_list *lst, int (*f)(), void *data) -{ - if (!lst) - return (0); - if ((*f)(lst->content, data)) - return (1); - return (ft_lstiter(lst->next, f, data)); -} diff --git a/libftasm/srcs/lst/ft_lstlast.c b/libftasm/srcs/lst/ft_lstlast.c deleted file mode 100644 index addae8fc..00000000 --- a/libftasm/srcs/lst/ft_lstlast.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstlast.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:48 by jhalford #+# #+# */ -/* Updated: 2017/02/09 20:46:28 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstlast(t_list *lst) -{ - if (lst) - while (lst->next) - lst = lst->next; - return (lst); -} diff --git a/libftasm/srcs/lst/ft_lstmap.c b/libftasm/srcs/lst/ft_lstmap.c deleted file mode 100644 index e0edbbaa..00000000 --- a/libftasm/srcs/lst/ft_lstmap.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstmap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:21 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstmap(t_list *lst, void *(*f)(void *)) -{ - t_list *elem; - - if (!lst) - return (NULL); - if (!(elem = (t_list *)ft_malloc(sizeof(*elem)))) - return (NULL); - elem->content = (*f)(lst->content); - elem->next = ft_lstmap(lst->next, f); - return (elem); -} diff --git a/libftasm/srcs/lst/ft_lstnadd.c b/libftasm/srcs/lst/ft_lstnadd.c deleted file mode 100644 index 3f542fad..00000000 --- a/libftasm/srcs/lst/ft_lstnadd.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstnadd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:51 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:52 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstnadd(t_list **alst, t_list *new, int n) -{ - t_list *lst; - int i; - - lst = *alst; - if (lst) - { - i = 0; - while (lst->next && i < n) - { - lst = lst->next; - i++; - } - while (lst->next) - lst = lst->next; - lst->next = new; - } - else - *alst = new; -} diff --git a/libftasm/srcs/lst/ft_lstnew.c b/libftasm/srcs/lst/ft_lstnew.c deleted file mode 100644 index e72d9ab7..00000000 --- a/libftasm/srcs/lst/ft_lstnew.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstnew.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/29 15:57:38 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstnew(void const *content, size_t content_size) -{ - t_list *new; - - if (!(new = (t_list *)ft_malloc(sizeof(*new)))) - return (NULL); - new->next = NULL; - new->content_size = content_size; - new->content = ft_memalloc(content_size + 1); - if (content) - ft_memcpy(new->content, content, content_size); - return (new); -} diff --git a/libftasm/srcs/lst/ft_lstnew_range.c b/libftasm/srcs/lst/ft_lstnew_range.c deleted file mode 100644 index 26632a3b..00000000 --- a/libftasm/srcs/lst/ft_lstnew_range.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstnew_range.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:54 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:54 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstnew_range(int a, int b) -{ - t_list *lst; - - if (a >= b) - return (NULL); - lst = NULL; - while (a < b) - { - b--; - ft_lstadd(&lst, ft_lstnew(&b, sizeof(int))); - } - return (lst); -} diff --git a/libftasm/srcs/lst/ft_lstsort.c b/libftasm/srcs/lst/ft_lstsort.c deleted file mode 100644 index 950d6fd3..00000000 --- a/libftasm/srcs/lst/ft_lstsort.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstsort.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:58 by jhalford #+# #+# */ -/* Updated: 2017/01/09 12:29:58 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstsort(t_list **begin_list, int (*cmp)()) -{ - t_list **indirect; - t_list *tmp; - t_list *tmp2; - - indirect = begin_list; - if (!*begin_list) - return ; - while (*indirect && (*indirect)->next) - { - if ((*cmp)((*indirect)->content, (*indirect)->next->content) > 0) - { - tmp = *indirect; - tmp2 = (*indirect)->next; - (*indirect)->next = (*indirect)->next->next; - *indirect = tmp2; - (*indirect)->next = tmp; - indirect = begin_list; - } - else - indirect = &(*indirect)->next; - } -} diff --git a/libftasm/srcs/lst/lst_insert_sort.c b/libftasm/srcs/lst/lst_insert_sort.c deleted file mode 100644 index d1a62412..00000000 --- a/libftasm/srcs/lst/lst_insert_sort.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lst_insert_sort.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/05/20 19:59:41 by ariard #+# #+# */ -/* Updated: 2017/05/20 20:05:32 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void lst_insert_sort(t_list **head, - int (cmp)()) -{ - t_list *new; - t_list *ptr; - - new = NULL; - while (*head) - { - ptr = *head; - *head = (*head)->next; - ft_lst_sorted_insert(&new, ptr, cmp); - } - *head = new; -} diff --git a/libftasm/srcs/lst/pop.c b/libftasm/srcs/lst/pop.c deleted file mode 100644 index df3be22e..00000000 --- a/libftasm/srcs/lst/pop.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* pop.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:09:56 by jhalford #+# #+# */ -/* Updated: 2017/03/24 20:05:13 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int pop(t_list **lst) -{ - t_list *top; - int item; - - top = *lst; - item = top ? *(int*)top->content : 0; - if (lst && *lst) - *lst = (*lst)->next; - ft_lstdelone(&top, ft_lst_cfree); - return (item); -} diff --git a/libftasm/srcs/lst/push.c b/libftasm/srcs/lst/push.c deleted file mode 100644 index 111b3505..00000000 --- a/libftasm/srcs/lst/push.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* push.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/02/09 15:59:39 by jhalford #+# #+# */ -/* Updated: 2017/03/02 20:59:42 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *push(t_list **stack, int elem) -{ - ft_lstadd(stack, ft_lstnew(&elem, sizeof(elem))); - return (*stack); -} diff --git a/libftasm/srcs/lst/top.c b/libftasm/srcs/lst/top.c deleted file mode 100644 index 2c3186e2..00000000 --- a/libftasm/srcs/lst/top.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* top.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/24 20:04:27 by jhalford #+# #+# */ -/* Updated: 2017/03/24 20:09:06 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int top(t_list *top) -{ - return (top ? *(int*)top->content : 0); -} diff --git a/libftasm/srcs/math/ft_addrcmp.c b/libftasm/srcs/math/ft_addrcmp.c deleted file mode 100644 index 5c430c71..00000000 --- a/libftasm/srcs/math/ft_addrcmp.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_addrcmp.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/14 15:59:10 by jhalford #+# #+# */ -/* Updated: 2017/01/11 16:28:40 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_addrcmp(void *a, void *b) -{ - return (a - b); -} diff --git a/libftasm/srcs/math/ft_ilen.c b/libftasm/srcs/math/ft_ilen.c deleted file mode 100644 index bbce37b5..00000000 --- a/libftasm/srcs/math/ft_ilen.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_ilen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:53:53 by jhalford #+# #+# */ -/* Updated: 2017/02/18 15:41:20 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_ilen(int n) -{ - size_t i; - - i = 1; - while (n /= 10) - i++; - return (i); -} diff --git a/libftasm/srcs/math/ft_ilen_base.c b/libftasm/srcs/math/ft_ilen_base.c deleted file mode 100644 index 3c6f9ae4..00000000 --- a/libftasm/srcs/math/ft_ilen_base.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_ilen_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:53:53 by jhalford #+# #+# */ -/* Updated: 2016/11/07 14:45:28 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_ilen_base(int n, int base) -{ - size_t i; - - i = 1; - while (n /= base) - i++; - return (i); -} diff --git a/libftasm/srcs/math/ft_itoa.c b/libftasm/srcs/math/ft_itoa.c deleted file mode 100644 index b1342f1c..00000000 --- a/libftasm/srcs/math/ft_itoa.c +++ /dev/null @@ -1,49 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_itoa.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:10 by jhalford #+# #+# */ -/* Updated: 2017/03/07 12:08:47 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static size_t ft_size(int n) -{ - size_t i; - - i = 1; - while (n /= 10) - i++; - return (i); -} - -char *ft_itoa(int n) -{ - int i; - char *str; - int neg; - - i = 0; - str = ft_strnew(ft_size(n) + 1); - neg = FT_NEG(n) ? 1 : 0; - if (n == 0) - { - str[i++] = '0'; - str[i] = '\0'; - return (str); - } - while (n) - { - str[i++] = FT_ABS(n % 10) + '0'; - n /= 10; - } - if (neg) - str[i++] = '-'; - str[i] = '\0'; - return (ft_strrev(str)); -} diff --git a/libftasm/srcs/math/ft_itoa_base.c b/libftasm/srcs/math/ft_itoa_base.c deleted file mode 100644 index edc60b46..00000000 --- a/libftasm/srcs/math/ft_itoa_base.c +++ /dev/null @@ -1,51 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_itoa_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:52:51 by jhalford #+# #+# */ -/* Updated: 2017/01/22 16:38:53 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static char *ft_flags(char *str, int *i, char *flags, int neg) -{ - if (neg) - str[*i++] = '-'; - else if (ft_strchr(flags, '+')) - str[*i++] = '+'; - else if (ft_strchr(flags, ' ')) - str[*i++] = ' '; - return (str); -} - -char *ft_itoa_base(int nbr, char *base, char *flags) -{ - int i; - int neg; - int base_size; - char *str; - - i = 0; - base_size = ft_strlen(base); - str = ft_strnew(ft_ilen_base(nbr, base_size) + 1); - neg = FT_NEG(nbr); - if (nbr == 0) - { - str[i++] = '0'; - str[i] = '\0'; - return (str); - } - while (nbr) - { - str[i++] = base[FT_ABS(nbr % base_size)]; - nbr = nbr / base_size; - } - str = ft_flags(str, &i, flags, neg); - str[i] = '\0'; - return (ft_strrev(str)); -} diff --git a/libftasm/srcs/math/ft_lllen.c b/libftasm/srcs/math/ft_lllen.c deleted file mode 100644 index 4ef07cc8..00000000 --- a/libftasm/srcs/math/ft_lllen.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lllen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:52:35 by jhalford #+# #+# */ -/* Updated: 2016/11/07 14:45:40 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_lllen(long long n) -{ - size_t i; - - i = 1; - while (n /= 10) - i++; - return (i); -} diff --git a/libftasm/srcs/math/ft_lllen_base.c b/libftasm/srcs/math/ft_lllen_base.c deleted file mode 100644 index 74b934eb..00000000 --- a/libftasm/srcs/math/ft_lllen_base.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lllen_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:52:35 by jhalford #+# #+# */ -/* Updated: 2016/11/07 14:46:15 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_lllen_base(long long n, int base) -{ - size_t i; - - i = 1; - while (n /= base) - i++; - return (i); -} diff --git a/libftasm/srcs/math/ft_lltoa_base.c b/libftasm/srcs/math/ft_lltoa_base.c deleted file mode 100644 index 69d31aff..00000000 --- a/libftasm/srcs/math/ft_lltoa_base.c +++ /dev/null @@ -1,52 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lltoa_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:10:42 by jhalford #+# #+# */ -/* Updated: 2017/02/18 15:23:41 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static char *ft_flags(char *str, int *i, char *flags, int neg) -{ - if (neg) - str[(*i)++] = '-'; - else if (ft_strchr(flags, '+')) - str[(*i)++] = '+'; - else if (ft_strchr(flags, ' ')) - str[(*i)++] = ' '; - return (str); -} - -char *ft_lltoa_base(long long nbr, char *base, char *flags) -{ - int i; - int neg; - int base_size; - char *str; - - i = 0; - base_size = ft_strlen(base); - str = ft_strnew(ft_lllen_base(nbr, base_size) + 1); - neg = FT_NEG(nbr); - if (nbr == 0) - { - str[i++] = '0'; - str[i] = '\0'; - return (str); - } - while (nbr) - { - str[i++] = base[FT_ABS(nbr % base_size)]; - nbr = nbr / base_size; - } - str = ft_flags(str, &i, flags, neg); - str[i] = 0; - ft_strrev(str); - return (str); -} diff --git a/libftasm/srcs/math/ft_uilen.c b/libftasm/srcs/math/ft_uilen.c deleted file mode 100644 index 9e87ca1f..00000000 --- a/libftasm/srcs/math/ft_uilen.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_uilen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:52:35 by jhalford #+# #+# */ -/* Updated: 2016/11/07 13:54:41 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_uilen(unsigned int n) -{ - size_t i; - - i = 1; - while (n /= 10) - i++; - return (i); -} diff --git a/libftasm/srcs/math/ft_uitoa_base.c b/libftasm/srcs/math/ft_uitoa_base.c deleted file mode 100644 index a09cb11e..00000000 --- a/libftasm/srcs/math/ft_uitoa_base.c +++ /dev/null @@ -1,47 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_uitoa_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:08:10 by jhalford #+# #+# */ -/* Updated: 2016/11/07 13:10:35 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static size_t ft_size(unsigned int n, int base) -{ - size_t i; - - i = 1; - while (n /= base) - i++; - return (i); -} - -char *ft_uitoa_base(unsigned int nbr, char *base) -{ - int i; - int base_size; - char *str; - - i = 0; - base_size = ft_strlen(base); - str = ft_strnew(ft_size(nbr, base_size) + 1); - if (nbr == 0) - { - str[i++] = '0'; - str[i] = '\0'; - return (str); - } - while (nbr) - { - str[i++] = base[nbr % base_size]; - nbr = nbr / base_size; - } - str[i] = '\0'; - return (ft_strrev(str)); -} diff --git a/libftasm/srcs/math/ft_ulltoa_base.c b/libftasm/srcs/math/ft_ulltoa_base.c deleted file mode 100644 index 5a5a3675..00000000 --- a/libftasm/srcs/math/ft_ulltoa_base.c +++ /dev/null @@ -1,47 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_ulltoa_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 13:07:50 by jhalford #+# #+# */ -/* Updated: 2017/02/18 16:07:02 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static size_t ft_size(unsigned long long n, int base) -{ - size_t i; - - i = 1; - while (n /= base) - i++; - return (i); -} - -char *ft_ulltoa_base(unsigned long long nbr, char *base) -{ - int i; - int base_size; - char *str; - - i = 0; - base_size = ft_strlen(base); - str = ft_strnew(ft_size(nbr, base_size) + 1); - if (nbr == 0) - { - str[i++] = '0'; - str[i] = '\0'; - return (str); - } - while (nbr) - { - str[i++] = base[nbr % base_size]; - nbr = nbr / base_size; - } - str[i] = '\0'; - return (ft_strrev(str)); -} diff --git a/libftasm/srcs/math/id.c b/libftasm/srcs/math/id.c deleted file mode 100644 index e23a5831..00000000 --- a/libftasm/srcs/math/id.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* id.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/20 12:20:59 by jhalford #+# #+# */ -/* Updated: 2017/03/20 12:21:01 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *id(void *data) -{ - return (data); -} diff --git a/libftasm/srcs/mem/ft_bzero.c b/libftasm/srcs/mem/ft_bzero.c deleted file mode 100644 index 6f1834b5..00000000 --- a/libftasm/srcs/mem/ft_bzero.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_bzero.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:56:08 by jhalford #+# #+# */ -/* Updated: 2016/11/03 14:56:09 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_bzero(void *s, size_t n) -{ - size_t i; - - i = -1; - while (++i < n) - *(char *)s++ = 0; -} diff --git a/libftasm/srcs/mem/ft_malloc.c b/libftasm/srcs/mem/ft_malloc.c deleted file mode 100644 index bb1b9b54..00000000 --- a/libftasm/srcs/mem/ft_malloc.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_malloc.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/21 15:45:00 by jhalford #+# #+# */ -/* Updated: 2017/03/23 18:31:10 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_malloc(size_t size) -{ - void *ptr; - - ptr = malloc(size); - if (!ptr) - { - ft_putstr_fd(strerror(errno), 2); - exit(errno); - } - return (ptr); -} diff --git a/libftasm/srcs/mem/ft_memalloc.c b/libftasm/srcs/mem/ft_memalloc.c deleted file mode 100644 index c2908094..00000000 --- a/libftasm/srcs/mem/ft_memalloc.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memalloc.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:25 by jhalford #+# #+# */ -/* Updated: 2017/06/22 21:51:30 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memalloc(size_t size) -{ - void *addr; - size_t i; - - addr = ft_malloc(size); - if (addr == NULL) - return (NULL); - i = -1; - while (++i < size) - ((char *)addr)[i] = 0; - return (addr); -} diff --git a/libftasm/srcs/mem/ft_memccpy.c b/libftasm/srcs/mem/ft_memccpy.c deleted file mode 100644 index ee5d8071..00000000 --- a/libftasm/srcs/mem/ft_memccpy.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memccpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:26 by jhalford #+# #+# */ -/* Updated: 2017/03/06 15:36:13 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memccpy(void *dst, const void *src, int c, size_t n) -{ - size_t i; - - i = -1; - while (++i < n) - { - *(char *)dst++ = *(char *)src; - if (*(char *)src++ == c) - return (dst); - } - return (NULL); -} diff --git a/libftasm/srcs/mem/ft_memchr.c b/libftasm/srcs/mem/ft_memchr.c deleted file mode 100644 index 96ddf009..00000000 --- a/libftasm/srcs/mem/ft_memchr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:28 by jhalford #+# #+# */ -/* Updated: 2016/11/11 17:41:21 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memchr(const void *s, int c, size_t n) -{ - void *a; - size_t i; - - i = -1; - a = (unsigned char *)s; - while (++i < n) - { - if (*(unsigned char *)a == (unsigned char)c) - return (a); - a++; - } - return (NULL); -} diff --git a/libftasm/srcs/mem/ft_memcmp.c b/libftasm/srcs/mem/ft_memcmp.c deleted file mode 100644 index 9dd827ee..00000000 --- a/libftasm/srcs/mem/ft_memcmp.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memcmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:30 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:44:21 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_memcmp(const void *s1, const void *s2, size_t n) -{ - size_t i; - int cmp; - - i = -1; - while (++i < n) - { - cmp = *(unsigned char *)s1++ - *(unsigned char *)s2++; - if (cmp) - return (cmp); - } - return (cmp); -} diff --git a/libftasm/srcs/mem/ft_memcpy.c b/libftasm/srcs/mem/ft_memcpy.c deleted file mode 100644 index a8edafaa..00000000 --- a/libftasm/srcs/mem/ft_memcpy.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:31 by jhalford #+# #+# */ -/* Updated: 2017/03/06 15:39:36 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memcpy(void *dst, const void *src, size_t n) -{ - char *c1; - char *c2; - - if (n == 0 || dst == src) - return (dst); - c1 = (char *)dst; - c2 = (char *)src; - while (--n) - *c1++ = *c2++; - *c1 = *c2; - return (dst); -} diff --git a/libftasm/srcs/mem/ft_memdel.c b/libftasm/srcs/mem/ft_memdel.c deleted file mode 100644 index 59a18066..00000000 --- a/libftasm/srcs/mem/ft_memdel.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memdel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:33 by jhalford #+# #+# */ -/* Updated: 2017/03/20 16:19:07 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_memdel(void **ap) -{ - if (ap && *ap) - { - free(*ap); - *ap = NULL; - } -} diff --git a/libftasm/srcs/mem/ft_memmove.c b/libftasm/srcs/mem/ft_memmove.c deleted file mode 100644 index 904d1aca..00000000 --- a/libftasm/srcs/mem/ft_memmove.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memmove.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:34 by jhalford #+# #+# */ -/* Updated: 2016/11/11 17:41:14 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memmove(void *dst, const void *src, size_t len) -{ - char *srcc; - char *dstc; - size_t i; - - i = -1; - srcc = (char *)src; - dstc = (char *)dst; - if (srcc < dstc) - while ((int)(--len) >= 0) - *(dstc + len) = *(srcc + len); - else - while (++i < len) - *(dstc + i) = *(srcc + i); - return (dst); -} diff --git a/libftasm/srcs/mem/ft_memset.c b/libftasm/srcs/mem/ft_memset.c deleted file mode 100644 index b99906e2..00000000 --- a/libftasm/srcs/mem/ft_memset.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memset.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:36 by jhalford #+# #+# */ -/* Updated: 2017/03/06 15:39:24 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memset(void *b, int c, size_t len) -{ - size_t i; - - i = -1; - while (++i < len) - ((unsigned char *)b)[i] = (unsigned char)c; - return (b); -} diff --git a/libftasm/srcs/mem/ft_realloc.c b/libftasm/srcs/mem/ft_realloc.c deleted file mode 100644 index 33f667a8..00000000 --- a/libftasm/srcs/mem/ft_realloc.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_realloc.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/11 17:37:53 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_realloc(void *data, int size) -{ - void *new; - - new = ft_memalloc(size); - ft_memcpy(new, data, ft_strlen(data)); - ft_memdel(&data); - return (new); -} diff --git a/libftasm/srcs/net/create_client.c b/libftasm/srcs/net/create_client.c deleted file mode 100644 index dfc2628a..00000000 --- a/libftasm/srcs/net/create_client.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "libft.h" - -int create_client(char *addr, int port, char *protoname) -{ - int sock; - struct protoent *proto; - struct sockaddr_in sin; - - if (!(proto = getprotobyname(protoname))) - return (-1); - sock = socket(PF_INET, SOCK_STREAM, proto->p_proto); - sin.sin_family = AF_INET; - sin.sin_port = htons(port); - sin.sin_addr.s_addr = inet_addr(addr); - if (connect(sock, (const struct sockaddr *)&sin, sizeof(sin)) < 0) - return (-1); - return (sock); -} - -void listener(int domain, int sock, int proto, void (*handler)(void *buf, int bytes, struct sockaddr_in *addr)) -{ int sd; - struct sockaddr_in addr; - unsigned char buf[1024]; - - sd = socket(domain, sock, proto); - if (sd < 0) - { - perror("listener socket"); - exit(0); - } - for (;;) - { int bytes; - socklen_t len=sizeof(addr); - - bzero(buf, sizeof(buf)); - bytes = recvfrom(sd, buf, sizeof(buf), 0, (struct sockaddr*)&addr, &len); - if (bytes > 0 && handler) - handler(buf, bytes, &addr); - else - perror("recvfrom"); - } - exit(0); -} diff --git a/libftasm/srcs/net/create_server.c b/libftasm/srcs/net/create_server.c deleted file mode 100644 index 3ab05efb..00000000 --- a/libftasm/srcs/net/create_server.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "libft.h" - -int create_server(int port, int backlog, char *protoname) -{ - int sock; - struct protoent *proto; - struct sockaddr_in sin; - - if (!(proto = getprotobyname(protoname))) - return (-1); - sock = socket(PF_INET, SOCK_STREAM, proto->p_proto); - sin.sin_family = AF_INET; - sin.sin_port = htons(port); - sin.sin_addr.s_addr = htonl(INADDR_ANY); - if (bind(sock, (const struct sockaddr *)&sin, sizeof(sin)) < 0) - return (-1); - listen(sock, backlog); - return (sock); -} diff --git a/libftasm/srcs/net/net_get.c b/libftasm/srcs/net/net_get.c deleted file mode 100644 index 9541282c..00000000 --- a/libftasm/srcs/net/net_get.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "libft.h" - -int net_get(int sock, char *msg, int size) -{ - int ack; - - ack = htons(ACK); - if (read(sock, msg, size) < 0) - return (-1); - if (write(sock, (char*)&ack, sizeof(ack)) < 0) - return (-1); - return (0); -} - -int net_get_fd(int sock, int fd, int size) -{ - int ack; - char msg[size]; - - ack = htons(ACK); - if (read(sock, msg, size) < 0) - return (-1); - if (write(sock, (char*)&ack, sizeof(ack)) < 0) - return (-1); - if (write(fd, msg, size) < 0) - return (-1); - return (0); -} - -int net_get_large(int sock, int fd) -{ - int i; - int num_blks; - int num_last_blk; - - net_get(sock, (char*)&num_blks, sizeof(num_blks)); - net_get(sock, (char*)&num_last_blk, sizeof(num_last_blk)); - num_blks = ntohs(num_blks); - num_last_blk = ntohs(num_last_blk); - i = -1; - while (++i < num_blks - 1) - net_get_fd(sock, fd, NET_MAXSIZE); - if (num_last_blk) - net_get_fd(sock, fd, num_last_blk); - return (0); -} diff --git a/libftasm/srcs/net/net_send.c b/libftasm/srcs/net/net_send.c deleted file mode 100644 index de981f56..00000000 --- a/libftasm/srcs/net/net_send.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "libft.h" - -int net_send(int sock, char *msg, int size) -{ - int ack; - - if (write(sock, msg, size) < 0) - return (-1); - if (read(sock, (char*)&ack, sizeof(ack)) < 0) - return (-1); - if (ntohs(ack) != ACK) - return (1); - return (0); -} - -int net_send_large(int sock, char *msg, int size) -{ - int i; - int num_blks; - int num_last_blk; - - num_blks = htons(size / NET_MAXSIZE + 1); - num_last_blk = htons(size % NET_MAXSIZE); - if (net_send(sock, (char*)&num_blks, sizeof(num_blks))) - return (1); - if (net_send(sock, (char*)&num_last_blk, sizeof(num_blks))) - return (1); - - num_blks = ntohs(num_blks); - num_last_blk = ntohs(num_last_blk); - i = -1; - while (++i < num_blks - 1) - net_send(sock, msg + i * NET_MAXSIZE, NET_MAXSIZE); - if (num_last_blk) - net_send(sock, msg + i * NET_MAXSIZE, num_last_blk); - return (0); -} diff --git a/libftasm/srcs/path/ft_path_notdir.c b/libftasm/srcs/path/ft_path_notdir.c deleted file mode 100644 index b59044f3..00000000 --- a/libftasm/srcs/path/ft_path_notdir.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_path_notdir.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/04 11:45:07 by jhalford #+# #+# */ -/* Updated: 2017/03/25 15:03:39 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_path_notdir(char *path) -{ - char *slash; - char *ret; - - ret = path; - if ((slash = ft_strrchr(path, '/')) && slash != path) - ret = slash + 1; - return (ret); -} diff --git a/libftasm/srcs/printing/ft_putchar.c b/libftasm/srcs/printing/ft_putchar.c deleted file mode 100644 index b607cf9a..00000000 --- a/libftasm/srcs/printing/ft_putchar.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putchar.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:37 by jhalford #+# #+# */ -/* Updated: 2016/11/04 13:11:49 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_putchar_fd(int c, int fd) -{ - return (write(fd, &c, 1)); -} - -int ft_putchar(int c) -{ - return (write(1, &c, 1)); -} diff --git a/libftasm/srcs/printing/ft_putendl.c b/libftasm/srcs/printing/ft_putendl.c deleted file mode 100644 index 615c929f..00000000 --- a/libftasm/srcs/printing/ft_putendl.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putendl.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:40 by jhalford #+# #+# */ -/* Updated: 2017/02/20 18:17:01 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_putendl_fd(char const *s, int fd) -{ - char nl; - int ret; - - nl = '\n'; - if ((ret = write(fd, s, ft_strlen(s)))) - return (ret); - return (write(fd, &nl, 1)); -} - -int ft_putendl(char const *s) -{ - return (ft_putendl_fd(s, 1)); -} diff --git a/libftasm/srcs/printing/ft_putnbr.c b/libftasm/srcs/printing/ft_putnbr.c deleted file mode 100644 index e0850ba8..00000000 --- a/libftasm/srcs/printing/ft_putnbr.c +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putnbr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/02 21:25:03 by jhalford #+# #+# */ -/* Updated: 2017/02/18 17:47:04 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_putnbr_loop(long n, int base, int fd) -{ - if (n >= base) - ft_putnbr_loop(n / base, base, fd); - return (ft_putchar_fd("0123456789abcdef"[n % base], fd)); -} - -int ft_putnbr_hex_fd(long n, int fd) -{ - ft_putstr_fd("0x", fd); - return (ft_putnbr_loop(n, 16, fd)); -} - -int ft_putnbr_fd(long n, int fd) -{ - if (n < 0) - ft_putchar_fd('-', fd); - n = FT_ABS(n); - return (ft_putnbr_loop(n, 10, fd)); -} - -int ft_putnbr_hex(long n) -{ - return (ft_putnbr_hex_fd(n, 1)); -} - -int ft_putnbr(long n) -{ - return (ft_putnbr_fd(n, 1)); -} diff --git a/libftasm/srcs/printing/ft_putstr.c b/libftasm/srcs/printing/ft_putstr.c deleted file mode 100644 index 985f1a99..00000000 --- a/libftasm/srcs/printing/ft_putstr.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/03 16:13:07 by jhalford #+# #+# */ -/* Updated: 2016/08/25 17:03:59 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_putstr_fd(char const *s, int fd) -{ - return (write(fd, s, ft_strlen(s))); -} - -int ft_putstr(char const *s) -{ - return (write(1, s, ft_strlen(s))); -} diff --git a/libftasm/srcs/printing/hexdump.c b/libftasm/srcs/printing/hexdump.c deleted file mode 100644 index 924e2004..00000000 --- a/libftasm/srcs/printing/hexdump.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -#include "libft.h" - -void hexdump(void *pAddressIn, long lSize) -{ - char szBuf[100]; - long lIndent = 1; - long lOutLen, lIndex, lIndex2, lOutLen2; - long lRelPos; - struct { char *pData; unsigned long lSize; } buf; - unsigned char *pTmp,ucTmp; - unsigned char *pAddress = (unsigned char *)pAddressIn; - - buf.pData = (char *)pAddress; - buf.lSize = lSize; - - while (buf.lSize > 0) - { - pTmp = (unsigned char *)buf.pData; - lOutLen = (int)buf.lSize; - if (lOutLen > 16) - lOutLen = 16; - - // create a 64-character formatted output line: - sprintf(szBuf, " > " - " " - " %08lX", pTmp-pAddress); - lOutLen2 = lOutLen; - - for(lIndex = 1+lIndent, lIndex2 = 53-15+lIndent, lRelPos = 0; - lOutLen2; - lOutLen2--, lIndex += 2, lIndex2++ - ) - { - ucTmp = *pTmp++; - - sprintf(szBuf + lIndex, "%02X ", (unsigned short)ucTmp); - if(!isprint(ucTmp)) ucTmp = '.'; // nonprintable char - szBuf[lIndex2] = ucTmp; - - if (!(++lRelPos & 3)) // extra blank after 4 bytes - { lIndex++; szBuf[lIndex+2] = ' '; } - } - - if (!(lRelPos & 3)) lIndex--; - - szBuf[lIndex ] = '<'; - szBuf[lIndex+1] = ' '; - - printf("%s\n", szBuf); - - buf.pData += lOutLen; - buf.lSize -= lOutLen; - } -} diff --git a/libftasm/srcs/rs/rs.c b/libftasm/srcs/rs/rs.c deleted file mode 100644 index 3cddd3ef..00000000 --- a/libftasm/srcs/rs/rs.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "libft.h" -#include - -double sqrt(double x); -struct s_stats g_rs = {0, 0, 0, 0, 0, 0, 0}; - -void rs_clear() -{ - g_rs.count = 0; - g_rs.min = DBL_MAX; - g_rs.max = -DBL_MAX; -} - -void rs_push(double n) -{ - double delta; - - g_rs.count++; - n < g_rs.min ? g_rs.min = n : (0); - n > g_rs.max ? g_rs.max = n : (0); - if (g_rs.count == 1) - { - g_rs.avg = n; - g_rs.m = 0; - } - else - { - delta = n - g_rs.avg; - g_rs.avg += delta / g_rs.count; - g_rs.m += delta * (n - g_rs.avg); - } -} - -void rs_calcmore() -{ - /* void *libm; */ - /* double (*sqrt)(double); */ - - if (g_rs.count == 0) - { - g_rs.min = 0; - g_rs.max = 0; - } - if (g_rs.count < 2) - { - g_rs.var = 0; - g_rs.stdev = 0; - return ; - } - g_rs.var = g_rs.m / (g_rs.count - 1); - /* if ((libm = dlopen("libm.dylib", 0)) == NULL) */ - /* printf("%s\n", dlerror()); */ - /* else if ((sqrt = dlsym(libm, "sqrt")) == NULL) */ - /* printf("%s\n", dlerror()); */ - /* else */ - g_rs.stdev = sqrt(g_rs.var); -} diff --git a/libftasm/srcs/sstr/ft_sstradd.c b/libftasm/srcs/sstr/ft_sstradd.c deleted file mode 100644 index c81a256d..00000000 --- a/libftasm/srcs/sstr/ft_sstradd.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstradd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 18:03:58 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char **ft_sstradd(char **sstr, char *new) -{ - int size; - char **newlist; - - size = 0; - if (sstr) - while (sstr[size]) - size++; - if (!(newlist = (char **)ft_memalloc(sizeof(char *) * (size + 2)))) - return (NULL); - if (sstr) - ft_memcpy(newlist, sstr, sizeof(char*) * size); - newlist[size] = ft_strdup(new); - newlist[size + 1] = NULL; - free(sstr); - return (newlist); -} diff --git a/libftasm/srcs/sstr/ft_sstrcat.c b/libftasm/srcs/sstr/ft_sstrcat.c deleted file mode 100644 index 313fc24d..00000000 --- a/libftasm/srcs/sstr/ft_sstrcat.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstrcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/10 16:58:06 by jhalford #+# #+# */ -/* Updated: 2016/12/10 17:03:27 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_sstrcat(char **sstr, char sep) -{ - int len; - int i; - char *out; - - i = 0; - len = 0; - if (!sstr) - return (NULL); - while (sstr[i]) - len += ft_strlen(sstr[i++]); - if (!(out = ft_strnew(sizeof(char) * (len + i + 1)))) - return (NULL); - ft_strcpy(out, sstr[0]); - i = 1; - while (sstr[i]) - { - ft_strcat(out, (char[]){sep, 0}); - ft_strcat(out, sstr[i++]); - } - return (out); -} diff --git a/libftasm/srcs/sstr/ft_sstrdel.c b/libftasm/srcs/sstr/ft_sstrdel.c deleted file mode 100644 index 403fcf00..00000000 --- a/libftasm/srcs/sstr/ft_sstrdel.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstrdel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 18:04:07 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:38:51 by wescande ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_sstrdel(char **sstr, int index) -{ - int i; - - i = index; - ft_strdel(&sstr[index]); - while (i == index || sstr[i]) - { - sstr[i] = sstr[i + 1]; - ++i; - } -} diff --git a/libftasm/srcs/sstr/ft_sstrdup.c b/libftasm/srcs/sstr/ft_sstrdup.c deleted file mode 100644 index 8517a125..00000000 --- a/libftasm/srcs/sstr/ft_sstrdup.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstrdup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/07 14:25:45 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char **ft_sstrdup(char **list) -{ - int i; - int size; - char **cpy; - - i = 0; - size = 0; - while (list[size]) - size++; - cpy = (char **)ft_malloc(sizeof(char *) * (size + 1)); - while (*list) - { - cpy[i++] = ft_strdup(*list); - list++; - } - cpy[i] = NULL; - return (cpy); -} diff --git a/libftasm/srcs/sstr/ft_sstrfree.c b/libftasm/srcs/sstr/ft_sstrfree.c deleted file mode 100644 index 7855228d..00000000 --- a/libftasm/srcs/sstr/ft_sstrfree.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstrfree.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/05 11:53:36 by jhalford #+# #+# */ -/* Updated: 2017/03/22 23:19:24 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_sstrfree(char **sstr) -{ - int i; - - i = 0; - if (sstr) - { - while (sstr[i]) - { - ft_strdel(sstr + i); - i++; - } - ft_strdel(sstr + i); - free(sstr); - } -} diff --git a/libftasm/srcs/sstr/ft_sstrmerge.c b/libftasm/srcs/sstr/ft_sstrmerge.c deleted file mode 100644 index 2705a285..00000000 --- a/libftasm/srcs/sstr/ft_sstrmerge.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstrmerge.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/24 17:40:50 by jhalford #+# #+# */ -/* Updated: 2017/03/24 18:05:08 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char **ft_sstrmerge(char **s1, char **s2) -{ - char **out; - - out = ft_sstrdup(s1); - if (!s2) - return (out); - while (*s2) - { - out = ft_sstradd(out, *s2); - s2++; - } - return (out); -} diff --git a/libftasm/srcs/sstr/ft_sstrprint.c b/libftasm/srcs/sstr/ft_sstrprint.c deleted file mode 100644 index 1ebc0f5e..00000000 --- a/libftasm/srcs/sstr/ft_sstrprint.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstrprint.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/28 15:17:33 by jhalford #+# #+# */ -/* Updated: 2016/11/28 15:18:12 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_sstrprint(char **list, char sep) -{ - ft_sstrprint_fd(STDOUT, list, sep); -} diff --git a/libftasm/srcs/sstr/ft_sstrprint_fd.c b/libftasm/srcs/sstr/ft_sstrprint_fd.c deleted file mode 100644 index 42225b7c..00000000 --- a/libftasm/srcs/sstr/ft_sstrprint_fd.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstrprint_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/28 15:17:29 by jhalford #+# #+# */ -/* Updated: 2017/03/18 03:37:16 by wescande ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_sstrprint_fd(int fd, char **list, char sep) -{ - int i; - - i = 0; - if (!list || !*list) - return ; - while (list[i]) - { - ft_putstr_fd(list[i++], fd); - if (list[i]) - ft_putchar_fd(sep, fd); - } -} diff --git a/libftasm/srcs/sstr/ft_sstrsort.c b/libftasm/srcs/sstr/ft_sstrsort.c deleted file mode 100644 index 25cf4134..00000000 --- a/libftasm/srcs/sstr/ft_sstrsort.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstrsort.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 18:03:37 by jhalford #+# #+# */ -/* Updated: 2017/03/23 14:40:25 by gwojda ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_sstrsort(char **list, int (*cmp)()) -{ - int i; - char *tmp; - - i = 0; - while (list[i] && list[i + 1]) - { - if ((*cmp)(list[i], list[i + 1]) > 0) - { - tmp = list[i]; - list[i] = list[i + 1]; - list[i + 1] = tmp; - i = 0; - } - else - i++; - } -} diff --git a/libftasm/srcs/sstr/ft_sstrstr.c b/libftasm/srcs/sstr/ft_sstrstr.c deleted file mode 100644 index d6618563..00000000 --- a/libftasm/srcs/sstr/ft_sstrstr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sstrstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/07 11:29:54 by ariard #+# #+# */ -/* Updated: 2017/03/22 21:54:40 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_sstrstr(char **sstr, char *find) -{ - int size; - - if (!sstr) - return (NULL); - size = ft_strlen(find); - while ((*sstr)) - { - if (ft_strncmp(*sstr, find, size) == 0) - return (*sstr); - sstr++; - } - return (NULL); -} diff --git a/libftasm/srcs/str/ft_atoi.c b/libftasm/srcs/str/ft_atoi.c deleted file mode 100644 index 546c58f6..00000000 --- a/libftasm/srcs/str/ft_atoi.c +++ /dev/null @@ -1,51 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_atoi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/03 16:17:21 by jhalford #+# #+# */ -/* Updated: 2017/03/22 22:21:21 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static int ft_iswhitespace(char c) -{ - if (c == ' ' || c == '\t' || c == '\n') - return (1); - else if (c == '\v' || c == '\f' || c == '\r') - return (1); - return (0); -} - -int ft_atoi(const char *str) -{ - int i; - int res; - int sign; - - if (!str || !*str) - return (0); - i = 0; - res = 0; - sign = 1; - while (ft_iswhitespace(str[i])) - i++; - if (str[i] == '-' || str[i] == '+') - { - if (str[i + 1] >= '0' && str[i + 1] <= '9') - { - sign = (str[i] == '+') ? 1 : -1; - i++; - } - else - return (0); - } - while (str[i] >= '0' && str[i] <= '9') - res = res * 10 + str[i++] - '0'; - res *= sign; - return (res); -} diff --git a/libftasm/srcs/str/ft_convert_base.c b/libftasm/srcs/str/ft_convert_base.c deleted file mode 100644 index 633a82ef..00000000 --- a/libftasm/srcs/str/ft_convert_base.c +++ /dev/null @@ -1,86 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_convert_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/07 23:31:20 by jhalford #+# #+# */ -/* Updated: 2016/11/03 18:03:07 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static int get_size(char *str) -{ - int i; - int j; - - i = 0; - while (str[i] != '\0') - { - if (str[i] == '+' || str[i] == '-') - return (0); - if (str[i] < 32 || str[i] > 126) - return (0); - j = 0; - while (j < i) - { - if (str[j] == str[i]) - return (0); - j++; - } - i++; - } - return (i); -} - -static int get_pos(char c, char *str) -{ - int i; - - i = 0; - while (c != str[i] && str[i]) - i++; - return (i); -} - -static int ft_check_str(char *str, char *base, int base_size) -{ - while (*str) - { - if (!(get_pos(*str, base) < base_size || *str == '-' || *str == '+')) - return (0); - str++; - } - return (1); -} - -char *ft_convert_base( - char *str, char *base_from, char *base_to, char *flags) -{ - int base_size; - int res; - int sign; - - base_size = get_size(base_from); - res = 0; - sign = 1; - if (!ft_check_str(str, base_from, base_size)) - return (ft_itoa_base(0, "0", flags)); - if (base_size > 1) - { - if (*str == '-' || *str == '+') - { - if (get_pos(*(str + 1), base_from) < base_size) - sign = (*str == '+') ? 1 : -1; - else - return (ft_itoa_base(0, "0", flags)); - str++; - } - while (get_pos(*str, base_from) < base_size) - res = res * base_size + sign * get_pos(*str++, base_from); - } - return (ft_itoa_base(res, base_to, flags)); -} diff --git a/libftasm/srcs/str/ft_putaddr_fd.c b/libftasm/srcs/str/ft_putaddr_fd.c deleted file mode 100644 index a6c52a37..00000000 --- a/libftasm/srcs/str/ft_putaddr_fd.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putaddr_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/02/18 18:47:04 by jhalford #+# #+# */ -/* Updated: 2017/02/18 18:48:58 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putaddr_fd(void *a, int fd) -{ - char out[19]; - unsigned long long addr; - int i; - - ft_putnbr((long)a); - ft_putchar('\n'); - addr = (unsigned long long)a; - out[18] = 0; - i = 17; - while (addr) - { - ft_putnbr(addr); - ft_putchar('\n'); - out[i--] = "0123456789ABCDEF"[addr % 16]; - addr /= 16; - } - out[i--] = 'x'; - out[i] = '0'; - ft_putstr_fd(out + i, fd); -} diff --git a/libftasm/srcs/str/ft_split_whitespaces.c b/libftasm/srcs/str/ft_split_whitespaces.c deleted file mode 100644 index ed744d0d..00000000 --- a/libftasm/srcs/str/ft_split_whitespaces.c +++ /dev/null @@ -1,79 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_split_whitespaces.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/02/03 16:07:17 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strdupi_w(char const *s) -{ - int i; - char *str; - - i = 0; - while (s[i] && s[i] != ' ' && s[i] != '\t') - i++; - str = (char *)ft_malloc(sizeof(char) * (i + 1)); - if (str) - { - str[i--] = '\0'; - while (i >= 0) - { - str[i] = s[i]; - i--; - } - } - return (str); -} - -static int ft_len_words(char const *s) -{ - int i; - int len; - - i = 0; - len = 0; - while (s[i]) - { - if ((i == 0 && s[i] != ' ' && s[i] != '\t') || ((s[i] != ' ' - && s[i] != '\t') && (s[i - 1] == ' ' || s[i - 1] == '\t'))) - len++; - i++; - } - return (len); -} - -char **ft_split_whitespaces(char const *s) -{ - int i; - char **str; - int j; - - str = NULL; - if (!(s)) - return (str); - str = (char **)ft_malloc(sizeof(char *) * (ft_len_words(s) + 1)); - i = 0; - j = 0; - if (!(str)) - return (str); - while (s[i]) - { - if ((i == 0 && s[i] != ' ' && s[i] != '\t') || ((s[i] != ' ' - && s[i] != '\t') && (s[i - 1] == ' ' || s[i - 1] == '\t'))) - { - str[j] = ft_strdupi_w((s + i)); - j++; - } - i++; - } - str[j] = NULL; - return (str); -} diff --git a/libftasm/srcs/str/ft_str3join.c b/libftasm/srcs/str/ft_str3join.c deleted file mode 100644 index 91384cbc..00000000 --- a/libftasm/srcs/str/ft_str3join.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_str3join.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 18:03:26 by jhalford #+# #+# */ -/* Updated: 2017/03/13 16:07:24 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_str3join(char const *s1, char const *s2, char const *s3) -{ - char *join; - int size; - - size = ft_strlen(s1) + ft_strlen(s2) + ft_strlen(s3); - join = ft_strnew(size + 1); - ft_strcpy(join, s1); - ft_strcat(join, s2); - ft_strcat(join, s3); - return (join); -} diff --git a/libftasm/srcs/str/ft_strappend.c b/libftasm/srcs/str/ft_strappend.c deleted file mode 100644 index 2e52529d..00000000 --- a/libftasm/srcs/str/ft_strappend.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strappend.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/13 12:16:31 by jhalford #+# #+# */ -/* Updated: 2017/02/19 05:50:12 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strappend(char **dst, char *src) -{ - char *out; - - if (!(out = ft_strjoin(*dst, src))) - return (-1); - ft_strdel(dst); - *dst = out; - return (0); -} diff --git a/libftasm/srcs/str/ft_strbetween.c b/libftasm/srcs/str/ft_strbetween.c deleted file mode 100644 index 7492077e..00000000 --- a/libftasm/srcs/str/ft_strbetween.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strbetween.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/11 16:26:44 by jhalford #+# #+# */ -/* Updated: 2017/01/12 14:54:17 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strbetween(char *start, char *end) -{ - char *out; - - out = ft_strnew(end - start + 1); - ft_strncpy(out, start, end - start); - return (out); -} diff --git a/libftasm/srcs/str/ft_strcat.c b/libftasm/srcs/str/ft_strcat.c deleted file mode 100644 index 76f6f25c..00000000 --- a/libftasm/srcs/str/ft_strcat.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/07 10:56:53 by jhalford #+# #+# */ -/* Updated: 2017/03/21 14:21:22 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strcat(char *s1, const char *s2) -{ - char *start; - - start = s1; - s1 += ft_strlen(s1); - if (s2) - while (*s2) - *s1++ = *s2++; - *s1 = 0; - return (start); -} diff --git a/libftasm/srcs/str/ft_strcatf.c b/libftasm/srcs/str/ft_strcatf.c deleted file mode 100644 index 8caa7036..00000000 --- a/libftasm/srcs/str/ft_strcatf.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcatf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/07 15:46:03 by jhalford #+# #+# */ -/* Updated: 2016/12/09 19:02:20 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strcatf(char *s1, const char *s2) -{ - char buf[ft_strlen(s1) + 1]; - - ft_strcpy(buf, s1); - ft_strcpy(s1, s2); - ft_strcat(s1, buf); - return (s1); -} diff --git a/libftasm/srcs/str/ft_strchr.c b/libftasm/srcs/str/ft_strchr.c deleted file mode 100644 index c2ad43f6..00000000 --- a/libftasm/srcs/str/ft_strchr.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:53 by jhalford #+# #+# */ -/* Updated: 2017/02/20 16:43:10 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strchr(const char *s, int c) -{ - char *a; - - if (!s) - return (NULL); - a = (char *)s; - while (*a) - { - if (*a == (char)c) - return (a); - a++; - } - if (*a == (char)c) - return (a); - return (NULL); -} diff --git a/libftasm/srcs/str/ft_strchrcpy.c b/libftasm/srcs/str/ft_strchrcpy.c deleted file mode 100644 index 06b88879..00000000 --- a/libftasm/srcs/str/ft_strchrcpy.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strchrcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/01 15:43:59 by ariard #+# #+# */ -/* Updated: 2017/03/07 11:08:55 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strchrcpy(char *dst, const char *src, char c) -{ - while (*src && *src != c) - *dst++ = *src++; - *dst = '\0'; - return (dst); -} diff --git a/libftasm/srcs/str/ft_strclr.c b/libftasm/srcs/str/ft_strclr.c deleted file mode 100644 index 834eb6f1..00000000 --- a/libftasm/srcs/str/ft_strclr.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strclr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:57:54 by jhalford #+# #+# */ -/* Updated: 2016/11/03 14:57:55 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_strclr(char *s) -{ - size_t size; - size_t i; - - size = ft_strlen(s); - i = -1; - while (++i < size) - s[i] = 0; -} diff --git a/libftasm/srcs/str/ft_strcmp.c b/libftasm/srcs/str/ft_strcmp.c deleted file mode 100644 index de85d971..00000000 --- a/libftasm/srcs/str/ft_strcmp.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/07 10:49:02 by jhalford #+# #+# */ -/* Updated: 2017/03/14 18:09:26 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strcmp(const char *s1, const char *s2) -{ - int i; - - i = 0; - if (!s1 || !s2) - return (1); - while (*(s1 + i) && *(s1 + i) == *(s2 + i)) - i++; - return (*((unsigned char*)s1 + i) - *((unsigned char*)s2 + i)); -} diff --git a/libftasm/srcs/str/ft_strcpy.c b/libftasm/srcs/str/ft_strcpy.c deleted file mode 100644 index 63ee8897..00000000 --- a/libftasm/srcs/str/ft_strcpy.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/07 10:48:12 by jhalford #+# #+# */ -/* Updated: 2017/03/13 16:06:49 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strcpy(char *dst, const char *src) -{ - int i; - - i = 0; - while (src && src[i]) - { - dst[i] = src[i]; - i++; - } - dst[i] = '\0'; - return (dst); -} diff --git a/libftasm/srcs/str/ft_strcspn.c b/libftasm/srcs/str/ft_strcspn.c deleted file mode 100644 index d55d8081..00000000 --- a/libftasm/srcs/str/ft_strcspn.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcspn.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/20 15:55:33 by jhalford #+# #+# */ -/* Updated: 2017/03/20 16:00:37 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strcspn(char *s, const char *delim) -{ - char *str; - - str = s; - while (*str) - if (ft_strchr(delim, *str)) - return (str - s); - else - str++; - return (str - s); -} diff --git a/libftasm/srcs/str/ft_strcut.c b/libftasm/srcs/str/ft_strcut.c deleted file mode 100644 index 75b4d51b..00000000 --- a/libftasm/srcs/str/ft_strcut.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcut.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 18:04:37 by jhalford #+# #+# */ -/* Updated: 2016/11/03 18:04:37 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strcut(char *str, char *cut) -{ - char *target; - - while ((target = ft_strstr(str, cut))) - { - ft_strcpy(target, target + ft_strlen(cut)); - } - return (str); -} diff --git a/libftasm/srcs/str/ft_strdel.c b/libftasm/srcs/str/ft_strdel.c deleted file mode 100644 index f9eb34e4..00000000 --- a/libftasm/srcs/str/ft_strdel.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strdel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:00 by jhalford #+# #+# */ -/* Updated: 2017/02/19 05:47:47 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_strdel(char **as) -{ - if (as && *as) - { - free(*as); - *as = NULL; - } -} diff --git a/libftasm/srcs/str/ft_strdup.c b/libftasm/srcs/str/ft_strdup.c deleted file mode 100644 index 556558f4..00000000 --- a/libftasm/srcs/str/ft_strdup.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strdup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/07 14:25:41 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strdup(const char *s1) -{ - char *dup; - - if (!s1 || !(dup = (char*)ft_malloc(sizeof(*dup) * (ft_strlen(s1) + 1)))) - return (NULL); - ft_strcpy(dup, s1); - return (dup); -} diff --git a/libftasm/srcs/str/ft_strdupchr.c b/libftasm/srcs/str/ft_strdupchr.c deleted file mode 100644 index 3fd5d0d5..00000000 --- a/libftasm/srcs/str/ft_strdupchr.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strdupchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/07 11:01:15 by ariard #+# #+# */ -/* Updated: 2017/03/22 23:12:37 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strdupchr(const char *str, char c) -{ - char *new; - - if (!str || !(new = ft_memalloc(sizeof(*new) * (ft_strlenchr(str, c) + 1)))) - return (NULL); - ft_strchrcpy(new, str, c); - return (new); -} diff --git a/libftasm/srcs/str/ft_strduptr.c b/libftasm/srcs/str/ft_strduptr.c deleted file mode 100644 index 59cfd835..00000000 --- a/libftasm/srcs/str/ft_strduptr.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strduptr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/06 13:37:12 by ariard #+# #+# */ -/* Updated: 2017/03/21 15:43:52 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strduptr(char *str, int (*is)(int c)) -{ - char *new; - char *tmp; - - new = ft_memalloc(sizeof(char *) * ft_strlen(str) + 1); - tmp = new; - while (*str && (is)((int)*str)) - *new++ = *str++; - *new = 0; - return (tmp); -} diff --git a/libftasm/srcs/str/ft_strequ.c b/libftasm/srcs/str/ft_strequ.c deleted file mode 100644 index 88e5580c..00000000 --- a/libftasm/srcs/str/ft_strequ.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strequ.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:04 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:02:10 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strequ(char const *s1, char const *s2) -{ - return (ft_strcmp(s1, s2) == 0); -} diff --git a/libftasm/srcs/str/ft_strinsert.c b/libftasm/srcs/str/ft_strinsert.c deleted file mode 100644 index fcf8b1b6..00000000 --- a/libftasm/srcs/str/ft_strinsert.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strinsert.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/21 18:21:57 by jhalford #+# #+# */ -/* Updated: 2016/11/21 18:21:57 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strinsert(char *str, char c, int n) -{ - char tmp[ft_strlen(str)]; - char *out; - - ft_strcpy(tmp, str + n); - str[n] = 0; - out = ft_str3join(str, (char[]){c, 0}, tmp); - return (out); -} diff --git a/libftasm/srcs/str/ft_stris.c b/libftasm/srcs/str/ft_stris.c deleted file mode 100644 index ba809f85..00000000 --- a/libftasm/srcs/str/ft_stris.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_stris.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/02 15:11:28 by ariard #+# #+# */ -/* Updated: 2017/03/20 16:01:06 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_stris(char *str, int (*f)()) -{ - while (*str) - if (!(f)(*str++)) - return (0); - return (1); -} diff --git a/libftasm/srcs/str/ft_striter.c b/libftasm/srcs/str/ft_striter.c deleted file mode 100644 index 8c309549..00000000 --- a/libftasm/srcs/str/ft_striter.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_striter.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:13 by jhalford #+# #+# */ -/* Updated: 2016/11/03 14:58:13 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_striter(char *s, void (*f)(char *)) -{ - size_t size; - size_t i; - - size = ft_strlen(s); - i = -1; - while (++i < size) - (*f)(s + i); -} diff --git a/libftasm/srcs/str/ft_striteri.c b/libftasm/srcs/str/ft_striteri.c deleted file mode 100644 index 80cdd8b5..00000000 --- a/libftasm/srcs/str/ft_striteri.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_striteri.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:15 by jhalford #+# #+# */ -/* Updated: 2016/11/03 14:58:15 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_striteri(char *s, void (*f)(unsigned int, char *)) -{ - size_t size; - size_t i; - - size = ft_strlen(s); - i = -1; - while (++i < size) - (*f)(i, s + i); -} diff --git a/libftasm/srcs/str/ft_strjoin.c b/libftasm/srcs/str/ft_strjoin.c deleted file mode 100644 index 2c064f33..00000000 --- a/libftasm/srcs/str/ft_strjoin.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strjoin.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:18 by jhalford #+# #+# */ -/* Updated: 2017/02/19 05:50:20 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strjoin(char const *s1, char const *s2) -{ - char *join; - - if (!(join = ft_strnew(ft_strlen(s1) + ft_strlen(s2) + 1))) - return (NULL); - if (s1) - ft_strcpy(join, s1); - if (s2) - ft_strcat(join, s2); - return (join); -} diff --git a/libftasm/srcs/str/ft_strlcat.c b/libftasm/srcs/str/ft_strlcat.c deleted file mode 100644 index df94eea4..00000000 --- a/libftasm/srcs/str/ft_strlcat.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/07 10:57:16 by jhalford #+# #+# */ -/* Updated: 2016/08/07 21:44:13 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlcat(char *dst, const char *src, size_t size) -{ - size_t i; - size_t dst_size; - size_t src_size; - - dst_size = ft_strlen(dst); - src_size = ft_strlen(src); - i = 0; - while (src[i] != '\0' && ((dst_size + i) < (size - 1))) - { - dst[dst_size + i] = src[i]; - i++; - } - dst[dst_size + i] = '\0'; - return (src_size + ((dst_size < size) ? dst_size : size)); -} diff --git a/libftasm/srcs/str/ft_strlen.c b/libftasm/srcs/str/ft_strlen.c deleted file mode 100644 index 9b65ad39..00000000 --- a/libftasm/srcs/str/ft_strlen.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:22 by jhalford #+# #+# */ -/* Updated: 2017/03/18 14:25:09 by gwojda ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlen(const char *s) -{ - int i; - - i = 0; - if (!s) - return (0); - while (s[i]) - i++; - return (i); -} diff --git a/libftasm/srcs/str/ft_strlenchr.c b/libftasm/srcs/str/ft_strlenchr.c deleted file mode 100644 index 1ea82cfa..00000000 --- a/libftasm/srcs/str/ft_strlenchr.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlenchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/01 16:10:54 by ariard #+# #+# */ -/* Updated: 2017/03/22 22:12:03 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlenchr(const char *s, char c) -{ - size_t i; - - i = 0; - while (*s && *s++ != c) - i++; - return (i); -} diff --git a/libftasm/srcs/str/ft_strmap.c b/libftasm/srcs/str/ft_strmap.c deleted file mode 100644 index 5c0353ae..00000000 --- a/libftasm/srcs/str/ft_strmap.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strmap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:24 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strmap(char const *s, char (*f)(char)) -{ - size_t size; - size_t i; - char *out; - - size = ft_strlen(s); - out = (char *)ft_malloc(sizeof(char) * (size + 1)); - if (out == NULL) - return (NULL); - i = -1; - while (++i < size) - out[i] = (*f)(s[i]); - return (out); -} diff --git a/libftasm/srcs/str/ft_strmapi.c b/libftasm/srcs/str/ft_strmapi.c deleted file mode 100644 index 7cc6d089..00000000 --- a/libftasm/srcs/str/ft_strmapi.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strmapi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:28 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) -{ - size_t size; - size_t i; - char *out; - - size = ft_strlen(s); - out = (char *)ft_malloc(sizeof(char) * (size + 1)); - if (out == NULL) - return (NULL); - i = -1; - while (++i < size) - out[i] = (*f)(i, s[i]); - return (out); -} diff --git a/libftasm/srcs/str/ft_strncat.c b/libftasm/srcs/str/ft_strncat.c deleted file mode 100644 index 31ab2262..00000000 --- a/libftasm/srcs/str/ft_strncat.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/07 10:57:07 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:02:27 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strncat(char *s1, const char *s2, size_t n) -{ - size_t size; - size_t j; - - size = ft_strlen(s1); - j = 0; - while (s2[j] != '\0' && j < n) - { - s1[size + j] = s2[j]; - j++; - } - s1[size + j] = '\0'; - return (s1); -} diff --git a/libftasm/srcs/str/ft_strncmp.c b/libftasm/srcs/str/ft_strncmp.c deleted file mode 100644 index 57b55b5f..00000000 --- a/libftasm/srcs/str/ft_strncmp.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/07 10:49:12 by jhalford #+# #+# */ -/* Updated: 2016/11/03 16:11:00 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strncmp(const char *s1, const char *s2, size_t n) -{ - int i; - - i = 0; - while (*(s1 + i) && *(s1 + i) == *(s2 + i) && i < (int)n) - i++; - if (i < (int)n) - return (*((unsigned char*)s1 + i) - *((unsigned char*)s2 + i)); - else - return (0); -} diff --git a/libftasm/srcs/str/ft_strncpy.c b/libftasm/srcs/str/ft_strncpy.c deleted file mode 100644 index 85dd41c7..00000000 --- a/libftasm/srcs/str/ft_strncpy.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/07 10:48:21 by jhalford #+# #+# */ -/* Updated: 2016/08/07 10:48:25 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strncpy(char *dst, const char *src, size_t len) -{ - size_t i; - - i = 0; - while (src[i] != '\0' && i < len) - { - dst[i] = src[i]; - i++; - } - while (i < len) - { - dst[i] = '\0'; - i++; - } - return (dst); -} diff --git a/libftasm/srcs/str/ft_strndup.c b/libftasm/srcs/str/ft_strndup.c deleted file mode 100644 index ff3ed5be..00000000 --- a/libftasm/srcs/str/ft_strndup.c +++ /dev/null @@ -1,12 +0,0 @@ - -#include "libft.h" - -char *ft_strndup(const char *s1, size_t n) -{ - char *dup; - - if (!(dup = ft_memalloc(n))) - return (NULL); - ft_strncpy(dup, s1, n); - return (dup); -} diff --git a/libftasm/srcs/str/ft_strnequ.c b/libftasm/srcs/str/ft_strnequ.c deleted file mode 100644 index 5dfd6005..00000000 --- a/libftasm/srcs/str/ft_strnequ.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnequ.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:32 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:02:36 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strnequ(char const *s1, char const *s2, size_t n) -{ - return (ft_strncmp(s1, s2, n) == 0); -} diff --git a/libftasm/srcs/str/ft_strnew.c b/libftasm/srcs/str/ft_strnew.c deleted file mode 100644 index 2e2ae1d6..00000000 --- a/libftasm/srcs/str/ft_strnew.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnew.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:34 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strnew(size_t size) -{ - char *addr; - size_t i; - - addr = (char *)ft_malloc(size + 1); - if (addr == NULL) - return (NULL); - i = -1; - while (++i <= size) - addr[i] = '\0'; - return (addr); -} diff --git a/libftasm/srcs/str/ft_strnstr.c b/libftasm/srcs/str/ft_strnstr.c deleted file mode 100644 index efa7e54f..00000000 --- a/libftasm/srcs/str/ft_strnstr.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:36 by jhalford #+# #+# */ -/* Updated: 2016/11/03 16:34:42 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strnstr(const char *big, const char *little, size_t len) -{ - size_t i; - int j; - - i = -1; - if (!*little) - return ((char *)big); - while (big[++i] && i < len) - { - j = 0; - while (big[i + j] == little[j] && i + j < len) - { - j++; - if (!little[j]) - return ((char *)big + i); - } - } - return (NULL); -} diff --git a/libftasm/srcs/str/ft_strrchr.c b/libftasm/srcs/str/ft_strrchr.c deleted file mode 100644 index e41d4566..00000000 --- a/libftasm/srcs/str/ft_strrchr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strrchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:38 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:08:33 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strrchr(const char *s, int c) -{ - char *a; - int i; - - a = (char *)s; - i = ft_strlen(a); - while (i >= 0) - { - if (a[i] == (char)c) - return (a + i); - i--; - } - return (NULL); -} diff --git a/libftasm/srcs/str/ft_strreplace.c b/libftasm/srcs/str/ft_strreplace.c deleted file mode 100644 index 7fb72527..00000000 --- a/libftasm/srcs/str/ft_strreplace.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strreplace.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/12 13:50:21 by jhalford #+# #+# */ -/* Updated: 2017/01/12 13:59:25 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strreplace(char **str, char *start, char *end, char *new) -{ - char *out; - - out = ft_strnew(ft_strlen(*str) - (end - start) + ft_strlen(new) + 1); - ft_strncpy(out, *str, start - *str); - ft_strcat(out, new); - ft_strcat(out, end + 1); - ft_strdel(str); - *str = out; - return (out); -} diff --git a/libftasm/srcs/str/ft_strrev.c b/libftasm/srcs/str/ft_strrev.c deleted file mode 100644 index 73884204..00000000 --- a/libftasm/srcs/str/ft_strrev.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strrev.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 18:01:36 by jhalford #+# #+# */ -/* Updated: 2016/11/03 18:01:36 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strrev(char *str) -{ - int len; - char tmp; - int i; - - i = 0; - len = 0; - while (str[len] != '\0') - len++; - while (i < len / 2) - { - tmp = str[len - (i + 1)]; - str[len - (i + 1)] = str[i]; - str[i] = tmp; - i++; - } - return (str); -} diff --git a/libftasm/srcs/str/ft_strsepjoin.c b/libftasm/srcs/str/ft_strsepjoin.c deleted file mode 100644 index 8fbb0ee3..00000000 --- a/libftasm/srcs/str/ft_strsepjoin.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "libft.h" - -char *ft_strsepjoin(char **tab, char sep) -{ - char *join; - char **p; - int len; - - len = 0; - if (!(p = tab)) - return (NULL); - while (*p) - len += ft_strlen(*p++) + 1; - if (!(join = ft_strnew(len))) - return (NULL); - *join = 0; - p = tab; - while (*p) - { - ft_strcat(join, *p++); - ft_strcat(join, &sep); - } - join[len - 1] = 0; - return (join); -} diff --git a/libftasm/srcs/str/ft_strsplit.c b/libftasm/srcs/str/ft_strsplit.c deleted file mode 100644 index 049aa7ed..00000000 --- a/libftasm/srcs/str/ft_strsplit.c +++ /dev/null @@ -1,70 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strsplit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:40 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static int ft_countwords(char const *s, char c) -{ - if (c == '\0') - return ((*s == '\0') ? 0 : 1); - while (*s == c) - s++; - if (*s == '\0') - return (0); - while (*s != c && *s != '\0') - s++; - return (1 + ft_countwords(s, c)); -} - -static int get_word_len(char const *str, char c) -{ - int i; - int len; - - i = 0; - len = 0; - while (str[i] == c) - i++; - while (str[i] != c && str[i] != '\0') - { - i++; - len++; - } - return (len); -} - -char **ft_strsplit(char const *s, char c) -{ - int i; - int j; - int k; - char **str2; - - if (!s || !(str2 = (char **)ft_malloc(sizeof(*str2) * - (ft_countwords(s, c) + 1)))) - return (NULL); - i = -1; - j = 0; - while (++i < ft_countwords(s, c)) - { - k = 0; - if (!(str2[i] = ft_strnew(get_word_len(&s[j], c) + 1))) - str2[i] = NULL; - while (s[j] == c) - j++; - while (s[j] != c && s[j]) - str2[i][k++] = s[j++]; - str2[i][k] = '\0'; - } - str2[i] = 0; - return (str2); -} diff --git a/libftasm/srcs/str/ft_strstr.c b/libftasm/srcs/str/ft_strstr.c deleted file mode 100644 index bf8ab37a..00000000 --- a/libftasm/srcs/str/ft_strstr.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/08/07 10:48:35 by jhalford #+# #+# */ -/* Updated: 2016/11/03 16:28:05 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strstr(const char *big, const char *little) -{ - int i; - int j; - char *a; - - a = (char *)big; - i = 0; - if (!*little) - return (a); - while (a[i]) - { - j = 0; - while (a[i + j] == little[j]) - { - j++; - if (!little[j]) - return (a + i); - } - i++; - } - return (NULL); -} diff --git a/libftasm/srcs/str/ft_strsub.c b/libftasm/srcs/str/ft_strsub.c deleted file mode 100644 index 0c3fb11b..00000000 --- a/libftasm/srcs/str/ft_strsub.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strsub.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:43 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strsub(char const *s, unsigned int start, size_t len) -{ - char *out; - size_t i; - - if (!(out = (char *)ft_malloc(sizeof(char) * (len + 1)))) - return (NULL); - i = -1; - while (++i < len) - out[i] = s[i + start]; - out[i] = '\0'; - return (out); -} diff --git a/libftasm/srcs/str/ft_strtok.c b/libftasm/srcs/str/ft_strtok.c deleted file mode 100644 index dbb73ed9..00000000 --- a/libftasm/srcs/str/ft_strtok.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtok.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/07 18:08:31 by jhalford #+# #+# */ -/* Updated: 2017/03/22 22:23:33 by wescande ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strtok(char *s, const char *delim) -{ - static char *lasts; - int ch; - - if (s == 0) - s = lasts; - if ((ch = *s++) == 0) - return (0); - while (ft_strchr(delim, ch)) - if ((ch = *s++) == 0) - return (0); - --s; - lasts = s + ft_strcspn(s, delim); - if (*lasts != 0) - *lasts++ = 0; - return (s); -} diff --git a/libftasm/srcs/str/ft_strtrim.c b/libftasm/srcs/str/ft_strtrim.c deleted file mode 100644 index 22d17250..00000000 --- a/libftasm/srcs/str/ft_strtrim.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtrim.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 14:58:45 by jhalford #+# #+# */ -/* Updated: 2016/11/04 13:11:59 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strtrim(char const *s) -{ - char *out; - char *last; - - while (*s && FT_WS(*s)) - s++; - out = ft_strdup(s); - last = out + ft_strlen(out) - 1; - while (last > out && FT_WS(*last)) - *last-- = 0; - return (out); -} diff --git a/libftasm/srcs/sys/open_new.c b/libftasm/srcs/sys/open_new.c deleted file mode 100644 index 49491cce..00000000 --- a/libftasm/srcs/sys/open_new.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "libft.h" - -/* -** If file already exists, create xxx(1) instead, etc up to 9 -*/ - -int open_new(char *filename, int oflag) -{ - char *fname; - int fd; - int i; - int len; - - len = ft_strlen(filename); - fname = ft_strnew(len + 4); - ft_strcpy(fname, filename); - i = 0; - while (i < 10 && (fd = open(fname, oflag | O_CREAT | O_EXCL, 0644)) < 0 - && errno == EEXIST) - { - fname[len] = '('; - fname[len + 1] = ++i + '0'; - fname[len + 2] = ')'; - } - ft_strdel(&fname); - return (fd); -} diff --git a/libftasm/srcs/time/ft_mytime_free.c b/libftasm/srcs/time/ft_mytime_free.c deleted file mode 100644 index c8a89efc..00000000 --- a/libftasm/srcs/time/ft_mytime_free.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_mytime_free.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/25 11:45:29 by jhalford #+# #+# */ -/* Updated: 2017/02/18 13:11:33 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_mytime_free(t_mytime **time) -{ - ft_strdel(&(*time)->year); - ft_strdel(&(*time)->month); - ft_strdel(&(*time)->day); - ft_strdel(&(*time)->hour); - ft_strdel(&(*time)->min); - ft_strdel(&(*time)->sec); - ft_memdel((void **)time); -} diff --git a/libftasm/srcs/time/ft_mytime_get.c b/libftasm/srcs/time/ft_mytime_get.c deleted file mode 100644 index ab8f25b3..00000000 --- a/libftasm/srcs/time/ft_mytime_get.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_getstrtime.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/25 11:34:56 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_mytime *ft_mytime_get(time_t epoch) -{ - char *date; - t_mytime *time; - - time = (t_mytime*)ft_malloc(sizeof(*time)); - date = ctime(&epoch); - date[ft_strlen(date) - 1] = 0; - time->year = ft_isdigit(date[20]) ? - ft_strsub(date, 20, 4) : ft_strsub(date, 24, 5); - time->month = ft_strsub(date, 4, 3); - time->day = ft_strsub(date, 8, 2); - time->hour = ft_strsub(date, 11, 2); - time->min = ft_strsub(date, 14, 2); - time->sec = ft_strsub(date, 17, 2); - return (time); -} diff --git a/libftasm/srcs/time/ft_time_isrecent.c b/libftasm/srcs/time/ft_time_isrecent.c deleted file mode 100644 index ec195653..00000000 --- a/libftasm/srcs/time/ft_time_isrecent.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_time_isrecent.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/03 18:01:04 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:44:24 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_time_isrecent(time_t event) -{ - time_t now; - - now = time(&now); - if (now - event >= 0 && now - event <= 6 * 365 / 12 * 24 * 60 * 60) - return (1); - else - return (0); -}