diff --git a/libft/includes/color.h b/libft/includes/color.h new file mode 100644 index 00000000..2c7b09e7 --- /dev/null +++ b/libft/includes/color.h @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* color.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/25 13:36:48 by jhalford #+# #+# */ +/* Updated: 2016/11/25 18:27:28 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef COLOR_H +# define COLOR_H +# include "libft.h" + +# define FG_BLACK "\x1b[30m" +# define FG_RED "\x1b[31m" +# define FG_GREEN "\x1b[32m" +# define FG_YELLOW "\x1b[33m" +# define FG_BLUE "\x1b[34m" +# define FG_MAGENTA "\x1b[35m" +# define FG_CYAN "\x1b[36m" +# define FG_DEFAULT "\x1b[0m" + +# define BG_BLACK "\x1b[40m" +# define BG_RED "\x1b[41m" +# define BG_GREEN "\x1b[42m" +# define BG_YELLOW "\x1b[43m" +# define BG_BLUE "\x1b[44m" +# define BG_MAGENTA "\x1b[45m" +# define BG_CYAN "\x1b[46m" +# define BG_DEFAULT "\x1b[49m" + +void ft_color_reset(void); +void ft_color_set(char *fg, char *bg); + +#endif diff --git a/libft/includes/libft.h b/libft/includes/libft.h index 216c1b6d..5af9a166 100644 --- a/libft/includes/libft.h +++ b/libft/includes/libft.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */ -/* Updated: 2016/11/23 13:56:46 by jhalford ### ########.fr */ +/* Updated: 2016/11/25 16:02:22 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,15 +14,19 @@ # define LIBFT_H # include "ft_xattr.h" +# include "mytime.h" # include "lst.h" # include "dlst.h" # include "btree.h" +# include "color.h" # include # include # include # include # include +# include +# include # define FT_WS(x) (x == ' ' || x == '\t' || x == '\n') # define FT_ABS(x) (((x) < 0) ? -(x) : (x)) @@ -125,8 +129,6 @@ char **ft_sstrdup(char **list); void ft_sstrdel(char **sstr, int index); void ft_sstrfree(char **sstr); -int ft_time_isrecent(time_t event); - char *ft_path_notdir(char *path); int ft_printf(const char *format, ...); diff --git a/libft/includes/mytime.h b/libft/includes/mytime.h new file mode 100644 index 00000000..1bd8c58f --- /dev/null +++ b/libft/includes/mytime.h @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* mytime.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/25 11:43:12 by jhalford #+# #+# */ +/* Updated: 2016/11/25 18:28:27 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/libft/src/btree/btree_print.c b/libft/src/btree/btree_print.c index 757fa330..41d3224e 100644 --- a/libft/src/btree/btree_print.c +++ b/libft/src/btree/btree_print.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 18:06:24 by jhalford #+# #+# */ -/* Updated: 2016/11/21 15:13:44 by jhalford ### ########.fr */ +/* Updated: 2016/11/25 18:28:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/color/ft_color_reset.c b/libft/src/color/ft_color_reset.c new file mode 100644 index 00000000..4b557bff --- /dev/null +++ b/libft/src/color/ft_color_reset.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 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/libft/src/color/ft_color_set.c b/libft/src/color/ft_color_set.c new file mode 100644 index 00000000..55313cfc --- /dev/null +++ b/libft/src/color/ft_color_set.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_color_set.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/25 13:53:46 by jhalford #+# #+# */ +/* Updated: 2016/11/25 14:05:39 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_color_set(char *fg, char *bg) +{ + ft_putstr(fg); + ft_putstr(bg); +} diff --git a/libft/src/str/ft_strsub.c b/libft/src/str/ft_strsub.c index 67e74782..f4259a58 100644 --- a/libft/src/str/ft_strsub.c +++ b/libft/src/str/ft_strsub.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:43 by jhalford #+# #+# */ -/* Updated: 2016/11/16 17:52:01 by jhalford ### ########.fr */ +/* Updated: 2016/11/25 11:31:36 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/time/ft_mytime_free.c b/libft/src/time/ft_mytime_free.c new file mode 100644 index 00000000..08c06dde --- /dev/null +++ b/libft/src/time/ft_mytime_free.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_mytime_free.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/25 11:45:29 by jhalford #+# #+# */ +/* Updated: 2016/11/25 11:48:12 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/libft/src/time/ft_mytime_get.c b/libft/src/time/ft_mytime_get.c new file mode 100644 index 00000000..29d26941 --- /dev/null +++ b/libft/src/time/ft_mytime_get.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_getstrtime.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/25 11:34:56 by jhalford #+# #+# */ +/* Updated: 2016/11/25 11:55:18 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + + +t_mytime *ft_mytime_get(time_t epoch) +{ + char *date; + t_mytime *time; + + time = (t_mytime*)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/libft/src/time/ft_time_isrecent.c b/libft/src/time/ft_time_isrecent.c index 0a01102d..04712152 100644 --- a/libft/src/time/ft_time_isrecent.c +++ b/libft/src/time/ft_time_isrecent.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 18:01:04 by jhalford #+# #+# */ -/* Updated: 2016/11/08 16:12:50 by jhalford ### ########.fr */ +/* Updated: 2016/11/25 11:43:52 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/xattr/ft_xattr_count.c b/libft/src/xattr/ft_xattr_count.c index 880c66d6..01b96eb5 100644 --- a/libft/src/xattr/ft_xattr_count.c +++ b/libft/src/xattr/ft_xattr_count.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 18:00:52 by jhalford #+# #+# */ -/* Updated: 2016/11/03 18:00:56 by jhalford ### ########.fr */ +/* Updated: 2016/11/25 17:22:07 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */