diff options
Diffstat (limited to 'header.h')
| -rw-r--r-- | header.h | 67 |
1 files changed, 34 insertions, 33 deletions
@@ -6,58 +6,52 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/29 00:06:46 by cacharle #+# #+# */ -/* Updated: 2019/10/31 00:04:28 by cacharle ### ########.fr */ +/* Updated: 2019/11/05 23:58:48 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef HEADER_H # define HEADER_H +# include <unistd.h> +# include <stdlib.h> # include <stdarg.h> # include "libft.h" -# define TRUE 1 -# define FALSE 0 +# define SPECIFIERS_STR "ncspdiuxX%" +# define FLAGS_STR "#0- +'" -# define HEX_SYMBOLS "0123456789abcdef" -# define HEX_MAJ_SYMBOLS "0123456789ABCDEF" +# define IS_STANDALONE_FLAG(c) (ft_strchr(FLAGS_STR, c) != NULL) -# define IN_STR(str, c) (ft_strchr(str, c) != NULL) -# define IS_STANDALONE_FLAG(c) (IN_STR("0-+ #'", c)) - -# define CONVERSIONS_STR "ncspdiuxX%" - -# define FLAG_LEFT_ADJUSTED (1 << 0) -# define FLAG_ZERO_PADDING (1 << 1) -# define FLAG_MIN_WIDTH_WILDCARD (1 << 2) -# define FLAG_PRECISION_WILDCARD (1 << 3) -# define FLAG_MIN_WIDTH_OVERWRITE (1 << 4) -# define FLAG_SIGNED (1 << 5) -# define FLAG_SPACE (1 << 6) -# define FLAG_ALTERNATE (1 << 7) -# define FLAG_SHORT_SHORT (1 << 8) -# define FLAG_SHORT (1 << 9) -# define FLAG_LONG (1 << 10) -# define FLAG_LONG_LONG (1 << 11) +# define FLAG_MINUS (1 << 0) +# define FLAG_ZERO (1 << 1) +# define FLAG_SIGNED (1 << 2) +# define FLAG_SPACE (1 << 3) +# define FLAG_ALTERNATE (1 << 4) +# define FLAG_SHORT (1 << 5) +# define FLAG_SHORT_SHORT (1 << 6) +# define FLAG_LONG (1 << 7) +# define FLAG_LONG_LONG (1 << 8) +# define FLAG_WIDTH_WILDCARD (1 << 9) +# define FLAG_PRECISION_WILDCARD (1 << 10) +# define FLAG_WIDTH_OVERWRITE (1 << 11) # define ITOA_HEX_LOW(x) (ft_itoa_unsigned_base(x, "0123456789abcdef")) # define ITOA_HEX_UP(x) (ft_itoa_unsigned_base(x, "0123456789ABCDEF")) # define ITOA_DEC(x) (ft_itoa_base(x, "0123456789")) -#include <stdio.h> - typedef int t_bool; typedef short t_flags; typedef struct { int precision; - int min_width; + int width; t_flags flags; - char type; + char specifier; int fmt_len; int size; - int *written; + long long int *written; } t_pformat; typedef struct s_flist @@ -84,16 +78,14 @@ t_pformat *parse_reduced(char *fmt); */ char *convert(t_pformat *pformat, va_list ap); -char *convert_type(va_list ap, t_pformat *pformat); -char *handle_padding(t_pformat *pformat, char *str); +char *convert_specifier(va_list ap, t_pformat *pformat); +char *handle_width(t_pformat *pformat, char *str); char *handle_precision(t_pformat *pformat, char *str); -char *add_hex_prefix(char *str); /* ** utils.c */ -int strrchr_index(const char *s, char c); char *ft_itoa_base(long long int n, char *base); char *ft_itoa_unsigned_base(long long unsigned int n, char *base); @@ -103,8 +95,8 @@ char *ft_strtoupper(char *str); ** extract.c */ -char *extract_standalone_flags(t_pformat *pformat, char *fmt); -char *extract_min_width(t_pformat *pformat, char *fmt); +char *extract_flags(t_pformat *pformat, char *fmt); +char *extract_width(t_pformat *pformat, char *fmt); char *extract_precision(t_pformat *pformat, char *fmt); char *extract_length_modifier(t_pformat *pformat, char *fmt); @@ -130,5 +122,14 @@ char *convert_uint(va_list ap, t_pformat *pformat); char *convert_hex(va_list ap, t_pformat *pformat); char *convert_percent(va_list ap, t_pformat *pformat); char *convert_written(va_list ap, t_pformat *pformat); +char *convert_none(va_list ap, t_pformat *pformat); + +/* +** length_modifier.c +*/ + +long long unsigned int length_modifier_unsigned_int( + va_list ap, t_pformat *pformat); +long long int length_modifier_int(va_list ap, t_pformat *pformat); #endif |
