This commit is contained in:
Loic Deridder
2025-02-12 10:10:29 +01:00
parent ced584b17a
commit adc59eb33b
20 changed files with 822 additions and 662 deletions

View File

@@ -23,21 +23,23 @@
# include <stdlib.h>
# include <string.h>
# define UNSET_ARG "not enough arguments"
# define EXPRT_INV "not a valid identifier"
// void echo(char *msg, int flag);
int builtin_echo(t_ast_n *node, char **envp);
int builtin_exit(char **arg, bool depth, t_ast_n *node);
int builtin_pwd(char **arg);
int builtin_env(char **arg, char **envp);
int builtin_unset(char **arg, t_ast_n *head);
int builtin_cd(char **arg, t_ast_n *head);
int builtin_export(char **arg, t_ast_n *head);
int builtin_unset(char **arg, t_ast_n *head);
int builtin_cd(char **arg, t_ast_n *head);
int builtin_export(char **arg, t_ast_n *head);
//UTILS
int count_char(char *str);
int count_args(char **tab);
int extractenv(char *str, char **envp);
int count_char(char *str);
int count_args(char **tab);
int extractenv(char *str, char **envp);
char *ft_getenv(char *str, char **envp);
int err_msg_cmd(char *cmd, char *arg, char *msg, int code);
int err_msg_cmd(char *cmd, char *arg, char *msg, int code);
void char_swap(char **s1, char **s2);
#endif

View File

@@ -11,7 +11,7 @@
/* ************************************************************************** */
#ifndef EXEC_H
#define EXEC_H
# define EXEC_H
# include "../minishell.h"
# include <stdio.h>
@@ -19,7 +19,50 @@
# include <sys/types.h>
# include <stdlib.h>
# include <unistd.h>
# include <time.h>
int execute_command(t_ast_n *node);
int execute_command(t_ast_n *node);
//EXEC_REDIR
void handle_file(t_ast_n *node, int check, int i);
void handle_redir(t_ast_n *node);
void reset_redir(t_ast_n *node);
int err_fork_pline(int *pipes);
//EXEC_BUILTIN
int is_builtin(char *str);
int exec_builtin(t_ast_n *node);
//EXEC_PLINE
void exec_pcmd(t_ast_n *pcmd);
void exec_pchild(int *pipes, int index, t_ast_n *pcmd, int cmds);
int end_pline(pid_t last_pid, t_ast_n **pline);
int exec_pline(t_ast_n **pline);
//EXEC_SUBSH
int exec_shcmd(t_ast_n *node);
int execute_shcommand(t_ast_n *node);
int exec_subsh(t_ast_n *node);
//EXEC_HEREDOC
void expander_here(char **str, t_ast_n *node);
void here_remove_quote(t_ast_n *node, int j, char c);
int ifhere_remove_quote(t_ast_n *node, int j);
void read_input(t_ast_n *node, int j);
void here_doc(t_ast_n *node, int i);
//EXEC_UTILS
int execis_validchar(char c);
int execget_var_len(char *str, t_ast_n *node, int *j);
int get_dup_len(char *str, t_ast_n *node);
int execvalid_next(char c);
char *execextract_env(char *str, char **envp);
//EXEC_CMD
int count_cmds(t_ast_n **pline);
char *find_path(char *cmd, char **env);
void return_error(char *arg, char *msg, int code, t_ast_n *node);
int exec(t_ast_n *node);
int exec_scmd(t_ast_n *node);
#endif

View File

@@ -31,4 +31,12 @@ int in_dquote(char *str, char *ch);
int is_exvalidchar(char c);
int exvalid_next(char c);
//EXPANDER_VAR_UTILS
int expand_exit(t_ast_n *node, int j, int k);
int get_new_len(t_ast_n *node, int j);
int valid_expand(t_ast_n *node, int j, int k);
char *create_new(t_ast_n *node, int j, int *len);
void handle_copy(t_ast_n *node, int j, char **new);
void cat_exit(t_ast_n *node, char **new, int i, int *k);
#endif