-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf_x.c
More file actions
53 lines (48 loc) · 1.78 KB
/
ft_printf_x.c
File metadata and controls
53 lines (48 loc) · 1.78 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_x.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mfrisby <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/11 13:15:37 by mfrisby #+# #+# */
/* Updated: 2017/07/11 13:15:38 by mfrisby ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
static char *ft_printf_check_ml(t_env *e)
{
char *tmp;
if (e->m_ll)
tmp = ft_utoa_base(va_arg(e->pa, unsigned long long), 16);
else if (e->m_l)
tmp = ft_utoa_base(va_arg(e->pa, unsigned long), 16);
else if (e->m_j)
tmp = ft_utoa_base(va_arg(e->pa, uintmax_t), 16);
else if (e->m_z)
tmp = ft_utoa_base(va_arg(e->pa, size_t), 16);
else if (e->m_h)
tmp = ft_utoa_base((unsigned short)va_arg(e->pa, unsigned int), 16);
else if (e->m_hh)
tmp = ft_utoa_base((unsigned char)va_arg(e->pa, unsigned int), 16);
else
tmp = ft_utoa_base(va_arg(e->pa, unsigned int), 16);
return (tmp);
}
void ft_printf_x(t_env *e)
{
char *tmp;
tmp = NULL;
tmp = ft_printf_check_ml(e);
e->type = 'x';
if (ft_strcmp(tmp, "0") == 0)
{
e->flag_diese = 0;
if (e->precision == 0)
ft_printf_putflags(e, ft_strdup(""));
else
ft_printf_putflags(e, tmp);
return ;
}
ft_printf_putflags(e, tmp);
}