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

Go to the source code of this file.

Functions

bool parse_opt_c_str (char fmt, va_list *args, t_fmt *p_ret)
 

Variables

const char *const g_nullstr = "(null)"
 

Function Documentation

◆ parse_opt_c_str()

bool parse_opt_c_str ( char  fmt,
va_list *  args,
t_fmt p_ret 
)

Definition at line 18 of file parse_opt_c_str.c.

19 {
20  if (fmt == 'c' || fmt == '%')
21  {
22  p_ret->type = CHAR;
23  if (fmt == 'c')
24  p_ret->data.c = (char)va_arg(*args, int);
25  else
26  p_ret->data.c = '%';
27  p_ret->str_len = 1;
28  }
29  else if (fmt == 's')
30  {
31  p_ret->type = STR;
32  p_ret->data.str = va_arg(*args, char *);
33  if (p_ret->data.str == NULL)
34  p_ret->data.str = (char *)g_nullstr;
35  p_ret->str_len = ft_strlen(p_ret->data.str);
36  }
37  else
38  return (false);
39  return (true);
40 }
@ CHAR
@ STR
size_t ft_strlen(const char *s)
Definition: ft_strlen.c:15
const char *const g_nullstr
t_dtype type
t_data data
int str_len
char * str
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_nullstr

const char* const g_nullstr = "(null)"

Definition at line 16 of file parse_opt_c_str.c.