-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf.h
executable file
·134 lines (111 loc) · 4.02 KB
/
ft_printf.h
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/15 01:21:59 by akharrou #+# #+# */
/* Updated: 2019/05/23 14:34:13 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_PRINTF_H
# define FT_PRINTF_H
/*
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
*/
# include "Libft/libft.h"
# include <stdarg.h>
/*
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
*/
typedef struct s_format_info
{
int8_t flags;
int32_t width;
int32_t precision;
int8_t length;
int8_t specifier;
char **style;
char pad;
int8_t format_length;
} t_format;
typedef struct s_handler
{
char specifier;
char *(*handler)(t_format format, t_data arg);
} t_handler;
typedef struct s_style
{
char *style;
char *ansi_code;
} t_style;
/*
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
*/
# define NONE (-1)
enum e_flags
{
MINUS = (1 << 0),
PLUS = (1 << 1),
SPACE = (1 << 2),
HASH = (1 << 3),
ZERO = (1 << 4)
};
enum e_lengths
{
HH = sizeof(char),
H = sizeof(short),
L = sizeof(long int),
LL = sizeof(long long int),
LLL = sizeof(long double),
IU_MAX = sizeof(intmax_t),
SIZET = sizeof(size_t),
PTRDIFF = sizeof(ptrdiff_t)
};
/*
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
*/
int ft_printf(const char *format, ...);
int ft_dprintf(int filedes, const char *format, ...);
int ft_sprintf(char *str, const char *format, ...);
int ft_asprintf(char **ret, const char *format, ...);
int ft_vprintf(const char *format, va_list *args);
int ft_vdprintf(int filedes, const char *format, va_list *args);
int ft_vsprintf(char *str, const char *format, va_list *args);
int ft_vasprintf(char **ret, const char *format, va_list *args);
/*
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
*/
char *formatter(const char **buf, va_list *args, size_t *len);
char **parse_style(const char *format, int8_t *i);
t_format parse_format(const char *format, va_list *args);
t_data extract_agrument(t_format format, va_list *args);
int8_t parse_flags(const char *format, int8_t *i);
int32_t parse_width(const char *format, va_list *args, int8_t *i);
int32_t parse_precison(const char *format, va_list *args, int8_t *i);
int8_t parse_length(const char *format, int8_t *i);
int8_t parse_specifier(const char *format, int8_t *i);
char *apply_width(t_format format, char *str);
/*
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
*/
# define SPECIFIERS "csrpiufodxXb%"
char *c_handler(t_format format, t_data arg);
char *i_handler(t_format format, t_data arg);
char *d_handler(t_format format, t_data arg);
char *u_handler(t_format format, t_data arg);
char *f_handler(t_format format, t_data arg);
char *o_handler(t_format format, t_data arg);
char *x_handler(t_format format, t_data arg);
char *xx_handler(t_format format, t_data arg);
char *b_handler(t_format format, t_data arg);
char *s_handler(t_format format, t_data arg);
char *r_handler(t_format format, t_data arg);
char *p_handler(t_format format, t_data arg);
char *mod_handler(t_format format, t_data arg);
char *style_handler(t_format format, char *fstr);
/*
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
*/
#endif