diff options
Diffstat (limited to 'libft/include')
| -rw-r--r-- | libft/include/libft.h | 34 | ||||
| -rw-r--r-- | libft/include/libft_algo.h | 81 | ||||
| -rw-r--r-- | libft/include/libft_bt.h | 28 | ||||
| -rw-r--r-- | libft/include/libft_ctype.h | 36 | ||||
| -rw-r--r-- | libft/include/libft_def.h | 56 | ||||
| -rw-r--r-- | libft/include/libft_dlst.h | 30 | ||||
| -rw-r--r-- | libft/include/libft_dstr.h | 45 | ||||
| -rw-r--r-- | libft/include/libft_ht.h | 72 | ||||
| -rw-r--r-- | libft/include/libft_io.h | 46 | ||||
| -rw-r--r-- | libft/include/libft_lst.h | 68 | ||||
| -rw-r--r-- | libft/include/libft_mem.h | 39 | ||||
| -rw-r--r-- | libft/include/libft_printf.h | 27 | ||||
| -rw-r--r-- | libft/include/libft_str.h | 108 | ||||
| -rw-r--r-- | libft/include/libft_util.h | 20 | ||||
| -rw-r--r-- | libft/include/libft_vec.h | 60 |
15 files changed, 750 insertions, 0 deletions
diff --git a/libft/include/libft.h b/libft/include/libft.h new file mode 100644 index 0000000..e982608 --- /dev/null +++ b/libft/include/libft.h @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/10/07 09:45:02 by cacharle #+# #+# */ +/* Updated: 2020/04/03 06:32:37 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_H +# define LIBFT_H + +# include <unistd.h> +# include <stdarg.h> +# include <stdlib.h> +# include <stddef.h> +# include <stdbool.h> +# include <limits.h> +# include <errno.h> + +# ifdef __linux__ +# include <stdio.h> +# define OPEN_MAX FOPEN_MAX +# endif + +# include "libft_io.h" +# include "libft_mem.h" +# include "libft_str.h" +# include "libft_ctype.h" + +#endif diff --git a/libft/include/libft_algo.h b/libft/include/libft_algo.h new file mode 100644 index 0000000..e859de5 --- /dev/null +++ b/libft/include/libft_algo.h @@ -0,0 +1,81 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_algo.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/19 07:22:57 by cacharle #+# #+# */ +/* Updated: 2020/04/04 23:33:51 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** \file libft_algo.h +** \brief Algorithms +*/ + +#ifndef LIBFT_ALGO_H +# define LIBFT_ALGO_H + +# include <stdlib.h> +# include "libft_mem.h" +# include "libft_def.h" +# include "libft_str.h" + +/* +** \brief Range struct +** \param lo Lower bound +** \param hi Upper bound +*/ + +typedef struct +{ + int lo; + int hi; +} t_ftrange; + +/* +** \brief Merge sort consts struct +** \param base Array to sort +** \param left Left subarray +** \param right Right subarray +** \note Only used internaly by ft_mergesort +*/ + +struct s_merge_sorted_arrays +{ + void *base; + void *left; + void *right; +}; + +/* +** remove this horror +*/ + +typedef struct s_ft_search_const +{ + const void *key; + t_ftcompar_func compar; +} t_ftsearch_const; + +bool ft_is_set(void *base, size_t nel, size_t width, + t_ftcompar_func compar); +int ft_compar_int(const void *a, const void *b); +int ft_compar_str(const void *s1_p, const void *s2_p); +void ft_qsort(void *base, size_t nel, size_t width, + t_ftcompar_func compar); +int ft_mergesort(void *base, size_t nel, size_t width, + int (*compar)(const void *, const void *)); +int ft_heapsort(void *base, size_t nel, size_t width, + int (*compar)(const void *, const void *)); +void ft_reverse(void *base, size_t nel, size_t width); +void *ft_bsearch(const void *base, size_t nel, size_t width, + t_ftsearch_const *consts); +void *ft_lfind(const void *base, size_t *nelp, size_t width, + t_ftsearch_const *consts); +void *ft_lsearch(const void *base, size_t *nelp, size_t width, + t_ftsearch_const *consts); + +#endif diff --git a/libft/include/libft_bt.h b/libft/include/libft_bt.h new file mode 100644 index 0000000..6e2cc91 --- /dev/null +++ b/libft/include/libft_bt.h @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_bt.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/07 21:26:34 by cacharle #+# #+# */ +/* Updated: 2020/02/07 21:34:52 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_BT_H +# define LIBFT_BT_H + +# include <stdlib.h> + +typedef struct s_ftbtree +{ + void *data; + struct s_ftbtree *left; + struct s_ftbtree *right; +} t_ftbtree; + +t_ftbtree *ft_btnew(void *data); +void ft_btdestroy(t_ftbtree *tree, void (*del)(void *data)); + +#endif diff --git a/libft/include/libft_ctype.h b/libft/include/libft_ctype.h new file mode 100644 index 0000000..61f4534 --- /dev/null +++ b/libft/include/libft_ctype.h @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_ctype.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:35:31 by cacharle #+# #+# */ +/* Updated: 2020/02/28 12:08:52 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_CTYPE_H +# define LIBFT_CTYPE_H + +/* +** assertion +*/ + +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_isspace(int c); +int ft_isblank(int c); + +/* +** conversion +*/ + +int ft_toupper(int c); +int ft_tolower(int c); +int ft_todigit(int c); + +#endif diff --git a/libft/include/libft_def.h b/libft/include/libft_def.h new file mode 100644 index 0000000..7406959 --- /dev/null +++ b/libft/include/libft_def.h @@ -0,0 +1,56 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_def.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:36:56 by cacharle #+# #+# */ +/* Updated: 2020/04/04 21:40:37 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** \file libft_def.h +** \brief Type and constant definition +*/ + +#ifndef LIBFT_DEF_H +# define LIBFT_DEF_H + +# include <stddef.h> +# include <stdbool.h> + +# define TRUE 1 +# define FALSE 0 + +typedef unsigned char t_ftbyte; +typedef int t_ftbool; +typedef unsigned int t_ftsize; + +typedef char t_ftchar; +typedef unsigned char t_ftuchar; +typedef int t_ftint; +typedef unsigned int t_ftuint; +typedef long int t_ftlong; +typedef unsigned long int t_ftulong; + +/* +** \brief Standard delete function +** \param x Resource to delete +*/ + +typedef void (*t_ftdel_func)(void *x); + +/* +** \brief Standard comparison function +** \param x1 Resource 1 +** \param x2 Resource 2 +** \return negative number if x1 < x2, +** 0 if x1 == x2, +** positive number if x1 > x2 +*/ + +typedef int (*t_ftcompar_func)(const void *x1, const void *x2); + +#endif diff --git a/libft/include/libft_dlst.h b/libft/include/libft_dlst.h new file mode 100644 index 0000000..9870ea7 --- /dev/null +++ b/libft/include/libft_dlst.h @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_dlst.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/03 15:15:04 by charles #+# #+# */ +/* Updated: 2020/04/03 15:44:32 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_DLST_H +# define LIBFT_DLST_H + +# include <stdlib.h> +# include "libft_def.h" + +typedef struct s_ftdlst +{ + struct s_ftdlst *prev; + struct s_ftdlst *next; + void *data; +} t_ftdlst; + +t_ftdlst *ft_dlstnew(void *data); +void ft_dlstdestroy(t_ftdlst *dlst, t_ftdel_func del); +void ft_dlstdelone(t_ftdlst *dlst, t_ftdel_func del); + +#endif diff --git a/libft/include/libft_dstr.h b/libft/include/libft_dstr.h new file mode 100644 index 0000000..d482f73 --- /dev/null +++ b/libft/include/libft_dstr.h @@ -0,0 +1,45 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_dstr.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/03 10:39:51 by charles #+# #+# */ +/* Updated: 2020/06/09 17:35:47 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_DSTR_H +# define LIBFT_DSTR_H + +# include <stdlib.h> +# include "libft_def.h" +# include "libft_str.h" +# include "libft_mem.h" + +/* +** \brief Dynamic string struct +** \param str Underlying null-terminated character array +** \param length Number of character (not including the '\0') +** \param capacity Maximum length - 1 of the current string +*/ + +typedef struct s_ftdstr +{ + char *str; + size_t length; + size_t capacity; +} t_ftdstr; + +t_ftdstr *ft_dstrnew(char *from); +void ft_dstrdestroy(t_ftdstr *dstr); +t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); +t_ftdstr *ft_dstrwrap(char *str); +char *ft_dstrunwrap(t_ftdstr *dstr); +t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); +void ft_dstrerase(t_ftdstr *dstr, size_t start, size_t len); +t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *replacement, + size_t start, size_t end); + +#endif diff --git a/libft/include/libft_ht.h b/libft/include/libft_ht.h new file mode 100644 index 0000000..91aa153 --- /dev/null +++ b/libft/include/libft_ht.h @@ -0,0 +1,72 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_ht.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:36:09 by cacharle #+# #+# */ +/* Updated: 2020/09/09 15:47:22 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_HT_H +# define LIBFT_HT_H + +/* +** \file libft_ht.h +** \brief Hash table manipulation +*/ + +# include "libft.h" +# include "libft_def.h" +# include "libft_lst.h" +# include "libft_mem.h" + +/* +** \brief Hash table entry, key/value pair +** \param key String key +** \param value Pointer to data +*/ + +typedef struct s_ftht_entry +{ + char *key; + void *value; +} t_ftht_entry; + +/* +** \brief Hash table struct +** \param size Number of buckets +** \param buckets Bucket array, each bucket is a linked list +*/ + +typedef struct s_ftht +{ + size_t size; + t_ftlst **buckets; +} t_ftht; + +size_t ft_hthash(t_ftht *ht, char *key); + +t_ftht *ft_htnew(size_t size); +void ft_htdestroy(t_ftht *ht, t_ftdel_func del); +void *ft_htget(t_ftht *ht, char *key); +t_ftht_entry *ft_htset(t_ftht *ht, char *key, void *value, + t_ftdel_func del); +t_ftht_entry *ft_htset_safe(t_ftht *ht, char *key, void *value, + t_ftdel_func del); +void ft_htdelone(t_ftht *ht, char *key, t_ftdel_func del); +t_ftht_entry *ft_htentry_new(char *key, void *value); +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)); + +/* +** internals +*/ + +int ft_inter_htkey_cmp(const void *ref_key, const void *content); +void ft_inter_htdel_first_order(t_ftht_entry *entry); +void ft_inter_htdel_first_order_setup(t_ftdel_func del); +void ft_inter_htdel_first_order_teardown(void); + +#endif diff --git a/libft/include/libft_io.h b/libft/include/libft_io.h new file mode 100644 index 0000000..1294abc --- /dev/null +++ b/libft/include/libft_io.h @@ -0,0 +1,46 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_io.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:35:43 by cacharle #+# #+# */ +/* Updated: 2020/06/19 17:45:34 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_IO_H +# define LIBFT_IO_H + +# include <unistd.h> +# include <stdlib.h> +# include <limits.h> +# include "libft.h" + +void ft_putendl(char *s); +void ft_putchar(char c); +void ft_putstr(char const *s); +void ft_putnbr(int n); +void ft_putchar_fd(char c, int fd); +void ft_putstr_fd(char *s, int fd); +void ft_putendl_fd(char *s, int fd); +void ft_putnbr_fd(int n, int fd); + +char ft_getchar(void); + +# ifndef FTGL_BUFFER_SIZE +# define FTGL_BUFFER_SIZE 32 +# endif + +# define FTGL_OK 1 +# define FTGL_EOF 0 +# define FTGL_ERROR -1 + +/* +** ft_getline.c (get_next_line) +*/ + +int ft_getline(int fd, char **line); + +#endif diff --git a/libft/include/libft_lst.h b/libft/include/libft_lst.h new file mode 100644 index 0000000..0dc1e7c --- /dev/null +++ b/libft/include/libft_lst.h @@ -0,0 +1,68 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_lst.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:36:39 by cacharle #+# #+# */ +/* Updated: 2020/08/20 14:40:01 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_LST_H +# define LIBFT_LST_H + +/* +** \file libft_lst.h +** \brief Linked list Manipulation +*/ + +# include <stdlib.h> +# include "libft_def.h" +# include "libft_algo.h" + +/* +** \brief List struct +** \param data Pointer to node data +** \param next Pointer to next node or NULL if last node +*/ + +typedef struct s_ftlst +{ + void *data; + struct s_ftlst *next; +} t_ftlst; + +typedef void (*t_ftdel_func)(void *); + +t_ftlst *ft_lstnew(void const *data); +int ft_lstsize(t_ftlst *lst); +void ft_lstpush_front(t_ftlst **alst, t_ftlst *new); +t_ftlst *ft_lstpush_front_node(t_ftlst **alst, void *data); +void ft_lstpush_back(t_ftlst **alst, t_ftlst *new); +void ft_lstpop_front(t_ftlst **lst, void (*del)(void *)); +void ft_lstpop_back(t_ftlst **lst, void (*del)(void *)); +t_ftlst *ft_lstlast(t_ftlst *lst); +void ft_lstdelone(t_ftlst *lst, void (*del)(void *)); +void *ft_lstdestroy(t_ftlst **lst, void (*del)(void *)); +void ft_lstiter(t_ftlst *lst, void (*f)(void *)); +t_ftlst *ft_lstmap(t_ftlst *lst, void *(*f)(void *), + t_ftdel_func del); +t_ftlst *ft_lstreverse_ret(t_ftlst *lst); +void ft_lstreverse(t_ftlst **lst); +void ft_lstremove_if(t_ftlst **lst, + t_ftcompar_func cmp, const void *ref, + t_ftdel_func del); +void ft_lstinsert(t_ftlst **lst, t_ftlst *insert, size_t i); +t_ftlst *ft_lstbsearch(t_ftlst *lst, t_ftcompar_func cmp, + const void *ref); +t_ftlst *ft_lstlsearch(t_ftlst *lst, t_ftcompar_func cmp, + const void *ref); +t_ftlst *ft_lstlfind(t_ftlst *lst, t_ftcompar_func cmp, + const void *ref); +void ft_lstsort(t_ftlst **begin_list, t_ftcompar_func cmp); +t_ftlst *ft_lstsorted_merge(t_ftlst *l1, t_ftlst *l2, + t_ftcompar_func cmp); + +#endif diff --git a/libft/include/libft_mem.h b/libft/include/libft_mem.h new file mode 100644 index 0000000..26b4ccd --- /dev/null +++ b/libft/include/libft_mem.h @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_mem.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:35:57 by cacharle #+# #+# */ +/* Updated: 2020/02/28 12:17:48 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_MEM_H +# define LIBFT_MEM_H + +# include <stddef.h> +# include "libft_def.h" + +void ft_bzero(void *s, size_t n); +void *ft_memset(void *s, int c, size_t n); +void *ft_memcpy(void *dest, const void *src, size_t n); +void *ft_memccpy(void *dest, 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_calloc(size_t count, size_t size); +void ft_memswap(void *a, void *b, size_t size); +void *ft_memmem(const void *big, size_t big_len, + const void *little, size_t little_len); +void ft_memset_pattern4(void *b, const void *pattern4, + size_t len); + +/* +** bloat ? +*/ + +void ft_memdel(void **ap); + +#endif diff --git a/libft/include/libft_printf.h b/libft/include/libft_printf.h new file mode 100644 index 0000000..8e64208 --- /dev/null +++ b/libft/include/libft_printf.h @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_printf.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:36:47 by cacharle #+# #+# */ +/* Updated: 2020/01/31 10:36:51 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_PRINTF_H +# define LIBFT_PRINTF_H + +int ft_printf(const char *format, ...); +int ft_sprintf(char *str, const char *format, ...); +int ft_snprintf(char *str, size_t size, const char *format, ...); +int ft_asprintf(char **ret, const char *format, ...); +int ft_dprintf(int fd, const char *format, ...); +int ft_vprintf(const char *format, va_list ap); +int ft_vsprintf(char *str, const char *format, va_list ap); +int ft_vsnprintf(char *str, size_t size, const char *format, va_list ap); +int ft_vasprintf(char **ret, const char *format, va_list ap); +int ft_vdprintf(int fd, const char *format, va_list ap); + +#endif diff --git a/libft/include/libft_str.h b/libft/include/libft_str.h new file mode 100644 index 0000000..3a52a2f --- /dev/null +++ b/libft/include/libft_str.h @@ -0,0 +1,108 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_str.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ +/* Updated: 2020/10/08 09:40:44 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_STR_H +# define LIBFT_STR_H + +# include <stddef.h> +# include <stdbool.h> +# include "libft_ctype.h" +# include "libft_util.h" + +typedef enum +{ + FT_STRJOINF_FST, + FT_STRJOINF_SND, + FT_STRJOINF_ALL +} t_ftstrjoinf_tag; + +/* +** std +*/ + +size_t ft_strlen(const char *s); +char *ft_strcpy(char *dest, const char *src); +char *ft_strncpy(char *dest, const char *src, size_t n); +char *ft_strdup(const char *s); +char *ft_strndup(const char *s1, size_t n); +char *ft_strcat(char *dest, const char *src); +char *ft_strncat(char *dest, const char *src, size_t n); +size_t ft_strlcat(char *dst, const char *src, size_t size); +size_t ft_strlcpy(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 *haystack, const char *needle); +char *ft_strnstr(const char *haystack, const char *needle, 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 *nptr); + +/* +** extra +*/ + +void ft_striter(char *s, void (*f)(char *)); +void ft_striteri(char *s, void (*f)(unsigned int, char *)); +char *ft_strsub(char const *s, size_t start, size_t len); +char *ft_strsubf(char const *s, size_t start, size_t len); +char *ft_strjoin(char const *s1, char const *s2); +char *ft_strjoin3(char const *s1, char const *s2, char const *s3); +char *ft_strjoinf(char const *s1, char const *s2, t_ftstrjoinf_tag tag); +char *ft_strjoinf_fst(char const *s1, char const *s2); +char *ft_strjoinf_snd(char const *s1, char const *s2); +char *ft_strtrim(char const *s1, char const *set); +char **ft_split(char const *s, char c); +char **ft_splitf(char *s, char c); +int ft_strcount(char *str, char c); +char *ft_itoa(int n); +char *ft_itoa_cpy(char *dst, int n); +int ft_atoi_strict(const char *s); +long ft_strtol(const char *s, char **endptr, int base); +int ft_strcasecmp(const char *s1, const char *s2); +int ft_strncasecmp(const char *s1, const char *s2, size_t n); +size_t ft_strspn(const char *s, const char *charset); +size_t ft_strcspn(const char *s, const char *charset); +char *ft_strpbrk(const char *s, const char *charset); +char *ft_strsep(char **stringp, const char *delim); +size_t ft_strnlen(const char *s, size_t maxlen); +char *ft_strmap(char const *s, char (*f)(char)); +char *ft_strmapi(char *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_strtolower(char *s); +char *ft_strtoupper(char *s); +char *ft_strcat3(char *dest, const char *src1, const char *src2); + +/* +** glob +*/ + +bool ft_fnmatch(const char *pattern, const char *string); + +/* +** NULL terminated string array +*/ + +char *ft_strsjoin(char **strs, char *delim); +char *ft_strsjoinf(char **strs, char *delim); + +/* +** bloat ? +*/ + +/* +** char *ft_strnew(size_t size); +** void ft_strdel(char **as); +** void ft_strclr(char *s); +*/ + +#endif diff --git a/libft/include/libft_util.h b/libft/include/libft_util.h new file mode 100644 index 0000000..7a9e056 --- /dev/null +++ b/libft/include/libft_util.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_util.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/27 17:51:36 by cacharle #+# #+# */ +/* Updated: 2020/02/27 17:52:16 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_UTIL_H +# define LIBFT_UTIL_H + +# include <stdlib.h> + +void *ft_split_destroy(char **strs); + +#endif diff --git a/libft/include/libft_vec.h b/libft/include/libft_vec.h new file mode 100644 index 0000000..287ce6f --- /dev/null +++ b/libft/include/libft_vec.h @@ -0,0 +1,60 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_vec.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/01 18:57:16 by charles #+# #+# */ +/* Updated: 2020/10/11 14:04:43 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_VEC_H +# define LIBFT_VEC_H + +/* +** \file libft_vec.h +** \brief Vector manipulation +*/ + +# include <stdlib.h> +# include "libft_def.h" +# include "libft_mem.h" +# include "libft_algo.h" +# include "libft_lst.h" + +/* +** \brief Vector struct +** \param data Underlying array +** \param capacity Size of the underlying array +** \param size Number of element in the vector +*/ + +typedef struct s_ftvec +{ + void **data; + size_t capacity; + size_t size; +} t_ftvec; + +t_ftvec *ft_vecnew(size_t capacity); +void *ft_vecdestroy(t_ftvec *vec, void (*del)(void *elem)); +t_ftvec *ft_vecgrow(t_ftvec *vec); +t_ftvec *ft_vecreserve(t_ftvec *vec, size_t capacity); +t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed); +t_ftvec *ft_vecpush_safe(t_ftvec *vec, void *pushed); +void ft_vecpop(t_ftvec *vec, void (*del)(void *elem)); +void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); +void ft_veciter_addr(t_ftvec *vec, void (*f)(void **addr)); +void *ft_vectake(t_ftvec *vec, size_t i); +void ft_vecremove(t_ftvec *vec, size_t i, void (*del)(void *elem)); +t_ftvec *ft_vecinsert(t_ftvec *vec, size_t i, void *elem); +t_ftvec *ft_vecinsert_safe(t_ftvec *vec, size_t i, void *elem); +void ft_vecsort(t_ftvec *vec, t_ftcompar_func cmp); +void **ft_vecunwrap(t_ftvec *vec); +t_ftvec *ft_vecfrom_lst(t_ftlst *lst); +t_ftvec *ft_vecswallow_at( + t_ftvec *vec, size_t index, t_ftvec *swallowed); + +#endif |
