-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandle_oct.c
66 lines (62 loc) · 2.02 KB
/
handle_oct.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* handle_oct.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tyassine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/07 10:14:02 by tyassine #+# #+# */
/* Updated: 2016/04/07 10:14:04 by tyassine ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void han_oct2(va_list *now, t_data *d, t_type *v, t_form *i)
{
if (i->type == 3)
{
v->lo = (unsigned long int)va_arg(*now, unsigned long int);
d->string = itoabaseo(i, (v->lo), 8);
}
else if (i->type == 4)
{
v->llu = (unsigned long long)va_arg(*now, unsigned long long);
d->string = itoabaseo(i, (v->llu), 8);
}
else if (i->type == 5)
{
v->uim = (uintmax_t)va_arg(*now, uintmax_t);
d->string = itoabaseo(i, (v->uim), 8);
}
else if (i->type == 6)
{
v->uim = (uintmax_t)va_arg(*now, uintmax_t);
d->string = itoabaseo(i, (v->uim), 8);
}
}
int han_oct(va_list *now, t_data *d, t_type *v, t_form *i)
{
int ret;
ret = 0;
if (d->type == 'O')
i->type = 3;
if (i->type == 0)
{
v->o = va_arg(*now, unsigned int);
d->string = itoabaseo(i, (v->o), 8);
}
else if (i->type == 2)
{
v->hh = (unsigned char)va_arg(*now, unsigned int);
d->string = itoabaseo(i, (v->hh), 8);
}
else if (i->type == 1)
{
v->uh = (unsigned short)va_arg(*now, unsigned int);
d->string = itoabaseo(i, (v->uh), 8);
}
han_oct2(now, d, v, i);
ret = ft_strlen(d->string);
ret = print_unsigned(i, d, ret);
free(d->string);
return (ret);
}