minishell
parse_opt_ptr.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* parse_opt_ptr.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: kfujita <kfujita@student.42tokyo.jp> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/04/23 02:46:19 by kfujita #+# #+# */
9
/* Updated: 2022/04/26 00:22:29 by kfujita ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
ft_printf_local.h
"
14
#include "../ft_string/ft_string.h"
15
16
bool
parse_opt_ptr
(
char
fmt, va_list *args,
t_fmt
*p_ret)
17
{
18
size_t
num;
19
20
if
(fmt !=
'p'
)
21
return
(
false
);
22
p_ret->
type
=
PTR
;
23
num = (size_t)va_arg(*args,
void
*);
24
p_ret->
header
[0] =
'0'
;
25
p_ret->
header
[1] =
'x'
;
26
p_ret->
head_len
= 2;
27
if
(num == 0)
28
{
29
p_ret->
str_len
= 1;
30
p_ret->
data
.
c
=
'0'
;
31
}
32
else
33
p_ret->
str_len
=
get_numstr_base
(p_ret->
data
.
str_buf
, num, 16,
false
);
34
return
(
true
);
35
}
ft_printf_local.h
PTR
@ PTR
Definition:
ft_printf_local.h:30
get_numstr_base
int get_numstr_base(char *buf, size_t num, int base, bool is_upper)
Definition:
get_numstr_base.c:17
parse_opt_ptr
bool parse_opt_ptr(char fmt, va_list *args, t_fmt *p_ret)
Definition:
parse_opt_ptr.c:16
t_fmt
Definition:
ft_printf_local.h:48
t_fmt::type
t_dtype type
Definition:
ft_printf_local.h:49
t_fmt::data
t_data data
Definition:
ft_printf_local.h:50
t_fmt::str_len
int str_len
Definition:
ft_printf_local.h:53
t_fmt::head_len
t_uint8 head_len
Definition:
ft_printf_local.h:52
t_fmt::header
char header[3]
Definition:
ft_printf_local.h:51
t_data::c
char c
Definition:
ft_printf_local.h:42
t_data::str_buf
char str_buf[STR_BUF_LEN]
Definition:
ft_printf_local.h:38
libft
ft_printf
parse_opt_ptr.c
Generated by
1.9.1