-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_param_binary.c
49 lines (44 loc) · 1.69 KB
/
ft_param_binary.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_param_binary.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jraymond <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/02/13 21:53:25 by jraymond #+# #+# */
/* Updated: 2018/02/14 22:32:26 by jraymond ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_ll(t_printf *elem, va_list ap)
{
long long arg;
arg = va_arg(ap, long long);
if (elem->size & HH)
ft_print_binary(elem, arg, sizeof(char));
else if (elem->size & H)
ft_print_binary(elem, arg, sizeof(short));
else if (elem->size & L)
ft_print_binary(elem, arg, sizeof(int));
else
ft_print_binary(elem, arg, sizeof(long));
}
int ft_param_binary(t_printf *elem, va_list ap)
{
unsigned long long u_arg;
if (!(elem->size & LL))
ft_ll(elem, ap);
else
{
u_arg = va_arg(ap, unsigned long long);
if (elem->size & HH)
ft_print_ubinary(elem, u_arg, sizeof(char));
else if (elem->size & H)
ft_print_ubinary(elem, u_arg, sizeof(short));
else if (elem->size & L)
ft_print_ubinary(elem, u_arg, sizeof(int));
else
ft_print_ubinary(elem, u_arg, sizeof(long));
}
return (0);
}