minishell
ft_printf_local.h
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* ft_printf_local.h :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: kfujita <kfujita@student.42tokyo.jp> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2022/04/23 00:04:40 by kfujita #+# #+# */
9 /* Updated: 2023/01/30 17:12:07 by kfujita ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
13 #ifndef FT_PRINTF_LOCAL_H
14 # define FT_PRINTF_LOCAL_H
15 
16 # include <stddef.h>
17 # include <stdbool.h>
18 # include <stdarg.h>
19 # include "../ft_lst/ft_lst.h"
20 
21 // 2 + 16 + 1
22 # define STR_BUF_LEN (19)
23 
24 typedef unsigned char t_uint8;
25 
26 typedef enum e_dtype
27 {
28  STR,
30  PTR,
34 } t_dtype;
35 
36 typedef union u_data
37 {
38  char str_buf[STR_BUF_LEN];
39  char *str;
40  void *p_ptr;
41  size_t ptr;
42  char c;
43  int s_digit;
44  unsigned int u_digit;
45 } t_data;
46 
47 typedef struct s_printf_fmt
48 {
51  char header[3];
53  int str_len;
54  int min_len;
55  int max_len;
56 
57  bool f_upper: 1;
58  bool f_minus: 1;
59  bool f_zero: 1;
60  bool f_dot: 1;
61  bool f_hash: 1;
62  bool f_space: 1;
63  bool f_plus: 1;
64 } t_fmt;
65 
66 t_list *parse_format(const char *fmt, va_list *args);
67 
68 t_fmt *parse_opt(size_t *len, char **fmt, va_list *args);
69 t_fmt *check_no_opt_str(size_t *len, char **fmt, t_fmt *p_ret);
70 
71 void parse_opt_flags(char **fmt, t_fmt *p_ret);
72 bool parse_opt_c_str(char fmt, va_list *args, t_fmt *p_ret);
73 bool parse_opt_num(char fmt, va_list *args, t_fmt *p_ret);
74 bool parse_opt_ptr(char fmt, va_list *args, t_fmt *p_ret);
75 
76 bool is_valid_conv_char(char c);
77 bool is_valid_flag_char(char c);
78 
79 int print_all(int fd, t_list *list);
80 
81 #endif
unsigned char t_uint8
#define STR_BUF_LEN
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)
t_dtype
@ PTR
@ CHAR
@ INT_10BASE
@ UINT_10BASE
@ UINT_16BASE
@ STR
t_fmt * check_no_opt_str(size_t *len, char **fmt, t_fmt *p_ret)
int print_all(int fd, t_list *list)
Definition: print_all.c:106
bool is_valid_flag_char(char c)
t_list * parse_format(const char *fmt, va_list *args)
Definition: parse_format.c:18
bool parse_opt_ptr(char fmt, va_list *args, t_fmt *p_ret)
Definition: parse_opt_ptr.c:16
t_fmt * parse_opt(size_t *len, char **fmt, va_list *args)
Definition: parse_opt.c:17
t_dtype type
bool f_minus
t_data data
int max_len
int str_len
bool f_plus
bool f_upper
t_uint8 head_len
int min_len
bool f_dot
bool f_zero
bool f_space
bool f_hash
Definition: ft_lst.h:18
void * p_ptr
size_t ptr
unsigned int u_digit
char * str