Started from buttom go to the sky
This commit is contained in:
parent
96215449bd
commit
f811e55dea
4781 changed files with 10121 additions and 1743 deletions
27
stdme/include/me/printf/formatter/formatter.h
Normal file
27
stdme/include/me/printf/formatter/formatter.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* formatter.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/16 18:18:19 by maiboyer #+# #+# */
|
||||
/* Updated: 2023/11/18 19:11:23 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FORMATTER_H
|
||||
# define FORMATTER_H
|
||||
# include "me/printf/printf.h"
|
||||
# include "me/types.h"
|
||||
|
||||
void printf_x_low(t_printf_arg data, t_printf_func f);
|
||||
void printf_x_up(t_printf_arg data, t_printf_func f);
|
||||
void printf_o(t_printf_arg data, t_printf_func f);
|
||||
void printf_d(t_printf_arg data, t_printf_func f);
|
||||
void printf_u(t_printf_arg data, t_printf_func f);
|
||||
void printf_c(t_printf_arg data, t_printf_func f);
|
||||
void printf_s(t_printf_arg data, t_printf_func f);
|
||||
void printf_p(t_printf_arg data, t_printf_func f);
|
||||
|
||||
#endif
|
||||
76
stdme/include/me/printf/formatter/utils.h
Normal file
76
stdme/include/me/printf/formatter/utils.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* utils.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/16 17:58:41 by maiboyer #+# #+# */
|
||||
/* Updated: 2023/12/01 21:24:21 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef UTILS_H
|
||||
# define UTILS_H
|
||||
|
||||
# include "me/printf/matchers/matchers.h"
|
||||
# include "me/printf/printf.h"
|
||||
# include "me/types.h"
|
||||
# include <stdarg.h>
|
||||
|
||||
typedef struct s_prec_strs
|
||||
{
|
||||
t_str *out;
|
||||
t_str *pretty;
|
||||
bool free_out;
|
||||
} t_prec_strs;
|
||||
|
||||
typedef struct s_pad_and_stuff_args
|
||||
{
|
||||
t_usize fill_zero;
|
||||
t_usize fill;
|
||||
t_usize len;
|
||||
t_usize pretty_len;
|
||||
t_usize sign_len;
|
||||
t_str pretty;
|
||||
t_str str;
|
||||
t_str sign;
|
||||
bool allow_zero_fill;
|
||||
|
||||
} t_pad_and_stuff_args;
|
||||
typedef struct s_pad_inner_args
|
||||
{
|
||||
void *p_args;
|
||||
t_usize fmt_len;
|
||||
t_printf_func f;
|
||||
va_list *arguments;
|
||||
t_matcher_list *matchers;
|
||||
} t_pad_inner_args;
|
||||
|
||||
void set_var_for_pad_and_stuff(t_pad_and_stuff_args *a,
|
||||
t_printf_arg *d);
|
||||
void print_with_func(t_pad_and_stuff_args *a, t_printf_arg *d,
|
||||
t_printf_func f, t_const_str t);
|
||||
void pad_and_stuff(t_pad_and_stuff_args a, t_printf_arg d,
|
||||
t_printf_func f);
|
||||
void handle_prec_and_align(t_const_str fmt, t_usize *c_idx,
|
||||
t_printf_arg *c_arg);
|
||||
bool handle_atoi_stuff(t_const_str fmt, t_usize *c_idx,
|
||||
t_usize *nxt, t_printf_arg *c_arg);
|
||||
void set_params2(t_const_str fmt, t_usize *c_idx, t_usize *nxt,
|
||||
t_printf_arg *c_arg);
|
||||
bool set_params(t_const_str fmt, t_usize *c_idx, t_usize *nxt,
|
||||
t_printf_arg *c_arg);
|
||||
void ret_reset(t_usize *c_idx, t_usize *nxt, t_const_str fmt);
|
||||
t_printf_arg print_substr(t_usize *c_idx, t_usize *nxt, t_const_str fmt,
|
||||
t_pad_inner_args extra);
|
||||
void pad_inner(t_const_str fmt, t_usize *c_idx, t_usize *nxt,
|
||||
t_pad_inner_args extra);
|
||||
void advance_atoi(t_const_str fmt, t_usize *idx);
|
||||
void me_printf_str_inner(t_const_str fmt, t_printf_func f,
|
||||
va_list *arguments, void *p_args);
|
||||
void print_sign_if_needed(t_pad_and_stuff_args a, t_printf_arg d,
|
||||
t_printf_func f);
|
||||
void handle_weird_precision_stuff(t_printf_arg *data,
|
||||
t_prec_strs strs, t_usize value);
|
||||
#endif
|
||||
52
stdme/include/me/printf/matchers/matchers.h
Normal file
52
stdme/include/me/printf/matchers/matchers.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* matchers.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/16 18:09:07 by maiboyer #+# #+# */
|
||||
/* Updated: 2023/11/18 18:10:33 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MATCHERS_H
|
||||
# define MATCHERS_H
|
||||
|
||||
# include "me/printf/printf.h"
|
||||
# include "me/types.h"
|
||||
# include <stdarg.h>
|
||||
# define PRINTF_BUFFER_CHUNK 20
|
||||
|
||||
typedef struct s_matcher_tmp
|
||||
{
|
||||
char chr_val;
|
||||
t_i64 i64_val;
|
||||
t_u64 u64_val;
|
||||
} t_matcher_tmp_val;
|
||||
|
||||
typedef void (*t_matcher_func)(t_printf_arg data,
|
||||
t_printf_func f);
|
||||
typedef struct s_matcher
|
||||
{
|
||||
t_const_str matcher;
|
||||
t_usize matcher_len;
|
||||
t_printf_type arg_type;
|
||||
t_matcher_func f;
|
||||
} t_matcher;
|
||||
|
||||
typedef struct s_matcher_list
|
||||
{
|
||||
t_matcher data[PRINTF_BUFFER_CHUNK];
|
||||
struct s_matcher_list *next;
|
||||
} t_matcher_list;
|
||||
|
||||
t_matcher_list *get_matchers(void);
|
||||
bool insert_matcher(t_matcher matcher);
|
||||
t_matcher *find_matcher(t_const_str fmt,
|
||||
t_matcher_list *matchers, t_usize *c_idx);
|
||||
void call_matcher(t_matcher *matcher,
|
||||
t_printf_arg matcher_arguments, va_list args,
|
||||
t_printf_func f);
|
||||
|
||||
#endif
|
||||
69
stdme/include/me/printf/printf.h
Normal file
69
stdme/include/me/printf/printf.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* printf.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/16 18:10:27 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/02/09 15:06:53 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PRINTF_H
|
||||
|
||||
# define PRINTF_H
|
||||
# include "me/types.h"
|
||||
# include <stdarg.h>
|
||||
|
||||
typedef struct s_fprintf_arg
|
||||
{
|
||||
t_usize total_print;
|
||||
t_file fd;
|
||||
} t_fprintf_arg;
|
||||
|
||||
typedef enum e_printf_flags
|
||||
{
|
||||
PRECISION = 1 << 1,
|
||||
ALIGN = 1 << 2,
|
||||
ZERO_ALIGN = 1 << 3,
|
||||
SIGN = 1 << 4,
|
||||
} t_printf_flags;
|
||||
|
||||
typedef enum e_printf_type
|
||||
{
|
||||
CHAR = 1 << 0,
|
||||
STR = 1 << 1,
|
||||
U64 = 1 << 2,
|
||||
I64 = 1 << 3,
|
||||
VOID_PTR = 1 << 4,
|
||||
I32 = 1 << 5,
|
||||
U32 = 1 << 6,
|
||||
} t_printf_type;
|
||||
|
||||
typedef struct s_printf_extra_args
|
||||
{
|
||||
t_u64 precision;
|
||||
t_u64 align;
|
||||
bool left_align;
|
||||
bool space_align;
|
||||
bool pretty;
|
||||
} t_printf_extra_args;
|
||||
|
||||
typedef struct s_printf_args
|
||||
{
|
||||
void *argument;
|
||||
void *p_args;
|
||||
t_printf_extra_args extra;
|
||||
t_printf_flags flags;
|
||||
} t_printf_arg;
|
||||
|
||||
typedef void (*t_printf_func)(t_const_str to_write,
|
||||
t_usize to_write_len, void *p_args);
|
||||
|
||||
t_usize me_printf(t_const_str fmt, ...);
|
||||
t_usize me_eprintf(t_const_str fmt, ...);
|
||||
t_usize me_vprintf(t_const_str fmt, va_list *args);
|
||||
t_usize me_veprintf(t_const_str fmt, va_list *args);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue