minishell
parse_opt.c File Reference
Include dependency graph for parse_opt.c:

Go to the source code of this file.

Functions

t_fmtparse_opt (size_t *len, char **fmt, va_list *args)
 

Function Documentation

◆ parse_opt()

t_fmt* parse_opt ( size_t *  len,
char **  fmt,
va_list *  args 
)

Definition at line 17 of file parse_opt.c.

18 {
19  t_fmt *p_ret;
20 
21  *fmt += 1;
22  if (!is_valid_conv_char(**fmt)
23  && !is_valid_flag_char(**fmt))
24  return (check_no_opt_str(len, fmt, NULL));
25  p_ret = ft_calloc(1, sizeof(t_fmt));
26  if (p_ret == NULL)
27  return (p_ret);
28  while (is_valid_flag_char(**fmt))
29  parse_opt_flags(fmt, p_ret);
30  if (!(parse_opt_c_str(**fmt, args, p_ret)
31  || parse_opt_num(**fmt, args, p_ret)
32  || parse_opt_ptr(**fmt, args, p_ret)))
33  return (check_no_opt_str(len, fmt, p_ret));
34  *fmt += 1;
35  *len += ft_max(p_ret->min_len, p_ret->str_len + p_ret->head_len);
36  return (p_ret);
37 }
t_fmt * check_no_opt_str(size_t *len, char **fmt, t_fmt *p_ret)
void * ft_calloc(size_t count, size_t size)
Definition: ft_calloc.c:29
int ft_max(int a, int b)
Definition: ft_max.c:16
bool parse_opt_c_str(char fmt, va_list *args, t_fmt *p_ret)
void parse_opt_flags(char **fmt, t_fmt *p_ret)
bool parse_opt_num(char fmt, va_list *args, t_fmt *p_ret)
Definition: parse_opt_num.c:60
bool is_valid_conv_char(char c)
bool is_valid_flag_char(char c)
bool parse_opt_ptr(char fmt, va_list *args, t_fmt *p_ret)
Definition: parse_opt_ptr.c:16
int str_len
t_uint8 head_len
int min_len
Here is the call graph for this function:
Here is the caller graph for this function: