MiniDevil
As beautiful as a shell
Redirection execution (opens files & applies redirections) More...
Include dependency graph for executor_redir.c:Redirection execution (opens files & applies redirections)
Definition in file executor_redir.c.
Functions | |
| int | open_redir_file (char *file, t_node_type type) |
| Open a file for redirection (based on the redirection type) More... | |
| int | setup_redirection (int fd, t_node_type type) |
| Redirect STDIN or STDOUT to fd, saving the original. More... | |
| void | restore_fd (int saved_fd, t_node_type type) |
| Restore a previously saved file descriptor. More... | |
| int | handle_redir (t_ast *node, t_shell *shell) |
| Execute a redirection node. More... | |
| int open_redir_file | ( | char * | file, |
| t_node_type | type | ||
| ) |
Open a file for redirection (based on the redirection type)
Opens the file with appropriate flags:
< O_RDONLY for input> O_WRONLY | O_CREAT | O_TRUNC for output>> O_WRONLY | O_CREAT | O_APPEND for append| file | Filename to open |
| type | Redirection node type |
Definition at line 30 of file executor_redir.c.
References NODE_REDIR_APPEND, NODE_REDIR_IN, and NODE_REDIR_OUT.
Referenced by handle_redir().
Here is the caller graph for this function:| int setup_redirection | ( | int | fd, |
| t_node_type | type | ||
| ) |
Redirect STDIN or STDOUT to fd, saving the original.
| fd | File descriptor to redirect to |
| type | Redirection type (to determine STDIN or STDOUT target) |
Definition at line 59 of file executor_redir.c.
References NODE_REDIR_HEREDOC, and NODE_REDIR_IN.
Referenced by handle_redir().
Here is the caller graph for this function:| void restore_fd | ( | int | saved_fd, |
| t_node_type | type | ||
| ) |
Restore a previously saved file descriptor.
| saved_fd | Saved fd from setup_redirection() |
| type | Redirection type |
Definition at line 90 of file executor_redir.c.
References NODE_REDIR_HEREDOC, and NODE_REDIR_IN.
Referenced by handle_redir().
Here is the caller graph for this function:Execute a redirection node.
| node | AST redirection node |
| shell | Shell context |
Definition at line 117 of file executor_redir.c.
References t_redir_node::cmd, t_ast::data, executor(), t_redir_node::file, t_redir_node::heredoc_fd, NODE_REDIR_HEREDOC, open_redir_file(), t_ast_data::redir, restore_fd(), setup_redirection(), and t_ast::type.
Referenced by executor().
Here is the call graph for this function:
Here is the caller graph for this function: