-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf.h
76 lines (64 loc) · 2.26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gkhodizo <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/27 14:17:59 by gkhodizo #+# #+# */
/* Updated: 2020/08/01 13:17:41 by gkhodizo ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_PRINTF_H
# define FT_PRINTF_H
# include <unistd.h>
# include <stdlib.h>
# include <stdarg.h>
# include "./libft/libft.h"
typedef struct s_fmt
{
size_t is_null;
size_t is_minus;
size_t is_zero;
size_t width;
size_t is_precision;
size_t precision;
size_t negative_prec;
char specifier;
char *spec_value;
size_t is_value_negative;
size_t value_len;
} t_fmt;
typedef struct s_len
{
size_t print_len;
} t_len;
/*
** init and reset format
*/
int ft_printf(const char *format, ...);
void init_format(t_fmt *fmt, t_len *pf_len);
void reset_format(t_fmt *fmt);
/*
** parse format string
*/
void parse_input(char *str, t_fmt *fmt, t_len *pf_len,
va_list *ap);
int parse_flags(char *str, t_fmt *fmt);
int parse_width(char *str, t_fmt *fmt, va_list *ap);
int parse_precision(char *str, t_fmt *fmt, va_list *ap);
int parse_numeric(char *str, size_t *fmt);
int parse_specifier(char *str, t_fmt *fmt, va_list *ap);
void parse_spec_value(t_fmt *fmt, va_list *ap);
/*
** format string
*/
void null_char(t_fmt *fmt, t_len *pf_len);
char *format_hex(char *hex, char c);
void format_input(t_fmt *fmt, t_len *pf_len);
void format_precision_char(t_fmt *fmt);
void format_precision_num(t_fmt *fmt);
void format_width_char(t_fmt *fmt);
void format_width_num(t_fmt *fmt);
char *format_padding(t_fmt *fmt, int c, size_t reslen, int flag);
#endif