-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf.h
103 lines (91 loc) · 2.48 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gmarra <gmarra@student.42firenze.it> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/18 16:15:29 by gmarra #+# #+# */
/* Updated: 2024/12/18 17:30:28 by gmarra ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_PRINTF_H
# define FT_PRINTF_H
# include <unistd.h>
# include <stddef.h>
# include <stdlib.h>
# include <stdarg.h>
# include <stdint.h>
static inline void set_bit(unsigned int *mask, unsigned int bit_pos)
{
*mask |= 1U << bit_pos;
}
static inline void reset_bit(unsigned int *mask, unsigned int bit_pos)
{
*mask &= ~(1U << bit_pos);
}
static inline unsigned int get_bit(unsigned int mask, unsigned int bit_pos)
{
return ((mask >> bit_pos) & 1U);
}
enum e_bitmask
{
MINUS = 0,
PLUS = 1,
SPACE = 2,
ZERO = 3,
HASHTAG = 4,
WIDTH = 5,
DOT = 6,
IS_ZERO = 7,
IS_NEG = 8
};
enum e_typemask
{
CHR = 0xA1,
STR = 0x61,
PTR = 0x61,
DEC = 0x16F,
INT = 0x16F,
UINT = 0x6D,
HEX = 0x79
};
enum e_typeformat
{
TYPE_NONE,
TYPE_C,
TYPE_S,
TYPE_P,
TYPE_D,
TYPE_I,
TYPE_U,
TYPE_X,
TYPE_XX
};
typedef union u_numbers
{
int i;
uintptr_t u;
} t_convtypenum;
typedef struct s_placeholder
{
unsigned int flgmask;
int width;
int precision;
int format_type;
char *str;
} t_placeholder;
int ft_printf(const char *str, ...);
size_t ftpf_strlen(const char *str);
char *ftpf_strdup(const char *s);
void ftpf_toupper_str(char *str);
void write_char_str(const char *str, int *cnt, unsigned int str_flg,
unsigned int flgmask);
void format_str(t_placeholder *data2process);
char *convert_arg(int format_type, va_list args, unsigned int *flgmask);
char *ftpf_strchr(const char *str, int c);
char *ft_stradd(const char *str1, char *str2, unsigned int i);
char *ft_strshrink(char *str, size_t curr_dim, size_t new_dim);
void check_sign_zero(t_placeholder *data);
void ftpf_memset(void *s, int c, size_t n);
#endif