-
Notifications
You must be signed in to change notification settings - Fork 0
/
printf_tools2.c
80 lines (72 loc) · 2 KB
/
printf_tools2.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* printf_tools2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: moboustt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/12 21:56:57 by moboustt #+# #+# */
/* Updated: 2019/12/20 09:54:54 by moboustt ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int zero_input_x(t_struct *list, long out_hexa)
{
if (out_hexa == 0 && list->dot == 1 && list->width > 0 &&
(list->precision == -1 || list->precision == 0))
{
while (list->width-- > 0)
list->n += write(1, " ", 1);
return (1);
}
else if (out_hexa == 0 && list->dot == 1 &&
(list->precision == 0 || list->precision == -1))
{
write(1, "", 1);
return (1);
}
return (0);
}
int print_hexa(char *tb)
{
unsigned int ret;
int i;
i = 0;
ret = 0;
if (ft_strlen(tb) != 0)
{
while (tb[i] != '\0')
ret += write(1, &tb[i++], 1);
}
return (ret);
}
void if_zero(t_struct *list, unsigned int out_hexa, char *tb)
{
if (out_hexa == 0 && list->dot == 1 && list->width > 0 &&
(list->precision == 0 || list->precision == -1))
tb = "";
else if (out_hexa == 0)
tb = "0";
}
int pppp(t_struct *list, unsigned int hexa_len, char *tb)
{
if (list->width == -1 && list->precision == -1)
{
list->n += write(1, tb, hexa_len);
return (1);
}
return (0);
}
void *ft_memset(void *b, int c, size_t len)
{
unsigned int i;
char *bb;
i = 0;
bb = b;
while (i < len)
{
bb[i] = c;
i++;
}
return (bb);
}