From 74787eefa2ac85d85b484d0ca5dffc6a2a13331d Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 30 Mar 2020 16:41:54 +0200 Subject: Added Doxyfile --- src/eval.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src') diff --git a/src/eval.c b/src/eval.c index c88a0d3..907949d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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) { -- cgit