Updated Filelist

This commit is contained in:
Maieul BOYER 2024-07-30 14:54:11 +02:00
parent ed4015a8fe
commit f05826942a
No known key found for this signature in database
15 changed files with 182 additions and 163 deletions

View file

@ -12,6 +12,7 @@ signal_handler \
GEN_FILES = \
src/hashmap/env/env \
src/hashmap/env/env_clone \
src/hashmap/env/env_iter \
src/hashmap/env/env_utils \
src/vec/ast/ast \

View file

@ -9,11 +9,11 @@ me_alloc/merge_blocks \
me_alloc/pages \
me_alloc/realloc \
vg/dummy_block \
vg/dummy_mem_status \
vg/dummy_mempool \
vg/dummy_mempool_bis \
vg/dummy_mem_status \
vg/valgrind_block \
vg/valgrind_mem_status \
vg/valgrind_mempool \
vg/valgrind_mempool_bis \
vg/valgrind_mem_status \

View file

@ -1,4 +1,9 @@
SRC_FILES = \
arith/arith \
arith/arith_operation \
run_ast \
spawn_cmd/handle_redirection \
spawn_cmd/iter_funcs \
spawn_cmd/pipe \
spawn_cmd/process \

View file

@ -6,44 +6,57 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/29 17:24:19 by maiboyer #+# #+# */
/* Updated: 2024/07/29 19:09:56 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 14:30:45 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef _REDIRECTION_H
#define _REDIRECTION_H
# define _REDIRECTION_H
#include "me/types.h"
# include "me/types.h"
# include "me/fs/fs.h"
typedef struct s_exec_redirect t_exec_redirect;
typedef struct s_exec_redirect_fd t_exec_redirect_fd;
typedef struct s_exec_redirect_heredoc t_exec_redirect_heredoc;
typedef union u_exec_redirect t_exec_redirect;
struct s_exec_redirect_heredoc
{
};
struct s_exec_redirect_fd
{
int infile_fd;
int outfile_fd;
t_str file_path;
};
union u_exec_redirect_data {
t_exec_redirect_heredoc heredoc;
t_exec_redirect_fd fd;
};
enum e_exec_redirect_kind
{
EXEC_REDIR_FD,
EXEC_REDIR_HEREDOC,
EXEC_REDIR_PIPE,
};
struct s_exec_redirect
union u_exec_redirect
{
union u_exec_redirect_data data;
enum e_exec_redirect_kind kind;
struct s_exec_redirect_heredoc
{
enum e_exec_redirect_kind kind;
int in_fd;
t_const_str data;
} heredoc;
struct s_exec_redirect_fd
{
enum e_exec_redirect_kind kind;
int lhs_fd;
int rhs_fd;
t_const_str file_path;
} fd;
struct s_exec_redirect_pipe
{
enum e_exec_redirect_kind kind;
int stdin;
int stdout;
} piped;
};
static inline void free_redirection(t_exec_redirect self)
{
void mem_free(void *ptr);
if (self.kind == EXEC_REDIR_FD)
(void)(self.fd.file_path != NULL && (mem_free(self.fd.file_path), 1));
if (self.kind == EXEC_REDIR_HEREDOC)
(void)(self.heredoc.data != NULL && (mem_free(self.heredoc.data), 1));
}
#endif /* _REDIRECTION_H */

View file

@ -6,25 +6,26 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 17:57:29 by maiboyer #+# #+# */
/* Updated: 2024/01/04 17:59:30 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 14:33:50 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PIPE_H
# define PIPE_H
#define PIPE_H
# include "me/types.h"
#include "me/fs/fs.h"
#include "me/types.h"
/// @brief Pipe structure
typedef struct s_pipe
typedef struct s_exec_pipe
{
int read;
int write;
} t_pipe;
t_fd *read;
t_fd *write;
} t_exec_pipe;
/// @brief Create a pipe
/// @param[out] out the created pipe
/// @return the error
t_error create_pipe(t_pipe *out);
t_error create_pipe(t_exec_pipe *out);
#endif /* PIPE_H */

View file

@ -6,16 +6,16 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/03 15:43:08 by maiboyer #+# #+# */
/* Updated: 2024/07/11 18:59:04 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 13:23:00 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PROCESS_H
# define PROCESS_H
#define PROCESS_H
# include "me/types.h"
# include "me/vec/vec_str.h"
# include "me/vec/vec_u8.h"
#include "me/types.h"
#include "me/vec/vec_str.h"
#include "me/vec/vec_u8.h"
typedef t_i32 t_pid;
typedef t_i32 t_exit_code;
@ -27,8 +27,7 @@ enum e_redirection
R_FD = 2,
};
union u_redirection
{
union u_redirection {
struct s_fd_redirection
{
int value;
@ -73,9 +72,9 @@ static inline t_redirection inherited(void)
/// @return the redirection
static inline t_redirection fd(int fd)
{
return ((t_redirection){.tag = R_FD, \
.vals = (union u_redirection){\
.fd = {.value = fd}, \
return ((t_redirection){.tag = R_FD,
.vals = (union u_redirection){
.fd = {.value = fd},
}});
}
@ -89,8 +88,7 @@ enum e_wrapped_fd_tag
};
/// @brief Wrapped file descriptor
union u_wrapped_fd
{
union u_wrapped_fd {
struct s_read_only
{
int fd;
@ -117,9 +115,9 @@ typedef struct s_wrapped_fd
/// @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}, \
return ((t_wrapped_fd){.tag = READ_ONLY,
.vals = (union u_wrapped_fd){
.ro = {.fd = fd},
}});
}
@ -128,8 +126,7 @@ static inline t_wrapped_fd ro(int fd)
/// @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}}});
return ((t_wrapped_fd){.tag = WRITE_ONLY, .vals = (union u_wrapped_fd){.wo = {.fd = fd}}});
}
/// @brief Spawn information
@ -167,7 +164,6 @@ typedef struct s_process_output
/// @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_spawn_info info, t_process *process);
#endif /* PROCESS_H */

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */
/* Updated: 2024/07/29 19:04:56 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 14:52:09 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,6 +26,7 @@
#include <stdio.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-variable"
@ -728,3 +729,5 @@ t_error run_node(t_ast_node self, t_state *state, void *out)
}
*/
#pragma clang diagnostic pop

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_inner.c :+: :+: :+: */
/* handle_redirection.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 22:27:00 by maiboyer #+# #+# */
/* Updated: 2024/07/29 19:05:38 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 14:53:11 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,4 +16,5 @@
t_error handle_redirections(t_spawn_info *info, t_process *process)
{
return (ERROR);
}

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_iter_funcs.c :+: :+: :+: */
/* iter_funcs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 22:25:44 by maiboyer #+# #+# */
/* Updated: 2024/07/29 17:22:42 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 13:22:34 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,23 +19,12 @@ bool exec_find_null(const t_str *s)
return (s == NULL);
}
bool exec_str_start_with(t_const_str s, t_const_str prefix)
{
while (*prefix && *s)
{
if (*prefix++ != *s++)
return (false);
}
return (*prefix == '\0');
}
bool exec_find_path(const t_str *s)
{
t_str ss;
t_str str;
if (*s == NULL)
return (false);
ss = *s;
return (ss[0] == 'P' && ss[1] == 'A' && ss[2] == 'T' && ss[3] == 'H' && \
ss[4] == '=');
str = *s;
return (str[0] == 'P' && str[1] == 'A' && str[2] == 'T' && str[3] == 'H' && str[4] == '=');
}

View file

@ -6,19 +6,33 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 17:59:48 by maiboyer #+# #+# */
/* Updated: 2024/07/29 19:05:12 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 14:48:48 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec/spawn_cmd/pipe.h"
#include "me/fs/fs.h"
#include "me/str/str.h"
t_error exec_create_pipe(t_pipe *out)
t_error exec_create_pipe(t_exec_pipe *out)
{
int fds[2];
int fd[2];
struct s_file_slot *read;
struct s_file_slot *write;
if (pipe(fds))
if (pipe(fd))
return (ERROR);
out->read = fds[0];
out->write = fds[1];
read = get_unused_fd_slot();
if (read == NULL)
return (close(fd[0]), close(fd[1]), ERROR);
read->ty = SLOT_FD;
write = get_unused_fd_slot();
if (write == NULL)
return (read->ty = SLOT_UNUSED, close(fd[0]), close(fd[1]), ERROR);
write->ty = SLOT_FD;
read->slot.fd = (t_fd){.fd = fd[0], .type = FD_PIPE, .name = str_clone("<pipe[R]>"), .perms = FD_READ};
read->slot.fd = (t_fd){.fd = fd[1], .type = FD_PIPE, .name = str_clone("<pipe[W]>"), .perms = FD_WRITE};
out->read = &read->slot.fd;
out->write = &write->slot.fd;
return (NO_ERROR);
}

View file

@ -6,13 +6,13 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/03 16:22:41 by maiboyer #+# #+# */
/* Updated: 2024/07/29 19:06:23 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 13:22:17 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec/spawn_cmd/process.h"
#include "exec/spawn_cmd/pipe.h"
#include "me/mem/mem.h"
#include "me/os/pipe.h"
#include "me/printf/printf.h"
#include "me/str/str.h"
#include "me/string/string.h"
@ -25,7 +25,6 @@
bool exec_find_path(const t_str *s);
bool exec_find_null(const t_str *s);
bool exec_str_start_with(t_const_str s, t_const_str prefix);
t_error exec_handle_redirections(t_spawn_info *info, t_process *process);
t_error exec_spawn_process_exec(t_spawn_info info, t_process *process)
@ -40,7 +39,7 @@ t_error exec_spawn_process_exec(t_spawn_info info, t_process *process)
if (!vec_str_any(&info.environement, exec_find_null, &res) && res)
vec_str_push(&info.environement, NULL);
execve(info.binary_path, info.arguments.buffer, info.environement.buffer);
return (NO_ERROR);
return (ERROR);
}
t_error exec_in_path(t_spawn_info *info, t_process *process, t_const_str path_raw, t_string *s)
@ -71,7 +70,7 @@ t_error exec_find_binary(t_spawn_info *info, t_process *process)
if (info->binary_path == NULL)
return (ERROR);
s = string_new(256);
if (exec_str_start_with(info->binary_path, "/") || str_find_chr(info->binary_path, '/') != NULL)
if (info->binary_path[0] == '/' || str_find_chr(info->binary_path, '/') != NULL)
string_push(&s, info->binary_path);
else
{

View file

@ -2,9 +2,9 @@ SRC_FILES = \
line \
line_edit_actions \
line_edit_actions2 \
line_edit_mode \
line_editing \
line_editing2 \
line_edit_mode \
line_globals \
line_history \
line_internals \

View file

@ -114,28 +114,6 @@ primary_state_ids/primary_state_ids_18 \
primary_state_ids/primary_state_ids_19 \
primary_state_ids/primary_state_ids_20 \
primary_state_ids/primary_state_ids_21 \
small_parse_table_map/small_parse_table_map_0 \
small_parse_table_map/small_parse_table_map_1 \
small_parse_table_map/small_parse_table_map_2 \
small_parse_table_map/small_parse_table_map_3 \
small_parse_table_map/small_parse_table_map_4 \
small_parse_table_map/small_parse_table_map_5 \
small_parse_table_map/small_parse_table_map_6 \
small_parse_table_map/small_parse_table_map_7 \
small_parse_table_map/small_parse_table_map_8 \
small_parse_table_map/small_parse_table_map_9 \
small_parse_table_map/small_parse_table_map_10 \
small_parse_table_map/small_parse_table_map_11 \
small_parse_table_map/small_parse_table_map_12 \
small_parse_table_map/small_parse_table_map_13 \
small_parse_table_map/small_parse_table_map_14 \
small_parse_table_map/small_parse_table_map_15 \
small_parse_table_map/small_parse_table_map_16 \
small_parse_table_map/small_parse_table_map_17 \
small_parse_table_map/small_parse_table_map_18 \
small_parse_table_map/small_parse_table_map_19 \
small_parse_table_map/small_parse_table_map_20 \
small_parse_table_map/small_parse_table_map_21 \
small_parse_table/small_parse_table_0 \
small_parse_table/small_parse_table_1 \
small_parse_table/small_parse_table_2 \
@ -968,6 +946,28 @@ small_parse_table/small_parse_table_828 \
small_parse_table/small_parse_table_829 \
small_parse_table/small_parse_table_830 \
small_parse_table/small_parse_table_831 \
small_parse_table_map/small_parse_table_map_0 \
small_parse_table_map/small_parse_table_map_1 \
small_parse_table_map/small_parse_table_map_2 \
small_parse_table_map/small_parse_table_map_3 \
small_parse_table_map/small_parse_table_map_4 \
small_parse_table_map/small_parse_table_map_5 \
small_parse_table_map/small_parse_table_map_6 \
small_parse_table_map/small_parse_table_map_7 \
small_parse_table_map/small_parse_table_map_8 \
small_parse_table_map/small_parse_table_map_9 \
small_parse_table_map/small_parse_table_map_10 \
small_parse_table_map/small_parse_table_map_11 \
small_parse_table_map/small_parse_table_map_12 \
small_parse_table_map/small_parse_table_map_13 \
small_parse_table_map/small_parse_table_map_14 \
small_parse_table_map/small_parse_table_map_15 \
small_parse_table_map/small_parse_table_map_16 \
small_parse_table_map/small_parse_table_map_17 \
small_parse_table_map/small_parse_table_map_18 \
small_parse_table_map/small_parse_table_map_19 \
small_parse_table_map/small_parse_table_map_20 \
small_parse_table_map/small_parse_table_map_21 \
symbols_metadata/symbols_metadata_0 \
symbols_metadata/symbols_metadata_1 \
symbols_names/symbols_names_0 \

View file

@ -6,7 +6,7 @@
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/03 13:20:01 by maiboyer #+# #+# #
# Updated: 2024/07/23 21:53:40 by maiboyer ### ########.fr #
# Updated: 2024/07/30 14:52:58 by maiboyer ### ########.fr #
# #
# **************************************************************************** #
@ -14,17 +14,14 @@ ANAME = gmr
BUILD_DIR = ../build
SRC_DIR = ./static
#../tree-sitter-sh/src
#./static
BONUS_FLAGS =
NAME = lib$(ANAME).a
LIB_NAME ?=
TARGET = $(BUILD_DIR)/$(NAME)
CC ?= cc
CFLAGS = -Wall -Wextra -Werror -MMD -I./includes -I../includes -I../output/include -I../tree-sitter-sh/src
CFLAGS = -Wall -Wextra -Werror -MMD -I./includes -I../includes -I../output/include
CFLAGS += $(CFLAGS_ADDITIONAL)
#CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-return=runtime -fno-common -fsanitize-address-use-after-scope
-include Filelist.$(ANAME).mk

View file

@ -38,10 +38,10 @@ fs/read \
fs/read_to_vec \
fs/write \
gnl/get_next_line \
hash/hasher \
hash/hash_signed \
hash/hash_str \
hash/hash_unsigned \
hash/hasher \
hash/sip/sip13 \
hash/sip/sip_utils \
hash/sip/sip_utils2 \
@ -89,10 +89,6 @@ printf/printf \
printf/printf_fd \
printf/printf_str \
printf/vprintf \
string/mod \
string/string_insert \
string/string_remove \
string/string_reserve \
str/str_clone \
str/str_compare \
str/str_find_chr \
@ -109,6 +105,10 @@ str/str_n_find_str \
str/str_split \
str/str_substring \
str/str_trim \
string/mod \
string/string_insert \
string/string_remove \
string/string_reserve \
GEN_FILES = \
convert/i16_to_str \