Merge branch 'feature/executor-gl' into solo
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
# include "minishell.h"
|
||||
# include "core.h"
|
||||
|
||||
typedef unsigned char (*t_builtin_func)(t_command cmd, t_minishell *minishell);
|
||||
typedef uint8_t (*t_builtin_func)(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
@@ -25,24 +25,36 @@ typedef unsigned char (*t_builtin_func)(t_command cmd, t_minishell *minishell)
|
||||
|
||||
/* builtins.c */
|
||||
|
||||
extern u_int8_t set_builtins(t_minishell *minishell);
|
||||
extern uint8_t set_builtins(t_minishell *minishell);
|
||||
|
||||
extern u_int8_t is_builtin(const char *command_name, t_minishell *minishell);
|
||||
extern uint8_t is_builtin(const char *command_name, t_minishell *minishell);
|
||||
|
||||
/* cd.c */
|
||||
|
||||
extern u_int8_t builtin_cd(t_command cmd, t_minishell *minishell);
|
||||
extern uint8_t builtin_cd(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* echo.c */
|
||||
|
||||
extern u_int8_t builtin_echo(t_command cmd, t_minishell *minishell);
|
||||
extern uint8_t builtin_echo(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* exit.c */
|
||||
|
||||
extern u_int8_t builtin_exit(t_command cmd, t_minishell *minishell);
|
||||
extern uint8_t builtin_exit(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* pwd.c */
|
||||
|
||||
extern u_int8_t builtin_pwd(t_command cmd, t_minishell *minishell);
|
||||
extern uint8_t builtin_pwd(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* env.c */
|
||||
|
||||
extern uint8_t builtin_env(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* export.c */
|
||||
|
||||
extern uint8_t builtin_export(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* unset.c */
|
||||
|
||||
extern uint8_t builtin_unset(t_command cmd, t_minishell *minishell);
|
||||
|
||||
#endif /* BUILTINS_H */
|
||||
|
||||
@@ -82,12 +82,6 @@ typedef struct s_minishell
|
||||
bool exit;
|
||||
} t_minishell;
|
||||
|
||||
typedef struct s_redirection
|
||||
{
|
||||
t_token_type type;
|
||||
char *target;
|
||||
} t_redirection;
|
||||
|
||||
/**
|
||||
* @brief Structure representing a single command in the shell
|
||||
*
|
||||
@@ -142,4 +136,6 @@ extern void free_envp(char **envp);
|
||||
|
||||
extern char *get_env(const char *env_name, t_minishell *msh);
|
||||
|
||||
extern void unset_env(const char *env_name, t_minishell *msh);
|
||||
|
||||
#endif /* CORE_H */
|
||||
|
||||
@@ -19,23 +19,42 @@
|
||||
|
||||
# define READ_PIPE 0
|
||||
# define WRITE_PIPE 1
|
||||
|
||||
typedef struct s_pipeline
|
||||
{
|
||||
int prev_read_fd;
|
||||
int pipefd[2];
|
||||
} t_pipeline;
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
/******************************************************************************/
|
||||
|
||||
// executor.c
|
||||
|
||||
# define PIPE_ERROR -1
|
||||
# define FORK_ERROR -1
|
||||
|
||||
extern uint8_t execute(t_list *command, t_minishell *minishell);
|
||||
typedef struct s_pipeline
|
||||
{
|
||||
int prev_read_fd;
|
||||
int pipefd[2];
|
||||
} t_pipeline;
|
||||
|
||||
typedef struct s_exec_state
|
||||
{
|
||||
uint8_t exit_status;
|
||||
t_pipeline pipeline;
|
||||
t_list *current_command;
|
||||
pid_t last_child_pid;
|
||||
} t_exec_state;
|
||||
|
||||
extern uint8_t execute(t_list *command, t_minishell *minishell);
|
||||
extern uint8_t executor_execute_command(t_command *cmd, t_minishell *msh);
|
||||
extern char *executor_resolve_command_path(const t_command *cmd,
|
||||
t_minishell *msh);
|
||||
extern bool executor_is_builtin_command(const t_command *cmd,
|
||||
t_minishell *msh);
|
||||
extern int executor_create_pipe_if_needed(t_list *node, t_pipeline *pl);
|
||||
extern bool executor_is_fork_required(t_list *node, const t_pipeline *pl,
|
||||
t_minishell *msh);
|
||||
extern void executor_setup_child_input(t_pipeline *pipeline);
|
||||
extern void executor_setup_child_output(t_list *node, t_pipeline *pl);
|
||||
extern void executor_child_process(t_list *node, t_pipeline *pl,
|
||||
t_minishell *msh);
|
||||
extern void executor_parent_cleanup(t_list *node, t_pipeline *pl);
|
||||
extern uint8_t executor_wait_for_children(pid_t last_child_pid);
|
||||
extern void executor_cmdfree(t_command *command);
|
||||
extern bool executor_apply_redirections(const t_command *command,
|
||||
int *saved_stdin, int *saved_stdout);
|
||||
extern void executor_restore_redirections(int saved_stdin,
|
||||
int saved_stdout);
|
||||
|
||||
#endif /* EXECUTOR_H */
|
||||
|
||||
Reference in New Issue
Block a user