diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-03-30 16:41:54 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-03-30 16:41:54 +0200 |
| commit | 74787eefa2ac85d85b484d0ca5dffc6a2a13331d (patch) | |
| tree | 61000ecb790c31ec317f0f7758db4e2595e3bfbc /src/eval.c | |
| parent | ffec9915be37ceebeadeb12958cbb7424cbd3633 (diff) | |
| download | minishell-74787eefa2ac85d85b484d0ca5dffc6a2a13331d.tar.gz minishell-74787eefa2ac85d85b484d0ca5dffc6a2a13331d.tar.bz2 minishell-74787eefa2ac85d85b484d0ca5dffc6a2a13331d.zip | |
Added Doxyfile
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -1,5 +1,49 @@ #include "minishell.h" +t_val *val_new_redir(t_val_type type, char *filename) +{ + t_val *val; + + if ((val = val_new(type)) == NULL) + return (NULL); + if (type == VAL_REDIR_IN) + val->data.fd = open(filename, O_RDONLY); + else if (type == VAL_REDIR_OUT) + val->data.fd = open(filename, O_WRONLY); + else if (type == VAL_REDIR_APPEND) + val->data.fd = open(filename, O_RDWR); + if (val->data.fd < 0) + { + free(val); + return (NULL); + } + return (val); +} + +t_val *val_new_err(char *msg) +{ + t_val *val; + + if ((val == malloc(sizeof(t_val))) == NULL) + return (NULL); + val->type = VAL_ERR; + if ((val->data.str = ft_strdup(msg)) == NULL) + return (NULL); + return (val); +} + +t_val *read_ast(t_ast *ast) +{ + t_val *val; + + if (ast->tag == TAG_REDIR_IN) + { + val = val_new(); + val->type = VAL_REDIR_IN; + val->value.fd = open(ast->content, O_RDONLY); + } +} + static bool check_node(t_ast *ast) { |
