diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/ast.h | 8 | ||||
| -rw-r--r-- | include/eval.h | 35 | ||||
| -rw-r--r-- | include/minishell.h | 16 | ||||
| -rw-r--r-- | include/parser.h | 4 |
4 files changed, 29 insertions, 34 deletions
diff --git a/include/ast.h b/include/ast.h index 317e1b8..53221fa 100644 --- a/include/ast.h +++ b/include/ast.h @@ -6,7 +6,7 @@ /* By: charles <charles@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:05:38 by charles #+# #+# */ -/* Updated: 2020/06/17 16:43:12 by nahaddac ### ########.fr */ +/* Updated: 2020/06/18 13:35:38 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,7 +26,7 @@ struct s_ast; /* -** \brief Line struct +** \brief Operation struct ** \param left AST to the left of separator ** \param right AST to the right of separator ** \param sep Type of separator @@ -43,7 +43,7 @@ typedef struct s_op /* ** \brief AST node tag (type) ** \param TAG_CMD Command AST node -** \param TAG_LINE Line AST node +** \param TAG_OP Operation AST node */ enum e_ast_tag @@ -56,7 +56,7 @@ enum e_ast_tag /* ** \brief AST node struct ** \param tag Node tag -** \param line Line struct +** \param op Operation struct ** \param cmd_argv Array of string tokens ** \param in STDIN redirection string tokens ** \param out STDOUT redirection string tokens diff --git a/include/eval.h b/include/eval.h index bde0cd7..60d6f23 100644 --- a/include/eval.h +++ b/include/eval.h @@ -6,7 +6,7 @@ /* By: charles <charles@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:05:30 by charles #+# #+# */ -/* Updated: 2020/06/17 15:49:49 by nahaddac ### ########.fr */ +/* Updated: 2020/06/18 13:38:53 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ */ # include "minishell.h" +# include "lexer.h" # include "ast.h" /* @@ -47,7 +48,7 @@ typedef struct t_op *op; int fd_in; int fd_out; -} t_fork_param_line; +} t_fork_param_op; typedef struct { @@ -57,21 +58,16 @@ typedef struct t_builtin_func builtin; } t_fork_param_cmd; -#define MS_NO_FD -2 +# define MS_NO_FD -2 +# define FDS_WRITE 1 +# define FDS_READ 0 /* -** eval.c +** op.c */ -int eval(int fd_in, int fd_out, t_eval_state *state, t_ast *ast); - -/* -** exec.c -*/ - -bool exec_is_path(char *path_str); -bool exec_is_valid(char *exec_path); -char *exec_search_path(t_path path, char *path_var, char *exec_name); +int eval_op(int fds[2], t_env env, t_path path, t_op *op); +int eval(int fds[2], t_env env, t_path path, t_ast *ast); enum e_error { @@ -99,12 +95,21 @@ void error_eval_put(enum e_error id, char *unexpected); ** cmd.c */ -int eval_cmd(t_env env, t_path path, t_ast *ast); +int fork_wrap(int fds[2], void *passed, int (*wrapped)(void *param)); +int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast); /* ** redir.c */ -bool redir_extract(t_ftlst *redirs, t_env env, int *fd_in, int *fd_out); +bool redir_extract(t_ftlst *redirs, t_env env, int fds[2]); + +/* +** exec.c +*/ + +bool exec_is_path(char *exec_name); +bool exec_is_valid(char *exec_path); +char *exec_search_path(t_path path, char *path_var, char *exec_name); #endif diff --git a/include/minishell.h b/include/minishell.h index 97b12e4..5f4f56a 100644 --- a/include/minishell.h +++ b/include/minishell.h @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/26 15:33:51 by cacharle #+# #+# */ -/* Updated: 2020/06/15 09:47:20 by charles ### ########.fr */ +/* Updated: 2020/06/18 13:45:27 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,18 +42,6 @@ # define PIPE_CLOSED -1 -/* -** \brief Pipe write index -*/ - -# define PIPE_WRITE 1 - -/* -** \brief Pipe read index -*/ - -# define PIPE_READ 0 - # define BUILTIN_NOT_FOUND -2 typedef t_ftht* t_path; @@ -70,8 +58,10 @@ t_path path_update(t_path path, char *path_var); */ t_env env_from_array(char **envp); +int env_keycmp(char *var, char *key); char *env_search(t_env env, char *key); char *env_search_first_match(t_env env, const char *haystack); +char *env_export(t_env env, char *key, char *value); /* ** builtin*.c - directory with all builtin commands diff --git a/include/parser.h b/include/parser.h index 0dfeb18..f3a425e 100644 --- a/include/parser.h +++ b/include/parser.h @@ -6,7 +6,7 @@ /* By: cacharle <cacharle@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/28 09:00:00 by cacharle #+# #+# */ -/* Updated: 2020/06/18 12:40:22 by nahaddac ### ########.fr */ +/* Updated: 2020/06/18 14:04:07 by nahaddac ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,7 +39,7 @@ t_ret *parse(t_ftlst *input); -t_ret *parse_op(t_ftlst *input) +t_ret *parse_op(t_ftlst *input); t_ret *parse_expr(t_ftlst *input); t_ret *parse_cmd(t_ftlst *input); |
