aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ast.h2
-rw-r--r--include/eval.h43
-rw-r--r--include/lexer.h3
-rw-r--r--include/minishell.h9
4 files changed, 45 insertions, 12 deletions
diff --git a/include/ast.h b/include/ast.h
index 4e89c96..bcb5e11 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/01 17:05:38 by charles #+# #+# */
-/* Updated: 2020/06/14 10:28:53 by charles ### ########.fr */
+/* Updated: 2020/06/14 17:47:10 by charles ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/include/eval.h b/include/eval.h
index 8fbbb1c..f834d45 100644
--- a/include/eval.h
+++ b/include/eval.h
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/01 17:05:30 by charles #+# #+# */
-/* Updated: 2020/06/14 10:33:54 by charles ### ########.fr */
+/* Updated: 2020/06/15 11:09:49 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -27,7 +27,6 @@
typedef struct
{
- int p[2];
t_path path;
t_env env;
} t_eval_state;
@@ -54,8 +53,11 @@ typedef struct
{
char *exec_path;
char **argv;
- char **envp;
-} t_fork_param_execve;
+ t_env env;
+ t_builtin_func builtin;
+} t_fork_param_cmd;
+
+#define MS_NO_FD -2
/*
** eval.c
@@ -71,11 +73,38 @@ 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);
+enum e_error
+{
+ ERROR_AMBIGUOUS_REDIR,
+ ERROR_OPEN,
+ ERROR_CMD_NOT_FOUND,
+ ERROR_SYNTAX,
+};
+
+typedef struct
+{
+ enum e_error id;
+ int status;
+ char *msg; // if NULL call strerror
+ // char *basename;
+} t_error;
+
+/*
+** error.c
+*/
+
+void error_eval_put(enum e_error id, char *unexpected);
+
+/*
+** cmd.c
+*/
+
+int eval_cmd(t_env env, t_path path, t_ast *ast);
+
/*
-** pipe.c
+** redir.c
*/
-// int pipe_setup_parent(t_cmd *cmd, int pipe_in[2], int pipe_out[2]);
-// int pipe_setup_child(int pipe_in[2], int pipe_out[2]);
+bool redir_extract(t_ftlst *redirs, t_env env, int *fd_in, int *fd_out);
#endif
diff --git a/include/lexer.h b/include/lexer.h
index bc1238c..5886035 100644
--- a/include/lexer.h
+++ b/include/lexer.h
@@ -21,6 +21,7 @@ enum e_token_tag
TAG_STR_DOUBLE = 1 << 10,
TAG_STR_SINGLE = 1 << 11,
TAG_STICK = 1 << 12,
+
TAG_IS_STR = TAG_STR | TAG_STR_SINGLE | TAG_STR_DOUBLE,
TAG_IS_REDIR = TAG_REDIR_IN | TAG_REDIR_OUT | TAG_REDIR_APPEND,
};
@@ -41,5 +42,7 @@ int lexe_space(char *input);
t_token *token_new(enum e_token_tag tag, char *content);
void token_destroy(t_token *token);
+void token_destroy_lst(t_ftlst *tokens);
+void token_destroy_lst2(t_ftlst *tokens1, t_ftlst *tokens2);
#endif
diff --git a/include/minishell.h b/include/minishell.h
index 2afbed9..97b12e4 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/12 11:57:36 by charles ### ########.fr */
+/* Updated: 2020/06/15 09:47:20 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -95,8 +95,8 @@ struct s_builtin_entry
t_builtin_func func;
};
-int builtin_dispatch_run(char **argv, t_env env);
-bool builtin_check_exec_name(char *exec_name);
+t_builtin_func builtin_search_func(char *name);
+
int builtin_echo(char **argv, t_env env);
int builtin_cd(char **argv, t_env env);
int builtin_pwd(char **argv, t_env env);
@@ -109,6 +109,7 @@ int builtin_exit(char **argv, t_env env);
** preprocess.c
*/
-char **preprocess(t_ftvec *argv, t_env env);
+char **preprocess(t_ftlst **tokens, t_env env);
+char *preprocess_filename(t_ftlst **tokens, t_env env);
#endif