-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlibftprintf.h
More file actions
93 lines (80 loc) · 2.91 KB
/
Copy pathlibftprintf.h
File metadata and controls
93 lines (80 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cado-car <cado-car@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/04 13:10:30 by cado-car #+# #+# */
/* Updated: 2021/08/20 19:47:00 by cado-car ### ########lyon.fr */
/* */
/* ************************************************************************** */
#ifndef LIBFTPRINTF_H
# define LIBFTPRINTF_H
# include <stdarg.h>
# include <stdlib.h>
# include <unistd.h>
# include <inttypes.h>
# include <wchar.h>
# include "../libft/libft.h"
# define HOLDER_CONVERSION "cspdiuxX%o"
# define HOLDER_ALL "-0# +123456789*"
# define HOLDER_ALL_FLAGS "-0# +"
# define HOLDER_JUSTIFY '-'
# define HOLDER_PREFIX "# +"
# define HOLDER_PAD '0'
# define HOLDER_PRECISION '.'
# define HOLDER_STAR '*'
# define OCTAL_BASE "01234567"
# define DECIMAL_BASE "0123456789"
# define HEXADECIMAL_U_BASE "0123456789ABCDEF"
# define HEXADECIMAL_L_BASE "0123456789abcdef"
# define PTR_HEX_L_PREFIX "0x"
# define HEX_U_PREFIX "0X"
# define OCT_PREFIX "0"
# define MINUS '-'
# define PLUS '+'
# define SPACE ' '
typedef struct s_format
{
const char *format;
va_list ap;
size_t i;
size_t len;
} t_format;
typedef struct s_holder
{
int left_justify;
char *prefix;
char padding;
int width;
int precision;
char conversion;
char *argument;
size_t len;
} t_holder;
int ft_printf(const char *format, ...);
int ft_vprintf(const char *format, va_list ap);
// Structs' initialization
t_format *ft_initialize_format(const char *format, va_list ap);
t_holder *ft_initialize_holder(void);
// Placeholder
void ft_placeholder(t_format *fmt);
void *ft_parse(t_format *fmt, t_holder *h);
void ft_parse_flags(t_format *fmt, t_holder *h);
void ft_parse_width(t_format *fmt, t_holder *h);
void ft_parse_precision(t_format *fmt, t_holder *h);
void ft_parse_conversion(t_format *fmt, t_holder *h);
// Conversions
void ft_type_conversion(t_format *fmt, t_holder *h);
void ft_convert_c(t_format *fmt, t_holder *h);
void ft_convert_s(t_format *fmt, t_holder *h);
void ft_convert_p(t_format *fmt, t_holder *h);
void ft_convert_d_i(t_format *fmt, t_holder *h);
void ft_convert_ux(t_format *fmt, t_holder *h, char *base);
void ft_convert_pct(t_holder *h);
// Conversions utils
void ft_fill_left_pad(char **src, char padding, int width);
void ft_fill_right_pad(char **src, char padding, int width);
void ft_add_prefix(t_holder *h, int sign);
#endif