Added: Pipex as ressources, not most readable code tho...

This commit is contained in:
Maieul BOYER 2024-03-27 13:42:54 +01:00
parent 9482844642
commit 5d425048f2
No known key found for this signature in database
38 changed files with 2975 additions and 0 deletions

View file

@ -0,0 +1,51 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_buf_str.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
/* Updated: 2023/12/09 17:53:00 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VEC_BUF_STR_H
# define VEC_BUF_STR_H
# include "me/buffered_str/buf_str.h"
# include "me/types.h"
typedef void (*t_free_buf_str_item)(t_buffer_str);
typedef struct s_vec_buf_str
{
t_free_buf_str_item free_func;
t_usize len;
t_usize capacity;
t_buffer_str *buffer;
} t_vec_buf_str;
t_vec_buf_str vec_buf_str_new(t_usize capacity,
t_free_buf_str_item free_function);
t_error vec_buf_str_push(t_vec_buf_str *vec,
t_buffer_str element);
t_error vec_buf_str_pop(t_vec_buf_str *vec,
t_buffer_str *value);
void vec_buf_str_free(t_vec_buf_str vec);
t_error vec_buf_str_reserve(t_vec_buf_str *vec,
t_usize wanted_capacity);
t_error vec_buf_str_find(t_vec_buf_str *vec,
bool (*fn)(const t_buffer_str *), t_usize *index);
t_error vec_buf_str_find_starting(t_vec_buf_str *vec,
bool (*fn)(const t_buffer_str *),
t_usize starting_index, t_usize *index);
t_error vec_buf_str_all(t_vec_buf_str *vec,
bool (*fn)(const t_buffer_str *), bool *result);
t_error vec_buf_str_any(t_vec_buf_str *vec,
bool (*fn)(const t_buffer_str *), bool *result);
void vec_buf_str_iter(t_vec_buf_str *vec,
void (*fn)(t_usize index, t_buffer_str *value,
void *state), void *state);
#endif

View file

@ -0,0 +1,49 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_process.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
/* Updated: 2023/12/09 17:53:00 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VEC_PROCESS_H
# define VEC_PROCESS_H
# include "me/os/process.h"
# include "me/types.h"
typedef void (*t_free_process_item)(t_process);
typedef struct s_vec_process
{
t_free_process_item free_func;
t_usize len;
t_usize capacity;
t_process *buffer;
} t_vec_process;
t_vec_process vec_process_new(t_usize capacity,
t_free_process_item free_function);
t_error vec_process_push(t_vec_process *vec, t_process element);
t_error vec_process_pop(t_vec_process *vec, t_process *value);
void vec_process_free(t_vec_process vec);
t_error vec_process_reserve(t_vec_process *vec,
t_usize wanted_capacity);
t_error vec_process_find(t_vec_process *vec,
bool (*fn)(const t_process *), t_usize *index);
t_error vec_process_find_starting(t_vec_process *vec,
bool (*fn)(const t_process *),
t_usize starting_index, t_usize *index);
t_error vec_process_all(t_vec_process *vec,
bool (*fn)(const t_process *), bool *result);
t_error vec_process_any(t_vec_process *vec,
bool (*fn)(const t_process *), bool *result);
void vec_process_iter(t_vec_process *vec,
void (*fn)(t_usize index, t_process *value,
void *state), void *state);
#endif

View file

@ -0,0 +1,46 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_str.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
/* Updated: 2023/12/09 17:53:00 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VEC_STR_H
# define VEC_STR_H
# include "me/types.h"
typedef void (*t_free_str_item)(t_str);
typedef struct s_vec_str
{
t_free_str_item free_func;
t_usize len;
t_usize capacity;
t_str *buffer;
} t_vec_str;
t_vec_str vec_str_new(t_usize capacity,
t_free_str_item free_function);
t_error vec_str_push(t_vec_str *vec, t_str element);
t_error vec_str_pop(t_vec_str *vec, t_str *value);
void vec_str_free(t_vec_str vec);
t_error vec_str_reserve(t_vec_str *vec, t_usize wanted_capacity);
t_error vec_str_find(t_vec_str *vec, bool (*fn)(const t_str *),
t_usize *index);
t_error vec_str_find_starting(t_vec_str *vec,
bool (*fn)(const t_str *), t_usize starting_index,
t_usize *index);
t_error vec_str_all(t_vec_str *vec, bool (*fn)(const t_str *),
bool *result);
t_error vec_str_any(t_vec_str *vec, bool (*fn)(const t_str *),
bool *result);
void vec_str_iter(t_vec_str *vec, void (*fn)(t_usize index,
t_str *value, void *state), void *state);
#endif

View file

@ -0,0 +1,45 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_u8.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
/* Updated: 2023/12/09 17:53:00 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VEC_U8_H
# define VEC_U8_H
# include "me/types.h"
typedef void (*t_free_u8_item)(t_u8);
typedef struct s_vec_u8
{
t_free_u8_item free_func;
t_usize len;
t_usize capacity;
t_u8 *buffer;
} t_vec_u8;
t_vec_u8 vec_u8_new(t_usize capacity, t_free_u8_item free_function);
t_error vec_u8_push(t_vec_u8 *vec, t_u8 element);
t_error vec_u8_pop(t_vec_u8 *vec, t_u8 *value);
void vec_u8_free(t_vec_u8 vec);
t_error vec_u8_reserve(t_vec_u8 *vec, t_usize wanted_capacity);
t_error vec_u8_find(t_vec_u8 *vec, bool (*fn)(const t_u8 *),
t_usize *index);
t_error vec_u8_find_starting(t_vec_u8 *vec,
bool (*fn)(const t_u8 *), t_usize starting_index,
t_usize *index);
t_error vec_u8_all(t_vec_u8 *vec, bool (*fn)(const t_u8 *),
bool *result);
t_error vec_u8_any(t_vec_u8 *vec, bool (*fn)(const t_u8 *),
bool *result);
void vec_u8_iter(t_vec_u8 *vec, void (*fn)(t_usize index,
t_u8 *value, void *state), void *state);
#endif