-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandle_int.c
More file actions
66 lines (62 loc) · 1.92 KB
/
handle_int.c
File metadata and controls
66 lines (62 loc) · 1.92 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* handle_int.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tyassine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/07 10:13:15 by tyassine #+# #+# */
/* Updated: 2016/04/07 10:13:17 by tyassine ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void han_int2(va_list *now, t_data *d, t_type *v, t_form *info)
{
if (info->type == 3)
{
v->ld = va_arg(*now, long);
d->string = itoabase((v->ld), 10, 0);
}
if (info->type == 4)
{
v->lld = va_arg(*now, long long);
d->string = itoabase((v->lld), 10, 0);
}
else if (info->type == 5)
{
v->im = (intmax_t)va_arg(*now, intmax_t);
d->string = itoabase((v->im), 10, 0);
}
else if (info->type == 6)
{
v->lld = (long long)va_arg(*now, long long);
d->string = itoabase((v->lld), 10, 0);
}
}
int han_int(va_list *now, t_data *d, t_type *v, t_form *i)
{
int ret;
ret = 0;
if (d->type == 'D')
i->type = 3;
if (i->type == 2)
{
v->c = (char)va_arg(*now, int);
d->string = itoabase((v->c), 10, 0);
}
else if (i->type == 1)
{
v->h = (short)va_arg(*now, int);
d->string = itoabase((v->h), 10, 0);
}
else if (i->type == 0)
{
v->d = (int)va_arg(*now, int);
d->string = itoabase((v->d), 10, 0);
}
han_int2(now, d, v, i);
ret = ft_strlen(d->string);
ret = print_long(i, d, ret);
free(d->string);
return (ret);
}