Finished the norm in stdme normal code
This commit is contained in:
parent
3cfbf07882
commit
5bc68504f9
19 changed files with 44 additions and 325 deletions
|
|
@ -1,5 +1,4 @@
|
|||
SRC_FILES = \
|
||||
from_node \
|
||||
from_node/ast_free \
|
||||
from_node/ast_free_scripting \
|
||||
from_node/from_node \
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/03 13:20:01 by maiboyer #+# #+# #
|
||||
# Updated: 2024/07/23 21:52:40 by maiboyer ### ########.fr #
|
||||
# Updated: 2024/07/30 16:02:19 by maiboyer ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ LIB_NAME ?=
|
|||
TARGET = $(BUILD_DIR)/$(NAME)
|
||||
CC ?= clang
|
||||
CFLAGS = -Wno-unused-command-line-argument -Wall -Werror -Wextra -g3 -L$(BUILD_DIR) -MMD -rdynamic -DBASE_PATH='"$(BASE_PATH)/"'
|
||||
CFLAGS = $(CFLAGS_ADDITIONAL)
|
||||
CFLAGS += $(CFLAGS_ADDITIONAL)
|
||||
|
||||
-include Filelist.$(ANAME).mk
|
||||
|
||||
|
|
|
|||
|
|
@ -6,31 +6,17 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/27 21:13:15 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/30 14:07:41 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/30 15:58:54 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ARITH_H
|
||||
# define ARITH_H
|
||||
|
||||
# include <stddef.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
|
||||
# include "app/state.h"
|
||||
# include "ast/ast.h"
|
||||
# include "exec/run.h"
|
||||
# include "me/convert/numbers_to_str.h"
|
||||
# include "me/convert/str_to_numbers.h"
|
||||
# include "me/hashmap/hashmap_env.h"
|
||||
# include "me/mem/mem.h"
|
||||
# include "me/os/pipe.h"
|
||||
# include "me/os/process.h"
|
||||
# include "me/str/str.h"
|
||||
# include "me/string/string.h"
|
||||
# include "me/types.h"
|
||||
# include "me/vec/vec_estr.h"
|
||||
# include "me/vec/vec_str.h"
|
||||
# include <unistd.h>
|
||||
|
||||
typedef t_error (*t_arith_op_func)(t_ast_node self, t_state *state, t_i64 *out);
|
||||
|
||||
|
|
@ -6,13 +6,14 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/03 15:43:08 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/30 13:23:00 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/30 16:28:05 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PROCESS_H
|
||||
#define PROCESS_H
|
||||
|
||||
#include "me/fs/fs.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_str.h"
|
||||
#include "me/vec/vec_u8.h"
|
||||
|
|
@ -30,7 +31,7 @@ enum e_redirection
|
|||
union u_redirection {
|
||||
struct s_fd_redirection
|
||||
{
|
||||
int value;
|
||||
t_fd *value;
|
||||
} fd;
|
||||
struct s_piped_redirection
|
||||
{
|
||||
|
|
@ -41,7 +42,7 @@ union u_redirection {
|
|||
};
|
||||
|
||||
/// @brief Redirection for spawning a process
|
||||
typedef struct s_redirection
|
||||
typedef struct s_process_redirection
|
||||
{
|
||||
enum e_redirection tag;
|
||||
union u_redirection vals;
|
||||
|
|
@ -70,7 +71,7 @@ static inline t_redirection inherited(void)
|
|||
/// @brief Create a file descriptor redirection
|
||||
/// @param fd file descriptor to redirect
|
||||
/// @return the redirection
|
||||
static inline t_redirection fd(int fd)
|
||||
static inline t_redirection fd(t_fd *fd)
|
||||
{
|
||||
return ((t_redirection){.tag = R_FD,
|
||||
.vals = (union u_redirection){
|
||||
|
|
@ -78,59 +79,8 @@ static inline t_redirection fd(int fd)
|
|||
}});
|
||||
}
|
||||
|
||||
/// @brief Wrapped file descriptor tag
|
||||
enum e_wrapped_fd_tag
|
||||
{
|
||||
READ_ONLY,
|
||||
WRITE_ONLY,
|
||||
READ_WRITE,
|
||||
INVALID,
|
||||
};
|
||||
|
||||
/// @brief Wrapped file descriptor
|
||||
union u_wrapped_fd {
|
||||
struct s_read_only
|
||||
{
|
||||
int fd;
|
||||
} ro;
|
||||
struct s_write_only
|
||||
{
|
||||
int fd;
|
||||
} wo;
|
||||
struct s_read_write
|
||||
{
|
||||
int fd;
|
||||
} rw;
|
||||
};
|
||||
|
||||
/// @brief Wrapped file descriptor
|
||||
typedef struct s_wrapped_fd
|
||||
{
|
||||
enum e_wrapped_fd_tag tag;
|
||||
union u_wrapped_fd vals;
|
||||
} t_wrapped_fd;
|
||||
|
||||
/// @brief Create a Read only wrapped file descriptor
|
||||
/// @param fd file descriptor to wrap
|
||||
/// @return the wrapped file descriptor
|
||||
static inline t_wrapped_fd ro(int fd)
|
||||
{
|
||||
return ((t_wrapped_fd){.tag = READ_ONLY,
|
||||
.vals = (union u_wrapped_fd){
|
||||
.ro = {.fd = fd},
|
||||
}});
|
||||
}
|
||||
|
||||
/// @brief Create a Write only wrapped file descriptor
|
||||
/// @param fd file descriptor to wrap
|
||||
/// @return the wrapped file descriptor
|
||||
static inline t_wrapped_fd wo(int fd)
|
||||
{
|
||||
return ((t_wrapped_fd){.tag = WRITE_ONLY, .vals = (union u_wrapped_fd){.wo = {.fd = fd}}});
|
||||
}
|
||||
|
||||
/// @brief Spawn information
|
||||
typedef struct s_spawn_info
|
||||
typedef struct s_exec_spawn_info
|
||||
{
|
||||
t_redirection stdin;
|
||||
t_redirection stdout;
|
||||
|
|
@ -140,30 +90,18 @@ typedef struct s_spawn_info
|
|||
t_str binary_path;
|
||||
void (*forked_free)(void *);
|
||||
void *forked_free_args;
|
||||
} t_spawn_info;
|
||||
} t_exec_spawn_info;
|
||||
|
||||
/// @brief Process information
|
||||
typedef struct s_process
|
||||
{
|
||||
t_wrapped_fd stdin;
|
||||
t_wrapped_fd stdout;
|
||||
t_wrapped_fd stderr;
|
||||
t_pid pid;
|
||||
} t_process;
|
||||
/// @struct Process output
|
||||
/// @brief Process output information
|
||||
typedef struct s_process_output
|
||||
{
|
||||
t_pid pid;
|
||||
t_vec_u8 stdout;
|
||||
t_vec_u8 stderr;
|
||||
t_exit_code exit_code;
|
||||
} t_process_output;
|
||||
} t_exec_process;
|
||||
|
||||
/// @brief Spawn a new process with the given information
|
||||
/// @param info the information to spawn the process
|
||||
/// @param process data returned by the function
|
||||
/// @return true if an error occured, false otherwise
|
||||
t_error spawn_process(t_spawn_info info, t_process *process);
|
||||
t_error spawn_process(t_exec_spawn_info info, t_exec_process *process);
|
||||
|
||||
#endif /* PROCESS_H */
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/26 15:14:50 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/30 14:07:29 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/30 16:31:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./arith.h"
|
||||
#include "exec/arith.h"
|
||||
#include "me/types.h"
|
||||
#include "me/convert/str_to_numbers.h"
|
||||
|
||||
/// ADD OPERATOR STUFF
|
||||
t_error _binary_get_op(t_ast_arithmetic_operator op, t_arith_op_func *out)
|
||||
|
|
@ -100,17 +101,6 @@ t_ast_node _arith_postfix_to_ast_node(t_ast_arithmetic_postfix *self)
|
|||
struct s_ast_node, data.arithmetic_postfix)));
|
||||
}
|
||||
|
||||
/*
|
||||
t_ast_node _arith_postfix_to_ast_node(t_ast_arithmetic_postfix *self)
|
||||
{
|
||||
t_u8 *ptr;
|
||||
|
||||
ptr = (void *)(self);
|
||||
return ((void *)(ptr - offsetof(\
|
||||
struct s_ast_node, data.arithmetic_postfix)));
|
||||
}
|
||||
*/
|
||||
|
||||
// this is black magic don't worry
|
||||
t_ast_node _arith_literal_to_ast_node(t_ast_arithmetic_literal *self)
|
||||
{
|
||||
|
|
@ -182,7 +172,6 @@ t_error run_arithmetic_binary(t_ast_arithmetic_binary *arithmetic_binary, \
|
|||
t_error run_arithmetic_ternary(t_ast_arithmetic_ternary *arithmetic_ternary, \
|
||||
t_state *state, t_i64 *out)
|
||||
{
|
||||
t_arith_op_func func;
|
||||
t_i64 cond;
|
||||
|
||||
if (arithmetic_ternary == NULL || state == NULL || out == NULL)
|
||||
|
|
@ -234,11 +223,7 @@ t_ast_arithmetic_unary *arithmetic_unary, t_state *state, t_i64 *out)
|
|||
t_error run_arithmetic_expansion( \
|
||||
t_ast_arithmetic_expansion *arithmetic_expansion, t_state *state, t_i64 *out)
|
||||
{
|
||||
t_arith_op_func func;
|
||||
|
||||
if (arithmetic_expansion == NULL || state == NULL || out == NULL)
|
||||
return (ERROR);
|
||||
if (_get_node_number(arithmetic_expansion->expr, state, out))
|
||||
return (ERROR);
|
||||
return (NO_ERROR);
|
||||
return (_get_node_number(arithmetic_expansion->expr, state, out));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./arith.h"
|
||||
#include "exec/arith.h"
|
||||
|
||||
t_error _binary_op_add(t_ast_node self, t_state *state, t_i64 *out)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/04 22:27:00 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/30 14:53:11 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/30 16:03:43 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
#include "exec/spawn_cmd/process.h"
|
||||
#include "me/types.h"
|
||||
|
||||
t_error handle_redirections(t_spawn_info *info, t_process *process)
|
||||
t_error handle_redirections(t_exec_spawn_info *info, t_exec_process *process)
|
||||
{
|
||||
return (ERROR);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue