blob: ba2fbcd69e5e87aab986cd2f684bd40897dc4239 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#ifndef AST_EXEC_FUNCTIONS_H
#define AST_EXEC_FUNCTIONS_H
#include "builtins/builtins.h"
#include "exec/ast_eval.h"
#define BASE_RW_SIZE 256
typedef int (*exec_f)(struct ast *ast);
/**
* @brief Evaluates the given AST and return the exit code of it.
* A command can be a shell builtin or an external binary file called with
* `execvp`.
* @param ast An `AST_COMMAND` AST to evaluate. It is given as a `struct ast*`
* and uses inheritance-like principle.
*/
int exec_ast_command(struct ast *ast);
/**
* @brief Evaluates the given AST and return the exit code of it.
* It performs a lazy evaluation.
* @param ast An `AST_LOGICAL` AST to evaluate. It is given as a `struct ast*`
* and uses inheritance-like principle.
*/
int exec_ast_logical(struct ast *ast);
/**
* @brief Evaluates the given AST and return the exit code of the last
* `AST_COMMAND`.
* @param ast An `AST_LIST` AST to evaluate. It is given as a `struct ast*`
* and uses inheritance-like principle.
*/
int exec_ast_list(struct ast *ast);
/**
* @brief Evaluates the given AST and return the exit code of it.
* It performs a lazy evaluation.
* @param ast An `AST_IF` AST to evaluate. It is given as a `struct ast*`
* and uses inheritance-like principle.
*/
int exec_ast_if(struct ast *ast);
/**
* @brief Evaluates the given AST and return the exit code of it.
* It redirects the standard output of `ast->left` to the standard input of
* `ast->right`.
* @param ast An `AST_PIPELINE` AST to evaluate. It is given as a `struct ast*`
* and uses inheritance-like principle.
*/
int exec_ast_pipe(struct ast *ast);
/**
* @brief Evaluates the given AST and return the exit code of it.
* It gets the redirection details from `ast->redir` which is a `struct
* redirect`.
* @param ast An `AST_REDIRECTION` AST to evaluate. It is given as a `struct
* ast*` and uses inheritance-like principle.
*/
int exec_ast_redirection(struct ast *ast);
int exec_ast_while(struct ast *ast);
int exec_ast_assign(struct ast *ast);
int exec_ast_for(struct ast *ast);
/**
* @brief Evaluates the given AST and return the exit code of it.
* It gets the ast corresponding to the subshell and executes it in a new
* environment thanks to the fork(2) function.
* @param ast An `AST_SUBSHELL` AST to evaluate It is given as a `struct ast*`
* and uses inheritance-like principle.
*/
int exec_ast_subshell(struct ast *ast);
#endif /* ! AST_EXEC_FUNCTIONS_H */
|