-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibftprintf.h
More file actions
143 lines (132 loc) · 4.81 KB
/
libftprintf.h
File metadata and controls
143 lines (132 loc) · 4.81 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
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
135
136
137
138
139
140
141
142
143
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libftprintf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbalon-s <mbalon-s@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/22 17:33:09 by mbalon-s #+# #+# */
/* Updated: 2019/03/02 22:10:18 by mbalon-s ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIBFTPRINTF_H
# define LIBFTPRINTF_H
# include <string.h>
# include <stdarg.h>
# include <inttypes.h>
# define INITIAL_BUFFER_SIZE 2048
typedef enum e_specificator
{
UNKNOWN,
PERCENT,
CHAR,
STRING,
INTEGER,
OCT,
HEX,
HEX_UPPER,
UNSIGNED,
POINTER,
A_FLOAT,
A_FLOAT_UPPER,
FLOAT,
} t_specificator;
typedef struct s_smartstr
{
char *str;
size_t len;
size_t size;
} t_smartstr;
typedef struct s_floating_point
{
int exponent;
unsigned long long fraction;
unsigned int sign : 1;
unsigned int integer : 1;
unsigned int nan : 1;
unsigned int inf : 1;
} t_floating_point;
typedef struct s_specification
{
int minwidth;
int precision;
t_specificator specificator;
char ch;
unsigned align_left : 1;
unsigned force_sign : 1;
unsigned force_spacing : 1;
unsigned force_zeroes : 1;
unsigned alt_print : 1;
unsigned wildcard_minwidth : 1;
unsigned wildcard_precision : 1;
unsigned get_wildcard_minwidth : 1;
unsigned get_wildcard_precision : 1;
unsigned precision_set : 1;
unsigned short_mod : 1;
unsigned short_short_mod : 1;
unsigned long_mod : 1;
unsigned long_long_mod : 1;
unsigned long_double_mod : 1;
unsigned size_t_mod : 1;
unsigned intmax_t_mod : 1;
} t_specification;
typedef size_t (*t_outputfunc) (char **pstr, t_specification, va_list);
int ft_printf(const char *format, ...);
void ft_getstrbyspec(t_specification spec,
t_smartstr *pbuf,
va_list ap);
t_smartstr *ft_smartstrncat(t_smartstr *smartstr,
const char *s, size_t len);
void ft_flushsmartstr(t_smartstr *smartstr);
ssize_t ft_expandsmartstr(t_smartstr *smartstr);
char *ft_strchr(const char *s, int c);
char *ft_strcpy(char *dst, const char *src);
int ft_instr(char c, char *s);
size_t ft_ulfromstr(const char *s, unsigned long *dst);
void *ft_memset(void *b, int c, size_t len);
void ft_bzero(void *s, size_t n);
size_t ft_strlen(const char *s);
char *ft_strncpy(char *dst, const char *src, size_t len);
size_t ft_getspecificator(const char *format,
t_specification *pspec);
int ft_count_digits_unsigned(unsigned long long int nbr,
unsigned base);
long long int ft_get_signed_arg(va_list ap, t_specification spec);
unsigned long long int ft_get_unsigned_arg(va_list ap, t_specification spec);
size_t ft_percent_format(char **pdst, t_specification spec);
size_t ft_unknown_format(char **pdst, t_specification spec);
size_t ft_char_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_string_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_unicode_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_integer_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_oct_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_hex_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_hex_upper_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_unsigned_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_pointer_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_afloat_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_afloat_upper_format(char **pdst, t_specification spec,
va_list ap);
size_t ft_float_format(char **pdst, t_specification spec,
va_list ap);
int ft_utf8_count_bytes(unsigned int c);
unsigned int ft_utf8_convert(unsigned int c, int bytes);
void ft_format_hex(unsigned long long int nbr,
t_specification spec,
char *str, char b);
void ft_fill_floating_point(double nbr,
t_floating_point *dst);
void ft_fill_long_floating_point(long double nbr,
t_floating_point *dst);
int ft_count_digits_signed(long long int nbr);
#endif