-
Notifications
You must be signed in to change notification settings - Fork 0
/
int_parsers_bonus.c
51 lines (42 loc) · 1.59 KB
/
int_parsers_bonus.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* int_parsers_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gmachado <gmachado@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/15 02:52:50 by gmachado #+# #+# */
/* Updated: 2022/05/29 03:16:48 by gmachado ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf_bonus.h"
int parse_int(va_list args, t_format *format)
{
int nbr;
nbr = va_arg(args, int);
if (nbr >= 0)
nbr = -nbr;
else
format->flags |= MINUS_PREFIX;
return (putnbr_dec_int(nbr, format));
}
int parse_uint(va_list args, t_format *format)
{
unsigned int nbr;
nbr = va_arg(args, unsigned int);
return (putnbr_dec_uint(nbr, format));
}
int parse_hex_upper(va_list args, t_format *format)
{
unsigned int nbr;
nbr = va_arg(args, unsigned int);
format->flags |= UPPERCASE;
return (putnbr_hex_uint(nbr, format));
}
int parse_hex_lower(va_list args, t_format *format)
{
unsigned int nbr;
nbr = va_arg(args, unsigned int);
format->flags |= LOWERCASE;
return (putnbr_hex_uint(nbr, format));
}