diff options
Diffstat (limited to 'libft/inc/libft.h')
-rw-r--r-- | libft/inc/libft.h | 158 |
1 files changed, 130 insertions, 28 deletions
diff --git a/libft/inc/libft.h b/libft/inc/libft.h index 1a47877..843e97c 100644 --- a/libft/inc/libft.h +++ b/libft/inc/libft.h @@ -1,24 +1,27 @@ /* ************************************************************************** */ -/* LE - / */ -/* / */ -/* libft.h .:: .:/ . .:: */ -/* +:+:+ +: +: +:+:+ */ -/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */ -/* #+# #+ #+ #+# */ -/* Created: 2019/10/07 18:15:13 by rbousset #+# ## ## #+# */ -/* Updated: 2019/10/13 14:17:02 by rbousset ### #+. /#+ ###.fr */ -/* / */ -/* / */ +/* */ +/* ::: :::::::: */ +/* libft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ /* ************************************************************************** */ # ifndef LIBFT_H # define LIBFT_H #include <stddef.h> +#include <stdarg.h> #include <inttypes.h> +# define FT_MIN_HEX_BASE "0123456789abcdef" +# define FT_MAJ_HEX_BASE "0123456789ABCDEF" +# define FT_PRINTF_CONV_CHARSET "cspdiuxX%" # ifndef BUFFER_SIZE -# define BUFFER_SIZE 72 +# define BUFFER_SIZE 72 # endif typedef struct s_list @@ -27,21 +30,40 @@ typedef struct s_list struct s_list *next; } t_list; +typedef struct s_gnl +{ + int fd; + char *rest; + struct s_gnl *next; +} t_gnl; + +typedef struct s_printflist +{ + int putlen; + char conv; + char actconv; + char *fullflag; + size_t flaglen; + int width; + int precision; + uint8_t isreverse; + uint8_t isneg; + uint8_t isaz; + int8_t isaspace; + uint8_t isaplus; + int8_t lh; + uint8_t zflag; + uint8_t issharp; + uint8_t isminus; + int fulllen; + char *output; +} t_printflist; + /* ** VOID */ -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); -void *ft_calloc(size_t count, size_t size); -void *ft_realloc(void *ptr, size_t size); -int ft_putchar_fd(char c, int fd); -int ft_putstr_fd(char *s, int fd); void ft_putendl_fd(char *s, int fd); void ft_putnbr_fd(int n, int fd); void ft_lstadd_front(t_list **alst, t_list *new); @@ -50,8 +72,17 @@ void ft_lstdelone(t_list *lst, void (*del)(void *)); void ft_lstclear(t_list **lst, void (*del)(void *)); void ft_lstiter(t_list *lst, void (*f)(void *)); void ft_kernel_panic(void); -void ft_putnbr(long long nb); -void ft_putnbr_base(long long nb, char *base); +void ft_putnbr(long nb); +void ft_putnbr_base(long nb, char *base); +void ft_memdel(void **ptr); +void *ft_memset(void *b, int c, size_t len); +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); +void *ft_calloc(size_t count, size_t size); +void *ft_nrealloc(void *ptr, size_t oldsize, size_t newsize); /* ** CHAR @@ -67,8 +98,10 @@ char *ft_substr(const char *s, unsigned int start, size_t len); char *ft_strjoin(const char *s1, const char *s2); char *ft_strtrim(const char *s1, const char *set); -char *ft_itoa(long long n); -char *ft_itoa_base(long long n, char *base); +char *ft_itoa(long n); +char *ft_itoa_base(long n, char *base); +char *ft_uitoa(unsigned long n); +char *ft_uitoa_base(unsigned long n, char *base); char *ft_strmapi(const char *s, char (*f)(unsigned int, char)); char *ft_nstr(size_t size); @@ -80,8 +113,10 @@ char **ft_split(const char *s, char c); uint8_t ft_isspace(int c); uint8_t ft_ischarset(const char *charset, int c); -uint8_t ft_intlen(long long n); -uint8_t ft_intlen_base(long long n, char *base); +uint8_t ft_intlen(long n); +uint8_t ft_intlen_base(long n, char *base); +uint8_t ft_uintlen(unsigned long n); +uint8_t ft_uintlen_base(unsigned long n, char *base); int ft_memcmp(const void *s1, const void *s2, size_t n); int ft_isalpha(int c); int ft_isdigit(int c); @@ -97,9 +132,11 @@ int ft_putchar(int c); int ft_putnchar(int c, const size_t n); int ft_putstr(const char *s); int ft_putendl(const char *s); +int ft_putchar_fd(char c, int fd); +int ft_putstr_fd(char *s, int fd); int ft_strcmp(const char *s1, const char *s2); -int get_next_line(int fd, char **line); long ft_memlchr(const void *s, int c, size_t n); +long ft_strlchr(const char *s, int c); size_t ft_strlen(const char *s); size_t ft_strlcpy(char *dst, const char *src, size_t size); size_t ft_strlcat(char *dst, const char *src, size_t size); @@ -114,5 +151,70 @@ t_list *ft_lstnew(void *content); t_list *ft_lstlast(t_list *lst); t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)); +/* +** get_next_line +*/ + +char *ft_strchr_gnl(const char *s, int c); +char *ft_swap_gnl(char *s1, char *free_ft); +int get_next_line(int fd, char **line); +int ft_free_gnl(int fd, t_gnl **list); +size_t ft_strlen_gnl(const char *s, char c); +t_gnl *ft_find_fd(int fd, t_gnl **list); + +/* +** ft_printf +*/ + +void ft_printf_process(const char *format, + va_list arg, + t_printflist *pflist); +void ft_printf_reinit_struct(t_printflist *pflist); +void ft_printf_cat_output(char *src, + size_t len, + t_printflist *format); +void ft_printf_treat_flags(va_list arg, + t_printflist *pflist); +void ft_printf_put_c(va_list arg, t_printflist *pflist); +void ft_printf_put_s(va_list arg, t_printflist *pflist); +void ft_printf_put_p(va_list arg, t_printflist *pflist); +void ft_printf_put_d(va_list arg, t_printflist *pflist); +void ft_printf_put_u(va_list arg, t_printflist *pflist); +void ft_printf_put_x(va_list arg, t_printflist *pflist); +void ft_printf_put_big_x(va_list arg, t_printflist *pflist); +void ft_printf_put_perc(va_list arg, t_printflist *pflist); +void ft_printf_put_none(t_printflist *pflist); +void ft_printf_put_width_pre(t_printflist *pflist); +void ft_printf_put_width_post(t_printflist *pflist); +char *ft_printf_get_flags(const char *format, + int pos, + t_printflist *pflist); +char *ft_printf_flag_to_atoi(char *str); +char *ft_printf_get_width_nstr(char *str, + t_printflist *pflist); +uint8_t ft_printf_is_multiwrite(const char *format); +int ft_printf_flags(const char *format, + int pos, + va_list arg, + t_printflist *pflist); +int ft_printf(const char *format, + ...) __attribute__((format(printf,1,2))); +int ft_dprintf(int fd, + const char *format, + ...) __attribute__((format(printf,2,3))); +int ft_sprintf(char *str, + const char *format, + ...) __attribute__((format(printf,2,3))); +int ft_printf_get_partlen(const char *format); +int ft_printf_putpart(const char *format, + int start, + int len, + t_printflist *pflist); +int ft_printf_put_precision(t_printflist *pflist); +int ft_printf_get_s_putlen(char *str, t_printflist *pflist); +int ft_printf_fetch_width(va_list arg, + char *nstr, + t_printflist *pflist); +t_printflist *ft_printf_init_struct(const char *format); # endif |