maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
execute.c File Reference
#include "builtins.h"
#include "libft.h"
#include <stdio.h>
#include <sys/wait.h>
#include "shell.h"
#include "execute.h"
#include "tokens.h"
#include "pipe.h"
#include "redirection.h"
#include "exit_status.h"
#include "signals.h"
Include dependency graph for execute.c:

Go to the source code of this file.

Functions

int execute_ast (t_ast *node, t_ms_data *data)
 execute Abstract Syntax Tree
 

Function Documentation

◆ execute_ast()

int execute_ast ( t_ast node,
t_ms_data data 
)

execute Abstract Syntax Tree

--

  • Parameters
    nodeAbstract Syntax Tree Node
  • Parameters
    dataminishell data struct
  • Returns
    int return status:
  • - 0: success
  • - 1: error

Definition at line 38 of file execute.c.

39{
40 if (!node)
41 return (EXIT_FAILURE);
42 if (node->type == PIPE)
43 return (builtin_pipe(node, data));
44 else if (node->type == REDIR_IN)
45 return (redirect_in(node, data));
46 else if (node->type == REDIR_OUT)
47 return (redirect_out(node, data));
48 else if (node->type == REDIR_APPEND)
49 return (redirect_append(node, data));
50 else if (node->type == REDIR_HEREDOC)
51 return (redirect_here_doc(node, data));
52 else if (node->type == PHRASE)
53 {
54 data->args = node->args;
55 return (execute(data));
56 }
57 return (EXIT_SUCCESS);
58}
int execute(t_ms_data *data)
execute distribution function
#define EXIT_SUCCESS
Definition exit_status.h:16
#define EXIT_FAILURE
Definition exit_status.h:17
int builtin_pipe(t_ast *node, t_ms_data *data)
execute pipe when | is found in the command
Definition pipe.c:35
int redirect_out(t_ast *node, t_ms_data *data)
int redirect_in(t_ast *node, t_ms_data *data)
redirection input in context of executing AST
Definition redirect_in.c:38
int redirect_append(t_ast *node, t_ms_data *data)
redirect append ">>" to the end of the file output
int redirect_here_doc(t_ast *node, t_ms_data *data)
char ** args
Definition tokens.h:52
t_token_type type
Definition tokens.h:51
char ** args
Definition shell.h:23
@ REDIR_IN
Definition tokens.h:34
@ PHRASE
Definition tokens.h:31
@ REDIR_HEREDOC
Definition tokens.h:37
@ PIPE
Definition tokens.h:32
@ REDIR_OUT
Definition tokens.h:35
@ REDIR_APPEND
Definition tokens.h:36

References s_ms_data::args, s_ast::args, builtin_pipe(), execute(), EXIT_FAILURE, EXIT_SUCCESS, PHRASE, PIPE, REDIR_APPEND, REDIR_HEREDOC, REDIR_IN, REDIR_OUT, redirect_append(), redirect_here_doc(), redirect_in(), redirect_out(), and s_ast::type.

Referenced by execute_child(), execute_child(), process_ast_and_io(), redirect_append(), redirect_in(), and redirect_out().

Here is the call graph for this function:
Here is the caller graph for this function: