-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf.h
82 lines (70 loc) · 2.23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rnishimo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/01 17:03:18 by rnishimo #+# #+# */
/* Updated: 2022/01/29 22:22:04 by rnishimo ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_PRINTF_H
# define FT_PRINTF_H
# include <stdarg.h>
# include <stdio.h>
# include <stdlib.h>
# include <stdbool.h>
# include <unistd.h>
# include "./libft/libft.h"
typedef struct s_str
{
char *str;
size_t size;
bool minus;
char specifier;
bool zero;
} t_str;
typedef struct s_flag
{
size_t width;
size_t precision;
bool minus;
bool zero;
bool dot;
bool sharp;
bool space;
bool plus;
} t_flag;
typedef struct s_print
{
size_t size;
size_t space;
size_t zero;
size_t sign;
size_t hex;
} t_print;
// main
int ft_printf(const char *format, ...);
size_t print(t_str *st_str, t_flag *st_flag);
t_print init_struct_print(t_str *st_str, t_flag *st_flag);
// parser
bool parse(char **format, va_list ap, t_str *st_str, t_flag *st_flag);
void get_c(va_list ap, t_str *st_str);
void get_s(va_list ap, t_str *st_str);
void get_p(va_list ap, t_str *st_str);
void get_d(va_list ap, t_str *st_str);
void get_u(va_list ap, t_str *st_str);
void get_x(va_list ap, t_str *st_str);
void get_xx(va_list ap, t_str *st_str);
void get_per(t_str *st_str);
// parser_error
void parse_error(t_str *st_str, t_flag *st_flag);
// utils
void set_number_base(char *str, long long num, const char *base);
void set_unsigned_number_base(char *str, size_t num, const char *base);
// debug
void debug_t_print(t_print *st);
void debug_t_flag(t_flag *st);
void debug_t_str(t_str *st);
#endif