-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandle_hex.c
More file actions
69 lines (64 loc) · 2.05 KB
/
handle_hex.c
File metadata and controls
69 lines (64 loc) · 2.05 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* handle_hex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tyassine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/07 10:12:54 by tyassine #+# #+# */
/* Updated: 2016/04/07 10:12:58 by tyassine ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void han_hex2(va_list *now, t_data *d, t_type *v, t_form *i)
{
int x;
x = d->type == 'x' ? 0 : 1;
if (i->type == 1)
{
v->uh = (unsigned short)va_arg(*now, unsigned int);
d->string = itoabasex(i, (v->uh), 16, x);
}
else if (i->type == 0)
{
v->x = va_arg(*now, unsigned int);
d->string = itoabasex(i, (v->x), 16, x);
}
else if (i->type == 5)
{
v->uim = (uintmax_t)va_arg(*now, uintmax_t);
d->string = itoabasex(i, (v->uim), 16, x);
}
else if (i->type == 6)
{
v->uim = (uintmax_t)va_arg(*now, uintmax_t);
d->string = itoabasex(i, (v->uim), 16, x);
}
}
int han_hex(va_list *now, t_data *d, t_type *v, t_form *i)
{
int ret;
int x;
ret = 0;
x = d->type == 'x' ? 0 : 1;
if (i->type == 3)
{
v->lo = va_arg(*now, long unsigned);
d->string = itoabasex(i, (v->lo), 16, x);
}
else if (i->type == 4)
{
v->llu = va_arg(*now, long long unsigned);
d->string = itoabasex(i, (v->llu), 16, x);
}
else if (i->type == 2)
{
v->hh = (unsigned char)va_arg(*now, unsigned int);
d->string = itoabasex(i, (v->hh), 16, x);
}
han_hex2(now, d, v, i);
ret = ft_strlen(d->string);
ret = print_unsigned(i, d, ret);
free(d->string);
return (ret);
}