-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_parsers.c
51 lines (44 loc) · 1.39 KB
/
gen_parsers.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* gen_parsers.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gmachado <gmachado@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/15 02:45:21 by gmachado #+# #+# */
/* Updated: 2022/05/18 00:51:02 by gmachado ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int parse_char(va_list args)
{
char ch;
ch = (char)va_arg(args, int);
write(1, &ch, 1);
return (1);
}
int parse_pointer(va_list args)
{
void *ptr;
ptr = va_arg(args, void *);
if (ptr == NULL)
{
write(1, "(nil)", 5);
return (5);
}
return (putnbr_hex_ptr((unsigned long long)ptr));
}
int parse_string(va_list args)
{
int len;
char *arg;
arg = va_arg(args, char *);
if (arg == NULL)
{
write(1, "(null)", 6);
return (6);
}
len = ft_strlen(arg);
write(1, arg, len);
return (len);
}