Finished the norm in stdme normal code

This commit is contained in:
Maieul BOYER 2024-07-30 16:31:46 +02:00
parent 3cfbf07882
commit 5bc68504f9
No known key found for this signature in database
19 changed files with 44 additions and 325 deletions

View file

@ -27,16 +27,12 @@ char/isupper \
char/tolower \
char/toupper \
convert/numbers_to_str \
fs/close \
fs/directory \
fs/fd \
fs/file \
fs/fs_internal \
fs/open \
fs/putchar_fd \
fs/putendl_fd \
fs/putnbr_fd \
fs/putstr_fd \
fs/read \
fs/read_to_vec \
fs/write \
fs/getters \
fs/putfd \
gnl/get_next_line \
hash/hash_signed \
hash/hash_str \

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* close.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 15:56:56 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:49:22 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CLOSE_H
# define CLOSE_H
# include "me/types.h"
bool me_close(int file, t_i32 *error);
#endif

View file

@ -1,22 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* open.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 15:29:38 by maiboyer #+# #+# */
/* Updated: 2024/01/05 16:43:37 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef OPEN_H
# define OPEN_H
# include "me/types.h"
t_error me_open(t_const_str path, bool read, bool write, int *file_out);
t_error me_open_truncate(t_const_str path, int *file_out);
t_error me_open_create(t_const_str path, int *file_out);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putchar_fd.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 04:42:45 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:49:06 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUTCHAR_FD_H
# define PUTCHAR_FD_H
# include "me/types.h"
void me_putchar_fd(char chr, int file);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putendl_fd.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 04:42:45 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:31:54 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUTENDL_FD_H
# define PUTENDL_FD_H
# include "me/types.h"
void me_putendl_fd(t_str str, int file);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putnbr_fd.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 12:45:06 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:32:41 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUTNBR_FD_H
# define PUTNBR_FD_H
# include "me/types.h"
void me_putnbr_fd(t_i32 n, int file);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putstr_fd.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 04:42:45 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:35:53 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUTSTR_FD_H
# define PUTSTR_FD_H
# include "me/types.h"
void me_putstr_fd(t_str str, int file);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* read.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 15:21:19 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:37:03 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef READ_H
# define READ_H
# include "me/types.h"
t_usize me_read(int fd, t_u8 *buffer, t_i64 buffer_max, bool *eof_out);
#endif

View file

@ -1,25 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* read_to_vec.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/24 18:50:37 by maiboyer #+# #+# */
/* Updated: 2023/12/24 18:57:36 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef READ_TO_VEC_H
# define READ_TO_VEC_H
# include "me/types.h"
# include "me/vec/vec_u8.h"
# ifndef READ_BUFFER_SIZE
# define READ_BUFFER_SIZE 4096
# endif
bool read_to_vec(t_const_str path, t_vec_u8 *out);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* write.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 15:27:33 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:36:48 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef WRITE_H
# define WRITE_H
# include "me/types.h"
bool me_write(int fd, t_u8 *buffer, t_i64 size);
#endif

View file

@ -6,33 +6,35 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/24 19:06:05 by maiboyer #+# #+# */
/* Updated: 2024/07/10 17:46:34 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 16:26:28 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/fs/close.h"
#include "me/fs/open.h"
#include "me/fs/read_to_vec.h"
#include "me/fs/write.h"
#include "me/fs/fs.h"
#include "me/img/qoi.h"
#include "me/mem/mem.h"
#include "me/vec/vec_u8.h"
#include <stdlib.h>
/// This has to be added into the me/fs/fs.h header at one point
t_error read_to_vec(t_const_str filename, t_vec_u8 *out);
t_i32 qoi_write(t_const_str filename, const void *data,
const t_qoi_desc *desc)
{
int f;
t_fd *f;
void *encoded;
t_i32 size;
if (me_open(filename, false, true, &f))
f = open_fd((t_str)filename, FD_WRITE, 0, FP_ALL_EXEC);
if (f == NULL)
return (0);
encoded = qoi_encode(data, desc, &size);
if (!encoded)
return (me_close(f, NULL), 0);
if (me_write(f, encoded, size))
return (me_close(f, NULL), 0);
me_close(f, NULL);
return (close_fd(f), 0);
if (write_fd(f, encoded, size, NULL))
return (close_fd(f), 0);
close_fd(f);
mem_free(encoded);
return (size);
}

View file

@ -6,13 +6,12 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/07 11:08:03 by maiboyer #+# #+# */
/* Updated: 2024/07/30 16:09:47 by rparodi ### ########.fr */
/* Updated: 2024/07/30 16:20:50 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "./gnu_source.h"
#include "me/fs/putendl_fd.h"
#include "me/fs/putstr_fd.h"
#include "me/fs/fs.h"
#include "me/types.h"
#include <dlfcn.h>
#include <execinfo.h>
@ -87,9 +86,10 @@ void print_trace(void)
void me_abort(t_str msg)
{
if (msg == NULL)
msg = "No message (msg was NULL)";
me_putstr_fd("Abort: ", 2);
me_putendl_fd(msg, 2);
msg = "No message provided";
put_string_fd(get_stderr(),"Abort: ");
put_string_fd(get_stderr(),msg);
put_char_fd(get_stderr(),'\n');
print_trace();
me_exit(134);
}